basalt-ui 2.27.1 → 2.28.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 (243) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/MIGRATING.md +172 -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-design/SKILL.md +1 -1
  7. package/agent/skills/basalt-design/references/catalogue.md +40 -36
  8. package/agent/skills/basalt-design/references/recipes.md +47 -0
  9. package/configs/oxlint-basalt.json +2 -1
  10. package/configs/oxlint-plugin.js +110 -2
  11. package/configs/oxlint-plugin.test.ts +99 -4
  12. package/dist/agent/chat/thread-message.d.ts +1 -160
  13. package/dist/agent/chat/thread-message.d.ts.map +1 -1
  14. package/dist/agent/chat/thread-message.js +7 -162
  15. package/dist/agent/chat/virtualize.d.ts +5 -5
  16. package/dist/charts/ChartCard.d.ts +5 -2
  17. package/dist/charts/ChartCard.d.ts.map +1 -1
  18. package/dist/charts/ChartCard.js +46 -13
  19. package/dist/charts/Lines.d.ts.map +1 -1
  20. package/dist/charts/Lines.js +11 -4
  21. package/dist/charts/Sparkline.d.ts +9 -2
  22. package/dist/charts/Sparkline.d.ts.map +1 -1
  23. package/dist/charts/Sparkline.js +104 -41
  24. package/dist/charts/chart-box.module.css +69 -3
  25. package/dist/charts/chart-box.module.css.d.ts +5 -0
  26. package/dist/charts/chart-card.module.css +12 -4
  27. package/dist/charts/chart-card.module.css.d.ts +1 -0
  28. package/dist/charts/compile.d.ts.map +1 -1
  29. package/dist/charts/compile.js +21 -19
  30. package/dist/charts/labels.d.ts +13 -3
  31. package/dist/charts/labels.d.ts.map +1 -1
  32. package/dist/charts/labels.js +131 -20
  33. package/dist/charts/legend.d.ts.map +1 -1
  34. package/dist/charts/legend.js +1 -1
  35. package/dist/charts/ref-label.d.ts +31 -8
  36. package/dist/charts/ref-label.d.ts.map +1 -1
  37. package/dist/charts/ref-label.js +40 -9
  38. package/dist/charts/sparkline.module.css +6 -0
  39. package/dist/charts/state.d.ts +3 -3
  40. package/dist/charts/state.d.ts.map +1 -1
  41. package/dist/charts/state.js +20 -2
  42. package/dist/cli/shot/capture.d.ts +6 -1
  43. package/dist/cli/shot/capture.d.ts.map +1 -1
  44. package/dist/cli/shot/capture.js +18 -5
  45. package/dist/common/empty-copy.d.ts +16 -0
  46. package/dist/common/empty-copy.d.ts.map +1 -0
  47. package/dist/common/empty-copy.js +9 -0
  48. package/dist/common/virtual-rows.d.ts +196 -0
  49. package/dist/common/virtual-rows.d.ts.map +1 -0
  50. package/dist/common/virtual-rows.js +290 -0
  51. package/dist/controls/controls.module.css +33 -1
  52. package/dist/controls/controls.module.css.d.ts +2 -0
  53. package/dist/controls/enum-filter.d.ts.map +1 -1
  54. package/dist/controls/enum-filter.js +8 -2
  55. package/dist/controls/filter-pill.d.ts +27 -3
  56. package/dist/controls/filter-pill.d.ts.map +1 -1
  57. package/dist/controls/filter-pill.js +15 -4
  58. package/dist/controls/form-layout.d.ts +9 -3
  59. package/dist/controls/form-layout.d.ts.map +1 -1
  60. package/dist/controls/form-layout.js +74 -12
  61. package/dist/controls/form-layout.module.css +112 -7
  62. package/dist/controls/form-layout.module.css.d.ts +1 -0
  63. package/dist/controls/multi-select-filter.d.ts +2 -2
  64. package/dist/controls/multi-select-filter.d.ts.map +1 -1
  65. package/dist/controls/multi-select-filter.js +12 -6
  66. package/dist/controls/range-filter.d.ts +1 -1
  67. package/dist/controls/range-filter.d.ts.map +1 -1
  68. package/dist/controls/range-filter.js +8 -2
  69. package/dist/dashboard/bar-list.d.ts +1 -1
  70. package/dist/dashboard/bar-list.d.ts.map +1 -1
  71. package/dist/dashboard/bar-list.js +6 -2
  72. package/dist/dashboard/bar-list.module.css +0 -2
  73. package/dist/dashboard/board-nav.d.ts +22 -0
  74. package/dist/dashboard/board-nav.d.ts.map +1 -0
  75. package/dist/dashboard/board-nav.js +49 -0
  76. package/dist/dashboard/board.d.ts +52 -0
  77. package/dist/dashboard/board.d.ts.map +1 -0
  78. package/dist/dashboard/board.js +228 -0
  79. package/dist/dashboard/board.module.css +160 -0
  80. package/dist/dashboard/board.module.css.d.ts +26 -0
  81. package/dist/dashboard/empty-state.d.ts +3 -3
  82. package/dist/dashboard/empty-state.d.ts.map +1 -1
  83. package/dist/dashboard/empty-state.js +13 -6
  84. package/dist/dashboard/event-list-model.d.ts +51 -0
  85. package/dist/dashboard/event-list-model.d.ts.map +1 -0
  86. package/dist/dashboard/event-list-model.js +72 -0
  87. package/dist/dashboard/event-list-rows.d.ts +23 -0
  88. package/dist/dashboard/event-list-rows.d.ts.map +1 -0
  89. package/dist/dashboard/event-list-rows.js +93 -0
  90. package/dist/dashboard/event-list-scroll.d.ts +27 -0
  91. package/dist/dashboard/event-list-scroll.d.ts.map +1 -0
  92. package/dist/dashboard/event-list-scroll.js +103 -0
  93. package/dist/dashboard/event-list-skeleton.d.ts +10 -0
  94. package/dist/dashboard/event-list-skeleton.d.ts.map +1 -0
  95. package/dist/dashboard/event-list-skeleton.js +36 -0
  96. package/dist/dashboard/event-list.d.ts +65 -0
  97. package/dist/dashboard/event-list.d.ts.map +1 -0
  98. package/dist/dashboard/event-list.js +178 -0
  99. package/dist/dashboard/event-list.module.css +283 -0
  100. package/dist/dashboard/event-list.module.css.d.ts +33 -0
  101. package/dist/dashboard/index.d.ts +2 -0
  102. package/dist/dashboard/index.d.ts.map +1 -1
  103. package/dist/dashboard/index.js +4 -0
  104. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  105. package/dist/dashboard/meter-parts.js +5 -3
  106. package/dist/dashboard/meter.module.css +2 -1
  107. package/dist/dashboard/query-state.js +1 -1
  108. package/dist/dashboard/settings-section.d.ts +4 -1
  109. package/dist/dashboard/settings-section.d.ts.map +1 -1
  110. package/dist/dashboard/settings-section.js +1 -1
  111. package/dist/dashboard/settings-section.module.css +19 -4
  112. package/dist/dashboard/stat-card-parts.d.ts +5 -1
  113. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  114. package/dist/dashboard/stat-card-parts.js +8 -3
  115. package/dist/dashboard/stat-card.d.ts.map +1 -1
  116. package/dist/dashboard/stat-card.js +26 -7
  117. package/dist/dashboard/stat-card.module.css +31 -7
  118. package/dist/dashboard/stat-card.module.css.d.ts +3 -0
  119. package/dist/dashboard/stat-strip.js +1 -1
  120. package/dist/dashboard/stat-strip.module.css +4 -1
  121. package/dist/dashboard/widget-header.d.ts.map +1 -1
  122. package/dist/dashboard/widget-header.js +15 -2
  123. package/dist/dashboard/widget-header.module.css +17 -1
  124. package/dist/guard/index.d.ts.map +1 -1
  125. package/dist/guard/index.js +2 -0
  126. package/dist/index.d.ts +1 -1
  127. package/dist/index.d.ts.map +1 -1
  128. package/dist/index.js +4 -0
  129. package/dist/shell/app-main.module.css +18 -0
  130. package/dist/styles.css +46 -8
  131. package/dist/surfaces.d.ts +2 -2
  132. package/dist/surfaces.d.ts.map +1 -1
  133. package/dist/surfaces.js +8 -2
  134. package/dist/table/cell-kinds.d.ts +44 -0
  135. package/dist/table/cell-kinds.d.ts.map +1 -0
  136. package/dist/table/cell-kinds.js +169 -0
  137. package/dist/table/cell-kinds.module.css +55 -0
  138. package/dist/table/cell-kinds.module.css.d.ts +15 -0
  139. package/dist/table/data-table-fold.d.ts +147 -0
  140. package/dist/table/data-table-fold.d.ts.map +1 -0
  141. package/dist/table/data-table-fold.js +288 -0
  142. package/dist/table/data-table-state.d.ts +10 -3
  143. package/dist/table/data-table-state.d.ts.map +1 -1
  144. package/dist/table/data-table-state.js +11 -6
  145. package/dist/table/data-table.d.ts +11 -26
  146. package/dist/table/data-table.d.ts.map +1 -1
  147. package/dist/table/data-table.js +354 -254
  148. package/dist/table/data-table.module.css +210 -3
  149. package/dist/table/data-table.module.css.d.ts +12 -0
  150. package/dist/table/table-features.d.ts +34 -4
  151. package/dist/table/table-features.d.ts.map +1 -1
  152. package/dist/table/table-features.js +10 -0
  153. package/dist/theme/card-inset.module.css +35 -0
  154. package/dist/theme/controls.module.css +32 -0
  155. package/dist/theme/ctl-theme.d.ts.map +1 -1
  156. package/dist/theme/ctl-theme.js +5 -0
  157. package/dist/theme/index.d.ts.map +1 -1
  158. package/dist/theme/index.js +14 -10
  159. package/dist/tokens/core.d.ts +1 -0
  160. package/dist/tokens/core.d.ts.map +1 -1
  161. package/dist/tokens/core.js +1 -0
  162. package/dist/tokens/derive.js +1 -1
  163. package/dist/tokens/palette.d.ts +2 -1
  164. package/dist/tokens/palette.d.ts.map +1 -1
  165. package/llms.txt +34 -5
  166. package/package.json +1 -1
  167. package/src/agent/chat/thread-message.tsx +10 -403
  168. package/src/agent/chat/virtualize.ts +5 -5
  169. package/src/charts/ChartCard.tsx +79 -17
  170. package/src/charts/Lines.tsx +13 -4
  171. package/src/charts/Sparkline.tsx +131 -45
  172. package/src/charts/chart-box.module.css +69 -3
  173. package/src/charts/chart-box.module.css.d.ts +5 -0
  174. package/src/charts/chart-card.module.css +12 -4
  175. package/src/charts/chart-card.module.css.d.ts +1 -0
  176. package/src/charts/compile.ts +24 -20
  177. package/src/charts/labels.ts +175 -24
  178. package/src/charts/legend.tsx +3 -2
  179. package/src/charts/ref-label.ts +86 -17
  180. package/src/charts/sparkline.module.css +6 -0
  181. package/src/charts/state.tsx +36 -7
  182. package/src/cli/shot/capture.ts +29 -6
  183. package/src/common/empty-copy.ts +17 -0
  184. package/src/common/virtual-rows.tsx +682 -0
  185. package/src/controls/controls.module.css +33 -1
  186. package/src/controls/controls.module.css.d.ts +2 -0
  187. package/src/controls/enum-filter.tsx +8 -2
  188. package/src/controls/filter-pill.tsx +80 -27
  189. package/src/controls/form-layout.module.css +112 -7
  190. package/src/controls/form-layout.module.css.d.ts +1 -0
  191. package/src/controls/form-layout.tsx +115 -22
  192. package/src/controls/multi-select-filter.tsx +22 -11
  193. package/src/controls/range-filter.tsx +9 -3
  194. package/src/dashboard/bar-list.module.css +0 -2
  195. package/src/dashboard/bar-list.tsx +8 -5
  196. package/src/dashboard/board-nav.ts +67 -0
  197. package/src/dashboard/board.module.css +160 -0
  198. package/src/dashboard/board.module.css.d.ts +26 -0
  199. package/src/dashboard/board.tsx +394 -0
  200. package/src/dashboard/empty-state.tsx +16 -9
  201. package/src/dashboard/event-list-model.ts +113 -0
  202. package/src/dashboard/event-list-rows.tsx +120 -0
  203. package/src/dashboard/event-list-scroll.ts +145 -0
  204. package/src/dashboard/event-list-skeleton.tsx +58 -0
  205. package/src/dashboard/event-list.module.css +283 -0
  206. package/src/dashboard/event-list.module.css.d.ts +33 -0
  207. package/src/dashboard/event-list.tsx +309 -0
  208. package/src/dashboard/index.ts +2 -0
  209. package/src/dashboard/meter-parts.tsx +9 -2
  210. package/src/dashboard/meter.module.css +2 -1
  211. package/src/dashboard/query-state.tsx +1 -1
  212. package/src/dashboard/settings-section.module.css +19 -4
  213. package/src/dashboard/settings-section.tsx +7 -2
  214. package/src/dashboard/stat-card-parts.tsx +20 -3
  215. package/src/dashboard/stat-card.module.css +31 -7
  216. package/src/dashboard/stat-card.module.css.d.ts +3 -0
  217. package/src/dashboard/stat-card.tsx +25 -6
  218. package/src/dashboard/stat-strip.module.css +4 -1
  219. package/src/dashboard/stat-strip.tsx +1 -1
  220. package/src/dashboard/widget-header.module.css +17 -1
  221. package/src/dashboard/widget-header.tsx +29 -5
  222. package/src/guard/index.ts +2 -0
  223. package/src/index.ts +4 -0
  224. package/src/shell/app-main.module.css +18 -0
  225. package/src/styles.css +46 -8
  226. package/src/surfaces.ts +7 -1
  227. package/src/table/cell-kinds.module.css +55 -0
  228. package/src/table/cell-kinds.module.css.d.ts +15 -0
  229. package/src/table/cell-kinds.tsx +234 -0
  230. package/src/table/data-table-fold.tsx +514 -0
  231. package/src/table/data-table-state.ts +24 -13
  232. package/src/table/data-table.module.css +210 -3
  233. package/src/table/data-table.module.css.d.ts +12 -0
  234. package/src/table/data-table.tsx +406 -359
  235. package/src/table/table-features.ts +44 -4
  236. package/src/theme/__snapshots__/plain-theme.test.ts.snap +2 -66
  237. package/src/theme/card-inset.module.css +35 -0
  238. package/src/theme/controls.module.css +32 -0
  239. package/src/theme/ctl-theme.tsx +8 -0
  240. package/src/theme/index.ts +12 -8
  241. package/src/tokens/core.ts +1 -0
  242. package/src/tokens/derive.ts +1 -1
  243. package/src/tokens/palette.ts +4 -1
