basalt-ui 2.19.0 → 2.21.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 (234) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/MIGRATING.md +291 -12
  3. package/agent/agents/basalt-design-reviewer.md +22 -5
  4. package/agent/rules/basalt-charts.md +1 -1
  5. package/agent/rules/basalt-mantine.md +1 -1
  6. package/agent/rules/basalt-tokens.md +2 -2
  7. package/agent/skills/basalt-app/SKILL.md +1 -1
  8. package/agent/skills/basalt-design/SKILL.md +10 -23
  9. package/agent/skills/basalt-design/references/anti-defaults.md +24 -0
  10. package/agent/skills/basalt-design/references/catalogue.md +48 -0
  11. package/agent/skills/basalt-design/references/concept.md +36 -0
  12. package/agent/skills/basalt-design/references/encoding-rules.md +45 -0
  13. package/agent/skills/basalt-design/references/stat-tile.md +24 -0
  14. package/agent/templates/AGENTS-block.md.tpl +3 -3
  15. package/agent/templates/DESIGN.md.tpl +1 -1
  16. package/configs/oxlint-plugin.js +34 -19
  17. package/configs/oxlint-plugin.test.ts +32 -2
  18. package/dist/charts/ChartCard.d.ts +33 -4
  19. package/dist/charts/ChartCard.d.ts.map +1 -1
  20. package/dist/charts/ChartCard.js +37 -11
  21. package/dist/charts/Donut.d.ts.map +1 -1
  22. package/dist/charts/Donut.js +13 -1
  23. package/dist/charts/Heatmap.js +1 -1
  24. package/dist/charts/Sparkline.d.ts +7 -1
  25. package/dist/charts/Sparkline.d.ts.map +1 -1
  26. package/dist/charts/Sparkline.js +137 -18
  27. package/dist/charts/box.d.ts +2 -0
  28. package/dist/charts/box.d.ts.map +1 -1
  29. package/dist/charts/box.js +2 -0
  30. package/dist/charts/chart-box.module.css +30 -0
  31. package/dist/charts/chart-box.module.css.d.ts +1 -0
  32. package/dist/charts/chart-card.module.css +47 -0
  33. package/dist/charts/chart-card.module.css.d.ts +7 -0
  34. package/dist/charts/compile.d.ts.map +1 -1
  35. package/dist/charts/compile.js +35 -8
  36. package/dist/charts/host.d.ts.map +1 -1
  37. package/dist/charts/host.js +2 -1
  38. package/dist/charts/index.d.ts +1 -1
  39. package/dist/charts/index.d.ts.map +1 -1
  40. package/dist/charts/sparkline.module.css +59 -0
  41. package/dist/charts/sparkline.module.css.d.ts +13 -0
  42. package/dist/charts/state.d.ts +5 -0
  43. package/dist/charts/state.d.ts.map +1 -1
  44. package/dist/charts/state.js +34 -4
  45. package/dist/charts/types.d.ts +6 -0
  46. package/dist/charts/types.d.ts.map +1 -1
  47. package/dist/cli/check-theme.d.ts.map +1 -1
  48. package/dist/cli/check-theme.js +3 -0
  49. package/dist/cli/help.d.ts.map +1 -1
  50. package/dist/cli/help.js +3 -2
  51. package/dist/cli/index.d.ts +4 -2
  52. package/dist/cli/index.d.ts.map +1 -1
  53. package/dist/cli/index.js +27 -15
  54. package/dist/cli/init.d.ts.map +1 -1
  55. package/dist/cli/init.js +3 -2
  56. package/dist/cli/shot/capture.d.ts.map +1 -1
  57. package/dist/cli/shot/capture.js +6 -1
  58. package/dist/cli/shot/detect.d.ts +51 -0
  59. package/dist/cli/shot/detect.d.ts.map +1 -0
  60. package/dist/cli/shot/detect.js +396 -0
  61. package/dist/cli/shot/index.d.ts.map +1 -1
  62. package/dist/cli/shot/index.js +7 -4
  63. package/dist/cli/shot/measure.d.ts +2 -0
  64. package/dist/cli/shot/measure.d.ts.map +1 -1
  65. package/dist/cli/shot/measure.js +2 -0
  66. package/dist/cli/shot/types.d.ts +4 -1
  67. package/dist/cli/shot/types.d.ts.map +1 -1
  68. package/dist/cli/shot/types.js +2 -0
  69. package/dist/cli/sync.d.ts +2 -0
  70. package/dist/cli/sync.d.ts.map +1 -1
  71. package/dist/cli/sync.js +2 -2
  72. package/dist/common/retry-button.d.ts +12 -0
  73. package/dist/common/retry-button.d.ts.map +1 -0
  74. package/dist/common/retry-button.js +22 -0
  75. package/dist/common/retry-button.module.css +58 -0
  76. package/dist/common/retry-button.module.css.d.ts +8 -0
  77. package/dist/controls/sync-button.d.ts +3 -0
  78. package/dist/controls/sync-button.d.ts.map +1 -1
  79. package/dist/dashboard/bar-list.d.ts +18 -4
  80. package/dist/dashboard/bar-list.d.ts.map +1 -1
  81. package/dist/dashboard/bar-list.js +39 -15
  82. package/dist/dashboard/bar-list.module.css +77 -2
  83. package/dist/dashboard/bar-list.module.css.d.ts +1 -0
  84. package/dist/dashboard/delta-badge.d.ts +8 -3
  85. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  86. package/dist/dashboard/delta-badge.js +9 -2
  87. package/dist/dashboard/index.d.ts +2 -0
  88. package/dist/dashboard/index.d.ts.map +1 -1
  89. package/dist/dashboard/meter-model.d.ts +53 -6
  90. package/dist/dashboard/meter-model.d.ts.map +1 -1
  91. package/dist/dashboard/meter-model.js +62 -14
  92. package/dist/dashboard/meter-parts.d.ts +5 -1
  93. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  94. package/dist/dashboard/meter-parts.js +140 -68
  95. package/dist/dashboard/meter.d.ts +29 -4
  96. package/dist/dashboard/meter.d.ts.map +1 -1
  97. package/dist/dashboard/meter.js +8 -1
  98. package/dist/dashboard/meter.module.css +74 -43
  99. package/dist/dashboard/meter.module.css.d.ts +4 -4
  100. package/dist/dashboard/query-state.d.ts +1 -1
  101. package/dist/dashboard/query-state.d.ts.map +1 -1
  102. package/dist/dashboard/query-state.js +16 -10
  103. package/dist/dashboard/settings-section.d.ts.map +1 -1
  104. package/dist/dashboard/settings-section.js +14 -25
  105. package/dist/dashboard/stat-card-parts.js +1 -1
  106. package/dist/dashboard/stat-card.d.ts +1 -1
  107. package/dist/dashboard/stat-card.d.ts.map +1 -1
  108. package/dist/dashboard/stat-card.js +5 -7
  109. package/dist/dashboard/stat-card.module.css +15 -7
  110. package/dist/dashboard/stat-group.d.ts +11 -2
  111. package/dist/dashboard/stat-group.d.ts.map +1 -1
  112. package/dist/dashboard/stat-group.js +9 -7
  113. package/dist/dashboard/stat-strip.d.ts +67 -0
  114. package/dist/dashboard/stat-strip.d.ts.map +1 -0
  115. package/dist/dashboard/stat-strip.js +115 -0
  116. package/dist/dashboard/stat-strip.module.css +291 -0
  117. package/dist/dashboard/stat-strip.module.css.d.ts +32 -0
  118. package/dist/dashboard/visual-slot.d.ts +2 -0
  119. package/dist/dashboard/visual-slot.d.ts.map +1 -0
  120. package/dist/dashboard/visual-slot.js +5 -0
  121. package/dist/dashboard/widget-header.d.ts +3 -3
  122. package/dist/dashboard/widget-header.module.css +10 -6
  123. package/dist/format/date.d.ts.map +1 -1
  124. package/dist/format/date.js +4 -3
  125. package/dist/format/shared.d.ts +6 -0
  126. package/dist/format/shared.d.ts.map +1 -1
  127. package/dist/format/shared.js +6 -2
  128. package/dist/guard/index.d.ts +16 -3
  129. package/dist/guard/index.d.ts.map +1 -1
  130. package/dist/guard/index.js +15 -1
  131. package/dist/guard/palette.d.ts +51 -0
  132. package/dist/guard/palette.d.ts.map +1 -0
  133. package/dist/guard/palette.js +190 -0
  134. package/dist/guard/series-file.d.ts +15 -0
  135. package/dist/guard/series-file.d.ts.map +1 -0
  136. package/dist/guard/series-file.js +29 -0
  137. package/dist/guard/types.d.ts +3 -3
  138. package/dist/guard/types.d.ts.map +1 -1
  139. package/dist/index.d.ts +3 -1
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +4 -0
  142. package/dist/styles.css +6 -0
  143. package/dist/surfaces.d.ts +1 -1
  144. package/dist/surfaces.d.ts.map +1 -1
  145. package/dist/surfaces.js +2 -0
  146. package/dist/theme/card-inset.module.css +76 -0
  147. package/dist/theme/card-inset.module.css.d.ts +9 -0
  148. package/dist/theme/controls.module.css +13 -0
  149. package/dist/theme/index.d.ts.map +1 -1
  150. package/dist/theme/index.js +41 -0
  151. package/dist/theme/nav-link.module.css +8 -10
  152. package/dist/theme/status-dot.d.ts +3 -2
  153. package/dist/theme/status-dot.d.ts.map +1 -1
  154. package/dist/theme/status-dot.js +12 -3
  155. package/dist/theme/status-verdict.d.ts +3 -2
  156. package/dist/theme/status-verdict.d.ts.map +1 -1
  157. package/dist/theme/status-verdict.js +3 -2
  158. package/dist/theme/status-verdict.module.css +4 -2
  159. package/dist/tokens/oklab.d.ts +28 -0
  160. package/dist/tokens/oklab.d.ts.map +1 -0
  161. package/dist/tokens/oklab.js +73 -0
  162. package/llms.txt +33 -7
  163. package/package.json +1 -1
  164. package/src/charts/ChartCard.tsx +79 -5
  165. package/src/charts/Donut.tsx +9 -1
  166. package/src/charts/Heatmap.tsx +1 -1
  167. package/src/charts/Sparkline.tsx +180 -18
  168. package/src/charts/box.tsx +2 -0
  169. package/src/charts/chart-box.module.css +30 -0
  170. package/src/charts/chart-box.module.css.d.ts +1 -0
  171. package/src/charts/chart-card.module.css +47 -0
  172. package/src/charts/chart-card.module.css.d.ts +7 -0
  173. package/src/charts/compile.ts +42 -9
  174. package/src/charts/host.tsx +6 -3
  175. package/src/charts/index.ts +1 -1
  176. package/src/charts/sparkline.module.css +59 -0
  177. package/src/charts/sparkline.module.css.d.ts +13 -0
  178. package/src/charts/state.tsx +53 -4
  179. package/src/charts/types.ts +6 -0
  180. package/src/cli/check-theme.ts +3 -0
  181. package/src/cli/help.ts +18 -1
  182. package/src/cli/index.ts +48 -17
  183. package/src/cli/init.ts +2 -1
  184. package/src/cli/shot/capture.ts +15 -2
  185. package/src/cli/shot/detect.ts +533 -0
  186. package/src/cli/shot/index.ts +8 -4
  187. package/src/cli/shot/measure.ts +4 -0
  188. package/src/cli/shot/types.ts +5 -1
  189. package/src/cli/sync.ts +4 -2
  190. package/src/common/retry-button.module.css +58 -0
  191. package/src/common/retry-button.module.css.d.ts +8 -0
  192. package/src/common/retry-button.tsx +29 -0
  193. package/src/controls/sync-button.tsx +3 -0
  194. package/src/dashboard/bar-list.module.css +77 -2
  195. package/src/dashboard/bar-list.module.css.d.ts +1 -0
  196. package/src/dashboard/bar-list.tsx +89 -18
  197. package/src/dashboard/delta-badge.tsx +21 -5
  198. package/src/dashboard/index.ts +2 -0
  199. package/src/dashboard/meter-model.ts +126 -20
  200. package/src/dashboard/meter-parts.tsx +224 -88
  201. package/src/dashboard/meter.module.css +74 -43
  202. package/src/dashboard/meter.module.css.d.ts +4 -4
  203. package/src/dashboard/meter.tsx +39 -5
  204. package/src/dashboard/query-state.tsx +26 -20
  205. package/src/dashboard/settings-section.tsx +1 -8
  206. package/src/dashboard/stat-card-parts.tsx +1 -1
  207. package/src/dashboard/stat-card.module.css +15 -7
  208. package/src/dashboard/stat-card.tsx +9 -9
  209. package/src/dashboard/stat-group.tsx +19 -8
  210. package/src/dashboard/stat-strip.module.css +291 -0
  211. package/src/dashboard/stat-strip.module.css.d.ts +32 -0
  212. package/src/dashboard/stat-strip.tsx +263 -0
  213. package/src/dashboard/visual-slot.ts +8 -0
  214. package/src/dashboard/widget-header.module.css +10 -6
  215. package/src/dashboard/widget-header.tsx +3 -3
  216. package/src/format/date.ts +6 -3
  217. package/src/format/shared.ts +11 -2
  218. package/src/guard/index.ts +17 -5
  219. package/src/guard/palette.ts +261 -0
  220. package/src/guard/series-file.ts +51 -0
  221. package/src/guard/types.ts +3 -2
  222. package/src/index.ts +7 -0
  223. package/src/styles.css +6 -0
  224. package/src/surfaces.ts +2 -0
  225. package/src/theme/__snapshots__/plain-theme.test.ts.snap +202 -24
  226. package/src/theme/card-inset.module.css +76 -0
  227. package/src/theme/card-inset.module.css.d.ts +9 -0
  228. package/src/theme/controls.module.css +13 -0
  229. package/src/theme/index.ts +56 -0
  230. package/src/theme/nav-link.module.css +8 -10
  231. package/src/theme/status-dot.tsx +17 -5
  232. package/src/theme/status-verdict.module.css +4 -2
  233. package/src/theme/status-verdict.tsx +9 -4
  234. package/src/tokens/oklab.ts +97 -0
