basalt-ui 2.15.0 → 2.17.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 (152) hide show
  1. package/CHANGELOG.md +157 -105
  2. package/MIGRATING.md +160 -12
  3. package/agent/agents/basalt-design-reviewer.md +3 -3
  4. package/agent/rules/basalt-mantine.md +1 -1
  5. package/agent/skills/basalt-design/SKILL.md +2 -2
  6. package/configs/card-inset.test.ts +57 -0
  7. package/configs/oxlint-basalt.json +1 -1
  8. package/configs/oxlint-plugin.js +42 -18
  9. package/configs/oxlint-plugin.test.ts +37 -6
  10. package/dist/agent/chat/thread-message.js +1 -1
  11. package/dist/agent/chat/thread-outcome-card.js +1 -1
  12. package/dist/charts/ChartCard.js +1 -1
  13. package/dist/charts/Donut.d.ts.map +1 -1
  14. package/dist/charts/Donut.js +2 -2
  15. package/dist/charts/DualPanel.js +2 -2
  16. package/dist/charts/Heatmap.d.ts.map +1 -1
  17. package/dist/charts/Heatmap.js +2 -2
  18. package/dist/charts/MirroredBars.js +2 -2
  19. package/dist/charts/Sparkline.d.ts +4 -2
  20. package/dist/charts/Sparkline.d.ts.map +1 -1
  21. package/dist/charts/Sparkline.js +3 -3
  22. package/dist/charts/chart-card.module.css +2 -2
  23. package/dist/charts/compile.d.ts +8 -3
  24. package/dist/charts/compile.d.ts.map +1 -1
  25. package/dist/charts/compile.js +19 -9
  26. package/dist/charts/cursor.d.ts +14 -1
  27. package/dist/charts/cursor.d.ts.map +1 -1
  28. package/dist/charts/cursor.js +29 -3
  29. package/dist/charts/date-tick-format.d.ts +17 -0
  30. package/dist/charts/date-tick-format.d.ts.map +1 -0
  31. package/dist/charts/date-tick-format.js +81 -0
  32. package/dist/charts/panel.d.ts +2 -1
  33. package/dist/charts/panel.d.ts.map +1 -1
  34. package/dist/charts/panel.js +3 -2
  35. package/dist/charts/types.d.ts +5 -1
  36. package/dist/charts/types.d.ts.map +1 -1
  37. package/dist/cli/shot/board.js +1 -1
  38. package/dist/cli/shot/capture.d.ts +16 -0
  39. package/dist/cli/shot/capture.d.ts.map +1 -1
  40. package/dist/cli/shot/capture.js +24 -3
  41. package/dist/cli/shot/measure.d.ts +21 -2
  42. package/dist/cli/shot/measure.d.ts.map +1 -1
  43. package/dist/cli/shot/measure.js +20 -5
  44. package/dist/cli/shot/playwright.d.ts +4 -0
  45. package/dist/cli/shot/playwright.d.ts.map +1 -1
  46. package/dist/cli/shot/types.d.ts +3 -2
  47. package/dist/cli/shot/types.d.ts.map +1 -1
  48. package/dist/dashboard/delta-badge.d.ts +2 -2
  49. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  50. package/dist/dashboard/delta-badge.js +12 -14
  51. package/dist/dashboard/query-state.d.ts +35 -0
  52. package/dist/dashboard/query-state.d.ts.map +1 -1
  53. package/dist/dashboard/query-state.js +12 -1
  54. package/dist/dashboard/settings-section.d.ts.map +1 -1
  55. package/dist/dashboard/settings-section.js +5 -2
  56. package/dist/dashboard/stat-card-parts.d.ts +40 -0
  57. package/dist/dashboard/stat-card-parts.d.ts.map +1 -0
  58. package/dist/dashboard/stat-card-parts.js +55 -0
  59. package/dist/dashboard/stat-card.d.ts +46 -34
  60. package/dist/dashboard/stat-card.d.ts.map +1 -1
  61. package/dist/dashboard/stat-card.js +157 -88
  62. package/dist/dashboard/stat-card.module.css +222 -9
  63. package/dist/dashboard/stat-card.module.css.d.ts +20 -0
  64. package/dist/dashboard/widget-header.d.ts.map +1 -1
  65. package/dist/dashboard/widget-header.js +73 -9
  66. package/dist/dashboard/widget-header.module.css +28 -20
  67. package/dist/guard/guard-hook.d.ts.map +1 -1
  68. package/dist/guard/index.d.ts +4 -2
  69. package/dist/guard/index.d.ts.map +1 -1
  70. package/dist/guard/index.js +18 -4
  71. package/dist/guard/vx-names.d.ts.map +1 -1
  72. package/dist/guard/vx-names.js +1 -0
  73. package/dist/shell/app-mobile-nav.module.css +2 -2
  74. package/dist/shell/app-sidebar-account.js +1 -1
  75. package/dist/shell/app-sidebar.js +2 -2
  76. package/dist/shell/app-sidebar.module.css +8 -8
  77. package/dist/shell/index.js +5 -1
  78. package/dist/shell/page-bar.js +1 -1
  79. package/dist/table/data-table.d.ts.map +1 -1
  80. package/dist/table/data-table.js +3 -0
  81. package/dist/theme/chrome-vars.d.ts +82 -0
  82. package/dist/theme/chrome-vars.d.ts.map +1 -0
  83. package/dist/theme/chrome-vars.js +36 -0
  84. package/dist/theme/controls.module.css +20 -1
  85. package/dist/theme/controls.module.css.d.ts +1 -0
  86. package/dist/theme/index.d.ts.map +1 -1
  87. package/dist/theme/index.js +61 -54
  88. package/dist/tokens/core.d.ts +10 -4
  89. package/dist/tokens/core.d.ts.map +1 -1
  90. package/dist/tokens/core.js +16 -10
  91. package/dist/tokens/ctl-vars.d.ts +15 -0
  92. package/dist/tokens/ctl-vars.d.ts.map +1 -0
  93. package/dist/tokens/ctl-vars.js +22 -0
  94. package/dist/tokens/derive.d.ts.map +1 -1
  95. package/dist/tokens/derive.js +2 -2
  96. package/dist/tokens/palette.d.ts +37 -29
  97. package/dist/tokens/palette.d.ts.map +1 -1
  98. package/dist/tokens/palette.js +32 -21
  99. package/dist/tokens/space-scale.d.ts +14 -0
  100. package/dist/tokens/space-scale.d.ts.map +1 -0
  101. package/dist/tokens/space-scale.js +10 -0
  102. package/llms.txt +6 -3
  103. package/package.json +1 -1
  104. package/src/agent/chat/thread-message.tsx +1 -1
  105. package/src/agent/chat/thread-outcome-card.tsx +2 -2
  106. package/src/charts/ChartCard.tsx +1 -1
  107. package/src/charts/Donut.tsx +2 -2
  108. package/src/charts/DualPanel.tsx +2 -2
  109. package/src/charts/Heatmap.tsx +2 -2
  110. package/src/charts/MirroredBars.tsx +2 -2
  111. package/src/charts/Sparkline.tsx +7 -5
  112. package/src/charts/chart-card.module.css +2 -2
  113. package/src/charts/compile.ts +31 -11
  114. package/src/charts/cursor.ts +48 -3
  115. package/src/charts/date-tick-format.ts +132 -0
  116. package/src/charts/panel.tsx +5 -3
  117. package/src/charts/types.ts +5 -1
  118. package/src/cli/shot/board.ts +1 -1
  119. package/src/cli/shot/capture.ts +35 -3
  120. package/src/cli/shot/measure.ts +33 -6
  121. package/src/cli/shot/playwright.ts +1 -1
  122. package/src/cli/shot/types.ts +3 -2
  123. package/src/dashboard/delta-badge.tsx +24 -18
  124. package/src/dashboard/query-state.tsx +38 -0
  125. package/src/dashboard/settings-section.tsx +5 -2
  126. package/src/dashboard/stat-card-parts.tsx +108 -0
  127. package/src/dashboard/stat-card.module.css +222 -9
  128. package/src/dashboard/stat-card.module.css.d.ts +20 -0
  129. package/src/dashboard/stat-card.tsx +291 -183
  130. package/src/dashboard/widget-header.module.css +28 -20
  131. package/src/dashboard/widget-header.tsx +103 -7
  132. package/src/guard/guard-hook.ts +3 -1
  133. package/src/guard/index.ts +27 -13
  134. package/src/guard/vx-names.ts +1 -0
  135. package/src/shell/app-mobile-nav.module.css +2 -2
  136. package/src/shell/app-sidebar-account.tsx +1 -1
  137. package/src/shell/app-sidebar.module.css +8 -8
  138. package/src/shell/app-sidebar.tsx +2 -2
  139. package/src/shell/index.tsx +10 -4
  140. package/src/shell/page-bar.tsx +1 -1
  141. package/src/table/data-table.tsx +10 -4
  142. package/src/theme/__snapshots__/plain-theme.test.ts.snap +185 -85
  143. package/src/theme/chrome-vars.ts +111 -0
  144. package/src/theme/controls.module.css +20 -1
  145. package/src/theme/controls.module.css.d.ts +1 -0
  146. package/src/theme/ctl-theme.tsx +1 -1
  147. package/src/theme/index.ts +82 -124
  148. package/src/tokens/core.ts +16 -8
  149. package/src/tokens/ctl-vars.ts +32 -0
  150. package/src/tokens/derive.ts +7 -2
  151. package/src/tokens/palette.ts +40 -29
  152. package/src/tokens/space-scale.ts +13 -0
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Component `vars` that carry the Wave 33 chrome (`docs/waves/design-parity/SPEC.md` § 6.12) and the
3
+ * ON-COLOR re-point they sit beside. Pure functions of theme + props, kept out of `theme/index.ts`
4
+ * so the tests can call them directly.
5
+ */
6
+ import type { MantineTheme } from '@mantine/core'
7
+
8
+ /**
9
+ * ON-COLOR: the foreground for a filled surface, decided in CSS. THE fix for Mantine's
10
+ * scheme-blind, contrast-blind `autoContrast`.
11
+ *
12
+ * Mantine picks the filled-variant text color ONCE, in JS, via `parseThemeColor({ color, theme })`
13
+ * — with NO `colorScheme` argument, so it resolves against the LIGHT `primaryShade` and bakes a
14
+ * static `color: var(--mantine-color-white)` into the element, while the BACKGROUND it pairs that
15
+ * with (`--mantine-color-{c}-filled`) stays a scheme-reactive CSS var. It gets away with it
16
+ * upstream only because Mantine's default `primaryShade` is `{ light: 6, dark: 8 }` — DARKER on
17
+ * dark, so white happens to stay right. It is luck, not logic: point `primaryShade.dark` at a
18
+ * lighter shade (as Basalt originally did) and every filled control in dark mode turns white-on-
19
+ * light. And even in one scheme the pick is wrong, because `isLightColor` is a BT.601 BRIGHTNESS
20
+ * test that does not track WCAG contrast — it handed white to lime `#97ba2e` at 2.24:1.
21
+ *
22
+ * Basalt removes the JS decision entirely. A fill is now scheme-INDEPENDENT and sits in a
23
+ * luminance band chosen so a WHITE label always clears AA (see `FILL` / `ACCENT` in
24
+ * tokens/palette.ts), so the on-color is a token, not a computation. `--vx-on-{color}` is emitted
25
+ * per color and resolves in pure CSS at paint time — the same discipline the rest of the `--vx-*`
26
+ * system follows. It is still MEASURED here (`legibleOn`) rather than hardcoded to white, so a
27
+ * consumer that retunes a family outside the band still gets the legible foreground.
28
+ *
29
+ * The palette already KNEW the answer: `ACCENT.onAccent` ("text on an accent fill") existed, and
30
+ * `Composer`'s send button hand-wired `color: var(--vx-on-accent)` — which was the ONLY reason that
31
+ * one control stayed legible while every generic Mantine control did not. The token was right;
32
+ * nothing bound the chrome to it. It is bound now (see `accentBridge` / `familyBridge`), and the
33
+ * Composer no longer needs the override.
34
+ *
35
+ * Fix: never let a foreground be decided in JS. `--vx-on-{color}` is emitted per color under BOTH
36
+ * scheme blocks of `cssVariablesResolver` (each resolved against the shade that scheme actually
37
+ * paints), so the foreground resolves in pure CSS at paint time — the same discipline the rest of
38
+ * the `--vx-*` system already follows. `basaltVariantColorResolver` re-points every filled variant
39
+ * at it, and the components that bypass the variant resolver (Checkbox / Radio / Tabs / Pagination /
40
+ * Stepper / Indicator / Timeline all call Mantine's `getContrastColor` directly) are re-pointed at
41
+ * it too, in `components` below. Regression-locked by `contrast.test.ts`.
42
+ */
43
+ export function onColor(theme: MantineTheme, color: string | undefined): string | undefined {
44
+ const name = color ?? theme.primaryColor
45
+ if (!Object.prototype.hasOwnProperty.call(theme.colors, name)) return undefined // hex / `blue.5`
46
+ return `var(--vx-on-${name})`
47
+ }
48
+
49
+ /**
50
+ * The on-color for a component that bypasses the variant resolver and calls Mantine's
51
+ * `getContrastColor` directly. `undefined` (autoContrast off, or a hex / indexed color) leaves
52
+ * Mantine's own value in place — `mergeVars` strips undefined before merging.
53
+ */
54
+ export function onColorFor(
55
+ theme: MantineTheme,
56
+ props: { color?: string | undefined; autoContrast?: boolean | undefined },
57
+ ): string | undefined {
58
+ const autoContrast = props.autoContrast ?? theme.autoContrast
59
+ return autoContrast ? onColor(theme, props.color) : undefined
60
+ }
61
+
62
+ /** The chrome opt-out: a call site that names a colour (even the primary one) keeps its hue. */
63
+ export function hasExplicitColor(color: string | undefined): boolean {
64
+ return color !== undefined
65
+ }
66
+
67
+ /**
68
+ * A `subtle` Button / ActionIcon that names no colour takes neutral ink for its label and an
69
+ * ink-6% hover (`docs/DESIGN-SPEC.md` §5 ghost idiom). An explicit `color=` — the primary one
70
+ * included — keeps Mantine's tinted label and hover: `color="red"` on a destructive text action
71
+ * carries its hue as the whole signal. Mantine hands the variant resolver `color || primaryColor`,
72
+ * so only the component props can tell "unnamed" from "primary" — hence vars, not the resolver.
73
+ */
74
+ export function subtleInkVars(props: {
75
+ color?: string | undefined
76
+ variant?: string | undefined
77
+ }): {
78
+ color: string | undefined
79
+ hover: string | undefined
80
+ } {
81
+ const ink = props.variant === 'subtle' && !hasExplicitColor(props.color)
82
+ return {
83
+ color: ink ? 'var(--vx-ink)' : undefined,
84
+ hover: ink ? 'color-mix(in srgb, var(--vx-ink) 6%, transparent)' : undefined,
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Tabs vars: the on-color re-point plus the active underline in ink (SPEC § 6.12). Only the
90
+ * underline `default` variant takes ink (`pills` fills with the colour); an explicit `color=` opts
91
+ * out. The return type lists `--tabs-text-color` and `--tabs-radius` because Mantine's
92
+ * `TabsCssVariables` type declares only `--tabs-color` / `--tabs-radius` while Tabs' OWN
93
+ * varsResolver writes `--tabs-text-color` (an upstream type gap).
94
+ */
95
+ export function tabsVars(
96
+ theme: MantineTheme,
97
+ props: {
98
+ color?: string | undefined
99
+ variant?: string | undefined
100
+ autoContrast?: boolean | undefined
101
+ },
102
+ ): { root: Record<'--tabs-color' | '--tabs-radius' | '--tabs-text-color', string | undefined> } {
103
+ const underline = !hasExplicitColor(props.color) && (props.variant ?? 'default') === 'default'
104
+ return {
105
+ root: {
106
+ '--tabs-text-color': onColorFor(theme, props),
107
+ '--tabs-color': underline ? 'var(--vx-ink)' : undefined,
108
+ '--tabs-radius': undefined,
109
+ },
110
+ }
111
+ }
@@ -276,7 +276,7 @@ html .accordionItem {
276
276
  /*
277
277
  * Tabs: the tab-list rule (and the inactive-tab hover underline) is a layout separator — the
278
278
  * divider token, not the heavy gray-3/dark-4 line. Mantine's scheme rules sit at (0,2,0); the
279
- * `html[...]` prefix lands (0,2,1). The active underline keeps `--tabs-color` untouched.
279
+ * `html[...]` prefix lands (0,2,1). The active underline's colour is set in the theme's Tabs `vars`.
280
280
  */
281
281
  html[data-mantine-color-scheme] .tabsRoot {
282
282
  --tab-border-color: var(--vx-divider);
@@ -304,3 +304,22 @@ html .tableRoot {
304
304
  html .tableRoot tbody tr:last-of-type {
305
305
  border-bottom: none;
306
306
  }
307
+
308
+ /*
309
+ * Badge leading glyph (`leftSection`): the state encoded by shape. 12px on a 20px chip, 4px gap
310
+ * (Mantine's own section margin is spacing.xs / 2 = 4), centred on the label.
311
+ */
312
+ .badgeSection {
313
+ --badge-section-margin: calc(0.25rem * var(--mantine-scale));
314
+ }
315
+
316
+ .badgeSection svg,
317
+ .badgeSection img {
318
+ width: calc(0.75rem * var(--mantine-scale));
319
+ height: calc(0.75rem * var(--mantine-scale));
320
+ flex-shrink: 0;
321
+ }
322
+
323
+ .badgeSection img {
324
+ object-fit: contain;
325
+ }
@@ -13,5 +13,6 @@ declare const classes: {
13
13
  readonly accordionItem: string
14
14
  readonly tabsRoot: string
15
15
  readonly tableRoot: string
16
+ readonly badgeSection: string
16
17
  }
17
18
  export default classes
@@ -16,7 +16,7 @@
16
16
  * applicable" (the spec's own hedge) resolves to "not applicable" here.
17
17
  *
18
18
  * **Radio / Checkbox / Switch and their `.Group`s, and the one consequence worth stating.** These
19
- * three default to Mantine's `sm` — a 20px indicator beside the tier's 13.5px option label — which
19
+ * three default to Mantine's `sm` — a 20px indicator beside the tier's 13px option label — which
20
20
  * is what every filter popover and the mobile sheet rendered. They are here rather than fixed in a
21
21
  * CSS module because their geometry is a Mantine SIZE (five vars for a Switch alone), so the tier
22
22
  * reaches them the same way it reaches Button and Input: through `-ctl` vars in
@@ -81,9 +81,12 @@ import {
81
81
  import type { PaletteData, RadiusValues, SpaceValues } from '../tokens/palette'
82
82
  import { DEFAULT_DERIVE_CONFIG, isDefaultDeriveConfig, resolveDeriveConfig } from '../tokens/derive'
83
83
  import type { DeriveConfig } from '../tokens/derive'
84
- import { pxRem, VX } from '../tokens/core'
84
+ import { pxRem, TEXT_LINE, VX } from '../tokens/core'
85
+ import { CTL_HEIGHT_VARS } from '../tokens/ctl-vars'
86
+ import type { CtlHeightVar } from '../tokens/ctl-vars'
85
87
  import { SIZE_CLASS_BREAKPOINTS } from '../tokens/size-classes'
86
88
  import type { BasaltFontsConfig } from '../tokens/core'
89
+ import { onColor, onColorFor, subtleInkVars, tabsVars } from './chrome-vars'
87
90
  import controlsClasses from './controls.module.css'
88
91
  import floatingClasses from './floating.module.css'
89
92
  import navLinkClasses from './nav-link.module.css'
@@ -227,60 +230,6 @@ function buildDarkTuple(data: PaletteData): MantineColorsTuple {
227
230
  ] as unknown as MantineColorsTuple
228
231
  }
229
232
 
230
- /**
231
- * ON-COLOR: the foreground for a filled surface, decided in CSS. THE fix for Mantine's
232
- * scheme-blind, contrast-blind `autoContrast`.
233
- *
234
- * Mantine picks the filled-variant text color ONCE, in JS, via `parseThemeColor({ color, theme })`
235
- * — with NO `colorScheme` argument, so it resolves against the LIGHT `primaryShade` and bakes a
236
- * static `color: var(--mantine-color-white)` into the element, while the BACKGROUND it pairs that
237
- * with (`--mantine-color-{c}-filled`) stays a scheme-reactive CSS var. It gets away with it
238
- * upstream only because Mantine's default `primaryShade` is `{ light: 6, dark: 8 }` — DARKER on
239
- * dark, so white happens to stay right. It is luck, not logic: point `primaryShade.dark` at a
240
- * lighter shade (as Basalt originally did) and every filled control in dark mode turns white-on-
241
- * light. And even in one scheme the pick is wrong, because `isLightColor` is a BT.601 BRIGHTNESS
242
- * test that does not track WCAG contrast — it handed white to lime `#97ba2e` at 2.24:1.
243
- *
244
- * Basalt removes the JS decision entirely. A fill is now scheme-INDEPENDENT and sits in a
245
- * luminance band chosen so a WHITE label always clears AA (see `FILL` / `ACCENT` in
246
- * tokens/palette.ts), so the on-color is a token, not a computation. `--vx-on-{color}` is emitted
247
- * per color and resolves in pure CSS at paint time — the same discipline the rest of the `--vx-*`
248
- * system follows. It is still MEASURED here (`legibleOn`) rather than hardcoded to white, so a
249
- * consumer that retunes a family outside the band still gets the legible foreground.
250
- *
251
- * The palette already KNEW the answer: `ACCENT.onAccent` ("text on an accent fill") existed, and
252
- * `Composer`'s send button hand-wired `color: var(--vx-on-accent)` — which was the ONLY reason that
253
- * one control stayed legible while every generic Mantine control did not. The token was right;
254
- * nothing bound the chrome to it. It is bound now (see `accentBridge` / `familyBridge`), and the
255
- * Composer no longer needs the override.
256
- *
257
- * Fix: never let a foreground be decided in JS. `--vx-on-{color}` is emitted per color under BOTH
258
- * scheme blocks of `cssVariablesResolver` (each resolved against the shade that scheme actually
259
- * paints), so the foreground resolves in pure CSS at paint time — the same discipline the rest of
260
- * the `--vx-*` system already follows. `basaltVariantColorResolver` re-points every filled variant
261
- * at it, and the components that bypass the variant resolver (Checkbox / Radio / Tabs / Pagination /
262
- * Stepper / Indicator / Timeline all call Mantine's `getContrastColor` directly) are re-pointed at
263
- * it too, in `components` below. Regression-locked by `contrast.test.ts`.
264
- */
265
- function onColor(theme: MantineTheme, color: string | undefined): string | undefined {
266
- const name = color ?? theme.primaryColor
267
- if (!Object.prototype.hasOwnProperty.call(theme.colors, name)) return undefined // hex / `blue.5`
268
- return `var(--vx-on-${name})`
269
- }
270
-
271
- /**
272
- * The on-color for a component that bypasses the variant resolver and calls Mantine's
273
- * `getContrastColor` directly. `undefined` (autoContrast off, or a hex / indexed color) leaves
274
- * Mantine's own value in place — `mergeVars` strips undefined before merging.
275
- */
276
- function onColorFor(
277
- theme: MantineTheme,
278
- props: { color?: string | undefined; autoContrast?: boolean | undefined },
279
- ): string | undefined {
280
- const autoContrast = props.autoContrast ?? theme.autoContrast
281
- return autoContrast ? onColor(theme, props.color) : undefined
282
- }
283
-
284
233
  /** WCAG 2.x relative luminance. */
285
234
  function relativeLuminance(hex: string): number {
286
235
  const channels = hexToRgb(hex).map((c) => {
@@ -365,24 +314,9 @@ const basaltVariantColorResolver: VariantColorsResolver = (input) => {
365
314
  return autoContrast ? { ...resolved, color: on } : resolved
366
315
  }
367
316
 
368
- // `subtle`: hover is a NEUTRAL ink tint, not Mantine's accent tint
369
- // (`--mantine-color-{c}-light`). `docs/DESIGN-SPEC.md` §5 specifies the ghost idiom as "hover
370
- // ink-6% + ink icon", and a subtle Button had never followed it — it hovered into a saturated
371
- // accent block that read as a filled control appearing under the cursor. Fixing it HERE rather
372
- // than in controls.module.css is what makes Button and ActionIcon agree: both resolve `subtle`
373
- // through this one function, and §5's ghost icon button and a `variant="subtle"` Button are meant
374
- // to be the same idiom at two sizes.
375
- //
376
- // Scoped to the DEFAULT color on purpose. An explicitly-colored subtle control (`color="red"` on a
377
- // destructive text action) carries its hue as the whole signal, so neutralizing its hover would
378
- // erase the one thing that marks it dangerous — those keep Mantine's own tinted hover.
379
- if (input.variant === 'subtle') {
380
- const isDefaultColor = input.color === undefined || input.color === input.theme.primaryColor
381
- return isDefaultColor
382
- ? { ...resolved, hover: `color-mix(in srgb, var(--vx-ink) 6%, transparent)` }
383
- : resolved
384
- }
385
-
317
+ // `subtle` stays Mantine's: Button and ActionIcon get their ink label + hover in `subtleInkVars`
318
+ // (the resolver is always handed `color || primaryColor`, so it cannot tell "unnamed" from an
319
+ // explicit primary colour — only the component props can).
386
320
  // `outline`: the tone's own text colour, pulled toward ink so the label keeps its hue at AA
387
321
  // (grey outline badges measured 3.9:1 on the light page).
388
322
  if (input.variant === 'outline') {
@@ -467,7 +401,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
467
401
  // buttons ≥28px sit at ~6px). `radius.md` = 0.375rem = 6px, mirrored by `--vx-radius-ctrl` — every
468
402
  // control without its own explicit `radius` prop (Button, ActionIcon, TextInput, NumberInput,
469
403
  // PasswordInput, Select, Textarea) falls back to this default. Card/Paper bypass this scale
470
- // entirely — they resolve straight to `var(--vx-radius-card)` (7px, see the
404
+ // entirely — they resolve straight to `var(--vx-radius-card)` (10px, see the
471
405
  // `components.Card`/`Paper` overrides below).
472
406
  defaultRadius: 'md',
473
407
  // Named weight ladder (v9 fontWeights).
@@ -485,6 +419,11 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
485
419
  lg: rem(VX.text.lg),
486
420
  xl: rem(VX.text.xl),
487
421
  },
422
+ // Dense rungs get grid-aligned line boxes (13/20, 12/16); md and up keep Mantine's ratios.
423
+ lineHeights: {
424
+ xs: lineRatio(TEXT_LINE.xs, VX.text.xs),
425
+ sm: lineRatio(TEXT_LINE.sm, VX.text.sm),
426
+ },
488
427
  // Deliberate, OWNED spacing + radius scales — the single edit point, not inherited Mantine
489
428
  // defaults. Denser than Mantine's stock lg/xl for a tighter, data-driven surface. 10 12 16 18 24.
490
429
  // Reads `spacing.scale`, NOT `spacing.anchors` — a scale stop tracks density independently of
@@ -538,7 +477,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
538
477
  // resolves to the SAME three tokens:
539
478
  // • background → `--vx-surface-panel` (the panel surface, NOT the page body).
540
479
  // • depth → `--vx-shadow-card` (whisper shadow + ring, replaces `withBorder`).
541
- // • radius → `--vx-radius-card` (7px).
480
+ // • radius → `--vx-radius-card` (10px).
542
481
  // This is the single source the user's "strict surface across components" demands; the
543
482
  // `raw-surface` guard then stops consumers re-overriding any of it inline.
544
483
  Card: ext<typeof Card>({
@@ -559,10 +498,12 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
559
498
  },
560
499
  },
561
500
  }),
562
- // Mantine's default Badge radius is a full 1000px pill; the spec's delta/status badges sit at
563
- // radius 6 (docs/DESIGN-SPEC.md §4/§5). Count badges (radius 5) are a distinct, smaller-radius
564
- // usage left to the call site (`radius={5}` prop) since Badge has no state to key off here.
565
- Badge: ext<typeof Badge>({ defaultProps: { radius: radius.ctrl } }),
501
+ // Status chip (SPEC § 6.10): `light` + `tight`, neutral until `color=` opts in (the accent is
502
+ // never a status chip's default); a `leftSection` glyph is sized in `badgeSection`.
503
+ Badge: ext<typeof Badge>({
504
+ defaultProps: { variant: 'light', color: 'gray', radius: radius.tight },
505
+ classNames: { section: controlsClasses.badgeSection },
506
+ }),
566
507
  // Alert renders its title in the body font by default; bring it onto the head-font idiom
567
508
  // (docs/DESIGN-SPEC.md §5) like every other titled surface. Radius/padding/color tint are
568
509
  // already on-system (defaultRadius 'md' control tier + the variant color resolver), so only
@@ -634,19 +575,20 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
634
575
  // `--nl-padding` var), so the spec padding is forced inline here, where it wins
635
576
  // deterministically on every render path.
636
577
  padding: 'var(--vx-space-row-inset-y) var(--vx-space-row-inset-x)',
637
- // The body step on the ROOT, not just the label: the body element sizes itself from the
638
- // root's inherited line-height (which, left at the default 1.55, alone pushed rows to
639
- // ~37px). The tightened 1.35 keeps rows compact as the scale grows. Reads
578
+ // The dense-row step (`sm`) on the ROOT, not just the label: the body element sizes
579
+ // itself from the root's inherited line-height (which, left at the default 1.55, alone
580
+ // pushed rows to ~37px). The row line-height (1.54, a 20px line at 13px) keeps rows
581
+ // compact as the scale grows. Reads
640
582
  // `--vx-space-row-line-height` (density-tracking, ADDITIVE law — see `deriveSpacing`'s
641
583
  // doc in `tokens/palette.ts` for why this one differs from the padding's multiplier).
642
- fontSize: VX.text.md,
584
+ fontSize: VX.text.sm,
643
585
  lineHeight: 'var(--vx-space-row-line-height)',
644
586
  // Nav rows sit in the 5-6px radius tier (docs/DESIGN-SPEC.md §4), not square.
645
587
  borderRadius: 'var(--vx-radius-ctrl)',
646
588
  },
647
589
  // Mantine pins the label at `font-size-sm` explicitly, so the root value alone
648
590
  // doesn't reach it.
649
- label: { fontSize: VX.text.md, lineHeight: 'var(--vx-space-row-line-height)' },
591
+ label: { fontSize: VX.text.sm, lineHeight: 'var(--vx-space-row-line-height)' },
650
592
  },
651
593
  }),
652
594
  // Field idiom (docs/DESIGN-SPEC.md §5): field surface + `shadow-raised` depth + faint placeholder,
@@ -733,25 +675,35 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
733
675
  // `size="xs"`) on Mantine's own static height.
734
676
  Button: ext<typeof Button>({
735
677
  classNames: { root: controlsClasses.buttonRoot },
736
- vars: (_theme, props) => ({
737
- root: {
738
- '--button-height':
739
- props.size === 'md'
740
- ? 'calc(var(--vx-space-control-height) * var(--mantine-scale))'
741
- : undefined,
742
- },
743
- }),
678
+ vars: (_theme, props) => {
679
+ const ink = subtleInkVars(props)
680
+ return {
681
+ root: {
682
+ '--button-height':
683
+ props.size === 'md'
684
+ ? 'calc(var(--vx-space-control-height) * var(--mantine-scale))'
685
+ : undefined,
686
+ '--button-color': ink.color,
687
+ '--button-hover': ink.hover,
688
+ },
689
+ }
690
+ },
744
691
  }),
745
692
  ActionIcon: ext<typeof ActionIcon>({
746
693
  classNames: { root: controlsClasses.actionIconRoot },
747
- vars: (_theme, props) => ({
748
- root: {
749
- '--ai-size':
750
- props.size === 'md'
751
- ? 'calc(var(--vx-space-control-height) * var(--mantine-scale))'
752
- : undefined,
753
- },
754
- }),
694
+ vars: (_theme, props) => {
695
+ const ink = subtleInkVars(props)
696
+ return {
697
+ root: {
698
+ '--ai-size':
699
+ props.size === 'md'
700
+ ? 'calc(var(--vx-space-control-height) * var(--mantine-scale))'
701
+ : undefined,
702
+ '--ai-color': ink.color,
703
+ '--ai-hover': ink.hover,
704
+ },
705
+ }
706
+ },
755
707
  }),
756
708
  // CheckboxCard / RadioCard (`withBorder`, true by default): same live regression as Button/
757
709
  // ActionIcon before this pass — Mantine ships `border: 1px solid transparent` as the BASE
@@ -810,12 +762,12 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
810
762
  //
811
763
  // The track's padding is `SPACE_FIXED.segmentedTrackInset`, a plain literal — NOT a
812
764
  // `--vx-space-*` var — because it is density-EXEMPT: it is load-bearing for the nested-corner
813
- // law (`RADIUS.card === RADIUS_STEP.tight + segmentedTrackInset`, see that constant's doc in
814
- // `tokens/palette.ts`), and `radius.card`/`RADIUS_STEP.tight` two lines below already track the
765
+ // law (`RADIUS.ctrl === RADIUS_STEP.fine + segmentedTrackInset`, see that constant's doc in
766
+ // `tokens/palette.ts`), and `radius.ctrl`/`RADIUS_STEP.fine` below already track the
815
767
  // RADIUS knob together, so the inset between them must stay fixed at exactly 2 regardless of
816
768
  // density.
817
769
  SegmentedControl: ext<typeof SegmentedControl>({
818
- defaultProps: { radius: radius.card },
770
+ defaultProps: { radius: radius.ctrl },
819
771
  classNames: {
820
772
  label: segmentedControlClasses.label,
821
773
  control: segmentedControlClasses.control,
@@ -852,7 +804,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
852
804
  // ink-12% fill sat one shade from the track and read as a hover state.
853
805
  boxShadow: 'var(--vx-shadow-raised)',
854
806
  outline: '1px solid color-mix(in srgb, var(--vx-ink) 14%, transparent)',
855
- borderRadius: 'var(--vx-radius-tight)',
807
+ borderRadius: 'var(--vx-radius-fine)',
856
808
  },
857
809
  // Conditionally spread the WHOLE key (never a present `label: undefined`) — the package
858
810
  // builds under `exactOptionalPropertyTypes`, which treats a key present-but-`undefined` as
@@ -925,12 +877,12 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
925
877
  },
926
878
  styles: {
927
879
  itemTitle: {
928
- fontSize: VX.text.md,
880
+ fontSize: VX.text.sm,
929
881
  fontWeight: 600,
930
882
  color: 'var(--vx-ink)',
931
883
  },
932
884
  itemContent: {
933
- fontSize: VX.text.md,
885
+ fontSize: VX.text.sm,
934
886
  color: 'var(--vx-muted)',
935
887
  },
936
888
  },
@@ -983,7 +935,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
983
935
  boxShadow: 'var(--vx-shadow-overlay)',
984
936
  },
985
937
  item: {
986
- fontSize: VX.text.md,
938
+ fontSize: VX.text.sm,
987
939
  borderRadius: 'var(--vx-radius-ctrl)',
988
940
  padding: 'var(--vx-space-row-inset-y) var(--vx-space-row-inset-x)',
989
941
  },
@@ -1099,7 +1051,7 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
1099
1051
  textTransform: 'uppercase',
1100
1052
  color: 'var(--vx-faint)',
1101
1053
  },
1102
- td: { height: spacing.step.tableRowHeight },
1054
+ td: { height: spacing.step.tableRowHeight, fontSize: VX.text.sm },
1103
1055
  },
