basalt-ui 2.16.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 (89) hide show
  1. package/CHANGELOG.md +149 -126
  2. package/MIGRATING.md +101 -15
  3. package/agent/agents/basalt-design-reviewer.md +2 -2
  4. package/agent/skills/basalt-design/SKILL.md +2 -2
  5. package/configs/oxlint-plugin.js +2 -2
  6. package/dist/charts/Donut.d.ts.map +1 -1
  7. package/dist/charts/Donut.js +2 -2
  8. package/dist/charts/DualPanel.js +2 -2
  9. package/dist/charts/Heatmap.d.ts.map +1 -1
  10. package/dist/charts/Heatmap.js +2 -2
  11. package/dist/charts/MirroredBars.js +2 -2
  12. package/dist/charts/Sparkline.d.ts +4 -2
  13. package/dist/charts/Sparkline.d.ts.map +1 -1
  14. package/dist/charts/Sparkline.js +3 -3
  15. package/dist/charts/compile.d.ts +8 -3
  16. package/dist/charts/compile.d.ts.map +1 -1
  17. package/dist/charts/compile.js +19 -9
  18. package/dist/charts/cursor.d.ts +14 -1
  19. package/dist/charts/cursor.d.ts.map +1 -1
  20. package/dist/charts/cursor.js +29 -3
  21. package/dist/charts/date-tick-format.d.ts +17 -0
  22. package/dist/charts/date-tick-format.d.ts.map +1 -0
  23. package/dist/charts/date-tick-format.js +81 -0
  24. package/dist/charts/panel.d.ts +2 -1
  25. package/dist/charts/panel.d.ts.map +1 -1
  26. package/dist/charts/panel.js +3 -2
  27. package/dist/charts/types.d.ts +5 -1
  28. package/dist/charts/types.d.ts.map +1 -1
  29. package/dist/cli/shot/capture.d.ts +16 -0
  30. package/dist/cli/shot/capture.d.ts.map +1 -1
  31. package/dist/cli/shot/capture.js +24 -3
  32. package/dist/cli/shot/playwright.d.ts +4 -0
  33. package/dist/cli/shot/playwright.d.ts.map +1 -1
  34. package/dist/dashboard/delta-badge.d.ts +2 -2
  35. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  36. package/dist/dashboard/delta-badge.js +12 -14
  37. package/dist/dashboard/query-state.d.ts +35 -0
  38. package/dist/dashboard/query-state.d.ts.map +1 -1
  39. package/dist/dashboard/query-state.js +12 -1
  40. package/dist/dashboard/stat-card-parts.d.ts +40 -0
  41. package/dist/dashboard/stat-card-parts.d.ts.map +1 -0
  42. package/dist/dashboard/stat-card-parts.js +55 -0
  43. package/dist/dashboard/stat-card.d.ts +46 -34
  44. package/dist/dashboard/stat-card.d.ts.map +1 -1
  45. package/dist/dashboard/stat-card.js +148 -79
  46. package/dist/dashboard/stat-card.module.css +220 -7
  47. package/dist/dashboard/stat-card.module.css.d.ts +20 -0
  48. package/dist/dashboard/widget-header.d.ts.map +1 -1
  49. package/dist/dashboard/widget-header.js +73 -9
  50. package/dist/dashboard/widget-header.module.css +25 -17
  51. package/dist/guard/index.js +2 -2
  52. package/dist/theme/chrome-vars.d.ts +82 -0
  53. package/dist/theme/chrome-vars.d.ts.map +1 -0
  54. package/dist/theme/chrome-vars.js +36 -0
  55. package/dist/theme/controls.module.css +20 -1
  56. package/dist/theme/controls.module.css.d.ts +1 -0
  57. package/dist/theme/index.d.ts.map +1 -1
  58. package/dist/theme/index.js +30 -33
  59. package/dist/tokens/derive.d.ts.map +1 -1
  60. package/dist/tokens/derive.js +2 -2
  61. package/llms.txt +6 -3
  62. package/package.json +1 -1
  63. package/src/charts/Donut.tsx +2 -2
  64. package/src/charts/DualPanel.tsx +2 -2
  65. package/src/charts/Heatmap.tsx +2 -2
  66. package/src/charts/MirroredBars.tsx +2 -2
  67. package/src/charts/Sparkline.tsx +7 -5
  68. package/src/charts/compile.ts +31 -11
  69. package/src/charts/cursor.ts +48 -3
  70. package/src/charts/date-tick-format.ts +132 -0
  71. package/src/charts/panel.tsx +5 -3
  72. package/src/charts/types.ts +5 -1
  73. package/src/cli/shot/capture.ts +35 -3
  74. package/src/cli/shot/playwright.ts +1 -1
  75. package/src/dashboard/delta-badge.tsx +24 -18
  76. package/src/dashboard/query-state.tsx +38 -0
  77. package/src/dashboard/stat-card-parts.tsx +108 -0
  78. package/src/dashboard/stat-card.module.css +220 -7
  79. package/src/dashboard/stat-card.module.css.d.ts +20 -0
  80. package/src/dashboard/stat-card.tsx +282 -174
  81. package/src/dashboard/widget-header.module.css +25 -17
  82. package/src/dashboard/widget-header.tsx +103 -7
  83. package/src/guard/index.ts +2 -2
  84. package/src/theme/__snapshots__/plain-theme.test.ts.snap +128 -40
  85. package/src/theme/chrome-vars.ts +111 -0
  86. package/src/theme/controls.module.css +20 -1
  87. package/src/theme/controls.module.css.d.ts +1 -0
  88. package/src/theme/index.ts +39 -101
  89. package/src/tokens/derive.ts +7 -2