@@ -179,8 +179,26 @@ function cardOf(trigger: Element): Element | null {
179
179
  }
180
180
 
181
181
  /**
182
- * Places the bubble in the VIEWPORT: below the glyph, flipped above when it would overflow the
183
- * bottom edge, shifted sideways to stay inside the left and right edges. Re-places on scroll, resize
182
+ * The card's header block: the `WidgetHeader` root (title row, value, subtitle, sparkline) plus the
183
+ * facts row `ChartCard` renders as its sibling; a host with no `WidgetHeader` (`StatCard`, a strip cell)
184
+ * marks its own block with `data-basalt-header-block`. The bubble opens below THIS, not below the glyph, so
185
+ * it covers the plot and never the headline figures it annotates. Only siblings of the root count —
186
+ * a facts row deeper in the card's body belongs to the body, never to the header.
187
+ */
188
+ const FACTS = '[data-basalt-facts], [data-basalt-facts-skeleton]'
189
+ function headerBlockOf(trigger: Element, card: Element): Element[] {
190
+ // `StatCard` and strip cells mark the element bounding their headline (caption row + value rows).
191
+ const marked = trigger.closest('[data-basalt-header-block]')
192
+ if (marked !== null && card.contains(marked)) return [marked]
193
+ const root = trigger.closest('[data-tier]')
194
+ if (root === null || root === card || !card.contains(root)) return []
195
+ const siblings = [...(root.parentElement?.children ?? [])]
196
+ return [root, ...siblings.filter((el) => el !== root && el.matches(FACTS))]
197
+ }
198
+
199
+ /**
200
+ * Places the bubble in the VIEWPORT: below the glyph (inside a card, below its header
201
+ * block), flipped above when it would overflow the bottom edge, shifted sideways to stay inside the left and right edges. Re-places on scroll, resize
184
202
  * and when the bubble's own box changes while open. The bubble is a top-layer popover and
185
203
  * `position: fixed`, so a card's `overflow: hidden` (every basalt card has one) can never clip it —
186
204
  * the W32 round 0-3 defect at 390. `clear` forgets the position on close, so a reopen starts hidden.
@@ -210,7 +228,12 @@ function useBubblePosition(
210
228
  // The documentElement's client box is the viewport minus classic scrollbars.
211
229
  const viewW = document.documentElement.clientWidth
212
230
  const viewH = document.documentElement.clientHeight
213
- const below = t.bottom + BUBBLE_GAP
231
+ // Re-queried per place: a skeleton -> facts swap replaces the facts node while open.
232
+ const block = card === null ? [] : headerBlockOf(trigger, card)
233
+ const blockRects = block.map((el) => el.getBoundingClientRect())
234
+ const blockTop = Math.min(t.top, ...blockRects.map((r) => r.top))
235
+ const blockBottom = Math.max(t.bottom, ...blockRects.map((r) => r.bottom))
236
+ const below = blockBottom + BUBBLE_GAP
214
237
  const above = t.top - BUBBLE_GAP - b.height
215
238
  const overflows = below + b.height > viewH - BUBBLE_EDGE
216
239
  // Inside a card the bubble never leaves the card's own box upward: above the header is the
@@ -225,8 +248,9 @@ function useBubblePosition(
225
248
  if (above >= floor) top = above
226
249
  else if (card !== null) {
227
250
  const slid = Math.max(floor, viewH - BUBBLE_EDGE - b.height)
228
- // Never cover the glyph itself: when the slid bubble would, take the viewport flip instead.
229
- const covers = slid < t.bottom && slid + b.height > t.top
251
+ // Never cover the header block (glyph included): when the slid bubble would, take the
252
+ // viewport flip instead.
253
+ const covers = slid < blockBottom && slid + b.height > blockTop
230
254
  top = covers ? viewportFlip : slid
231
255
  }
232
256
  }
@@ -1073,6 +1073,8 @@ export const PLUGIN_RULE_IDS: ReadonlySet<string> = new Set([
1073
1073
  'no-dev-helper',
1074
1074
  // AST-only: a `<ViewTransition>` ancestor of `<Outlet>` is a JSX-ancestry claim over two import-resolved names.
1075
1075
  'route-view-transition',
1076
+ // AST-only: a text-colour position (`c=`, a `style` object's `color`) is a JSX/property claim over a member chain.
1077
+ 'status-fill-as-text',
1076
1078
  // These two honour `basalt-agent-allow`, never `theme-allow` — but they are still REAL ids, so
1077
1079
  // a `theme-allow ai-sdk-major` must parse as a (useless) scoped annotation rather than as prose.
1078
1080
  'agent-no-raw-usechat',
package/src/index.ts CHANGED
@@ -59,6 +59,10 @@ export {
59
59
  type MeterZone,
60
60
  BarList,
61
61
  type BarListProps,
62
+ EventList,
63
+ type EventListProps,
64
+ Board,
65
+ type BoardProps,
62
66
  PageSummary,
63
67
  type PageSummaryProps,
64
68
  } from './dashboard'
@@ -107,6 +107,24 @@
107
107
  * table's page-sticky offset reads it instead of repeating this module's `sm` switch.
108
108
  */