1104
1056
  }),
1105
1057
  // The v9 thumb indicator is a center dot painted in the TRACK color — over the remapped
@@ -1117,17 +1069,11 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
1117
1069
  // The tab-list bottom rule (and the inactive-tab hover underline) is a layout separator, not
1118
1070
  // control chrome — it reads the divider token instead of the heavy gray-3/dark-4 line
1119
1071
  // (controls.module.css; custom properties are stripped from `styles` objects). The active tab
1120
- // underline keeps `--tabs-color` (accent) untouched.
1072
+ // underline takes ink, not the accent (SPEC § 6.12; DESIGN-CORE § Accent discipline);
1073
+ // `color=` opts back in. Only the underline `default` variant — `pills` fills with the colour.
1121
1074
  Tabs: ext<typeof Tabs>({
1122
1075
  classNames: { root: controlsClasses.tabsRoot },
1123
- // The on-color re-point (see below). Cast: Mantine's `TabsCssVariables` type declares only
1124
- // `--tabs-color` / `--tabs-radius`, yet Tabs' OWN varsResolver writes `--tabs-text-color` —
1125
- // an upstream type gap, so the var it actually paints the active tab with is otherwise
1126
- // unreachable from the theme.
1127
- vars: (theme, props) =>
1128
- ({ root: { '--tabs-text-color': onColorFor(theme, props) } }) as unknown as {
1129
- root: Record<'--tabs-color' | '--tabs-radius', string | undefined>
1130
- },
1076
+ vars: tabsVars,
1131
1077
  }),