@@ -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
@@ -86,6 +86,7 @@ import { CTL_HEIGHT_VARS } from '../tokens/ctl-vars'
86
86
  import type { CtlHeightVar } from '../tokens/ctl-vars'
87
87
  import { SIZE_CLASS_BREAKPOINTS } from '../tokens/size-classes'
88
88
  import type { BasaltFontsConfig } from '../tokens/core'
89
+ import { onColor, onColorFor, subtleInkVars, tabsVars } from './chrome-vars'
89
90
  import controlsClasses from './controls.module.css'
90
91
  import floatingClasses from './floating.module.css'
91
92
  import navLinkClasses from './nav-link.module.css'
@@ -229,60 +230,6 @@ function buildDarkTuple(data: PaletteData): MantineColorsTuple {
229
230
  ] as unknown as MantineColorsTuple
230
231
  }
231
232
 
232
- /**
233
- * ON-COLOR: the foreground for a filled surface, decided in CSS. THE fix for Mantine's
234
- * scheme-blind, contrast-blind `autoContrast`.
235
- *
236
- * Mantine picks the filled-variant text color ONCE, in JS, via `parseThemeColor({ color, theme })`
237
- * — with NO `colorScheme` argument, so it resolves against the LIGHT `primaryShade` and bakes a
238
- * static `color: var(--mantine-color-white)` into the element, while the BACKGROUND it pairs that
239
- * with (`--mantine-color-{c}-filled`) stays a scheme-reactive CSS var. It gets away with it
240
- * upstream only because Mantine's default `primaryShade` is `{ light: 6, dark: 8 }` — DARKER on
241
- * dark, so white happens to stay right. It is luck, not logic: point `primaryShade.dark` at a
242
- * lighter shade (as Basalt originally did) and every filled control in dark mode turns white-on-
243
- * light. And even in one scheme the pick is wrong, because `isLightColor` is a BT.601 BRIGHTNESS
244
- * test that does not track WCAG contrast — it handed white to lime `#97ba2e` at 2.24:1.
245
- *
246
- * Basalt removes the JS decision entirely. A fill is now scheme-INDEPENDENT and sits in a
247
- * luminance band chosen so a WHITE label always clears AA (see `FILL` / `ACCENT` in
248
- * tokens/palette.ts), so the on-color is a token, not a computation. `--vx-on-{color}` is emitted
249
- * per color and resolves in pure CSS at paint time — the same discipline the rest of the `--vx-*`
250
- * system follows. It is still MEASURED here (`legibleOn`) rather than hardcoded to white, so a
251
- * consumer that retunes a family outside the band still gets the legible foreground.
252
- *
253
- * The palette already KNEW the answer: `ACCENT.onAccent` ("text on an accent fill") existed, and
254
- * `Composer`'s send button hand-wired `color: var(--vx-on-accent)` — which was the ONLY reason that
255
- * one control stayed legible while every generic Mantine control did not. The token was right;
256
- * nothing bound the chrome to it. It is bound now (see `accentBridge` / `familyBridge`), and the
257
- * Composer no longer needs the override.
258
- *
259
- * Fix: never let a foreground be decided in JS. `--vx-on-{color}` is emitted per color under BOTH
260
- * scheme blocks of `cssVariablesResolver` (each resolved against the shade that scheme actually
261
- * paints), so the foreground resolves in pure CSS at paint time — the same discipline the rest of
262
- * the `--vx-*` system already follows. `basaltVariantColorResolver` re-points every filled variant
263
- * at it, and the components that bypass the variant resolver (Checkbox / Radio / Tabs / Pagination /
264
- * Stepper / Indicator / Timeline all call Mantine's `getContrastColor` directly) are re-pointed at
265
- * it too, in `components` below. Regression-locked by `contrast.test.ts`.
266
- */
267
- function onColor(theme: MantineTheme, color: string | undefined): string | undefined {
268
- const name = color ?? theme.primaryColor
269
- if (!Object.prototype.hasOwnProperty.call(theme.colors, name)) return undefined // hex / `blue.5`
270
- return `var(--vx-on-${name})`
271
- }
272
-
273
- /**
274
- * The on-color for a component that bypasses the variant resolver and calls Mantine's
275
- * `getContrastColor` directly. `undefined` (autoContrast off, or a hex / indexed color) leaves
276
- * Mantine's own value in place — `mergeVars` strips undefined before merging.
277
- */
278
- function onColorFor(
279
- theme: MantineTheme,
280
- props: { color?: string | undefined; autoContrast?: boolean | undefined },
281
- ): string | undefined {
282
- const autoContrast = props.autoContrast ?? theme.autoContrast
283
- return autoContrast ? onColor(theme, props.color) : undefined
284
- }
285
-
286
233
  /** WCAG 2.x relative luminance. */