109
109
  --basalt-main-pad-block: var(--vx-space-stack-md);
110
+ /*
111
+ * PUBLIC `--basalt-main-content-h` — the height of Main's CONTENT box: what an element at
112
+ * `height: var(--basalt-main-content-h)` needs to fill the scrollport with nothing to scroll (a
113
+ * map, an editor, a full-page canvas). Descendants inherit the resolved length.
114
+ *
115
+ * It is the viewport minus the five things that are not content: the header offset, the footer
116
+ * offset PLUS the safe-area inset (same pair as `margin-bottom` above), the band, and Main's block
117
+ * padding twice. The band is `--basalt-page-bar-h` (its content box, published by `PageBar`) plus
118
+ * its own 1 px `border-bottom` the var never counts (`page-aside.module.css` explains the same
119
+ * pixel): `var(--basalt-page-bar-h, -1px) + 1px` adds it only while a band exists and nets to 0
120
+ * without one. `h="100%"` cannot do this job — Main sizes itself by flex, so a percentage height
121
+ * on a child does not resolve against it.
122
+ */
123
+ --basalt-main-content-h: calc(
124
+ 100dvh - var(--app-shell-header-offset, 0px) - var(--app-shell-footer-offset, 0px) -
125
+ env(safe-area-inset-bottom, 0px) - (var(--basalt-page-bar-h, -1px) + 1px) - 2 *
126
+ var(--basalt-main-pad-block)
127
+ );
110
128
  padding: var(--basalt-main-pad-block) var(--app-shell-padding);
