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
@@ -5,7 +5,7 @@ import type { ForeignPart, PartRenderer, PartRenderers, TranscriptPart } from '.
5
5
  import type { StreamStatus } from '../thread.js';
6
6
  import type { BasaltProps } from '../../common/props.js';
7
7
  import type { MessageAffordances } from './message-affordances.js';
8
- import type { VirtualizeOptions, VirtualizeProps } from './virtualize.js';
8
+ import type { VirtualizeProps } from './virtualize.js';
9
9
  /**
10
10
  * Mantine overrides for `PartList`'s default headless renderers — the house style for rendering
11
11
  * an `AgentPart` inside a chat surface.
@@ -25,165 +25,6 @@ export declare const threadPartRenderers: Partial<AgentPartRenderers>;
25
25
  export declare const messageBlockRenderCounter: {
26
26
  count: number;
27
27
  };
28
- /** Caps `applyInitialScroll`'s clobber-recovery retries (see `./virtualize`'s fourth composition
29
- * rule for the full mechanism this guards). A small fixed budget, not a time/frame-based deadline:
30
- * every observed case of virtual-core's `_willUpdate` clobbering this effect's jump resolves within
31
- * one extra commit, so this exists purely as a backstop against a pathological DOM that never
32
- * reports settled — not as the expected path. Once exhausted, the effect gives up and marks the
33
- * jump permanently done wherever the last attempt landed, rather than fighting the DOM (or a user
34
- * who has since scrolled away) forever. Exported (like `messageBlockRenderCounter`) purely so its
35
- * test can assert the exact bound without duplicating the number; not part of the public surface. */
36
- export declare const MAX_INITIAL_SCROLL_ATTEMPTS = 5;
37
- type TranscriptRow = {
38
- readonly key: string;
39
- readonly node: JSX.Element;
40
- };
41
- type VirtualizedTranscriptProps = BasaltProps & {
42
- readonly rows: readonly TranscriptRow[];
43
- readonly height: number | string;
44
- readonly overscan: number;
45
- readonly estimateSize: number;
46
- readonly initialScroll: NonNullable<VirtualizeOptions['initialScroll']>;
47
- };
48
- /**
49
- * The degrade target: every row rendered unwindowed inside a fixed-height scroll container.
50
- * This is what a `virtualize: true` transcript falls back to when `@tanstack/react-virtual` fails
51
- * to resolve (peer absent) — same visual shape (a scrollable `height`-bound pane), just without
52
- * windowing.
53
- *
54
- * NOT used as the `Suspense` fallback (see `VirtualizeSuspenseFallback` below) — mounting every
55
- * real `MessageBlock` subtree for the one tick the lazy import takes to settle would make that
56
- * settle a genuine unmount/remount of every rendered row, re-firing each row's effects once and
57
- * risking hitting a message mid-stream during the resolve window.
58
- */
59
- declare function NonVirtualizedRows({ rows, height, className, style, }: VirtualizedTranscriptProps): JSX.Element;
60
- /** Test-only escape hatch (mirrors `messageBlockRenderCounter` above) — proves the peer-absent
61
- * degrade target itself renders every row without windowing and without throwing, without having
62
- * to fight `React.lazy`'s permanent once-per-module-instance resolution cache to simulate the
63
- * peer's absence at the `import()` layer (see thread-message.test.tsx's virtualization describe
64
- * block for why that approach was rejected). Not exported from `agent-chat/index.ts`. */
65
- export declare const nonVirtualizedRowsFallback: typeof NonVirtualizedRows;
66
- /**
67
- * Minimal structural slice of `Virtualizer` (virtual-core 3.17.1) that
68
- * {@link resolveGuardedMeasurement} needs — `indexFromElement`/`itemSizeCache`/`options` are all
69
- * public instance members, but typing against the real (generic, peer-only) `Virtualizer` class
70
- * would force this test-only-exported helper to import the peer's runtime types at module scope,
71
- * the exact static-import-forces-the-peer problem the surrounding `lazy(() => import(...))` exists
72
- * to avoid. A structural type sidesteps that without loosening to `any`. Generic over the item
73
- * element type (rather than fixed at `Element`) so it stays exactly assignable FROM a real
74
- * `Virtualizer<TScrollElement, TItemElement>` at the call site below — `indexFromElement` is
75
- * declared with arrow-property (not method) syntax upstream, so it is checked contravariantly, and
76
- * a fixed `Element` parameter there does not structurally match a real instance's narrower
77
- * `TItemElement` parameter.
78
- */
79
- type MeasurementCacheHost<TItemElement extends Element> = {
80
- readonly indexFromElement: (node: TItemElement) => number;
81
- readonly itemSizeCache: Map<unknown, number>;
82
- readonly options: {
83
- readonly getItemKey: (index: number) => unknown;
84
- readonly estimateSize: (index: number) => number;
85
- };
86
- };
87
- /**
88
- * Resolves the size a `measureElement` implementation should report, given what the underlying
89
- * (default or custom) measurement already produced: that value unchanged when it is a genuine
90
- * measurement, or the row's own last-known size when it is `0` — never a real reading for a mounted
91
- * row, so a `0` only ever means the ResizeObserver measured through a `display: none` (or otherwise
92
- * unlaid-out) ancestor, e.g. a virtualized transcript sitting inside a collapsed `ThreadFeedRow`.
93
- * Falling through to it unguarded is what corrupted `itemSizeCache`/`measurementsCache`: virtual-
94
- * core's default `resizeItem` writes whatever `measureElement` returns with no floor, so every
95
- * mounted row remeasures at 0px the instant an ancestor hides, `getTotalSize()` collapses within
96
- * the same tick, and the collapse is never undone — a later real remeasurement only OVERWRITES
97
- * entries the ResizeObserver happens to re-fire for, it does not restore ones that silently kept
98
- * their poisoned 0 (see `virtualize.ts`'s composition-rule doc for the full mechanism and the
99
- * measured numbers).
100
- *
101
- * Takes the already-computed `size` plus the {@link MeasurementCacheHost} slice, rather than
102
- * wrapping the `measureElement` function itself, so this stays a plain, non-generic-over-a-
103
- * generic-function call at its one call site below (`instance` there is `Virtualizer<TScrollElement,
104
- * TItemElement>` for THAT call's concrete type arguments, not the peer's own generic
105
- * `measureElement` export — wrapping the latter directly hits TS's higher-rank inference limits on
106
- * a doubly-generic HOF). That shape is also what makes this unit-testable with a fake host object
107
- * and no ResizeObserver/layout engine at all (happy-dom has neither). Not exported from
108
- * `agent-chat/index.ts`: a test-only escape hatch, matching
109
- * `messageBlockRenderCounter`/`nonVirtualizedRowsFallback` above.
110
- */
111
- export declare function resolveGuardedMeasurement<TItemElement extends Element>(host: MeasurementCacheHost<TItemElement>, element: TItemElement, size: number): number;
112
- /**
113
- * Decides what `VirtualizedRowsInner`'s one-shot initial-scroll effect should do this render,
114
- * given the inputs the effect closes over. Pure and peer/DOM-free — pulled out of the lazy-loaded
115
- * closure for the same reason `resolveGuardedMeasurement` is: it stays unit-testable without a
116
- * real `Virtualizer` instance or `@tanstack/react-virtual` itself.
117
- *
118
- * `'start'` and an empty transcript resolve to `'skip-done'` — there is nothing to scroll to, and
119
- * DONE is permanent (see `virtualize.ts`'s fourth composition rule: the real scroll must fire at
120
- * most once, ever, so a later append never yanks a user who has scrolled up). A non-positive
121
- * `containerHeight` — the transcript's own scroll node measuring `0`, e.g. mounted behind a
122
- * `display: none` ancestor per `virtualize.ts`'s third composition rule — resolves to
123
- * `'skip-retry'`: NOT done, so the caller's effect (which re-runs after EVERY commit until the jump
124
- * lands — see {@link applyInitialScroll}) gets another chance the next time this subtree renders,
125
- * instead of permanently stranding the transcript at the top the moment it becomes visible. Only a
126
- * genuinely measured, non-empty, `'end'`-targeted mount resolves to `'scroll'`.
127
- */
128
- export declare function resolveInitialScrollAction(initialScroll: NonNullable<VirtualizeOptions['initialScroll']>, rowCount: number, containerHeight: number): 'scroll' | 'skip-done' | 'skip-retry';
129
- /** The mutable half of the one-shot initial-scroll contract. `hasApplied` is whether it has
130
- * PERMANENTLY finished — either there was nothing to do (`'start'`/empty transcript), or
131
- * `scrollToEnd` fired and was subsequently CONFIRMED (via a real DOM read — see
132
- * {@link applyInitialScroll}'s doc for why virtual-core's own tracked offset can't be trusted for
133
- * this) to have survived whatever else committed since. `attempts` counts how many times
134
- * `scrollToEnd` has been (re-)fired this mount; 0 means never attempted, and also gates whether a
135
- * call re-derives {@link resolveInitialScrollAction} at all. One instance lives for the lifetime of
136
- * a `VirtualizedRowsInner` mount, held in a `useRef` so it survives re-renders without itself
137
- * triggering one. */
138
- export type InitialScrollState = {
139
- hasApplied: boolean;
140
- attempts: number;
141
- };
142
- /**
143
- * The stateful half of "fires once, on first mount, and never again" (`virtualize.ts`'s fourth
144
- * composition rule): wraps {@link resolveInitialScrollAction}'s per-call decision with the
145
- * ACROSS-CALLS memory that decision alone can't carry. Exported (like `resolveGuardedMeasurement`)
146
- * so `VirtualizedRowsInner`'s effect below calls this SAME function rather than a hand-mirrored
147
- * copy for tests — a fake `scrollToEnd` is the only DOM/peer-free way to prove the guard, since a
148
- * real `Virtualizer`'s own `followOnAppend` also calls the real DOM `scrollTo` on a later append,
149
- * making that specific call indistinguishable from this one at the DOM boundary (see this
150
- * function's test suite for the measurement that ruled that boundary out).
151
- *
152
- * Firing `scrollToEnd()` once is NOT the same as landing there: virtual-core 3.17.1's own
153
- * `_willUpdate` (verified against the installed dist) writes to the SAME scroll container from
154
- * `this.scrollOffset`, which updates only from the ASYNCHRONOUS native `scroll` event — never from
155
- * the synchronous call that requested a scroll. A commit that runs `_willUpdate` before this
156
- * effect gets a turn (element-attach) or that re-derives an anchor while `scrollOffset` still holds
157
- * the pre-jump value writes that STALE offset straight back to `scrollTop`, undoing the jump within
158
- * about one extra commit of it landing (see `./virtualize`'s fourth composition rule for the full
159
- * trace this was diagnosed from). So `resolveInitialScrollAction`'s `'scroll'` outcome does not, by
160
- * itself, set `hasApplied`: `isAtEnd` — a real `scrollTop`/`scrollHeight`/`clientHeight` read, the
161
- * one piece of ground truth that is NEVER stale, unlike virtual-core's own tracked offset — is
162
- * consulted on the NEXT call (i.e. the next commit, exactly the cadence this dependency-free effect
163
- * already runs on) to confirm the jump survived. If it didn't, `scrollToEnd` fires again; if it did,
164
- * `hasApplied` is set and the effect is inert for the rest of the mount. `MAX_INITIAL_SCROLL_ATTEMPTS`
165
- * bounds this so a DOM that pathologically never reports settled — or a user who scrolls away mid-
166
- * measurement — can never be fought forever; once exhausted, `hasApplied` is set regardless, wherever
167
- * the last attempt left the container.
168
- *
169
- * `state.hasApplied` is the ONLY thing that can permanently stop this from calling `scrollToEnd`
170
- * again: `'start'` and an empty transcript set it immediately (nothing to verify), and `'skip-retry'`
171
- * deliberately leaves it `false` so a transcript that mounted behind a hidden ancestor gets another
172
- * attempt on the caller's next commit, rather than being silently abandoned the moment it becomes
173
- * visible. That retry — and the clobber-recovery above — is why the caller's effect carries NO
174
- * dependency array: the commit that matters (a collapsed `ThreadFeedRow` flipping its body back to
175
- * `display: block`, or virtual-core's own follow-up commit after this effect's own jump) changes
176
- * neither the row count nor the virtualizer identity, so a dependency-keyed effect would never
177
- * re-run for it.
178
- *
179
- * `getContainerHeight` is a THUNK, not a number, for the same reason: reading `offsetHeight` forces
180
- * a synchronous layout, and it is read at most ONCE per mount — only on the very first call
181
- * (`attempts === 0`) — never again while verifying or retrying, so a landed transcript still pays
182
- * nothing for the effect it keeps re-running (a streaming transcript commits on every chunk).
183
- * `isAtEnd` is cheaper (a plain property read, no forced reflow beyond what the browser already
184
- * tracks) and is exactly what the verification/retry loop above consults instead.
185
- */
186
- export declare function applyInitialScroll(state: InitialScrollState, initialScroll: NonNullable<VirtualizeOptions['initialScroll']>, rowCount: number, getContainerHeight: () => number, scrollToEnd: () => void, isAtEnd: () => boolean): void;
187
28
  type ThreadTranscriptBase = BasaltProps & {
188
29
  /** Settled messages for the thread, oldest first. */
189
30
  readonly messages: readonly ChatMessage<TranscriptPart>[];
@@ -1 +1 @@
1
- {"version":3,"file":"thread-message.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,GAAG,eAAe,CAAA;AAgD1E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CA8I1E"}
@@ -11,12 +11,13 @@ import {
11
11
  UnstyledButton
12
12
  } from "@mantine/core";
13
13
  import { useDisclosure, useFocusWithin, useHover, useMergedRef } from "@mantine/hooks";
14
- import { Fragment, lazy, memo, Suspense, useLayoutEffect, useMemo, useRef } from "react";
14
+ import { Fragment, memo, useLayoutEffect, useMemo, useRef } from "react";
15
15
  import { isLiveStatus } from "../thread.js";
16
16
  import { coalesceParts } from "../coalesce.js";
17
17
  import { narrowAgentPart } from "../foreign.js";
18
18
  import { PartList } from "../part-list.js";
19
19
  import { cx } from "../../common/props.js";
20
+ import { VirtualRows } from "../../common/virtual-rows.js";
20
21
  import { assertRequiredProps } from "../../common/validate.js";
21
22
  import { Markdown } from "../../content/markdown.js";
22
23
  import { CopyAction } from "../../content/copy-action.js";
@@ -243,162 +244,7 @@ const MessageBlock = memo(MessageBlockImpl, areMessageBlockPropsEqual);
243
244
  MessageBlock.displayName = "MessageBlock";
244
245
  const DEFAULT_VIRTUALIZE_OVERSCAN = 6;
245
246
  const DEFAULT_VIRTUALIZE_ESTIMATE_SIZE = 160;
246
- const DEFAULT_VIRTUALIZE_SCROLL_END_THRESHOLD = 64;
247
247
  const DEFAULT_VIRTUALIZE_INITIAL_SCROLL = "end";
248
- const MAX_INITIAL_SCROLL_ATTEMPTS = 5;
249
- function NonVirtualizedRows({
250
- rows,
251
- height,
252
- className,
253
- style
254
- }) {
255
- return (
256
- // theme-allow raw-scroll-container — degrade target owns its own scroll node, same as the real virtualizer below.
257
- /* @__PURE__ */ jsx(Box, { className: cx(className), style: { height, overflow: "auto", ...style }, children: /* @__PURE__ */ jsx(Stack, { gap: "sm", children: rows.map((row) => /* @__PURE__ */ jsx(Fragment, { children: row.node }, row.key)) }) })
258
- );
259
- }
260
- const nonVirtualizedRowsFallback = NonVirtualizedRows;
261
- function resolveGuardedMeasurement(host, element, size) {
262
- if (size > 0) return size;
263
- const index = host.indexFromElement(element);
264
- const key = host.options.getItemKey(index);
265
- return host.itemSizeCache.get(key) ?? host.options.estimateSize(index);
266
- }
267
- function resolveInitialScrollAction(initialScroll, rowCount, containerHeight) {
268
- if (initialScroll === "start") return "skip-done";
269
- if (rowCount === 0) return "skip-done";
270
- if (containerHeight <= 0) return "skip-retry";
271
- return "scroll";
272
- }
273
- function applyInitialScroll(state, initialScroll, rowCount, getContainerHeight, scrollToEnd, isAtEnd) {
274
- if (state.hasApplied) return;
275
- if (state.attempts > 0) {
276
- if (isAtEnd() || state.attempts >= MAX_INITIAL_SCROLL_ATTEMPTS) {
277
- state.hasApplied = true;
278
- return;
279
- }
280
- scrollToEnd();
281
- state.attempts += 1;
282
- return;
283
- }
284
- const action = resolveInitialScrollAction(initialScroll, rowCount, getContainerHeight());
285
- if (action === "skip-retry") return;
286
- if (action === "skip-done") {
287
- state.hasApplied = true;
288
- return;
289
- }
290
- scrollToEnd();
291
- state.attempts += 1;
292
- }
293
- function isContainerAtEnd(container, threshold) {
294
- if (container === null) return false;
295
- const distanceFromEnd = container.scrollHeight - container.clientHeight - container.scrollTop;
296
- return distanceFromEnd <= threshold;
297
- }
298
- const LazyVirtualizedRows = lazy(
299
- () => import("@tanstack/react-virtual").then(({ useVirtualizer, measureElement: defaultMeasureElement }) => {
300
- function VirtualizedRowsInner({
301
- rows,
302
- height,
303
- overscan,
304
- estimateSize,
305
- initialScroll,
306
- className,
307
- style
308
- }) {
309
- const parentRef = useRef(null);
310
- const initialScrollStateRef = useRef({
311
- hasApplied: false,
312
- attempts: 0
313
- });
314
- const virtualizer = useVirtualizer({
315
- count: rows.length,
316
- getScrollElement: () => parentRef.current,
317
- estimateSize: () => estimateSize,
318
- overscan,
319
- getItemKey: (index) => rows[index]?.key ?? index,
320
- anchorTo: "end",
321
- followOnAppend: true,
322
- scrollEndThreshold: DEFAULT_VIRTUALIZE_SCROLL_END_THRESHOLD,
323
- useFlushSync: false,
324
- // Guards against the hidden-ancestor cache-poisoning mechanism
325
- // `resolveGuardedMeasurement`'s doc and `virtualize.ts`'s composition rules describe —
326
- // NOT `enabled: false`, which virtual-core 3.17.1 wires to WIPE
327
- // `itemSizeCache`/`measurementsCache` entirely (`getMeasurements`'s `!enabled` branch)
328
- // rather than pause measurement, so toggling it off/on around a collapse would be
329
- // strictly worse than the bug it was meant to fix.
330
- measureElement: (element, entry, instance) => resolveGuardedMeasurement(
331
- instance,
332
- element,
333
- defaultMeasureElement(element, entry, instance)
334
- )
335
- });
336
- useLayoutEffect(() => {
337
- applyInitialScroll(
338
- initialScrollStateRef.current,
339
- initialScroll,
340
- rows.length,
341
- () => parentRef.current?.offsetHeight ?? 0,
342
- () => virtualizer.scrollToEnd({ behavior: "auto" }),
343
- () => isContainerAtEnd(parentRef.current, DEFAULT_VIRTUALIZE_SCROLL_END_THRESHOLD)
344
- );
345
- });
346
- return /* @__PURE__ */ jsx(
347
- Box,
348
- {
349
- ref: parentRef,
350
- className: cx(className),
351
- style: { height, overflow: "auto", ...style },
352
- children: /* @__PURE__ */ jsx(Box, { style: { height: virtualizer.getTotalSize(), position: "relative" }, children: virtualizer.getVirtualItems().map((virtualItem) => {
353
- const row = rows[virtualItem.index];
354
- if (row === void 0) return null;
355
- return /* @__PURE__ */ jsx(
356
- Box,
357
- {
358
- ref: virtualizer.measureElement,
359
- "data-index": virtualItem.index,
360
- style: {
361
- position: "absolute",
362
- top: 0,
363
- left: 0,
364
- width: "100%",
365
- transform: `translateY(${virtualItem.start}px)`
366
- },
367
- children: row.node
368
- },
369
- row.key
370
- );
371
- }) })
372
- }
373
- );
374
- }
375
- return { default: VirtualizedRowsInner };
376
- }).catch(() => ({ default: NonVirtualizedRows }))
377
- );
378
- Object.assign(LazyVirtualizedRows, { displayName: "LazyVirtualizedRows" });
379
- function VirtualizeSuspenseFallback({
380
- height,
381
- className,
382
- style
383
- }) {
384
- return /* @__PURE__ */ jsx(Box, { className: cx(className), style: { height, overflow: "auto", ...style } });
385
- }
386
- function VirtualizedTranscript(props) {
387
- return /* @__PURE__ */ jsx(
388
- Suspense,
389
- {
390
- fallback: /* @__PURE__ */ jsx(
391
- VirtualizeSuspenseFallback,
392
- {
393
- height: props.height,
394
- ...props.className !== void 0 && { className: props.className },
395
- ...props.style !== void 0 && { style: props.style }
396
- }
397
- ),
398
- children: /* @__PURE__ */ jsx(LazyVirtualizedRows, { ...props })
399
- }
400
- );
401
- }
402
248
  const EMPTY_RENDERERS = {};
403
249
  function useStableCallback(callback) {
404
250
  const callbackRef = useRef(callback);
@@ -496,10 +342,14 @@ function ThreadTranscript(props) {
496
342
  );
497
343
  if (virtualized !== null) {
498
344
  return /* @__PURE__ */ jsx(
499
- VirtualizedTranscript,
345
+ VirtualRows,
500
346
  {
501
347
  rows,
502
348
  height: virtualized.height,
349
+ gap: 0,
350
+ fallbackGap: "var(--mantine-spacing-sm)",
351
+ anchorTo: "end",
352
+ followOnAppend: true,
503
353
  overscan: virtualized.options.overscan ?? DEFAULT_VIRTUALIZE_OVERSCAN,
504
354
  estimateSize: virtualized.options.estimateSize ?? DEFAULT_VIRTUALIZE_ESTIMATE_SIZE,
505
355
  initialScroll: virtualized.options.initialScroll ?? DEFAULT_VIRTUALIZE_INITIAL_SCROLL,
@@ -511,12 +361,7 @@ function ThreadTranscript(props) {
511
361
  return /* @__PURE__ */ jsx(Stack, { gap: "sm", className: cx(className), ...style !== void 0 && { style }, children: rows.map((row) => /* @__PURE__ */ jsx(Fragment, { children: row.node }, row.key)) });
512
362
  }
513
363
  export {
514
- MAX_INITIAL_SCROLL_ATTEMPTS,
515
364
  ThreadTranscript,
516
- applyInitialScroll,
517
365
  messageBlockRenderCounter,
518
- nonVirtualizedRowsFallback,
519
- resolveGuardedMeasurement,
520
- resolveInitialScrollAction,
521
366
  threadPartRenderers
522
367
  };
@@ -24,11 +24,11 @@
24
24
  * `ThreadFeedRow`) — collapsing does not corrupt its measurement cache, and re-expanding restores
25
25
  * the same scroll position (same top-visible row) it had before the collapse. This is NOT free of
26
26
  * virtual-core: hiding an ancestor makes every mounted row's ResizeObserver box report `0` (a
27
- * `display: none` ancestor un-lays-out its descendants), and virtual-core 3.17.1's default
27
+ * `display: none` ancestor un-lays-out its descendants), and virtual-core 3.18.0's default
28
28
  * `measureElement`/`resizeItem` write that `0` into `itemSizeCache` with no floor — unguarded, a
29
29
  * few collapse/expand cycles permanently shrink `getTotalSize()` and silently scroll the visible
30
30
  * window to a DIFFERENT part of the transcript (`scrollTop` stays put; the content under it moves).
31
- * `thread-message.tsx` closes this with a `measureElement` override (`resolveGuardedMeasurement`)
31
+ * `common/virtual-rows.tsx` closes this with a `measureElement` override (`resolveGuardedMeasurement`)
32
32
  * that treats a `0` reading as unreliable and keeps the last-known size instead of committing it —
33
33
  * see that function's doc for the full mechanism, including why `useVirtualizer`'s `enabled` option
34
34
  * is NOT the fix (it wipes the measurement cache outright, worse than the bug). A consumer combining a
@@ -37,7 +37,7 @@
37
37
  * `useVirtualizer` call has no stale cache to poison).
38
38
  *
39
39
  * A fourth composition rule: a virtualized transcript SCROLLS ITSELF on mount. `initialScroll`
40
- * defaults to `'end'` — `anchorTo: 'end'` and `followOnAppend` (both wired in `thread-message.tsx`)
40
+ * defaults to `'end'` — `anchorTo: 'end'` and `followOnAppend` (both wired in `common/virtual-rows.tsx`)
41
41
  * only keep an ALREADY-at-the-end transcript pinned as content changes; neither performs the initial
42
42
  * jump, so left alone a freshly mounted virtualized transcript renders at message #0, not the
43
43
  * newest. The fix fires exactly once, on first mount, via `scrollToEnd()` — never again, so a user
@@ -50,11 +50,11 @@
50
50
  * if the transcript's own scroll container measures 0px on mount (e.g. mounted behind a hidden
51
51
  * ancestor) — it then lands on the first commit where the container is genuinely measurable, which