287
234
  function relativeLuminance(hex: string): number {
288
235
  const channels = hexToRgb(hex).map((c) => {
@@ -367,24 +314,9 @@ const basaltVariantColorResolver: VariantColorsResolver = (input) => {
367
314
  return autoContrast ? { ...resolved, color: on } : resolved
368
315
  }
369
316
 
370
- // `subtle`: hover is a NEUTRAL ink tint, not Mantine's accent tint
371
- // (`--mantine-color-{c}-light`). `docs/DESIGN-SPEC.md` §5 specifies the ghost idiom as "hover
372
- // ink-6% + ink icon", and a subtle Button had never followed it — it hovered into a saturated
373
- // accent block that read as a filled control appearing under the cursor. Fixing it HERE rather
374
- // than in controls.module.css is what makes Button and ActionIcon agree: both resolve `subtle`
375
- // through this one function, and §5's ghost icon button and a `variant="subtle"` Button are meant
376
- // to be the same idiom at two sizes.
377
- //
378
- // Scoped to the DEFAULT color on purpose. An explicitly-colored subtle control (`color="red"` on a
379
- // destructive text action) carries its hue as the whole signal, so neutralizing its hover would
380
- // erase the one thing that marks it dangerous — those keep Mantine's own tinted hover.
381
- if (input.variant === 'subtle') {
382
- const isDefaultColor = input.color === undefined || input.color === input.theme.primaryColor
383
- return isDefaultColor
384
- ? { ...resolved, hover: `color-mix(in srgb, var(--vx-ink) 6%, transparent)` }
385
- : resolved
386
- }
387
-
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).
388
320
  // `outline`: the tone's own text colour, pulled toward ink so the label keeps its hue at AA
389
321
  // (grey outline badges measured 3.9:1 on the light page).
390
322
  if (input.variant === 'outline') {
@@ -566,10 +498,12 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
566
498
  },
567
499
  },
568
500
  }),
569
- // Mantine's default Badge radius is a full 1000px pill; the spec's delta/status badges sit at
570
- // radius 6 (docs/DESIGN-SPEC.md §4/§5). Count badges (radius 5) are a distinct, smaller-radius
571
- // usage left to the call site (`radius={5}` prop) since Badge has no state to key off here.
572
- 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
+ }),
573
507
  // Alert renders its title in the body font by default; bring it onto the head-font idiom
574
508
  // (docs/DESIGN-SPEC.md §5) like every other titled surface. Radius/padding/color tint are
575
509
  // already on-system (defaultRadius 'md' control tier + the variant color resolver), so only