111
129
  /* Without this a wide flex/grid child (a bare table, a nowrap control row) sizes Main to ITSELF. */
112
130
  min-width: 0;
package/src/styles.css CHANGED
@@ -177,14 +177,6 @@
177
177
  outline-color: var(--vx-accent);
178
178
  }
179
179
 
180
- /* The chart host is a focusable element Mantine does not own, so no `mantine-focus-*` class reaches
181
- it and the UA ring paints instead: a white double ring in dark (argo strength strip and
182
- diagnostics at dark 390). There is no media or pointer branch behind it. */
183
- .basalt-chart:focus-visible {
184
- outline: 2px solid var(--vx-accent);
185
- outline-offset: calc(0.125rem * var(--mantine-scale));
186
- }
187
-
188
180
  /* Hubot Sans is a condensed display face — the spec pins it at 88% font-stretch everywhere it
189
181
  lands (headings + the Mantine Title component). Read from the knob declared above rather than
190
182
  hardcoded here, so a consumer retunes it in one declaration instead of fighting these bare
@@ -394,6 +386,52 @@
394
386
  }
395
387
  }
396
388
 
389
+ /* MapLibre's compact attribution (Wave 43, argo's astro Map tab). basalt has no maplibre dependency;
390
+ * this only restyles the control a consumer's map renders, onto the radius scale and the micro text
391
+ * size: the shipped 12 px radius on the box and its 24 px button is off the scale and, over a card,
392
+ * a nested step under 3 px. The box takes the control tier (4 px under a flush card), the button the
393
+ * Mantine `xs` step (4 px under the box).
394
+ *
395
+ * UNLAYERED on purpose: `maplibre-gl.css` is unlayered, and an unlayered rule beats every layered
396
+ * one whatever the specificity, so a `@layer basalt` block would lose to it. The doubled `:root`
397
+ * lifts each rule to (0,4,0), over maplibre's highest (0,3,0) (`.maplibregl-ctrl-bottom-left >
398
+ * .maplibregl-ctrl-attrib.maplibregl-compact-show`, which sets its own 12 px radius), whichever
399
+ * stylesheet loads last and in every corner and state. A consumer overrides with a longer selector,
400
+ * or an equal one later in source. `.maplibregl-ctrl-group` is not here: its 4 px radius is already
401
+ * a scale step. */
402
+ :root:root .maplibregl-ctrl.maplibregl-ctrl-attrib {
403
+ border-radius: var(--vx-radius-ctrl);
404
+ background-color: var(--vx-surface-panel);
405
+ color: var(--vx-muted);
406
+ font-size: var(--vx-text-micro);
407
+ }
408
+
409
+ :root:root .maplibregl-ctrl-attrib a {
410
+ color: inherit;
411
+ }
412
+
413
+ /* One step under the box, snapped onto the scale like the SegmentedControl indicator: 2 when the box
414
+ * leaves a 3 px step, else square. */
415
+ :root:root .maplibregl-ctrl-attrib-button {
416
+ /* theme-allow css-raw-surface — a snapped nested step: the scale's 2 px xs, or square under a small box */
417
+ border-radius: round(down, min(2px, max(0px, var(--vx-radius-ctrl) - 3px)), 2px);
418
+ }
419
+
420
+ /* The glyph is maplibre's dark SVG background-image, drawn again as a mask in the muted ink so it
421
+ * follows the scheme (a `filter` would also invert the button's own fill). */
422
+ :root:root .maplibregl-ctrl-attrib-button {
423
+ background-image: none;
424
+ }
425
+
426
+ :root:root .maplibregl-ctrl-attrib-button::after {
427
+ content: '';
428
+ position: absolute;
429
+ inset: 0;
430
+ background-color: var(--vx-muted);
431
+ mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 20 20'%3E%3Cpath fill-rule='evenodd' d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0v-3'/%3E%3C/svg%3E")
432
+ center / 24px 24px no-repeat;
433
+ }
434
+
397
435
  /* chart-engine:start — generated by scripts/gen-chart-css.ts from chartEngineCss() */
