basalt-ui 1.4.0 → 1.5.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 (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +27 -2
  3. package/agent/rules/basalt-mantine.md +1 -1
  4. package/agent/rules/basalt-tokens.md +2 -2
  5. package/agent/skills/basalt-design/SKILL.md +1 -1
  6. package/dist/charts/kinds/Donut.js +1 -0
  7. package/dist/charts/theme.js +6 -6
  8. package/dist/cli/index.d.ts.map +1 -1
  9. package/dist/cli/index.js +8 -3
  10. package/dist/content/article-card.module.css +1 -1
  11. package/dist/content/callout.module.css +3 -3
  12. package/dist/content/prose.module.css +1 -1
  13. package/dist/content/reading-progress.module.css +2 -2
  14. package/dist/guard/guard-hook.js +1 -1
  15. package/dist/guard/index.d.ts.map +1 -1
  16. package/dist/guard/index.js +24 -5
  17. package/dist/guard/types.d.ts +6 -0
  18. package/dist/guard/types.d.ts.map +1 -1
  19. package/dist/theme/index.js +4 -4
  20. package/dist/theme/timeline.module.css +3 -3
  21. package/dist/theme-lab/index.js +1 -1
  22. package/dist/tokens/index.d.ts +25 -16
  23. package/dist/tokens/index.d.ts.map +1 -1
  24. package/dist/tokens/index.js +84 -46
  25. package/dist/tokens.css +102 -51
  26. package/llms.txt +2 -2
  27. package/package.json +71 -17
  28. package/src/agent-chat/composer.tsx +1 -1
  29. package/src/charts/kinds/Donut.tsx +1 -1
  30. package/src/charts/theme.tsx +6 -6
  31. package/src/cli/index.ts +10 -2
  32. package/src/cli/tokens-css.test.ts +17 -0
  33. package/src/content/article-card.module.css +1 -1
  34. package/src/content/callout.module.css +3 -3
  35. package/src/content/prose.module.css +1 -1
  36. package/src/content/reading-progress.module.css +2 -2
  37. package/src/guard/check-source.test.ts +98 -0
  38. package/src/guard/guard-hook.ts +1 -1
  39. package/src/guard/index.ts +60 -13
  40. package/src/guard/types.ts +6 -0
  41. package/src/theme/contrast.test.ts +23 -5
  42. package/src/theme/index.ts +5 -5
  43. package/src/theme/timeline.module.css +3 -3
  44. package/src/theme-lab/index.tsx +2 -2
  45. package/src/tokens/index.ts +106 -46
  46. package/src/tokens/palette.ts +2 -2
@@ -194,7 +194,7 @@ function DonutPlot<K extends string = SeriesKey>(props: DonutPlotProps<K>) {
194
194
  style={{
195
195
  position: 'absolute',
196
196
  inset: 0,
197
- display: 'flex',
197
+ display: 'flex', // theme-allow: centering over the donut hole — charts/ is Mantine-free, so Center is unavailable here
198
198
  alignItems: 'center',
199
199
  justifyContent: 'center',
200
200
  pointerEvents: 'none',
@@ -25,12 +25,12 @@ const REFS = {
25
25
  line: 'var(--vx-line)',
26
26
  line2: 'var(--vx-line2)',
27
27
  axis: 'var(--vx-axis)',
28
- axisStroke: 'var(--vx-axisStroke)',
29
- tooltipBg: 'var(--vx-tooltipBg)',
30
- tooltipText: 'var(--vx-tooltipText)',
31
- tooltipMuted: 'var(--vx-tooltipMuted)',
32
- tooltipBorder: 'var(--vx-tooltipBorder)',
33
- tooltipShadow: 'var(--vx-tooltipShadow)',
28
+ axisStroke: 'var(--vx-axis-stroke)',
29
+ tooltipBg: 'var(--vx-tooltip-bg)',
30
+ tooltipText: 'var(--vx-tooltip-text)',
31
+ tooltipMuted: 'var(--vx-tooltip-muted)',
32
+ tooltipBorder: 'var(--vx-tooltip-border)',
33
+ tooltipShadow: 'var(--vx-tooltip-shadow)',
34
34
  } as const
35
35
 
36
36
  const VxThemeContext = createContext<VxTheme | null>(null)
package/src/cli/index.ts CHANGED
@@ -419,7 +419,7 @@ export function checkTheme(cwd: string = process.cwd()): number {
419
419
  for (const [file, vs] of [...byFile].toSorted()) {
420
420
  console.error(file)
421
421
  for (const v of vs.toSorted((a, b) => a.line - b.line)) {
422
- console.error(` ${String(v.line).padStart(4)} ${v.kind.padEnd(22)} ${v.token}`)
422
+ console.error(` ${String(v.line).padStart(4)} ${v.kind.padEnd(22)} ${v.text}`)
423
423
  }
424
424
  console.error('')
425
425
  }
@@ -1765,6 +1765,11 @@ export function tokensCss(flags: string[], cwd: string = process.cwd()): number
1765
1765
  : { defaultScheme: defaultScheme as 'dark' | 'light' | 'none' }),
1766
1766
  ...(flags.includes('--media-fallback') ? { mediaFallback: true } : {}),
1767
1767
  ...(only === undefined ? {} : { only: only as 'core' | 'all' }),
1768
+ // The tokens-only consumer is exactly the one who writes these names by hand, so they are also
1769
+ // the one who wants the deprecated camelCase aliases gone — and this command is their only
1770
+ // entry point. Without the flag the CLI and the API could disagree about what basalt's tokens
1771
+ // are, which is the one thing this command is documented never to allow.
1772
+ ...(flags.includes('--no-legacy-aliases') ? { legacyAliases: false } : {}),
1768
1773
  })
1769
1774
 
1770
1775
  const out = flagValue(flags, '--out')
@@ -1880,7 +1885,10 @@ const USAGE =
1880
1885
  'check-theme | check-coverage | info [--json] | doctor | guard-hook | tokens:css | help>\n\n' +
1881
1886
  'tokens:css [--out <path>] [--selector-attribute <attr>] [--dark-value <v>] [--light-value <v>]\n' +
1882
1887
  ' [--default-scheme <dark|light|none>] [--media-fallback] [--only <core|all>]\n' +
1883
- ' Emit the --vx-* stylesheet (stdout unless --out). Defaults reproduce basalt-ui/tokens.css.\n\n' +
1888
+ ' [--no-legacy-aliases]\n' +
1889
+ ' Emit the --vx-* stylesheet (stdout unless --out). Defaults reproduce basalt-ui/tokens.css.\n' +
1890
+ ' --no-legacy-aliases drops the deprecated camelCase spellings (--vx-accentFill and friends),\n' +
1891
+ ' which are emitted by default as aliases of the canonical kebab-case names.\n\n' +
1884
1892
  'Every subcommand accepts --help / -h to print this message and exit without running.'
1885
1893
 
1886
1894
  /**
@@ -73,6 +73,23 @@ describe('tokens:css', () => {
73
73
  expect(existsSync(resolve(dir, 'out.css'))).toBe(false)
74
74
  })
75
75
 
76
+ it('--no-legacy-aliases drops every deprecated camelCase spelling while the canonical kebab names still resolve', () => {
77
+ const css = emit(['--no-legacy-aliases'])
78
+ expect(css).not.toContain('--vx-accentFill')
79
+ expect(css).not.toContain('--vx-tooltipBg')
80
+ expect(css).not.toContain('--vx-fillHover-')
81
+ expect(css).not.toContain('--vx-goodSoft')
82
+ expect(css).not.toContain('Deprecated camelCase aliases')
83
+ expect(css).toContain('--vx-accent-fill:')
84
+ expect(css).toContain('--vx-tooltip-bg:')
85
+ expect(css).toContain('--vx-fill-hover-')
86
+ expect(css).toContain('--vx-good-soft:')
87
+ })
88
+
89
+ it('--no-legacy-aliases output is byte-identical to buildPaletteCss({ legacyAliases: false }) — the CLI holds no emission logic of its own', () => {
90
+ expect(emit(['--no-legacy-aliases'])).toBe(buildPaletteCss({ legacyAliases: false }))
91
+ })
92
+
76
93
  it('`--help` short-circuits before the command runs — no file written', () => {
77
94
  const originalLog = console.log
78
95
  let log = ''
@@ -41,7 +41,7 @@
41
41
 
42
42
  .clickable:hover,
43
43
  .clickable:focus-visible {
44
- background-color: var(--vx-surface-panelHover);
44
+ background-color: var(--vx-surface-panel-hover);
45
45
  }
46
46
 
47
47
  .clickable:hover .title,
@@ -24,15 +24,15 @@
24
24
  }
25
25
 
26
26
  .good {
27
- --callout-ink: var(--vx-goodSolid);
27
+ --callout-ink: var(--vx-good-solid);
28
28
  }
29
29
 
30
30
  .warn {
31
- --callout-ink: var(--vx-warnSolid);
31
+ --callout-ink: var(--vx-warn-solid);
32
32
  }
33
33
 
34
34
  .bad {
35
- --callout-ink: var(--vx-badSolid);
35
+ --callout-ink: var(--vx-bad-solid);
36
36
  }
37
37
 
38
38
  .titleRow {
@@ -143,7 +143,7 @@
143
143
  }
144
144
 
145
145
  .root a:hover {
146
- color: var(--vx-accentHover);
146
+ color: var(--vx-accent-hover);
147
147
  text-decoration: underline;
148
148
  }
149
149
 
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * ReadingProgress — a fixed 2px top bar. The outer bar stays transparent; `.fill` carries the
3
- * `--vx-accentFill` band token (the FILL surface, never the ink `--vx-accent` — docs/DESIGN-SPEC.md
3
+ * `--vx-accent-fill` band token (the FILL surface, never the ink `--vx-accent` — docs/DESIGN-SPEC.md
4
4
  * §7's fill-band rule) and is scaled via `transform: scaleX()` from JS.
5
5
  */
6
6
 
@@ -18,7 +18,7 @@
18
18
  .fill {
19
19
  height: 100%;
20
20
  width: 100%;
21
- background: var(--vx-accentFill);
21
+ background: var(--vx-accent-fill);
22
22
  transform-origin: left;
23
23
  will-change: transform;
24
24
  }
@@ -385,6 +385,50 @@ describe('inline-spacing', () => {
385
385
  })
386
386
  })