@@ -741,25 +675,35 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
741
675
  // `size="xs"`) on Mantine's own static height.
742
676
  Button: ext<typeof Button>({
743
677
  classNames: { root: controlsClasses.buttonRoot },
744
- vars: (_theme, props) => ({
745
- root: {
746
- '--button-height':
747
- props.size === 'md'
748
- ? 'calc(var(--vx-space-control-height) * var(--mantine-scale))'
749
- : undefined,
750
- },
751
- }),
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
+ },
752
691
  }),
753
692
  ActionIcon: ext<typeof ActionIcon>({
754
693
  classNames: { root: controlsClasses.actionIconRoot },
755
- vars: (_theme, props) => ({
756
- root: {
757
- '--ai-size':
758
- props.size === 'md'
759
- ? 'calc(var(--vx-space-control-height) * var(--mantine-scale))'
760
- : undefined,
761
- },
762
- }),
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
+ },
763
707
  }),
764
708
  // CheckboxCard / RadioCard (`withBorder`, true by default): same live regression as Button/
765
709
  // ActionIcon before this pass — Mantine ships `border: 1px solid transparent` as the BASE
@@ -1125,17 +1069,11 @@ function buildTheme(data: PaletteData, options: BuildThemeOptions = {}): Mantine
1125
1069
  // The tab-list bottom rule (and the inactive-tab hover underline) is a layout separator, not
1126
1070
  // control chrome — it reads the divider token instead of the heavy gray-3/dark-4 line
1127
1071
  // (controls.module.css; custom properties are stripped from `styles` objects). The active tab
1128
- // 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.
1129
1074
  Tabs: ext<typeof Tabs>({
1130
1075
  classNames: { root: controlsClasses.tabsRoot },
1131
- // The on-color re-point (see below). Cast: Mantine's `TabsCssVariables` type declares only
1132
- // `--tabs-color` / `--tabs-radius`, yet Tabs' OWN varsResolver writes `--tabs-text-color` —
1133
- // an upstream type gap, so the var it actually paints the active tab with is otherwise
1134
- // unreachable from the theme.
1135
- vars: (theme, props) =>
1136
- ({ root: { '--tabs-text-color': onColorFor(theme, props) } }) as unknown as {
1137
- root: Record<'--tabs-color' | '--tabs-radius', string | undefined>
1138
- },
1076
+ vars: tabsVars,
1139
1077
  }),
1140
1078
 
1141
1079
  // ── ON-COLOR re-points (see the ON-COLOR doctrine above) ────────────────────────────────
@@ -317,10 +317,15 @@ const INK_TONE: Record<Side, Record<InkKey, number>> = {
317
317
  export type StatusKey = 'good' | 'warn' | 'bad'
318
318
 
319
319
  const STATUS_HUE: Record<StatusKey, number> = { good: 151.975, warn: 76.64, bad: 29.905 }
320
+ // Every stop is read as TEXT somewhere (`DeltaBadge`, a toned breakdown row), so each clears WCAG AA
321
+ // (4.5:1) on every text surface (bg / panel / panelHover / elevated / subtle / field) at the default
322
+ // derive config only (default seed, every level knob 0) — pinned in `derive.test.ts`; a retuned
323
+ // `lightLevel` / `darkLevel` / `neutral` is not covered. `warn` light sat at tone 54.64 (3.64:1 on the panel) and `bad`
324
+ // dark at 58.58 (4.22:1); both moved along their lightness axis only, hue and chroma untouched.
320
325
  const STATUS_STOP: Record<StatusKey, Record<Side, { tone: number; chroma: number }>> = {
321
326
  good: { light: { tone: 45.75, chroma: 37.75 }, dark: { tone: 70.23, chroma: 53.23 } },
322
- warn: { light: { tone: 54.64, chroma: 61.12 }, dark: { tone: 72.34, chroma: 62.55 } },
323
- bad: { light: { tone: 43.86, chroma: 54.46 }, dark: { tone: 58.58, chroma: 53.79 } },
327
+ warn: { light: { tone: 46, chroma: 61.12 }, dark: { tone: 72.34, chroma: 62.55 } },
328
+ bad: { light: { tone: 43.86, chroma: 54.46 }, dark: { tone: 66.5, chroma: 53.79 } },
324
329
  }
325
330
 
326
331
  /**