@@ -1,8 +1,17 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { cx } from "../common/props.js";
2
3
  import classes from "./status-dot.module.css";
3
- function StatusDot({ color }) {
4
- const style = { "--basalt-status-dot": color };
5
- return /* @__PURE__ */ jsx("span", { className: classes.dot, "data-basalt-status-dot": "", "aria-hidden": "true", style });
4
+ function StatusDot({ color, className, style }) {
5
+ const merged = { ...style, "--basalt-status-dot": color };
6
+ return /* @__PURE__ */ jsx(
7
+ "span",
8
+ {
9
+ className: cx(classes.dot, className),
10
+ "data-basalt-status-dot": "",
11
+ "aria-hidden": "true",
12
+ style: merged
13
+ }
14
+ );
6
15
  }
7
16
  export {
8
17
  StatusDot
@@ -1,9 +1,10 @@
1
- export type StatusVerdictProps = {
1
+ import type { BasaltProps } from '../common/props.js';
2
+ export type StatusVerdictProps = BasaltProps & {
2
3
  color: string;
3
4
  /** The short visible word ("Over", "Error"). */
4
5
  word: string;
5
6
  /** A longer phrase for assistive tech, read in place of the word. */
6
7
  phrase?: string;
7
8
  };
8
- export declare function StatusVerdict({ color, word, phrase }: StatusVerdictProps): import("react").JSX.Element;
9
+ export declare function StatusVerdict({ color, word, phrase, className, style }: StatusVerdictProps): import("react").JSX.Element;
9
10
  //# sourceMappingURL=status-verdict.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"status-verdict.d.ts","sourceRoot":"","sources":["../../src/theme/status-verdict.tsx"],"names":[],"mappings":"AAQA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,kBAAkB,+BAUxE"}
1
+ {"version":3,"file":"status-verdict.d.ts","sourceRoot":"","sources":["../../src/theme/status-verdict.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAIlD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,kBAAkB,+BAU1F"}
@@ -1,8 +1,9 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { cx } from "../common/props.js";
2
3
  import { StatusDot } from "./status-dot.js";
3
4
  import classes from "./status-verdict.module.css";
4
- function StatusVerdict({ color, word, phrase }) {
5
- return /* @__PURE__ */ jsxs("span", { className: classes.verdict, children: [
5
+ function StatusVerdict({ color, word, phrase, className, style }) {
6
+ return /* @__PURE__ */ jsxs("span", { className: cx(classes.verdict, className), ...style !== void 0 && { style }, children: [
6
7
  /* @__PURE__ */ jsx(StatusDot, { color }),
7
8
  /* @__PURE__ */ jsx("span", { "data-verdict-word": "", ...phrase !== void 0 && { "aria-hidden": true }, children: word }),
8
9
  phrase !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.hidden, children: phrase })
@@ -1,11 +1,13 @@
1
1
  /* A status dot plus its word: the dot carries the colour, the word is muted ink. `flex: none` keeps
2
- * it whole when a neighbouring caption or title truncates. */
2
+ * it whole when a neighbouring caption or title truncates. The word is the proportional sans, at the
3
+ * micro size: it is a sentence fragment ("Blocked · Waits on the API change"), not an UPPERCASE
4
+ * caption, so it never takes the mono. */
3
5
  .verdict {
4
6
  display: inline-flex;
5
7
  flex: none;
6
8
  align-items: center;
7
9
  gap: 5px;
8
- font-family: var(--basalt-font-mono);
10
+ font-family: var(--basalt-font-sans);
9
11
  font-size: var(--vx-text-micro);
10
12
  color: var(--vx-muted);
11
13
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * OKLab / OKLCH and colour-vision-deficiency simulation — Mantine-free, dependency-free.
3
+ *
4
+ * OKLab is Ottosson's definition (https://bottosson.github.io/posts/oklab/); the CVD matrices are
5
+ * Machado, Oliveira & Fernandes (2009), "A Physiologically-based Model for Simulation of Color
6
+ * Vision Deficiency", severity 1.0, applied to LINEAR sRGB. `deltaEOk` is the Euclidean OKLab
7
+ * distance ×100, the unit the series-palette guard's thresholds are written in.
8
+ */
9
+ export type Oklab = {
10
+ L: number;
11
+ a: number;
12
+ b: number;
13
+ };
14
+ export type Oklch = {
15
+ L: number;
16
+ C: number;
17
+ h: number;
18
+ };
19
+ export type CvdKind = 'protan' | 'deutan';
20
+ export declare function hexToOklab(hex: string): Oklab;
21
+ export declare function hexToOklch(hex: string): Oklch;
22
+ /** Euclidean OKLab distance ×100 between two hex colours. */
23
+ export declare function deltaEOk(hexA: string, hexB: string): number;
24
+ /** The hex a dichromat sees for `hex` — for display and tests; the checks stay in linear RGB. */
25
+ export declare function simulateCvd(hex: string, kind: CvdKind): string;
26
+ /** OKLab ΔE×100 between two colours as a dichromat sees them — no 8-bit round trip. */
27
+ export declare function deltaEOkCvd(hexA: string, hexB: string, kind: CvdKind): number;
28
+ //# sourceMappingURL=oklab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oklab.d.ts","sourceRoot":"","sources":["../../src/tokens/oklab.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACvD,MAAM,MAAM,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACvD,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAkDzC,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAE7C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAI7C;AAED,6DAA6D;AAC7D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI3D;AAUD,iGAAiG;AACjG,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAE9D;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAI7E"}
@@ -0,0 +1,73 @@
1
+ const MACHADO = {
2
+ protan: [
3
+ [0.152286, 1.052583, -0.204868],
4
+ [0.114503, 0.786281, 0.099216],
5
+ [-3882e-6, -0.048116, 1.051998]
6
+ ],
7
+ deutan: [
8
+ [0.367322, 0.860646, -0.227968],
9
+ [0.280085, 0.672501, 0.047413],
10
+ [-0.01182, 0.04294, 0.968881]
11
+ ]
12
+ };
13
+ function hexToLinear(hex) {
14
+ const raw = hex.replace("#", "");
15
+ const full = raw.length === 3 ? [...raw].map((c) => c + c).join("") : raw.slice(0, 6);
16
+ const channel = (i) => {
17
+ const c = Number.parseInt(full.slice(i, i + 2), 16) / 255;
18
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
19
+ };
20
+ return [channel(0), channel(2), channel(4)];
21
+ }
22
+ function linearToHex([r, g, b]) {
23
+ const encode = (c) => {
24
+ const v = Math.min(1, Math.max(0, c));
25
+ const s = v <= 31308e-7 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055;
26
+ return Math.round(s * 255).toString(16).padStart(2, "0");
27
+ };
28
+ return `#${encode(r)}${encode(g)}${encode(b)}`;
29
+ }
30
+ function linearToOklab([r, g, b]) {
31
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
32
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
33
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
34
+ return {
35
+ L: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
36
+ a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
37
+ b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
38
+ };
39
+ }
40
+ function hexToOklab(hex) {
41
+ return linearToOklab(hexToLinear(hex));
42
+ }
43
+ function hexToOklch(hex) {
44
+ const { L, a, b } = hexToOklab(hex);
45
+ const h = Math.atan2(b, a) * 180 / Math.PI;
46
+ return { L, C: Math.hypot(a, b), h: h < 0 ? h + 360 : h };
47
+ }
48
+ function deltaEOk(hexA, hexB) {
49
+ const x = hexToOklab(hexA);
50
+ const y = hexToOklab(hexB);
51
+ return 100 * Math.hypot(x.L - y.L, x.a - y.a, x.b - y.b);
52
+ }
53
+ function simulateCvdLinear(hex, kind) {
54
+ const [r, g, b] = hexToLinear(hex);
55
+ const [row0, row1, row2] = MACHADO[kind];
56
+ const mix = (row) => Math.min(1, Math.max(0, row[0] * r + row[1] * g + row[2] * b));
57
+ return [mix(row0), mix(row1), mix(row2)];
58
+ }
59
+ function simulateCvd(hex, kind) {
60
+ return linearToHex(simulateCvdLinear(hex, kind));
61
+ }
62
+ function deltaEOkCvd(hexA, hexB, kind) {
63
+ const x = linearToOklab(simulateCvdLinear(hexA, kind));
64
+ const y = linearToOklab(simulateCvdLinear(hexB, kind));
65
+ return 100 * Math.hypot(x.L - y.L, x.a - y.a, x.b - y.b);
66
+ }
67
+ export {
68
+ deltaEOk,
69
+ deltaEOkCvd,
70
+ hexToOklab,
71
+ hexToOklch,
72
+ simulateCvd
73
+ };
package/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- # basalt-ui v2.19.0
1
+ # basalt-ui v2.21.0
2
2
  # Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets
3
3
  #
4
4
  # Entry points: use the exact import specifier below; do not guess.
@@ -13,7 +13,7 @@
13
13
  # A subpath's `Install:` line is its required peers; `OptionalPeers:` are import()-only, install on use.
14
14
 
15
15
  Package: basalt-ui
16
- Version: 2.19.0
16
+ Version: 2.21.0
17
17
 
18
18
  ## basalt-ui
19
19
  Import: import { ... } from 'basalt-ui'
@@ -25,8 +25,9 @@ Signature: BarList(props: BarListProps): JSX.Element
25
25
  style?: CSSProperties
26
26
  label: string
27
27
  items: readonly BarListItem[]
28
- format?: (value: number) => string
28
+ format?: (value: number, part: "value" | "max") => string
29
29
  max?: number
30
+ variant?: "thin" | "inline"
30
31
  accentLeader?: boolean
31
32
  loading?: boolean
32
33
  loadingRows?: number
@@ -82,6 +83,7 @@ Signature: DeltaBadge(props: DeltaBadgeProps): JSX.Element
82
83
  format?: (value: number) => string
83
84
  withGlyph?: boolean
84
85
  period?: string
86
+ periodPrefix?: string
85
87
  Signature: EmptyState(props: EmptyStateProps): JSX.Element
86
88
  className?: string
87
89
  style?: CSSProperties
@@ -102,6 +104,9 @@ Signature: Meter(props: MeterProps): JSX.Element
102
104
  emptyText?: string
103
105
  shape?: "bar" | "ring"
104
106
  target?: number [with segments | zones]
107
+ ticks?: readonly MeterTick[] [with segments | zones]
108
+ tone?: "muted" | "ink" [with segments | zones]
109
+ size?: "row" [with segments | zones]
105
110
  startCaption?: ReactNode [with segments | zones]
106
111
  endCaption?: ReactNode [with segments | zones]
107
112
  value?: number | null [with zones]
@@ -207,11 +212,26 @@ Signature: StatCard(props: StatCardProps): JSX.Element
207
212
  actions?: ReactNode
208
213
  tone?: Tone
209
214
  Signature: StatGroup(props: StatGroupProps): JSX.Element
215
+ one of: variant="grid" | variant="strip"
210
216
  className?: string
211
217
  style?: CSSProperties
212
- cols?: StatGroupCols
213
- divided?: boolean
214
- children: ReactNode
218
+ variant?: "grid" | "strip"
219
+ cols?: StatGroupCols | 2 | 3 | 4 | 5 | 6
220
+ divided?: boolean [with variant="grid"]
221
+ children: ReactNode [with variant="grid"]
222
+ label: string [with variant="strip"]
223
+ cells: readonly StatStripCell[] [with variant="strip"]
224
+ footer?: readonly { key: string; content: ReactNode; }[] [with variant="strip"]
225
+ Signature: StatusDot(props: StatusDotProps): JSX.Element
226
+ className?: string
227
+ style?: CSSProperties
228
+ color: string
229
+ Signature: StatusVerdict(props: StatusVerdictProps): JSX.Element
230
+ className?: string
231
+ style?: CSSProperties
232
+ color: string
233
+ word: string
234
+ phrase?: string
215
235
  Signature: ThemeToggle(props: ThemeToggleProps): JSX.Element
216
236
  className?: string
217
237
  style?: CSSProperties
@@ -350,8 +370,11 @@ Signature: ChartCard(props: ChartCardProps): ReactElement<unknown, string | JSXE
350
370
  actions?: ReactNode
351
371
  state?: ChartState
352
372
  placeholderHeight?: number | ResponsiveChartHeight
373
+ onRetry?: (() => void)
374
+ retrying?: boolean
353
375
  stateAction?: ReactNode
354
376
  children?: ReactNode
377
+ facts: ChartFact | readonly ChartFact[]
355
378
  Signature: Donut(props: DonutProps<K>): ReactElement<unknown, string | JSXElementConstructor<any>>
356
379
  className?: string
357
380
  style?: CSSProperties
@@ -460,6 +483,9 @@ Signature: Sparkline(props: SparklineProps): ReactElement<unknown, string | JSXE
460
483
  emphasizeLast?: boolean
461
484
  emphasisColor?: string
462
485
  state?: ChartState
486
+ reference?: number | "mean"
487
+ format?: ((value: number) => string)
488
+ labels?: readonly string[]
463
489
  Signature: StackedArea(props: StackedAreaProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
464
490
  className?: string
465
491
  style?: CSSProperties
@@ -685,7 +711,7 @@ Signature: ThreadFeed(props: ThreadFeedProps): JSX.Element
685
711
  threads: AgentThread[]
686
712
  activeId: string | null
687
713
  onSelect: (id: string) => void
688
- variant?: "outcome" | "inline"
714
+ variant?: "inline" | "outcome"
689
715
  onSend?: ((thread: AgentThread, payload: ComposerSubmit) => void)
690
716
  renderRow?: ((thread: AgentThread) => ReactNode)
691
717
  anchor?: "start" | "end"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basalt-ui",
3
- "version": "2.19.0",
3
+ "version": "2.21.0",
4
4
  "description": "Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets",
5
5
  "keywords": [
6
6
  "charts",
@@ -87,14 +87,25 @@ const bodyClipStyle: CSSProperties = {
87
87
  padding: '2px var(--vx-space-card-inset-x, 1rem) var(--vx-space-card-inset-y, 0.75rem)',
88
88
  }
89
89
 
90
+ /** One headline figure: the value is the hero, then its unit, a comparison node and the period. */
91
+ export type ChartFact = {
92
+ value: ReactNode
93
+ unit?: string | undefined
94
+ /** Usually a `DeltaBadge`. */
95
+ comparison?: ReactNode
96
+ /** Plain text the figure covers, e.g. `last 30 d`. */
97
+ period?: string | undefined
98
+ }
99
+
90
100
  /** The three boxes a `ChartCard` paints. */
91
101
  export type ChartCardSlot = 'root' | 'header' | 'body'
92
102
 
93
- export type ChartCardProps = BasaltProps &
103
+ type ChartCardBaseProps = BasaltProps &
94
104
  SlotStylesProps<ChartCardSlot> & {
95
105
  title?: string | undefined
96
106
  icon?: ReactNode
97
- /** A muted line below the title row; does not by itself render the header. */
107
+ /** A muted line below the title row; does not by itself render the header. With `facts` it is the
108
+ * basis/as-of line after the facts row (always visible, never folded into the info glyph). */
98
109
  subtitle?: string | undefined
99
110
  /** `WidgetHeader`'s info glyph beside the title. */
100
111
  info?: string | undefined
@@ -113,11 +124,32 @@ export type ChartCardProps = BasaltProps &
113
124
  * unsized chart takes — pass the chart's own `height` when it states one, so a `<Suspense
114
125
  * fallback={<ChartCard state={{ pending: true }} …/>}>` reserves the final size. */
115
126
  placeholderHeight?: number | ResponsiveChartHeight | undefined
116
- /** A retry button or a "clear filters" link under the placeholder. */
127
+ /** An errored `state` shows the shared Retry button (the one `ErrorState` renders). */
128
+ onRetry?: (() => void) | undefined
129
+ /** A refetch is in flight: Retry is inert and marked busy. */
130
+ retrying?: boolean | undefined
131
+ /** Any other action under the placeholder, e.g. a "clear filters" link; after Retry. */
117
132
  stateAction?: ReactNode
118
133
  children?: ReactNode
119
134
  }
120
135
 
136
+ /**
137
+ * `facts` replaces the legacy `value`/`delta` hero: the two are mutually exclusive in the type. The
138
+ * facts show only at rest: while `state` is pending, errored or empty the figure would sit above a
139
+ * skeleton or a placeholder that contradicts it, so the header keeps its title row alone.
140
+ */
141
+ export type ChartCardProps = ChartCardBaseProps &
142
+ (
143
+ | {
144
+ /** The headline figure(s) under the title: value, unit, comparison, period. Wraps at half
145
+ * width, never clips. Replaces `value`/`delta`. */
146
+ facts: ChartFact | readonly ChartFact[]
147
+ value?: undefined
148
+ delta?: undefined
149
+ }
150
+ | { facts?: undefined }
151
+ )
152
+
121
153
  /** Drops explicit `undefined`s: `WidgetHeader` is exact-optional, this props type is not. */
122
154
  const definedOnly = <T extends object>(o: T): { [K in keyof T]?: Exclude<T[K], undefined> } =>
123
155
  Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as {
@@ -127,20 +159,59 @@ const definedOnly = <T extends object>(o: T): { [K in keyof T]?: Exclude<T[K], u
127
159
  /** A header renders when one of these is set (a subtitle or delta alone does not). */
128
160
  const HEADER_TRIGGERS = ['title', 'info', 'value', 'icon', 'count'] as const
129
161
 
162
+ function Facts({
163
+ facts,
164
+ basis,
165
+ }: {
166
+ facts: ChartFact | readonly ChartFact[]
167
+ basis?: string | undefined
168
+ }): ReactElement {
169
+ const list: readonly ChartFact[] = Array.isArray(facts) ? facts : [facts as ChartFact]
170
+ return (
171
+ <div data-basalt-facts="" className={classes.facts}>
172
+ <div className={classes.factsRow}>
173
+ {list.map((f, i) => (
174
+ <span key={i} data-basalt-fact="" className={classes.fact}>
175
+ <span data-basalt-fact-value="" className={classes.factValue}>
176
+ {f.value}
177
+ </span>
178
+ {f.unit !== undefined && <span className={classes.factUnit}>{f.unit}</span>}
179
+ {f.comparison}
180
+ {f.period !== undefined && <span className={classes.factPeriod}>{f.period}</span>}
181
+ </span>
182
+ ))}
183
+ </div>
184
+ {basis !== undefined && (
185
+ <p data-basalt-facts-basis="" className={classes.factsBasis}>
186
+ {basis}
187
+ </p>
188
+ )}
189
+ </div>
190
+ )
191
+ }
192
+
130
193
  export function ChartCard({
131
194
  actions,
132
195
  state,
133
196
  placeholderHeight,
134
197
  stateAction,
198
+ onRetry,
199
+ retrying,
135
200
  className,
136
201
  classNames,
137
202
  style,
138
203
  children,
204
+ facts,
139
205
  ...header
140
206
  }: ChartCardProps): ReactElement {
141
207
  const { ref, short } = useShortCard()
142
208
  const resolved = resolveChartState(state)
143
- const hasHeader = actions !== undefined || HEADER_TRIGGERS.some((k) => header[k] !== undefined)
209
+ const showFacts = facts !== undefined && resolved === null
210
+ const hasHeader =
211
+ actions !== undefined || showFacts || HEADER_TRIGGERS.some((k) => header[k] !== undefined)
212
+ // With facts the subtitle is the basis line after them, not WidgetHeader's foldable row.
213
+ const { subtitle, ...rest } = header
214
+ const headerProps = facts === undefined ? header : rest
144
215
 
145
216
  return (
146
217
  <ChartCardContext.Provider value>
@@ -156,12 +227,13 @@ export function ChartCard({
156
227
  <div className={cx(classes.header, classNames?.header)}>
157
228
  <WidgetHeader
158
229
  tier="widget"
159
- {...definedOnly(header)}
230
+ {...definedOnly(headerProps)}
160
231
  title={header.title ?? ''}
161
232
  {...(actions !== undefined && {
162
233
  actions: <span data-basalt-tier="widget">{actions}</span>,
163
234
  })}
164
235
  />
236
+ {showFacts && <Facts facts={facts} basis={subtitle} />}
165
237
  </div>
166
238
  )}
167
239
  <div
@@ -174,6 +246,8 @@ export function ChartCard({
174
246
  <ChartPlaceholder
175
247
  state={state}
176
248
  {...(placeholderHeight !== undefined && { height: placeholderHeight })}
249
+ {...(onRetry !== undefined && { onRetry })}
250
+ {...(retrying !== undefined && { retrying })}
177
251
  action={stateAction}
178
252
  />
179
253
  )}
@@ -239,7 +239,15 @@ export function Donut<K extends string = string>(props: DonutProps<K>): ReactEle
239
239
  {resolved === null && (centerLabel !== undefined || centerSubLabel !== undefined) && (
240
240
  <div style={centerStyle}>
241
241
  {centerLabel !== undefined && (
242
- <span style={{ color: VX.ink, fontSize: VX.text.lg, fontWeight: 600 }}>
242
+ <span
243
+ style={{
244
+ color: VX.ink,
245
+ fontFamily: 'var(--basalt-font-numeral, var(--basalt-font-sans))',
246
+ fontVariantNumeric: 'lining-nums',
247
+ fontSize: VX.text.lg,
248
+ fontWeight: 600,
249
+ }}
250
+ >
243
251
  {centerLabel}
244
252
  </span>
245
253
  )}
@@ -261,7 +261,7 @@ export function Heatmap<T, K extends string = string>(props: HeatmapProps<T, K>)
261
261
  const ticks = { line: false as const, size: 0 }
262
262
  const cls = resolveContainerClass(width)
263
263
  const tickLabels = {
264
- fontSize: cls === 'wide' ? VX.text.micro : VX.text.nano,
264
+ fontSize: VX.text.micro,
265
265
  opacity: 1,
266
266
  thin: true,
267
267
  }