387
387
 
388
+ // ── 10b. Finding.text ─────────────────────────────────────────────────────────
389
+ //
390
+ // `token` stays the regex match (e.g. the unit-less numeric part of a spacing declaration);
391
+ // `text` is the full trimmed source line, so a human reading the report sees `padding: 0.75rem;`
392
+ // rather than the confusing partial match `padding: 0.75`.
393
+
394
+ describe('Finding.text', () => {
395
+ it('reports text as the full trimmed source line while token stays the truncated match', () => {
396
+ const f = checkSource(
397
+ '.foo {\n padding: 0.75rem;\n}\n',
398
+ 'src/Card.module.css',
399
+ DEFAULT_GUARD_CONFIG,
400
+ )
401
+ const hit = f.find((x) => x.kind === 'inline-spacing')
402
+ expect(hit?.token).toBe('padding: 0.75')
403
+ expect(hit?.text).toBe('padding: 0.75rem;')
404
+ })
405
+
406
+ it('reports the whole declaration including the unit for a CSS padding-left finding', () => {
407
+ const f = checkSource('padding-left: 1.25rem;', 'src/Card.module.css', DEFAULT_GUARD_CONFIG)
408
+ const hit = f.find((x) => x.kind === 'inline-spacing')
409
+ expect(hit?.token).toBe('padding-left: 1.25')
410
+ expect(hit?.text).toBe('padding-left: 1.25rem;')
411
+ })
412
+
413
+ it('truncates a line over 100 characters with a trailing …', () => {
414
+ const filler = 'x'.repeat(200)
415
+ const f = checkSource(
416
+ `padding: 16px; /* ${filler} */`,
417
+ 'src/Card.module.css',
418
+ DEFAULT_GUARD_CONFIG,
419
+ )
420
+ const hit = f.find((x) => x.kind === 'inline-spacing')
421
+ expect(hit?.text.length).toBe(101)
422
+ expect(hit?.text.endsWith('…')).toBe(true)
423
+ })
424
+
425
+ it('trims a leading-indented line', () => {
426
+ const f = checkSource(' padding: 16px;', 'src/Card.module.css', DEFAULT_GUARD_CONFIG)
427
+ const hit = f.find((x) => x.kind === 'inline-spacing')
428
+ expect(hit?.text).toBe('padding: 16px;')
429
+ })
430
+ })
431
+
388
432
  // ── 11. inline-display ───────────────────────────────────────────────────────