398
436
  @layer basalt {
399
437
  :root {
package/src/surfaces.ts CHANGED
@@ -63,6 +63,7 @@ export const PLUGIN_RULE_ID_LIST = [
63
63
  'raw-breakpoint',
64
64
  'no-dev-helper',
65
65
  'route-view-transition',
66
+ 'status-fill-as-text',
66
67
  ] as const
67
68
 
68
69
  /** One registered oxlint plugin rule id — the literal union of {@link PLUGIN_RULE_ID_LIST}. */
@@ -357,7 +358,12 @@ export const SURFACES = {
357
358
  // The type-scale rules live with the tokens, not with `.`: both police a value that left the
358
359
  // `--vx-*` system, which is this surface's whole subject. `token-layer-boundary` is the
359
360
  // repo-local-only rule that keeps the layer upstream of Mantine (see below).
360
- pluginRules: ['no-raw-font-size', 'raw-size-literal', 'token-layer-boundary'],
361
+ pluginRules: [
362
+ 'no-raw-font-size',
363
+ 'raw-size-literal',
364
+ 'status-fill-as-text',
365
+ 'token-layer-boundary',
366
+ ],
361
367
  description:
362
368
  'VX token refs, buildPaletteCss, defineSeries, seriesTokens, groupTokens, alpha (Mantine-free)',
363
369
  globs: {
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Cell kinds (`meta.kind`, SPEC § 6.6). Each class is the CHROME of one kind on its `<td>`; the font
3
+ * SIZE stays the theme's `sm` on `td`. Colours are tokens, never literals.
4
+ */
5
+ .entity {
6
+ max-width: 100%;
7
+ overflow: hidden;
8
+ font-weight: 500;
9
+ color: var(--vx-ink);
10
+ text-overflow: ellipsis;
11
+ white-space: nowrap;
12
+ }
13
+
14
+ .status {
15
+ white-space: nowrap;
16
+ }
17
+
18
+ /* SPEC D33: figures are the proportional sans with lining tabular numerals; only times are mono. */
19
+ .number {
20
+ font-variant-numeric: tabular-nums;
21
+ font-weight: 500;
22
+ color: var(--vx-ink);
23
+ white-space: nowrap;
24
+ }
25
+
26
+ .relativeTime {
27
+ font-family: var(--mantine-font-family-monospace);
28
+ font-variant-numeric: tabular-nums;
29
+ color: var(--vx-muted);
30
+ white-space: nowrap;
31
+ }
32
+
33
+ .meter {
34
+ min-width: calc(4rem * var(--mantine-scale));
35
+ }
36
+
37
+ .text {
38
+ color: var(--vx-ink);
39
+ white-space: normal;
40
+ }
41
+
42
+ /* An absent value: a muted em dash, never an empty cell. */
43
+ .dash {
44
+ color: var(--vx-faint);
45
+ }
46
+
47
+ /* The full date for assistive tech, inside the `<time>`: visually hidden, still announced. */
48
+ .srOnly {
49
+ position: absolute;
50
+ width: 1px;
51
+ height: 1px;
52
+ overflow: hidden;
53
+ clip-path: inset(50%);
54
+ white-space: nowrap;
55
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
3
+ * signature — so dot access stays verbatim under the package's strict flags.
4
+ */
5
+ declare const classes: {
6
+ readonly dash: string
7
+ readonly entity: string
8
+ readonly meter: string
9
+ readonly number: string
10
+ readonly relativeTime: string
11
+ readonly srOnly: string
12
+ readonly status: string
13
+ readonly text: string
14
+ }
15
+ export default classes
@@ -0,0 +1,234 @@
1
+ /**
2
+ * `meta.kind` for `BasaltDataTable` (`docs/waves/design-parity/SPEC.md` § 6.6): the chrome a cell
3
+ * takes by KIND, and the content a kind supplies when its column has no `cell` of its own. The table
4
+ * calls three seams from its header and cell render sites: {@link resolveKind} (validate),
5
+ * {@link kindClass} / {@link kindAlign} (chrome) and {@link KindCell} (content).
6
+ */
7
+ import { Badge, Skeleton, Tooltip } from '@mantine/core'
8
+ import type { Cell, Column, RowData } from '@tanstack/react-table'
9
+ import { FlexRender } from '@tanstack/react-table'
10
+ import type { ReactNode } from 'react'
11
+ import { cx } from '../common/props'
12
+ import { Meter } from '../dashboard/meter'
13
+ import { dateTime, integer, relativeTime } from '../format'
14
+ import { numberFormat } from '../format/shared'
15
+ import { DATA_TABLE_COLUMN_KINDS } from './table-features'
16
+ import type { BasaltTableFeatures, DataTableAlign, DataTableColumnKind } from './table-features'
17
+ import classes from './cell-kinds.module.css'
18
+
19
+ /**
20
+ * The table's own default `cell` (TanStack's, restated), installed as `defaultColumn.cell` so a
21
+ * column WITHOUT a renderer is identifiable by identity: v9 merges its default into every
22
+ * `columnDef`, so `columnDef.cell === undefined` can never be asked.
23
+ */
24
+ export function DEFAULT_CELL(props: { renderValue(): unknown }) {
25
+ return (props.renderValue() as { toString?(): string } | null | undefined)?.toString?.() ?? null
26
+ }
27
+
28
+ const KINDS: ReadonlySet<string> = new Set(DATA_TABLE_COLUMN_KINDS)
29
+
30
+ /** Reads `meta.kind`, throwing on a value outside the seven — the check a type cannot make at runtime. */
31
+ export function resolveKind<T extends RowData>(
32
+ column: Column<BasaltTableFeatures, T, unknown>,
33
+ ): DataTableColumnKind | undefined {
34
+ const kind = column.columnDef.meta?.kind
35
+ if (kind === undefined) return undefined
36
+ if (!KINDS.has(kind)) {
37
+ throw new Error(
38
+ `BasaltDataTable: column "${column.id}" has meta.kind=${JSON.stringify(kind)} — ` +
39
+ `expected ${DATA_TABLE_COLUMN_KINDS.map((k) => `'${k}'`).join(' | ')}.`,
40
+ )
41
+ }
42
+ return kind
43
+ }
44
+
45
+ /** Figures read right: the kind's default alignment, which an explicit `meta.align` overrides. */
46
+ export function kindAlign(kind: DataTableColumnKind | undefined): DataTableAlign | undefined {
47
+ return kind === 'number' || kind === 'money' ? 'right' : undefined
48
+ }
49
+
50
+ /**
51
+ * Column sizing law (SPEC § 6.6): a data column is as wide as its header or widest cell (body cells
52
+ * hold one line), and the slack of a wide container goes to ONE place — the LAST `text` column (a
53
+ * notes/detail column that may wrap), else a trailing spacer after the last data column — so a name
54
+ * sits beside its figures, never a third of the table away. An `entity` column is content-sized.
55
+ * `fixedIds` (the checkbox and actions columns) fit too but are not data. An earlier `text` column
56
+ * keeps its auto share (it may wrap), and a table where no column opted into a kind renders as
57
+ * before: no fit marks, no spacer.
58
+ */
59
+ export function planColumnSizing<T extends RowData>(
60
+ columns: readonly Column<BasaltTableFeatures, T, unknown>[],
61
+ fixedIds: ReadonlySet<string>,
62
+ ): { fitIds: ReadonlySet<string>; spacer: boolean } {
63
+ const data = columns.filter((column) => !fixedIds.has(column.id))
64
+ const kinds = new Map(data.map((column) => [column.id, resolveKind(column)]))
65
+ const fitIds = new Set(columns.filter((column) => fixedIds.has(column.id)).map((c) => c.id))
66
+ const hasKinds = data.some((column) => kinds.get(column.id) !== undefined)
67
+ if (!hasKinds) return { fitIds, spacer: false }
68
+ const slackId = data.findLast((column) => kinds.get(column.id) === 'text')?.id
69
+ for (const column of data) {
70
+ if (column.id === slackId || kinds.get(column.id) === 'text') continue
71
+ fitIds.add(column.id)
72
+ }
73
+ return { fitIds, spacer: slackId === undefined }
74
+ }
75
+
76
+ /**
77
+ * A bar's width by kind. A share (`100%`) of a content-sized cell is that cell's own width, so the
78
+ * fit columns take it; the slack column has no width of its own and takes a fixed length.
79
+ */
80
+ const SKELETON_WIDTH: Record<DataTableColumnKind | 'kindless', string> = {
81
+ number: '3rem',
82
+ money: '3rem',
83
+ status: '4.5rem',
84
+ 'relative-time': '4.5rem',
85
+ meter: '4rem',
86
+ entity: '100%',
87
+ text: '10rem',
88
+ kindless: '100%',
89
+ }
90
+
91
+ /** A loading bar shaped like the kind's value: a figure short and flush right, a chip chip-sized. */
92
+ export function KindSkeleton({
93
+ kind,
94
+ right,
95
+ }: {
96
+ kind: DataTableColumnKind | undefined
97
+ right: boolean
98
+ }): ReactNode {
99
+ const chip = kind === 'status'
100
+ const width = SKELETON_WIDTH[kind ?? 'kindless']
101
+ return (
102
+ <Skeleton
103
+ height={chip ? 20 : 16}
104
+ radius="sm"
105
+ w={width}
106
+ maw="100%"
107
+ {...(right && { ml: 'auto' })}
108
+ />
109
+ )
110
+ }
111
+
112
+ const KIND_CLASS: Record<DataTableColumnKind, string> = {
113
+ entity: classes.entity,
114
+ status: classes.status,
115
+ number: classes.number,
116
+ money: classes.number,
117
+ 'relative-time': classes.relativeTime,
118
+ meter: classes.meter,
119
+ text: classes.text,
120
+ }
121
+
122
+ export function kindClass(kind: DataTableColumnKind): string {
123
+ return cx(KIND_CLASS[kind])
124
+ }
125
+
126
+ /** A whole number groups; a fraction is kept whole (`integer` would round 12.5 to 13). */
127
+ function formatFigure(value: number): string {
128
+ return Number.isInteger(value)
129
+ ? integer(value)
130
+ : numberFormat(undefined, { signDisplay: 'negative', maximumFractionDigits: 20 }).format(value)
131
+ }
132
+
133
+ /**
134
+ * A `money` figure: grouped, with the currency's own minor digits (`120,000.00` USD, `120,000` JPY)
135
+ * and no symbol — the header names the code (`Salary (USD / yr)`, SPEC § 6.6).
136
+ */
137
+ function formatMoney(value: number, currency: string): string {
138
+ const digits = numberFormat(undefined, { style: 'currency', currency }).resolvedOptions()
139
+ .maximumFractionDigits
140
+ return numberFormat(undefined, {
141
+ signDisplay: 'negative',
142
+ minimumFractionDigits: digits,
143
+ maximumFractionDigits: digits,
144
+ }).format(value)
145
+ }
146
+
147
+ /** The theme draws no dot for plain `gray`, but every chip in a status column carries one. */
148
+ const chipColor = (color: string | undefined): string =>
149
+ color === undefined || color === 'gray' ? 'var(--vx-faint)' : color
150
+
151
+ const Dash = () => <span className={classes.dash}>—</span>
152
+
153
+ function isAbsent(value: unknown): boolean {
154
+ return value === null || value === undefined || value === ''
155
+ }
156
+
157
+ function toDate(value: unknown): Date | undefined {
158
+ if (!(value instanceof Date) && typeof value !== 'number' && typeof value !== 'string') {
159
+ return undefined
160
+ }
161
+ const date = new Date(value)
162
+ return Number.isNaN(date.getTime()) ? undefined : date
163
+ }
164
+
165
+ function columnLabel<T extends RowData>(column: Column<BasaltTableFeatures, T, unknown>): string {
166
+ const { header } = column.columnDef
167
+ return typeof header === 'string' ? header : column.id
168
+ }
169
+
170
+ function RelativeTime({ value }: { value: unknown }) {
171
+ const date = toDate(value)
172
+ if (date === undefined) return <Dash />
173
+ const full = dateTime(date)
174
+ return (
175
+ // Below the cell and on keyboard focus: above it the tip covered the header's label on row one.
176
+ <Tooltip label={full} position="bottom" events={{ hover: true, focus: true, touch: false }}>
177
+ {/* oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- the tooltip opens on focus */}
178
+ <time dateTime={date.toISOString()} tabIndex={0}>
179
+ {relativeTime(date)}
180
+ <span className={classes.srOnly}>{`, ${full}`}</span>
181
+ </time>
182
+ </Tooltip>
183
+ )
184
+ }
185
+
186
+ /** The cell of a column with a `kind`: the column's own `cell` if it has one, else the kind's content. */
187
+ export function KindCell<T extends RowData>({
188
+ kind,
189
+ cell,
190
+ }: {
191
+ kind: DataTableColumnKind
192
+ cell: Cell<BasaltTableFeatures, T, unknown>
193
+ }): ReactNode {
194
+ const { column } = cell
195
+ const { cell: render, meta } = column.columnDef
196
+ if (render !== DEFAULT_CELL) return <FlexRender cell={cell} />
197
+ const value = cell.getValue()
198
+ switch (kind) {
199
+ case 'number':
200
+ case 'money': {
201
+ if (typeof value !== 'number' || !Number.isFinite(value)) return <Dash />
202
+ return kind === 'money' ? formatMoney(value, meta?.currency ?? 'USD') : formatFigure(value)
203
+ }
204
+ case 'relative-time':
205
+ return <RelativeTime value={value} />
206
+ case 'status':
207
+ if (isAbsent(value)) return <Dash />
208
+ return <Badge color={chipColor(meta?.statusColor?.(value))}>{String(value)}</Badge>
209
+ case 'meter':
210
+ return (
211
+ <Meter
212
+ size="row"
213
+ label={columnLabel(column)}
214
+ value={typeof value === 'number' ? value : null}
215
+ max={meta?.meterMax ?? 1}
216
+ />
217
+ )
218
+ case 'entity':
219
+ case 'text':
220
+ return isAbsent(value) ? <Dash /> : String(value)
221
+ default:
222
+ return kind satisfies never
223
+ }
224
+ }
225
+
226
+ /** A cell's content through its kind when it has one — the body cell and the fold disclosure share it. */
227
+ export function CellContent<T extends RowData>({
228
+ cell,
229
+ }: {
230
+ cell: Cell<BasaltTableFeatures, T, unknown>
231
+ }): ReactNode {
232
+ const kind = resolveKind(cell.column)
233
+ return kind === undefined ? <FlexRender cell={cell} /> : <KindCell kind={kind} cell={cell} />
234
+ }