1132
1078
 
1133
1079
  // ── ON-COLOR re-points (see the ON-COLOR doctrine above) ────────────────────────────────
@@ -1314,7 +1260,7 @@ const CTL_NUMBER_CHEVRON_SIZE = 10
1314
1260
  const CTL_NUMBER_RIGHT_SECTION_WIDTH = 17
1315
1261
  /**
1316
1262
  * The `ctl` tier's Radio/Checkbox indicator box, in px — 16, the SAME square
1317
- * `theme/icon-slot.module.css` gives every icon in the tier, and for the same reason: a 13.5px
1263
+ * `theme/icon-slot.module.css` gives every icon in the tier, and for the same reason: a 13px
1318
1264
  * option label needs a mark it reads as part of the row rather than as a control beside it. Mantine's
1319
1265
  * default is `sm` (20px) and its `md` is 24px, both of which made the popover a column of controls
1320
1266
  * (the sheet/panel forms found the same thing and went further — `docs/CONTROLS-SPEC.md` §3's
@@ -1392,14 +1338,12 @@ const CTL_SLIDER_TRACK_SIZE = 6
1392
1338
  * (`docs/CONTROLS-SPEC.md` §2.1) is the same 30px as the buttons beside it — Mantine's tallest
1393
1339
  * shipped Badge is 32px `xl`, and none of its tiers is 30.
1394
1340
  */