389
433
 
390
434
  describe('inline-display', () => {
@@ -623,6 +667,39 @@ describe('chart-missing-aria-label', () => {
623
667
  })
624
668
  expect(kinds(f)).not.toContain('chart-missing-aria-label')
625
669
  })
670
+
671
+ // ── reported line: the tag's OPENING line, not the end of the match ─────────
672
+ //
673
+ // The scan used to compute its line from the END of the matched tag, so on a multi-line-
674
+ // formatted chart element the reported line was the closing `/>` rather than the `<Bars` line
675
+ // that is actually missing the prop. Invisible while the report only printed `token`; visible
676
+ // the moment `Finding.text` started quoting the reported source line back.
677
+
678
+ it('reports the OPENING tag line (and quotes it in text) for a multi-line-formatted chart element', () => {
679
+ const text = ['<Bars', ' data={points}', ' height={240}', '/>'].join('\n')
680
+ const f = find(text)
681
+ const hit = f.find((x) => x.kind === 'chart-missing-aria-label')
682
+ expect(hit?.line).toBe(1)
683
+ expect(hit?.text).toBe('<Bars')
684
+ })
685
+
686
+ it('reports the same line as before for a single-line chart element (no regression)', () => {
687
+ const f = find(`<ZonedLine data={points} height={240} chartId="x" />`)
688
+ const hit = f.find((x) => x.kind === 'chart-missing-aria-label')
689
+ expect(hit?.line).toBe(1)
690
+ })
691
+
692
+ it('a theme-allow comment on the CLOSING line of a multi-line tag still suppresses the finding (back-compat)', () => {
693
+ const text = ['<Bars', ' data={points}', ' height={240}', '/> // theme-allow'].join('\n')
694
+ const f = find(text)
695
+ expect(kinds(f)).not.toContain('chart-missing-aria-label')
696
+ })
697
+
698
+ it('a theme-allow comment on the OPENING line of a multi-line tag also suppresses the finding', () => {
699
+ const text = ['<Bars // theme-allow', ' data={points}', ' height={240}', '/>'].join('\n')
700
+ const f = find(text)
701
+ expect(kinds(f)).not.toContain('chart-missing-aria-label')
702
+ })
626
703
  })