52
52
  * is what makes "opens at the newest message" hold for a transcript whose lazy virtualizer settled
53
- * while its `ThreadFeedRow` was collapsed. See `thread-message.tsx`'s `applyInitialScroll` for the
53
+ * while its `ThreadFeedRow` was collapsed. See `common/virtual-rows.tsx`'s `applyInitialScroll` for the
54
54
  * guard, and `VirtualizedRowsInner` for why its effect is deliberately dependency-free.
55
55
  *
56
56
  * Firing `scrollToEnd()` once is not sufficient on its own to land there, because virtual-core
57
- * 3.17.1's own `_willUpdate` writes to the SAME scroll container on the very next commit it runs
57
+ * 3.18.0's own `_willUpdate` writes to the SAME scroll container on the very next commit it runs
58
58
  * on, from state that lags behind the DOM: `_scrollToOffset` only ever records the write's
59
59
  * intent (`_intendedScrollOffset`) — `this.scrollOffset` itself updates ASYNCHRONOUSLY, from the
60
60
  * native `scroll` event, not from the call that requested it. So a commit that runs `_willUpdate`
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
- import type { BasaltProps, SlotStylesProps } from '../common/props.js';
2
+ import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props.js';
3
3
  import type { DeltaPolarity } from '../dashboard/delta-badge.js';