1395
- function ctlSizeVars(): Record<string, string> {
1341
+ function ctlSizeVars(): Record<string, string> & Record<CtlHeightVar, string> {
1396
1342
  const ctlHeight = 'calc(var(--vx-space-control-height-ctl) * var(--mantine-scale))'
1397
1343
  return {
1398
- '--button-height-ctl': ctlHeight,
1344
+ ...heightVars(ctlHeight),
1399
1345
  '--button-padding-x-ctl': `calc(${pxRem(CTL_PADDING_X)} * var(--mantine-scale))`,
1400
- '--input-height-ctl': ctlHeight,
1401
1346
  '--input-padding-y-ctl': `calc(${pxRem(CTL_INPUT_PADDING_Y)} * var(--mantine-scale))`,
1402
- '--ai-size-ctl': ctlHeight,
1403
1347
  '--ai-size-icon': 'calc(var(--vx-space-control-height-widget) * var(--mantine-scale))',
1404
1348
  // A shorthand pair (`<y> <x>`), the shape SegmentedControl's own `--sc-padding-*` vars take.
1405
1349
  // `y` stays a bare literal (the label's own box height is now enforced by the `size === 'ctl'`
@@ -1410,7 +1354,6 @@ function ctlSizeVars(): Record<string, string> {
1410
1354
  '--combobox-chevron-size-ctl': pxRem(CTL_CHEVRON_SIZE),
1411
1355
  '--ni-chevron-size-ctl': pxRem(CTL_NUMBER_CHEVRON_SIZE),
1412
1356
  '--ni-right-section-width-ctl': `calc(${pxRem(CTL_NUMBER_RIGHT_SECTION_WIDTH)} * var(--mantine-scale))`,
1413
- '--badge-height-ctl': ctlHeight,
1414
1357
  '--badge-padding-x-ctl': `calc(${pxRem(CTL_PADDING_X)} * var(--mantine-scale))`,
1415
1358
  '--badge-fz-ctl': `calc(${pxRem(VX.text.xs)} * var(--mantine-scale))`,
1416
1359
  // `= VX.text.sm` per `docs/CONTROLS-SPEC.md` §5 — same `calc(<rem> * var(--mantine-scale))`
@@ -1418,7 +1361,7 @@ function ctlSizeVars(): Record<string, string> {
1418
1361
  '--mantine-font-size-ctl': `calc(${pxRem(VX.text.sm)} * var(--mantine-scale))`,
1419
1362
  '--mantine-line-height-ctl': 'var(--mantine-line-height-sm)',
1420
1363
  // Radio / Checkbox / Switch — the three components whose DEFAULT (`sm`, a 20px indicator) sat
1421
- // beside a 13.5px option label in every popover and sheet basalt draws. Every prefix here was
1364
+ // beside a 13px option label in every popover and sheet basalt draws. Every prefix here was
1422
1365
  // read out of the installed `@mantine/core` source, and `ctl-tier-coverage.test.ts` now scans
1423
1366
  // those three components too, so a future minor that adds a `getSize` call fails the build
1424
1367
  // instead of resolving the new var to its initial value. Note there is NO
@@ -1438,6 +1381,21 @@ function ctlSizeVars(): Record<string, string> {
1438
1381
  }
1439
1382
  }
1440
1383
 
1384
+ /** Every `ctl` height var set to one value — typed over {@link CTL_HEIGHT_VARS} so a var added to the
1385
+ * list cannot be missing from the tier. */
1386
+ function heightVars(height: string): Record<CtlHeightVar, string> {
1387
+ return Object.fromEntries(CTL_HEIGHT_VARS.map((name) => [name, height])) as Record<
1388
+ CtlHeightVar,
1389
+ string
1390
+ >
1391
+ }
1392
+
1393
+ /** A px line box as the unitless ratio Mantine's `lineHeights` take, to 4 decimals (like
1394
+ * `rowLineHeight`, which rounds to 2) so the emitted var carries no float noise. */
1395
+ function lineRatio(linePx: number, fontPx: number): string {
1396
+ return String(Math.round((linePx / fontPx) * 10000) / 10000)
1397
+ }
1398
+
1441
1399
  /** `radius` knob: an integer level, so an out-of-range value is a tsc error (V2-SPEC §3). */
1442
1400
  export type BasaltRadiusLevel = -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5
1443
1401
 
@@ -9,6 +9,7 @@
9
9
  * Grounded in argo `packages/charts/src/{tokens,palette,theme-vars,utils/color}.ts`.
10
10
  */
11
11
 
12
+ import { denseCtlBlock } from './ctl-vars'
12
13
  import {
13
14
  buildPaletteData,
14
15
  RADIUS,
@@ -94,6 +95,8 @@ export const alpha = (token: string, a: number): string =>
94
95
  * Type is a token axis like color / spacing / radius / motion: a single edit point, never a
95
96
  * hardcoded literal at a call site. Every font-size in the framework resolves to a step here.
96
97
  *
98
+ * `TEXT_LINE` (below) pins the two dense rungs to grid-aligned line boxes.
99
+ *
97
100
  * Two representations are DERIVED from this one object, so they cannot drift:
98
101
  * • `VX.text.*` — plain numbers, for inline `style` objects and visx SVG props (React appends
99
102
  * `px`; SVG presentation attributes can't resolve `var()`, so a ref string would break charts).
@@ -128,17 +131,21 @@ export const alpha = (token: string, a: number): string =>
128
131
  const TEXT = {
129
132
  nano: 10, // engraved/graphic label INSIDE a drawn object (a plate face, a dial, a chip) — never UI copy or prose
130
133
  micro: 11, // mono uppercase micro-label (table th, Menu.Label, sidebar/section headers, axis ticks)
131
- xs: 12.5, // delta badges, tooltip meta, dense chrome, StatCard labels
132
- sm: 13.5, // table/stat numerals, chart tooltip, legend
133
- md: 15, // BODY — nav rows, menu items, timeline, labels, prose; chart/card titles
134
+ xs: 12, // delta badges, tooltip meta, dense chrome, StatCard labels — 16px line (`TEXT_LINE.xs`)
135
+ sm: 13, // DENSE ROWS — table cells, nav rows, list/event rows, menu items; numerals, tooltip, legend — 20px line (`TEXT_LINE.sm`)
136
+ md: 15, // BODY — prose and form labels; chart/card titles
134
137
  lg: 16, // breadcrumb current — ALSO the iOS input floor (do not lower)
135
138
  xl: 18, // section titles
136
139
  h2: 21, // article-density Prose h2 (docs/CONTENT-SPEC.md §5)
137
- kpi: 24, // the StatCard hero numeral (density pass: 31 → 24, tighter/less shouty)
140
+ kpi: 22, // the StatCard hero numeral (mono 500; 31 → 24 → 22, tighter/less shouty)
138
141
  h1: 26, // article-density Prose h1 (docs/CONTENT-SPEC.md §5)
139
142
  display: 30, // a numeral read at arm's length (a keypad readout, a timer, a kiosk figure) — not a heading
140
143
  } as const
141
144
 
145
+ /** Grid-aligned line boxes (px) for the two dense rungs — `theme/index.ts` re-expresses them as the
146
+ * Mantine `lineHeights` `xs`/`sm`, so a `<Text size="sm">` row is a 20px box and a meta line 16px. */
147
+ export const TEXT_LINE = { xs: 16, sm: 20 } as const
148
+
142
149
  export const VX = {
143
150
  // Non-color sizing constants
144
151
  // Stroke WEIGHTS, not spacing — deliberately fixed, never density-tracking (see
@@ -489,6 +496,7 @@ function spaceDecls(space: SpaceValues): string[] {
489
496
  decl('space-control-height-tag', pxRem(space.anchors.controlHeightTag)),
490
497
  decl('space-control-height-widget', pxRem(space.anchors.controlHeightWidget)),
491
498
  decl('space-control-height-ctl', pxRem(space.anchors.controlHeightCtl)),
499
+ decl('space-control-height-dense', pxRem(space.anchors.controlHeightDense)),
492
500
  decl('space-stack-xs', `${space.anchors.stackXs}px`),
493
501
  decl('space-stack-sm', `${space.anchors.stackSm}px`),
494
502
  decl('space-stack-md', `${space.anchors.stackMd}px`),
@@ -911,7 +919,7 @@ const coarseHitBlock = `@media (pointer: coarse) {\n :root {\n --vx-hit: ${H
911
919
  * (`appShellInsetMobile`), and the card ladder INSIDE that gutter never moved — card insets stayed
912
920
  * `xs`/`sm` and a `Section`'s gaps stayed `stackMd` at every width — so a 390px phone still read
913
921
  * "content spacing too big" after the gutter fix. Two rungs close it: the card's horizontal inset
914
- * steps `sm` -> `xs`, and the Section's gap steps `stackMd` -> `stackSm`.
922
+ * steps `md` -> `sm`, and the Section's gap steps `stackMd` -> `stackSm`.
915
923
  *
916
924
  * Why it lives HERE and not in the three CSS files that consume it: two of those three sites are
917
925
  * INLINE styles in TSX (`dashboard/stat-card.tsx`, `charts/primitives/ChartCard.tsx`), and an
@@ -932,7 +940,7 @@ const coarseHitBlock = `@media (pointer: coarse) {\n :root {\n --vx-hit: ${H
932
940
  */
933
941
  function spaceMobileDecls(space: SpaceValues): string[] {
934
942
  return [
935
- decl('space-card-inset-x', `${space.scale.xs}px`),
943
+ decl('space-card-inset-x', `${space.scale.sm}px`),
936
944
  decl('space-section-gap', `${space.anchors.stackSm}px`),
937
945
  ]
938
946
  }
@@ -997,8 +1005,8 @@ export function buildPaletteCss(
997
1005
  // consumer never receives the base pair the block exists to override.
998
1006
  const rootBlock =
999
1007
  only === 'core'
1000
- ? `:root {\n${derived}\n}\n${coarseHitBlock}`
1001
- : `:root {\n${derived}\n}\n${mobileLadderBlock(DEFAULT_SPACE_VALUES)}\n${coarseHitBlock}`
1008
+ ? `:root {\n${derived}\n}\n${coarseHitBlock}\n${denseCtlBlock()}`
1009
+ : `:root {\n${derived}\n}\n${mobileLadderBlock(DEFAULT_SPACE_VALUES)}\n${coarseHitBlock}\n${denseCtlBlock()}`
1002
1010
 
1003
1011
  // The legacy shape — kept verbatim, and only reachable when the caller asked for nothing.
1004
1012
  if (opts.scheme === undefined && opts.defaultScheme === undefined && !opts.mediaFallback) {
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The Mantine size vars that carry the `ctl` tier's HEIGHT — one list, read by `ctlSizeVars`
3
+ * (`theme/index.ts`, which sets each to the `ctl` height) and by {@link denseCtlBlock} (which
4
+ * restates each at the dense height for `[data-basalt-dense]`). Mantine substitutes these where they
5
+ * are declared (`:root`), so the dense tier cannot re-point the token alone.
6
+ */
7
+ export const CTL_HEIGHT_VARS = [
8
+ '--button-height-ctl',
9
+ '--input-height-ctl',
10
+ '--ai-size-ctl',
11
+ '--badge-height-ctl',
12
+ ] as const
13
+
14
+ export type CtlHeightVar = (typeof CTL_HEIGHT_VARS)[number]
15
+
16
+ /**
17
+ * The dense-tier rule (SPEC D6), emitted beside `coarseHitBlock` in the palette CSS. A scope that
18
+ * carries `data-basalt-dense` re-points the `ctl` height at `--vx-space-control-height-dense` at
19
+ * FINE pointers only; a coarse pointer keeps the `ctl` height and the 44px hit overlay.
20
+ */
21
+ export function denseCtlBlock(): string {
22
+ const height = 'calc(var(--vx-space-control-height-dense) * var(--mantine-scale))'
23
+ const decls = CTL_HEIGHT_VARS.map((name) => ` ${name}: ${height};`).join('\n')
24
+ return [
25
+ '@media (pointer: fine) {',
26
+ ' [data-basalt-dense] {',
27
+ ' --vx-space-control-height-ctl: var(--vx-space-control-height-dense);',
28
+ decls,
29
+ ' }',
30
+ '}',
31
+ ].join('\n')
32
+ }