627
704
 
628
705
  // ── 16. card-with-border ─────────────────────────────────────────────────────
@@ -1173,6 +1250,27 @@ describe('CSS applicability', () => {
1173
1250
  expect(cssSpacing('padding: 2em')).toEqual(['inline-spacing'])
1174
1251
  })
1175
1252
 
1253
+ it('does NOT read a unitless fraction — that is a ratio, not a length', () => {
1254
+ // visx band padding. Ten of these in one consumer's chart files the day the leading-decimal fix
1255
+ // shipped: `padding` here is dimensionless 0–1, and "use p/m/gap with xs..xl" cannot be done to
1256
+ // it. Admitting `.75rem` and admitting `0.3` are the same regex change; the unit tells them
1257
+ // apart. Scoping inline-spacing out of chart files would also have cleared it, and would have
1258
+ // dropped real coverage inside charts/ while leaving the false positive live everywhere else.
1259
+ const scale = (src: string): GuardKind[] =>
1260
+ kinds(checkSource(src, 'src/charts/kinds/Bars.tsx', DEFAULT_GUARD_CONFIG)).filter(
1261
+ (k) => k === 'inline-spacing',
1262
+ )
1263
+ expect(
1264
+ scale('const s = scalePoint<string>({ domain: d, range: [0, w], padding: 0.3 })'),
1265
+ ).toEqual([])
1266
+ expect(scale('const s = scaleBand({ padding: .2 })')).toEqual([])
1267
+ // A unitless INTEGER is still 4px by React's convention, and still a finding.
1268
+ expect(scale('<Box style={{ padding: 4 }} />')).toEqual(['inline-spacing'])
1269
+ // A fraction WITH a unit is a real length and still flags — above the sub-scale ceiling, since
1270
+ // 0.3rem is 4.8px and would be excused by the micro-spacing escape for that reason instead.
1271
+ expect(cssSpacing('padding: 0.7rem')).toEqual(['inline-spacing'])
1272
+ })
1273
+
1176
1274
  it('reads a CSS number without its integer part, and one carrying an explicit +', () => {
1177
1275
  // `.75rem` IS `0.75rem` and `+12px` IS `12px`. Requiring a leading digit skipped both — the
1178
1276
  // same silent skip the `0.` guard was fixed for, one spelling over.
@@ -115,7 +115,7 @@ export function evaluateGuardHook(
115
115
  if (findings.length === 0) return { permissionDecision: 'allow' }
116
116
 
117
117
  const shown = findings.slice(0, 10)
118
- const lines = shown.map((f) => `${f.kind} @ ${f.line}: ${f.token}`)
118
+ const lines = shown.map((f) => `${f.kind} @ ${f.line}: ${f.text}`)
119
119
  const extra = findings.length > 10 ? ` (+${findings.length - 10} more)` : ''
120
120
  const reason =
121
121
  `basalt theme-guard: ${findings.length} off-palette/off-system violation(s) in ${target.relPath}\n` +
@@ -82,17 +82,26 @@ const SPACING_PROP = `(?:padding|margin)(?:${BOX_SIDE}|-${BOX_SIDE_KEBAB})?|gap|
82
82
  // starting `0.` matched the guard and dropped out of the scan entirely. `0.75rem` is 12px, a real
83
83
  // spacing value, and it was invisible. `(?!0(?![.\d]))` excuses only a zero that ends there.
84
84
  //
85
- // The number itself is `[-+]?(?:\d|\.\d)`, not `-?\d`: CSS lets a value carry an explicit `+` and
86
- // omit the integer part, so `.75rem` and `+12px` are the same spacing as `0.75rem` and `12px`.
87
- // Requiring a leading digit skipped both — the same silent-skip the zero guard above was fixed for,
88
- // one spelling over.
89
- //
90
85
  // The property is preceded by `(?<![\w-])`, not `\b`: a `\b` boundary sits inside a hyphenated
91
86
  // identifier, so every custom property whose NAME ends in a spacing word — the token layer's own
92
87
  // `--vx-space-article-header-padding-bottom`, a consumer's `--card-padding-inline` — matched as if
93
88
  // it were a declaration. A custom property is a definition, not a rendered spacing decision.
89
+ //
90
+ // The number does two things at once. CSS lets a value carry an explicit `+` and omit the integer
91
+ // part, so `.75rem` and `+12px` are the same spacing as `0.75rem` and `12px`; requiring a leading
92
+ // digit skipped both — the same silent-skip the zero guard above was fixed for, one spelling over.
93
+ //
94
+ // But admitting a fractional part also admits values that are not lengths at all. A UNITLESS
95
+ // fraction is never a spacing literal: `padding: 4` in an inline style is 4px by React's convention,
96
+ // while `padding: 0.3` is a RATIO — visx's band padding (`scalePoint({ padding: 0.3 })`) found this,
97
+ // ten times over in one consumer, and the guard's own advice ("use p/m/gap with xs..xl") is
98
+ // meaningless for it. So the discriminator is the UNIT, not the digit shape: a fraction must carry
99
+ // one (`.75rem`), and a unitless number must be an integer (`padding: 4` — still 4px, still a
100
+ // finding). `0.3` matches neither and drops out. `(?=[a-z%])` covers every CSS unit without
101
+ // enumerating them, and the sign stays outside so the zero guard still sees `-0` as a zero.
102
+ const SPACING_NUMBER = '(?:\\d*\\.\\d+(?=[a-z%])|\\d+(?!\\.\\d))'
94
103
  const INLINE_SPACING = new RegExp(
95
- `(?<![\\w-])(?:${SPACING_PROP})\\s*:\\s*(?!var\\()['"]?[-+]?(?!0(?![.\\d]))(?:\\d|\\.\\d)`,
104
+ `(?<![\\w-])(?:${SPACING_PROP})\\s*:\\s*(?!var\\()['"]?[-+]?(?!0(?![.\\d]))${SPACING_NUMBER}`,
96
105
  'g',
97
106
  )
98
107
 
@@ -271,6 +280,22 @@ function severityOf(kind: GuardKind, cfg: GuardConfig): GuardSeverity {
271
280
  return cfg.severity?.[kind] ?? (kind in GRACE_PERIOD_KINDS ? 'warn' : 'error')
272
281
  }
273
282
 
283
+ /** The `Finding.text` cap, in characters — a minified CSS line must not blow up the report. */
284
+ const FINDING_TEXT_MAX_LENGTH = 100
285
+
286
+ /**
287
+ * A finding's `text`: the trimmed source line it sits on, capped at {@link FINDING_TEXT_MAX_LENGTH}
288
+ * with a trailing `…`. Falls back to `fallbackToken` when `line` is out of range for the source
289
+ * (should not happen in practice, but a Finding's own `line` must never crash the render).
290
+ */
291
+ function textForFinding(sourceLine: string | undefined, fallbackToken: string): string {
292
+ if (sourceLine === undefined) return fallbackToken
293
+ const trimmed = sourceLine.trim()
294
+ return trimmed.length > FINDING_TEXT_MAX_LENGTH
295
+ ? `${trimmed.slice(0, FINDING_TEXT_MAX_LENGTH)}…`
296
+ : trimmed
297
+ }
298
+
274
299
  // ── Path predicate ────────────────────────────────────────────────────────────────────────────────
275
300
 
276
301
  function isChartFile(relPath: string): boolean {
@@ -733,9 +758,10 @@ function ruleApplies(kind: GuardKind, relPath: string): boolean {
733
758
  * if (findings.some((f) => f.kind === 'raw-hex')) { ... }
734
759
  */
735
760
  export function checkSource(text: string, relPath: string, cfg: GuardConfig): Finding[] {
736
- // Severity is stamped once at the end rather than at each of the ~20 push sites — it is a
737
- // property of the KIND and the config, never of the match.
738
- const findings: Omit<Finding, 'severity'>[] = []
761
+ // Severity and text are stamped once at the end rather than at each of the ~20 push sites — both
762
+ // are derived from state the push sites don't need: severity from the KIND and the config, text
763
+ // from the finding's own `line` against the source split below.
764
+ const findings: Omit<Finding, 'severity' | 'text'>[] = []
739
765
 
740
766
  // Derive the 3 dynamic regexes via GUARD_RULES pattern builders.
741
767
  const forbiddenAccentRe = (
@@ -885,6 +911,11 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
885
911
 
886
912
  // chart-missing-aria-label — full-text tag-scoped scan (same shape as unframed-chart above).
887
913
  // A tag is a violation only when its own (possibly multi-line) prop list has no `ariaLabel=`.
914
+ // Reports at the tag's OPENING line, like card-with-border below and unlike the end-of-match
915
+ // arithmetic this used to do: on a multi-line-formatted chart the end lands on the closing `/>`,
916
+ // which is what `Finding.text` would then quote back — the closing bracket rather than the tag
917
+ // that is missing the prop. The allow-comment is honored anywhere in the tag's span, so a
918
+ // `theme-allow` that used to sit on the closing line keeps working.
888
919
  if (
889
920
  GUARD_RULES['chart-missing-aria-label'].enabled!(cfg) &&
890
921
  ruleApplies('chart-missing-aria-label', relPath)
@@ -892,11 +923,19 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
892
923
  for (const m of codeText.matchAll(CHART_ENTRY_POINT_TAG)) {
893
924
  const tagText = m[0]
894
925
  if (HAS_ARIA_LABEL_PROP.test(tagText)) continue
895
- const lineNo = codeText.slice(0, (m.index ?? 0) + tagText.length).split('\n').length
896
- if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
926
+ const startLine = codeText.slice(0, m.index ?? 0).split('\n').length
927
+ const endLine = startLine + (tagText.split('\n').length - 1)
928
+ let skipped = false
929
+ for (let n = startLine; n <= endLine; n++) {
930
+ if (isSkippedLine(lines[n - 1] ?? '', cfg)) {
931
+ skipped = true
932
+ break
933
+ }
934
+ }
935
+ if (skipped) continue
897
936
  findings.push({
898
937
  relPath,
899
- line: lineNo,
938
+ line: startLine,
900
939
  token: tagText.slice(0, 40),
901
940
  kind: 'chart-missing-aria-label',
902
941
  })
@@ -948,7 +987,15 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
948
987
  // Per-rule, per-path exemption post-filter (§exemptRules) — applied once here so it uniformly
949
988
  // covers every kind regardless of whether it was emitted via the GUARD_RULES registry loop above
950
989
  // or one of the inline-handled kinds (raw-surface, raw-html-layout, sub-16-input-font, …).
990
+ //
991
+ // `text` is stamped here too, in the same single post-pass, off the ORIGINAL (unstripped) `lines`
992
+ // split — never `codeLines` — so a finding on a line whose comment was stripped still reports the
993
+ // real source text a human would read.
951
994
  return findings
952
995
  .filter((f) => !isRuleExempt(f.kind, f.relPath, cfg.exemptRules))
953
- .map((f) => ({ ...f, severity: severityOf(f.kind, cfg) }))
996
+ .map((f) => ({
997
+ ...f,
998
+ text: textForFinding(lines[f.line - 1], f.token),
999
+ severity: severityOf(f.kind, cfg),
1000
+ }))
954
1001
  }
@@ -56,6 +56,12 @@ export type Finding = {
56
56
  readonly relPath: string
57
57
  readonly line: number
58
58
  readonly token: string
59
+ /**
60
+ * The trimmed source line the finding sits on — what a human should read; `token` stays the
61
+ * matched substring for programmatic use. Truncated to 100 characters (with a trailing `…`) so
62
+ * a minified line can't blow up the report.
63
+ */
64
+ readonly text: string
59
65
  readonly kind: GuardKind
60
66
  /** Resolved per kind from {@link GuardConfig.severity} over the shipped default. */
61
67
  readonly severity: GuardSeverity
@@ -80,12 +80,30 @@ describe('the accent delegates to the palette, not to a computed guess', () => {
80
80
  for (const scheme of SCHEMES) {
81
81
  test(scheme, () => {
82
82
  expect(onColorVar(theme.primaryColor, scheme)).toBe(
83
- `var(--vx-onAccent, ${ACCENT.onAccent[scheme]})`,
83
+ `var(--vx-on-accent, ${ACCENT.onAccent[scheme]})`,
84
84
  )
85
85
  })
86
86
  }
87
87
  })
88
88
 
89
+ describe('--vx-on-accent has no collision with the per-color --vx-on-* family', () => {
90
+ // The 1.4.0 kebab-case rename moved the token layer's `--vx-onAccent` to `--vx-on-accent`.
91
+ // `onColorVars` (above) ALSO emits a `--vx-on-{name}` per Mantine color name — but `theme.colors`
92
+ // never registers a color literally named `'accent'` (the primary color is `'blue'`), so that
93
+ // family can never itself produce a `--vx-on-accent` key. The two stay distinct sources, not a
94
+ // merge: `--vx-on-accent` is exclusively the token layer's `ACCENT.onAccent` alias target.
95
+ test('theme.colors has no color named "accent"', () => {
96
+ expect(COLORS).not.toContain('accent')
97
+ })
98
+
99
+ for (const scheme of SCHEMES) {
100
+ test(`the resolver's own --vx-on-* map carries no accent key (${scheme})`, () => {
101
+ const vars = cssVariablesResolver(theme)[scheme]
102
+ expect(vars['--vx-on-accent']).toBeUndefined()
103
+ })
104
+ }
105
+ })
106
+
89
107
  describe('every filled surface is legible against its on-color', () => {
90
108
  // The floor is structural, not tuned: contrast(bg, white) * contrast(bg, black) is a constant
91
109
  // (~17.9 for this black), so always taking the larger of the two cannot drop below ~4.23.
@@ -211,7 +229,7 @@ describe('the accent is single-sourced: Mantine chrome is bridged to --vx-*', ()
211
229
  for (const [name, hex] of Object.entries(FILL)) {
212
230
  expect(vars[`--mantine-color-${name}-filled`]).toBe(`var(--vx-fill-${name}, ${hex})`)
213
231
  expect(vars[`--mantine-color-${name}-filled-hover`]).toContain(
214
- `var(--vx-fillHover-${name},`,
232
+ `var(--vx-fill-hover-${name},`,
215
233
  )
216
234
  }
217
235
  })
@@ -221,15 +239,15 @@ describe('the accent is single-sourced: Mantine chrome is bridged to --vx-*', ()
221
239
  // and links; Mantine's chrome drove buttons off a JS hex ramp that pointed at nothing. Overriding
222
240
  // `--vx-accent` restyled the charts and left every button untouched. These lock the bridge.
223
241
  for (const scheme of SCHEMES) {
224
- test(`the filled surface resolves through --vx-accentFill (${scheme})`, () => {
242
+ test(`the filled surface resolves through --vx-accent-fill (${scheme})`, () => {
225
243
  const vars = cssVariablesResolver(theme)[scheme]
226
244
  // `getThemeColor()` resolves any plain theme color to `-filled`, so this ONE var reaches the
227
245
  // variant resolver AND every component that fills from its own varsResolver.
228
246
  expect(vars[`--mantine-color-${theme.primaryColor}-filled`]).toBe(
229
- `var(--vx-accentFill, ${ACCENT.accentFill[scheme]})`,
247
+ `var(--vx-accent-fill, ${ACCENT.accentFill[scheme]})`,
230
248
  )
231
249
  expect(vars[`--mantine-color-${theme.primaryColor}-filled-hover`]).toBe(
232
- `var(--vx-accentFillHover, ${ACCENT.accentFillHover[scheme]})`,
250
+ `var(--vx-accent-fill-hover, ${ACCENT.accentFillHover[scheme]})`,
233
251
  )
234
252
  })
235
253
 
@@ -226,7 +226,7 @@ function buildDarkTuple(data: PaletteData): MantineColorsTuple {
226
226
  * consumer that retunes a family outside the band still gets the legible foreground.
227
227
  *
228
228
  * The palette already KNEW the answer: `ACCENT.onAccent` ("text on an accent fill") existed, and
229
- * `Composer`'s send button hand-wired `color: var(--vx-onAccent)` — which was the ONLY reason that
229
+ * `Composer`'s send button hand-wired `color: var(--vx-on-accent)` — which was the ONLY reason that
230
230
  * one control stayed legible while every generic Mantine control did not. The token was right;
231
231
  * nothing bound the chrome to it. It is bound now (see `accentBridge` / `familyBridge`), and the
232
232
  * Composer no longer needs the override.
@@ -304,7 +304,7 @@ function onColorVars(
304
304
  // chrome with it. Everything else is a generic surface with no declared foreground: measure it.
305
305
  vars[`--vx-on-${name}`] =
306
306
  name === theme.primaryColor
307
- ? `var(--vx-onAccent, ${data.ACCENT.onAccent[colorScheme]})`
307
+ ? `var(--vx-on-accent, ${data.ACCENT.onAccent[colorScheme]})`
308
308
  : legibleOn(filled, theme)
309
309
  }
310
310
  return vars
@@ -1044,8 +1044,8 @@ function accentBridge(
1044
1044
  const c = theme.primaryColor
1045
1045
  const { ACCENT } = data
1046
1046
  return {
1047
- [`--mantine-color-${c}-filled`]: `var(--vx-accentFill, ${ACCENT.accentFill[side]})`,
1048
- [`--mantine-color-${c}-filled-hover`]: `var(--vx-accentFillHover, ${ACCENT.accentFillHover[side]})`,
1047
+ [`--mantine-color-${c}-filled`]: `var(--vx-accent-fill, ${ACCENT.accentFill[side]})`,
1048
+ [`--mantine-color-${c}-filled-hover`]: `var(--vx-accent-fill-hover, ${ACCENT.accentFillHover[side]})`,
1049
1049
  [`--mantine-color-${c}-text`]: `var(--vx-accent, ${ACCENT.accent[side]})`,
1050
1050
  [`--mantine-color-${c}-outline`]: `var(--vx-accent, ${ACCENT.accent[side]})`,
1051
1051
  [`--mantine-color-${c}-light-color`]: `var(--vx-accent, ${ACCENT.accent[side]})`,
@@ -1068,7 +1068,7 @@ function familyBridge(data: PaletteData): Record<string, string> {
1068
1068
  for (const [name, hex] of Object.entries(data.FILL)) {
1069
1069
  vars[`--mantine-color-${name}-filled`] = `var(--vx-fill-${name}, ${hex})`
1070
1070
  vars[`--mantine-color-${name}-filled-hover`] =
1071
- `var(--vx-fillHover-${name}, color-mix(in srgb, ${hex} 88%, #000))`
1071
+ `var(--vx-fill-hover-${name}, color-mix(in srgb, ${hex} 88%, #000))`
1072
1072
  }
1073
1073
  return vars
1074
1074
  }
@@ -23,7 +23,7 @@
23
23
  * whether the bullet carries child content (Mantine's own `[data-active]` rule only fills solid
24
24
  * when a bullet child is present; a plain dot would otherwise render a white fill). */
25
25
  .itemBullet[data-active] {
26
- background-color: var(--vx-accentFill);
27
- border-color: var(--vx-accentFill);
28
- color: var(--vx-onAccent);
26
+ background-color: var(--vx-accent-fill);
27
+ border-color: var(--vx-accent-fill);
28
+ color: var(--vx-on-accent);
29
29
  }
@@ -8,7 +8,7 @@
8
8
  * a refresh.
9
9
  *
10
10
  * The chrome follows because `theme/index.ts` bridges Mantine's surface vars AND its primary-color
11
- * vars onto these same tokens — retuning `--vx-accentFill` restyles every Button/Switch/Checkbox
11
+ * vars onto these same tokens — retuning `--vx-accent-fill` restyles every Button/Switch/Checkbox
12
12
  * live. (It did NOT before: the accent was dual-sourced, so the lab moved the charts and left the
13
13
  * chrome alone.) Known limit: only the PRIMARY Mantine color is bridged. A `color="red"` filled
14
14
  * badge still reads Mantine's JS ramp and will not follow a lab override.
@@ -87,7 +87,7 @@ export const COLOR_GROUPS: ColorGroup[] = [
87
87
  items: [
88
88
  { var: '--vx-line', label: 'Line' },
89
89
  { var: '--vx-line2', label: 'Line 2' },
90
- { var: '--vx-dotStroke', label: 'Dot stroke' },
90
+ { var: '--vx-dot-stroke', label: 'Dot stroke' },
91
91
  ],
92
92
  },
93
93
  {