4
4
  import type { ChartState, ResponsiveChartHeight } from './types.js';
5
5
  /** One headline figure: the value is the hero, then its unit, a comparison node and the period. */
@@ -11,14 +11,16 @@ export type ChartFact = {
11
11
  /** Plain text the figure covers, e.g. `last 30 d`. A list is joined by ` · ` (`['last entry 3 d
12
12
  * ago', '12 entries']`) and, behind a `unit`, led by one. */
13
13
  period?: string | readonly string[] | undefined;
14
- /** Ink for the whole fact (text only, never a fill): a stale or off-target figure reads `warn`. */
14
+ /** Ink for the comparison, with its direction glyph (text only, never a fill): an off-target
15
+ * change reads `warn`. A fact with no comparison inks its value instead. A `DeltaBadge` comparison keeps
16
+ * its own polarity ink (it is inline), so `tone` is for plain-text comparisons. */
15
17
  tone?: ChartFactTone | undefined;
16
18
  };
17
19
  /** The status inks a fact can take, plus the muted one. */
18
20
  export type ChartFactTone = 'good' | 'warn' | 'bad' | 'muted';
19
21
  /** The three boxes a `ChartCard` paints. */
20
22
  export type ChartCardSlot = 'root' | 'header' | 'body';
21
- type ChartCardBaseProps = BasaltProps & SlotStylesProps<ChartCardSlot> & {
23
+ type ChartCardBaseProps = BasaltProps & DataAttributes & SlotStylesProps<ChartCardSlot> & {
22
24
  title?: string | undefined;
23
25
  icon?: ReactNode;
24
26
  /** A muted line below the title row; does not by itself render the header. With `facts` it is the
@@ -50,11 +52,16 @@ type ChartCardBaseProps = BasaltProps & SlotStylesProps<ChartCardSlot> & {
50
52
  * fallback>` should pass a numeric height instead. */
51
53
  placeholderHeight?: number | ResponsiveChartHeight | 'content' | undefined;
52
54
  /** The pending plot's ghost: `'bars'` (default), `'line'` for a line or area chart, or the bar
53
- * count when the loaded chart's data length is known. */
54
- ghost?: 'bars' | 'line' | number | undefined;
55
+ * count when the loaded chart's data length is known, `'band'` for a `BandStrip`. Omitted, a
56
+ * `Lines` or `StackedArea` body (bare, or inside plain elements) loads as a line, a `BandStrip`
57
+ * as one band row at its own `height`; a body wrapped in your own component hides
58
+ * its kind from the card, so pass `ghost="line"` there. */
59
+ ghost?: 'bars' | 'line' | 'band' | number | undefined;
55
60
  /** Placeholder data is showing: the facts row dims with the plot (a strip cell's `stale`). */
56
61
  stale?: boolean | undefined;
57
- /** What an errored `state` names: "Could not load {stateNoun}". Default: no noun. */
62
+ /** What an errored `state` names: "Could not load {stateNoun}". Default: the card's `title`; with
63
+ * neither, the title is a bare "Could not load". A leading capital is lowercased unless the next
64
+ * character is a capital or a non-letter ("Revenue" → "revenue", "KPI" and "2024 sales" stay). */
58
65
  stateNoun?: string | undefined;
59
66
  /** An errored `state` shows the shared Retry button (the one `ErrorState` renders). */
60
67
  onRetry?: (() => void) | undefined;
@@ -79,6 +86,6 @@ export type ChartCardProps = ChartCardBaseProps & ({
79
86
  } | {
80
87
  facts?: undefined;
81
88
  });
82
- export declare function ChartCard({ actions, state, placeholderHeight, stateAction, stale, stateNoun, ghost, onRetry, retrying, className, classNames, style, children, facts, ...header }: ChartCardProps): ReactElement;
89
+ export declare function ChartCard({ actions, state, placeholderHeight, stateAction, stale, stateNoun, ghost, onRetry, retrying, className, classNames, style, children, facts, ...headerAndData }: ChartCardProps): ReactElement;
83
90
  export {};
84
91
  //# sourceMappingURL=ChartCard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChartCard.d.ts","sourceRoot":"","sources":["../../src/charts/ChartCard.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAM7D,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAkFhE,mGAAmG;AACnG,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,SAAS,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,8BAA8B;IAC9B,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB;iEAC6D;IAC7D,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;IAC/C,mGAAmG;IACnG,IAAI,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CACjC,CAAA;AAED,2DAA2D;AAC3D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAA;AAE7D,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEtD,KAAK,kBAAkB,GAAG,WAAW,GACnC,eAAe,CAAC,aAAa,CAAC,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;kGAC8F;IAC9F,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,oDAAoD;IACpD,IAAI,CA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