basalt-ui 1.1.1 → 1.3.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 (191) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +46 -0
  3. package/README.md +64 -8
  4. package/agent/rules/basalt-app.md +126 -0
  5. package/agent/rules/basalt-content.md +3 -1
  6. package/agent/rules/basalt-tokens.md +14 -5
  7. package/agent/skills/basalt-app/SKILL.md +28 -7
  8. package/dist/agent/part-list.d.ts.map +1 -1
  9. package/dist/agent/part-list.js +17 -7
  10. package/dist/agent/stick-to-bottom.js +2 -2
  11. package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -1
  12. package/dist/agent-chat/thread-detail-panel.js +37 -33
  13. package/dist/agent-chat/thread-message.d.ts.map +1 -1
  14. package/dist/agent-chat/thread-message.js +8 -5
  15. package/dist/agent-chat/thread-outcome-card.js +3 -3
  16. package/dist/agent-chat/thread-workspace.js +1 -1
  17. package/dist/charts/primitives/ChartLegend.js +2 -0
  18. package/dist/charts/primitives/ChartTooltip.js +2 -1
  19. package/dist/cli/index.d.ts +29 -0
  20. package/dist/cli/index.d.ts.map +1 -1
  21. package/dist/cli/index.js +80 -9
  22. package/dist/connectivity/connectivity-indicator.d.ts.map +1 -1
  23. package/dist/connectivity/connectivity-indicator.js +3 -3
  24. package/dist/content/article-card.module.css +7 -5
  25. package/dist/content/article-layout.module.css +16 -12
  26. package/dist/content/callout.module.css +4 -4
  27. package/dist/content/code-block.module.css +8 -7
  28. package/dist/content/guide.module.css +3 -3
  29. package/dist/content/mermaid.module.css +2 -2
  30. package/dist/content/prose.module.css +59 -29
  31. package/dist/content/reading-progress.module.css +2 -0
  32. package/dist/content/toc.module.css +6 -3
  33. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  34. package/dist/dashboard/delta-badge.js +10 -2
  35. package/dist/dashboard/empty-state.d.ts.map +1 -1
  36. package/dist/dashboard/empty-state.js +3 -16
  37. package/dist/dashboard/settings-section.js +2 -2
  38. package/dist/dashboard/settings-section.module.css +2 -2
  39. package/dist/dashboard/stat-card.js +2 -1
  40. package/dist/data/virtual-list.d.ts.map +1 -1
  41. package/dist/data/virtual-list.js +12 -2
  42. package/dist/forms/FormErrorSummary.js +2 -2
  43. package/dist/guard/index.d.ts +20 -4
  44. package/dist/guard/index.d.ts.map +1 -1
  45. package/dist/guard/index.js +266 -38
  46. package/dist/guard/types.d.ts +24 -3
  47. package/dist/guard/types.d.ts.map +1 -1
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/provider/index.d.ts +30 -1
  51. package/dist/provider/index.d.ts.map +1 -1
  52. package/dist/provider/index.js +32 -7
  53. package/dist/provider/lab-theme.d.ts +39 -0
  54. package/dist/provider/lab-theme.d.ts.map +1 -0
  55. package/dist/provider/lab-theme.js +52 -0
  56. package/dist/shell/app-header.module.css +2 -2
  57. package/dist/shell/app-mobile-nav.module.css +1 -1
  58. package/dist/shell/app-sidebar-account.d.ts.map +1 -1
  59. package/dist/shell/app-sidebar-account.js +4 -2
  60. package/dist/shell/app-sidebar.d.ts.map +1 -1
  61. package/dist/shell/app-sidebar.js +4 -2
  62. package/dist/shell/app-sidebar.module.css +36 -26
  63. package/dist/shell/index.d.ts.map +1 -1
  64. package/dist/shell/index.js +11 -4
  65. package/dist/shell/sidebar-search.module.css +16 -4
  66. package/dist/styles.css +22 -11
  67. package/dist/surfaces.d.ts +21 -11
  68. package/dist/surfaces.d.ts.map +1 -1
  69. package/dist/surfaces.js +10 -3
  70. package/dist/theme/controls.module.css +1 -1
  71. package/dist/theme/floating.module.css +1 -1
  72. package/dist/theme/index.d.ts +116 -11
  73. package/dist/theme/index.d.ts.map +1 -1
  74. package/dist/theme/index.js +703 -566
  75. package/dist/theme/nav-link.module.css +1 -1
  76. package/dist/theme/use-basalt-spacing.d.ts +3 -0
  77. package/dist/theme/use-basalt-spacing.d.ts.map +1 -0
  78. package/dist/theme/use-basalt-spacing.js +8 -0
  79. package/dist/theme-lab/derive-controls.d.ts +13 -0
  80. package/dist/theme-lab/derive-controls.d.ts.map +1 -0
  81. package/dist/theme-lab/derive-controls.js +137 -0
  82. package/dist/theme-lab/derive-state.d.ts +55 -0
  83. package/dist/theme-lab/derive-state.d.ts.map +1 -0
  84. package/dist/theme-lab/derive-state.js +81 -0
  85. package/dist/theme-lab/index.d.ts +12 -2
  86. package/dist/theme-lab/index.d.ts.map +1 -1
  87. package/dist/theme-lab/index.js +13 -62
  88. package/dist/theme-toggle/index.d.ts.map +1 -1
  89. package/dist/theme-toggle/index.js +3 -2
  90. package/dist/tokens/derive.d.ts +89 -0
  91. package/dist/tokens/derive.d.ts.map +1 -0
  92. package/dist/tokens/derive.js +250 -0
  93. package/dist/tokens/hct.d.ts +34 -0
  94. package/dist/tokens/hct.d.ts.map +1 -0
  95. package/dist/tokens/hct.js +159 -0
  96. package/dist/tokens/index.d.ts +143 -7
  97. package/dist/tokens/index.d.ts.map +1 -1
  98. package/dist/tokens/index.js +322 -48
  99. package/dist/tokens/palette.d.ts +984 -167
  100. package/dist/tokens/palette.d.ts.map +1 -1
  101. package/dist/tokens/palette.js +617 -119
  102. package/dist/tokens.css +248 -0
  103. package/dist/vite-color-mix.d.ts +30 -0
  104. package/dist/vite-color-mix.d.ts.map +1 -0
  105. package/dist/vite-color-mix.js +80 -0
  106. package/dist/vite.d.ts +82 -1
  107. package/dist/vite.d.ts.map +1 -1
  108. package/dist/vite.js +312 -0
  109. package/llms.txt +14 -4
  110. package/package.json +41 -10
  111. package/src/agent/part-list.tsx +13 -7
  112. package/src/agent/stick-to-bottom.tsx +2 -2
  113. package/src/agent-chat/thread-detail-panel.tsx +13 -10
  114. package/src/agent-chat/thread-message.tsx +8 -5
  115. package/src/agent-chat/thread-outcome-card.tsx +2 -2
  116. package/src/agent-chat/thread-workspace.tsx +2 -2
  117. package/src/charts/primitives/ChartLegend.tsx +2 -2
  118. package/src/charts/primitives/ChartTooltip.tsx +2 -2
  119. package/src/cli/check-theme.test.ts +18 -0
  120. package/src/cli/index.ts +129 -6
  121. package/src/cli/tokens-css.test.ts +90 -0
  122. package/src/connectivity/connectivity-indicator.tsx +8 -2
  123. package/src/content/article-card.module.css +7 -5
  124. package/src/content/article-layout.module.css +16 -12
  125. package/src/content/callout.module.css +4 -4
  126. package/src/content/code-block.module.css +8 -7
  127. package/src/content/guide.module.css +3 -3
  128. package/src/content/mermaid.module.css +2 -2
  129. package/src/content/prose.module.css +59 -29
  130. package/src/content/prose.module.css.test.ts +55 -0
  131. package/src/content/reading-progress.module.css +2 -0
  132. package/src/content/toc.module.css +6 -3
  133. package/src/dashboard/delta-badge.tsx +10 -4
  134. package/src/dashboard/empty-state.tsx +3 -16
  135. package/src/dashboard/settings-section.module.css +2 -2
  136. package/src/dashboard/settings-section.tsx +2 -2
  137. package/src/dashboard/stat-card.tsx +2 -2
  138. package/src/data/virtual-list.tsx +12 -2
  139. package/src/forms/FormErrorSummary.tsx +1 -1
  140. package/src/guard/check-source.test.ts +483 -15
  141. package/src/guard/index.ts +426 -47
  142. package/src/guard/types.ts +24 -2
  143. package/src/index.ts +1 -0
  144. package/src/provider/index.test.tsx +100 -0
  145. package/src/provider/index.tsx +79 -7
  146. package/src/provider/lab-theme.test.ts +147 -0
  147. package/src/provider/lab-theme.ts +166 -0
  148. package/src/shell/app-header.module.css +2 -2
  149. package/src/shell/app-mobile-nav.module.css +1 -1
  150. package/src/shell/app-sidebar-account.tsx +9 -2
  151. package/src/shell/app-sidebar.module.css +36 -26
  152. package/src/shell/app-sidebar.tsx +12 -2
  153. package/src/shell/index.tsx +14 -3
  154. package/src/shell/sidebar-search.module.css +16 -4
  155. package/src/styles.css +22 -11
  156. package/src/surfaces.ts +24 -10
  157. package/src/theme/contrast.test.ts +19 -3
  158. package/src/theme/controls.module.css +1 -1
  159. package/src/theme/density-option.test.ts +96 -0
  160. package/src/theme/density-relations.test.ts +428 -0
  161. package/src/theme/derive-theme.test.ts +101 -0
  162. package/src/theme/floating.module.css +1 -1
  163. package/src/theme/fonts-option.test.ts +69 -0
  164. package/src/theme/index.ts +930 -563
  165. package/src/theme/nav-link.module.css +1 -1
  166. package/src/theme/radius-option.test.ts +86 -0
  167. package/src/theme/radius.test.ts +132 -0
  168. package/src/theme/spacing.test.ts +432 -0
  169. package/src/theme/use-basalt-spacing.test.tsx +51 -0
  170. package/src/theme/use-basalt-spacing.ts +38 -0
  171. package/src/theme-lab/derive-controls.test.ts +94 -0
  172. package/src/theme-lab/derive-controls.tsx +227 -0
  173. package/src/theme-lab/derive-state.test.ts +71 -0
  174. package/src/theme-lab/derive-state.ts +163 -0
  175. package/src/theme-lab/index.tsx +29 -68
  176. package/src/theme-lab/theme-lab.test.ts +4 -18
  177. package/src/theme-toggle/index.tsx +9 -4
  178. package/src/tokens/build-fonts-css.test.ts +51 -0
  179. package/src/tokens/build-radius-css.test.ts +25 -0
  180. package/src/tokens/density.test.ts +274 -0
  181. package/src/tokens/derive-radius.test.ts +62 -0
  182. package/src/tokens/derive.test.ts +30 -0
  183. package/src/tokens/derive.ts +481 -0
  184. package/src/tokens/hct.ts +231 -0
  185. package/src/tokens/index.ts +534 -48
  186. package/src/tokens/palette.test.ts +114 -0
  187. package/src/tokens/palette.ts +1118 -180
  188. package/src/vite-color-mix.test.ts +46 -0
  189. package/src/vite-color-mix.ts +137 -0
  190. package/src/vite.test.ts +192 -0
  191. package/src/vite.ts +502 -1
@@ -1,5 +1,17 @@
1
- import { ACCENT, FILL, INK, NEUTRAL, SEMANTIC, SHADOW, STATUS, SURFACE } from "./palette.js";
1
+ import {
2
+ buildPaletteData,
3
+ RADIUS,
4
+ RADIUS_STEP,
5
+ ROW_LINE_HEIGHT,
6
+ SHADOW,
7
+ SPACE,
8
+ SPACE_SCALE,
9
+ SPACE_STEP
10
+ } from "./palette.js";
2
11
  import { BP, p } from "./palette.js";
12
+ import { DEFAULT_DERIVE_CONFIG, deriveTokens, resolveDeriveConfig } from "./derive.js";
13
+ import { deriveRadius } from "./palette.js";
14
+ import { deriveSpacing } from "./palette.js";
3
15
  const alpha = (token, a) => `color-mix(in srgb, ${token} ${Math.round(a * 100)}%, transparent)`;
4
16
  const TEXT = {
5
17
  micro: 11,
@@ -23,14 +35,23 @@ const TEXT = {
23
35
  };
24
36
  const VX = {
25
37
  // Non-color sizing constants
38
+ // Stroke WEIGHTS, not spacing — deliberately fixed, never density-tracking (see
39
+ // `SPACE_STEP_BASE`'s "charts" group doc in tokens/palette.ts).
26
40
  lineWidth: 2.5,
27
41
  line2Width: 2,
28
42
  axisFont: TEXT.micro,
29
- dotR: 5,
43
+ // A discrete visual footprint (not a stroke weight), so — unlike `lineWidth`/`line2Width` above —
44
+ // it DOES track density; single-sourced from `SPACE_STEP.chartDotR` (see that constant's doc).
45
+ dotR: SPACE_STEP.chartDotR,
30
46
  // The ONE dashed pattern — plotted stroke, legend swatch, tooltip swatch all read this.
31
47
  dashArray: "6 4",
32
- // Legend layout — replaces the hardcoded 18/13 in ChartLegend.
33
- legendGap: 22,
48
+ // Legend layout — single-sourced from `SPACE_STEP.chartLegendGap` (density-tracking; see that
49
+ // constant's doc). Still a raw number here (not `var()`) — ChartLegend applies it via inline
50
+ // `style`, and this is the one static (level-0) value; `createBasaltTheme({ density })` has no
51
+ // wiring into chart render props yet, so this number does NOT move live with the knob (same
52
+ // "dev slider/production JS defaultProps" gap as Timeline's `bulletSize` — see `deriveSpacing`'s
53
+ // doc in tokens/palette.ts).
54
+ legendGap: SPACE_STEP.chartLegendGap,
34
55
  legendFontSize: TEXT.sm,
35
56
  // The type scale (px numbers — see TEXT above). Use in inline styles and visx SVG props;
36
57
  // use `var(--vx-text-*)` in CSS modules.
@@ -40,6 +61,9 @@ const VX = {
40
61
  radiusCard: "var(--vx-radius-card)",
41
62
  // Single source for the control corner radius (inputs, search, buttons, segmented track).
42
63
  radiusCtrl: "var(--vx-radius-ctrl)",
64
+ // Fully-rounded pill affordance (scroll-to-bottom button, chips) — fixed, does not track the
65
+ // radius knob (see `RADIUS_STEP.pill`'s doc in `tokens/palette.ts`).
66
+ radiusPill: "var(--vx-radius-pill)",
43
67
  // Secondary-line color (back-compat alias; now theme-aware via --vx-line2)
44
68
  line2Dark: "var(--vx-line2)",
45
69
  // Semantic fills — consistent opacity across all charts
@@ -121,20 +145,29 @@ const VX = {
121
145
  bad: "var(--vx-status-bad)",
122
146
  neutral: "var(--vx-status-neutral)"
123
147
  },
124
- // Shared sizing
125
- margin: { top: 12, right: 16, bottom: 30, left: 44 },
148
+ // Shared sizing — single-sourced from `SPACE_STEP.chartMargin*` (density-tracking; same
149
+ // static-value/no-live-wiring note as `legendGap` above).
150
+ margin: {
151
+ top: SPACE_STEP.chartMarginTop,
152
+ right: SPACE_STEP.chartMarginRight,
153
+ bottom: SPACE_STEP.chartMarginBottom,
154
+ left: SPACE_STEP.chartMarginLeft
155
+ },
126
156
  minPxPerTick: 55
127
157
  };
128
158
  const decl = (name, value) => ` --vx-${name}: ${value};`;
159
+ function pxRem(px) {
160
+ return `${px / 16}rem`;
161
+ }
129
162
  const groupSide = (prefix, map, side) => Object.entries(map).map(([key, pair]) => decl(`${prefix}${key}`, pair[side])).join("\n");
130
- function frameworkPrimitives(side) {
131
- const n = NEUTRAL;
132
- const s = SEMANTIC;
133
- const su = SURFACE;
134
- const ink = INK;
135
- const ac = ACCENT;
163
+ function frameworkPrimitives(side, data) {
164
+ const n = data.NEUTRAL;
165
+ const s = data.SEMANTIC;
166
+ const su = data.SURFACE;
167
+ const ink = data.INK;
168
+ const ac = data.ACCENT;
136
169
  return [
137
- groupSide("status-", STATUS, side),
170
+ groupSide("status-", data.STATUS, side),
138
171
  decl("goodSolid", s.good[side]),
139
172
  decl("badSolid", s.bad[side]),
140
173
  decl("warnSolid", s.warn[side]),
@@ -151,7 +184,7 @@ function frameworkPrimitives(side) {
151
184
  decl("tooltipMuted", n.tooltipMuted[side]),
152
185
  decl("tooltipBorder", n.tooltipBorder[side]),
153
186
  decl("tooltipShadow", n.tooltipShadow[side]),
154
- decl("legendText", side === "dark" ? "rgba(255,255,255,0.92)" : "rgba(38,38,38,0.82)"),
187
+ decl("legendText", n.legendText[side]),
155
188
  decl("ink", ink.ink[side]),
156
189
  decl("ink2", ink.ink2[side]),
157
190
  decl("muted", ink.muted[side]),
@@ -176,34 +209,200 @@ function frameworkPrimitives(side) {
176
209
  decl("surface-hairline", su.hairline[side])
177
210
  ].join("\n");
178
211
  }
179
- const FRAMEWORK_DERIVED = [
180
- decl("radius-card", "7px"),
181
- decl("radius-ctrl", "6px"),
182
- // Article-density Prose measure (docs/CONTENT-SPEC.md §5) — theme-independent, like the radii.
183
- decl("prose-measure", "72ch"),
184
- // The fill band (see FILL in palette.ts). Emitted on `:root`, NOT per scheme — a filled surface
185
- // is the same hex in both, which is the whole point: it is squeezed between its white label and
186
- // the page behind it, and only one luminance band satisfies both on both pages.
187
- ...Object.entries(FILL).map(([name, hex]) => decl(`fill-${name}`, hex)),
188
- // Hover is DERIVED from the fill, so retuning a fill (in the theme lab, or here) carries its
189
- // hover along instead of leaving a stale pair. 88% of the fill over black lands ~0.128 luminance:
190
- // a visible press-darkening that still clears AA for the white label (~5.9:1).
191
- ...Object.keys(FILL).map(
192
- (name) => decl(`fillHover-${name}`, `color-mix(in srgb, var(--vx-fill-${name}) 88%, #000)`)
193
- ),
194
- // The type scale, emitted from the SAME `TEXT` object `VX.text` reads — CSS modules and the
195
- // Mantine theme consume these; inline styles / visx read the numbers. One ladder, two forms.
196
- ...Object.entries(TEXT).map(([step, px]) => decl(`text-${step}`, `${px}px`)),
197
- decl("area-top", "22%"),
198
- decl("area-bottom", "1%"),
199
- decl("good", "color-mix(in srgb, var(--vx-goodSolid) 18%, transparent)"),
200
- decl("goodSoft", "color-mix(in srgb, var(--vx-goodSolid) 8%, transparent)"),
201
- decl("bad", "color-mix(in srgb, var(--vx-badSolid) 18%, transparent)"),
202
- decl("warn", "color-mix(in srgb, var(--vx-warnSolid) 8%, transparent)"),
203
- decl("goodRef", "color-mix(in srgb, var(--vx-goodSolid) 30%, transparent)"),
204
- decl("badRef", "color-mix(in srgb, var(--vx-badSolid) 30%, transparent)"),
205
- decl("warnRef", "color-mix(in srgb, var(--vx-warnSolid) 20%, transparent)")
206
- ].join("\n");
212
+ function spaceDecls(space) {
213
+ return [
214
+ decl("space-row-inset-x", `${space.anchors.rowInsetX}px`),
215
+ decl("space-row-inset-y", `${space.anchors.rowInsetY}px`),
216
+ // Additive law, not the multiplier — see `deriveSpacing`'s doc in `tokens/palette.ts`. No unit:
217
+ // `line-height` is a unitless CSS value.
218
+ decl("space-row-line-height", `${space.rowLineHeight}`),
219
+ // A `size: 'md'` Input's resolved height. Mantine's own `--input-height-md` is
220
+ // `calc(2.625rem * var(--mantine-scale))` (BOTH `styles.css` and `styles.layer.css`, verified
221
+ // in the installed package) — REM-relative to the root font size AND scale-aware, not a flat
222
+ // px. Emitting this in REM (via `pxRem`, not a bare `${…}px`) preserves the rem half; the
223
+ // `* var(--mantine-scale))` half is reconstructed at the Mantine-coupled call site
224
+ // (`theme/index.ts`'s `Input.extend` `vars`, which wraps this var in the matching `calc(...)`)
225
+ // — this module stays Mantine-free, so it cannot reference `--mantine-scale` itself. Flattening
226
+ // either half into a flat px would desync input height from the user's root font size (an
227
+ // accessibility regression) and from Mantine's global `--mantine-scale` knob.
228
+ decl("space-input-height", pxRem(space.anchors.inputHeight)),
229
+ // A `size: 'md'` Button's/ActionIcon's resolved height — SAME rem-plus-scale reasoning and
230
+ // reconstruction as `space-input-height` above (`theme/index.ts`'s `Button.extend`/
231
+ // `ActionIcon.extend` `vars`), single-sourced from the SAME `controlHeight` anchor
232
+ // `space-input-height` reads from (`SPACE_ANCHORS_BASE`'s doc in `tokens/palette.ts`).
233
+ decl("space-control-height", pxRem(space.anchors.controlHeight)),
234
+ decl("space-stack-xs", `${space.anchors.stackXs}px`),
235
+ decl("space-stack-sm", `${space.anchors.stackSm}px`),
236
+ decl("space-stack-md", `${space.anchors.stackMd}px`),
237
+ decl("space-stack-lg", `${space.anchors.stackLg}px`),
238
+ decl("space-stack-xl", `${space.anchors.stackXl}px`),
239
+ // The CSS-module spacing sweep's one-offs (docs/STATUS.md) — same single-source reasoning,
240
+ // grouped to match `SPACE_STEP_BASE`'s own grouping in tokens/palette.ts.
241
+ // Responsive pair (Decision 3) — `stickyHeaderClearance` is the desktop (`>= sm`) value,
242
+ // `stickyHeaderClearanceMobile` the mobile (`< sm`) override; a consumer CSS module picks
243
+ // whichever matches its own breakpoint (see `content/prose.module.css`).
244
+ decl("space-sticky-header-clearance", `${space.step.stickyHeaderClearance}px`),
245
+ decl("space-sticky-header-clearance-mobile", `${space.step.stickyHeaderClearanceMobile}px`),
246
+ decl("space-nav-icon-gap", `${space.step.navIconGap}px`),
247
+ decl("space-sidebar-region-gap", `${space.step.sidebarRegionGap}px`),
248
+ decl("space-prose-quote-inset-y", `${space.step.proseQuoteInsetY}px`),
249
+ decl("space-prose-quote-indent", `${space.step.proseQuoteIndent}px`),
250
+ decl("space-prose-inline-code-inset-y", `${space.step.proseInlineCodeInsetY}px`),
251
+ decl("space-prose-inline-code-inset-x", `${space.step.proseInlineCodeInsetX}px`),
252
+ decl("space-prose-code-block-inset-y", `${space.step.proseCodeBlockInsetY}px`),
253
+ decl("space-prose-code-block-inset-x", `${space.step.proseCodeBlockInsetX}px`),
254
+ decl("space-prose-heading-anchor-gap", `${space.step.proseHeadingAnchorGap}px`),
255
+ decl("space-prose-table-cell-inset-y", `${space.step.proseTableCellInsetY}px`),
256
+ decl("space-prose-table-cell-inset-x", `${space.step.proseTableCellInsetX}px`),
257
+ decl("space-prose-chat-list-gap-bottom", `${space.step.proseChatListGapBottom}px`),
258
+ decl("space-prose-chat-list-indent", `${space.step.proseChatListIndent}px`),
259
+ decl("space-prose-chat-list-item-gap", `${space.step.proseChatListItemGap}px`),
260
+ decl("space-prose-chat-nested-list-gap", `${space.step.proseChatNestedListGap}px`),
261
+ decl("space-prose-chat-heading-gap-top", `${space.step.proseChatHeadingGapTop}px`),
262
+ decl("space-prose-chat-heading-gap-bottom", `${space.step.proseChatHeadingGapBottom}px`),
263
+ decl("space-prose-article-paragraph-gap", `${space.step.proseArticleParagraphGap}px`),
264
+ decl("space-prose-article-list-gap-top", `${space.step.proseArticleListGapTop}px`),
265
+ decl("space-prose-article-list-gap-bottom", `${space.step.proseArticleListGapBottom}px`),
266
+ decl("space-prose-article-list-indent", `${space.step.proseArticleListIndent}px`),
267
+ decl("space-prose-article-h1-gap-top", `${space.step.proseArticleH1GapTop}px`),
268
+ decl("space-prose-article-h1-gap-bottom", `${space.step.proseArticleH1GapBottom}px`),
269
+ decl("space-prose-article-heading-gap-top", `${space.step.proseArticleHeadingGapTop}px`),
270
+ decl("space-prose-article-heading-gap-bottom", `${space.step.proseArticleHeadingGapBottom}px`),
271
+ decl("space-prose-article-h2-rule-gap", `${space.step.proseArticleH2RuleGap}px`),
272
+ decl("space-prose-article-block-gap", `${space.step.proseArticleBlockGap}px`),
273
+ decl("space-article-column-gap", `${space.step.articleColumnGap}px`),
274
+ decl("space-article-toc-rail-width", `${space.step.articleTocRailWidth}px`),
275
+ decl("space-article-header-gap", `${space.step.articleHeaderGap}px`),
276
+ decl("space-article-header-padding-bottom", `${space.step.articleHeaderPaddingBottom}px`),
277
+ decl("space-article-header-margin-bottom", `${space.step.articleHeaderMarginBottom}px`),
278
+ decl("space-article-meta-row-gap", `${space.step.articleMetaRowGap}px`),
279
+ decl("space-article-footer-gap", `${space.step.articleFooterGap}px`),
280
+ decl("space-article-footer-margin-top", `${space.step.articleFooterMarginTop}px`),
281
+ decl("space-article-footer-padding-top", `${space.step.articleFooterPaddingTop}px`),
282
+ decl("space-article-nav-target-gap", `${space.step.articleNavTargetGap}px`),
283
+ decl("space-code-block-header-gap", `${space.step.codeBlockHeaderGap}px`),
284
+ decl("space-code-block-header-inset-y", `${space.step.codeBlockHeaderInsetY}px`),
285
+ decl("space-code-block-header-inset-right", `${space.step.codeBlockHeaderInsetRight}px`),
286
+ decl("space-code-block-content-inset-x", `${space.step.codeBlockContentInsetX}px`),
287
+ decl("space-code-block-header-right-gap", `${space.step.codeBlockHeaderRightGap}px`),
288
+ decl("space-code-block-body-inset-y", `${space.step.codeBlockBodyInsetY}px`),
289
+ decl("space-code-block-floating-copy-offset", `${space.step.codeBlockFloatingCopyOffset}px`),
290
+ decl("space-callout-inset-y", `${space.step.calloutInsetY}px`),
291
+ decl("space-callout-inset-x", `${space.step.calloutInsetX}px`),
292
+ decl("space-callout-title-row-gap", `${space.step.calloutTitleRowGap}px`),
293
+ decl("space-toc-root-gap", `${space.step.tocRootGap}px`),
294
+ decl("space-toc-link-inset-y", `${space.step.tocLinkInsetY}px`),
295
+ decl("space-toc-link-indent", `${space.step.tocLinkIndent}px`),
296
+ decl("space-toc-sub-indent", `${space.step.tocSubIndent}px`),
297
+ decl("space-article-card-tags-gap", `${space.step.articleCardTagsGap}px`),
298
+ decl("space-article-card-tag-inset-y", `${space.step.articleCardTagInsetY}px`),
299
+ decl("space-article-card-tag-inset-x", `${space.step.articleCardTagInsetX}px`),
300
+ decl("space-article-card-meta-gap-top", `${space.step.articleCardMetaGapTop}px`),
301
+ decl("space-guide-body-gap-bottom", `${space.step.guideBodyGapBottom}px`),
302
+ decl("space-guide-footer-gap-top", `${space.step.guideFooterGapTop}px`),
303
+ decl("space-guide-footer-inset-top", `${space.step.guideFooterInsetTop}px`),
304
+ decl("space-sidebar-search-gap", `${space.step.sidebarSearchGap}px`),
305
+ decl("space-sidebar-search-trigger-height", `${space.step.sidebarSearchTriggerHeight}px`),
306
+ decl("space-settings-row-inset-y", `${space.step.settingsRowInsetY}px`),
307
+ decl("space-settings-row-gap", `${space.step.settingsRowGap}px`),
308
+ decl("space-mermaid-container-inset", `${space.step.mermaidContainerInset}px`),
309
+ decl("space-sidebar-brand-inset-top", `${space.step.sidebarBrandInsetTop}px`),
310
+ decl("space-sidebar-brand-inset-x", `${space.step.sidebarBrandInsetX}px`),
311
+ decl("space-sidebar-section-gap", `${space.step.sidebarSectionGap}px`),
312
+ decl("space-sidebar-account-inset-top", `${space.step.sidebarAccountInsetTop}px`),
313
+ decl("space-sidebar-account-inset-x", `${space.step.sidebarAccountInsetX}px`),
314
+ decl("space-sidebar-account-inset-bottom", `${space.step.sidebarAccountInsetBottom}px`),
315
+ decl("space-sidebar-avatar-size", `${space.step.sidebarAvatarSize}px`),
316
+ decl("space-sidebar-section-label-gap", `${space.step.sidebarSectionLabelGap}px`),
317
+ decl("space-sidebar-child-list-gap-top", `${space.step.sidebarChildListGapTop}px`),
318
+ decl("space-sidebar-child-list-gap-bottom", `${space.step.sidebarChildListGapBottom}px`),
319
+ decl("space-sidebar-child-list-indent", `${space.step.sidebarChildListIndent}px`),
320
+ decl("space-sidebar-child-row-inset-y", `${space.step.sidebarChildRowInsetY}px`),
321
+ decl("space-sidebar-child-row-indent", `${space.step.sidebarChildRowIndent}px`),
322
+ decl("space-app-header-mobile-actions-height", `${space.step.appHeaderMobileActionsHeight}px`),
323
+ decl("space-mobile-nav-tab-gap", `${space.step.mobileNavTabGap}px`),
324
+ decl("space-agent-rail-inset-x", `${space.step.agentRailInsetX}px`),
325
+ decl("space-agent-part-gap-top", `${space.step.agentPartGapTop}px`),
326
+ decl("space-agent-code-inset", `${space.step.agentCodeInset}px`),
327
+ decl("space-agent-error-inset-y", `${space.step.agentErrorInsetY}px`),
328
+ decl("space-agent-error-inset-x", `${space.step.agentErrorInsetX}px`),
329
+ decl("space-agent-scroll-button-gap-top", `${space.step.agentScrollButtonGapTop}px`),
330
+ decl("space-agent-message-inset-y", `${space.step.agentMessageInsetY}px`),
331
+ decl("space-agent-message-inset-x", `${space.step.agentMessageInsetX}px`),
332
+ decl("space-agent-transcript-inset", `${space.step.agentTranscriptInset}px`),
333
+ decl("space-badge-inset-y", `${space.step.badgeInsetY}px`),
334
+ decl("space-badge-inset-x", `${space.step.badgeInsetX}px`),
335
+ decl("space-stat-card-gap", `${space.step.statCardGap}px`),
336
+ decl("space-virtual-row-inset-y", `${space.step.virtualRowInsetY}px`),
337
+ decl("space-virtual-row-inset-x", `${space.step.virtualRowInsetX}px`)
338
+ // `chartLegendGap`/`chartMarginTop`/`chartMarginRight`/`chartMarginBottom`/`chartMarginLeft`/
339
+ // `chartDotR`/`progressBarSize`/`timelineBullet` are DELIBERATELY absent — see this function's
340
+ // doc for why (JS-number-only consumers, zero `var()` reads). `appShellHeaderHeight`/
341
+ // `appShellHeaderMobileHeight`/`appShellNavbarWidth`/`appShellNavbarRailWidth` join that list —
342
+ // `shell/index.tsx` reads all four as JS numbers via `useBasaltSpacing()` (Mantine's `AppShell`
343
+ // `header`/`navbar` props take numbers, not `var()` strings), so a `--vx-space-app-shell-*` decl
344
+ // here would have had zero consumers, framework-wide, the same dead-weight shape this function's
345
+ // doc already calls out for the chart/Progress/Timeline group. `sidebarAccountMenuWidth`/
346
+ // `sidebarSettingsMenuWidth` join it too — `app-sidebar-account.tsx`/`app-sidebar.tsx` read both
347
+ // as JS numbers via `useBasaltSpacing()` (Mantine's `<Menu width={…}>` also takes a number).
348
+ ];
349
+ }
350
+ const CORE_SPACE_VARS = new Set(
351
+ Object.keys(SPACE).map((key) => `space-${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`)
352
+ );
353
+ function isCoreSpaceDecl(line) {
354
+ const name = /^ {2}--vx-([\w-]+):/.exec(line)?.[1];
355
+ return name !== void 0 && CORE_SPACE_VARS.has(name);
356
+ }
357
+ const DEFAULT_SPACE_VALUES = {
358
+ anchors: SPACE,
359
+ scale: SPACE_SCALE,
360
+ step: SPACE_STEP,
361
+ rowLineHeight: ROW_LINE_HEIGHT
362
+ };
363
+ function frameworkDerived(data, only) {
364
+ const space = spaceDecls(DEFAULT_SPACE_VALUES);
365
+ return [
366
+ decl("radius-card", `${RADIUS.card}px`),
367
+ decl("radius-ctrl", `${RADIUS.ctrl}px`),
368
+ // The two offset tiers (SegmentedControl indicator/Kbd/Code, Progress/scale-sm) — added so a
369
+ // component's inline `styles`/`style` can read the SAME source as `RADIUS_STEP.tight`/`.fine`
370
+ // instead of a hand-typed literal (see `theme/index.ts`'s component sweep).
371
+ decl("radius-tight", `${RADIUS_STEP.tight}px`),
372
+ decl("radius-fine", `${RADIUS_STEP.fine}px`),
373
+ // The floating tier (Modal/Tooltip/Popover/Notification, content code/mermaid blocks).
374
+ decl("radius-floating", `${RADIUS_STEP.floating}px`),
375
+ // The pill affordance (scroll-to-bottom button, chips) — fixed, level-invariant, so it lives
376
+ // only in this static block, never in `buildRadiusCss`'s dynamic override (see
377
+ // `RADIUS_STEP.pill`'s doc).
378
+ decl("radius-pill", `${RADIUS_STEP.pill}px`),
379
+ ...only === "core" ? space.filter(isCoreSpaceDecl) : space,
380
+ // Article-density Prose measure (docs/CONTENT-SPEC.md §5) — theme-independent, like the radii.
381
+ decl("prose-measure", "72ch"),
382
+ // The fill band (see FILL in palette.ts). Emitted on `:root`, NOT per scheme — a filled surface
383
+ // is the same hex in both, which is the whole point: it is squeezed between its white label and
384
+ // the page behind it, and only one luminance band satisfies both on both pages.
385
+ ...Object.entries(data.FILL).map(([name, hex]) => decl(`fill-${name}`, hex)),
386
+ // Hover is DERIVED from the fill, so retuning a fill (in the theme lab, or here) carries its
387
+ // hover along instead of leaving a stale pair. 88% of the fill over black lands ~0.128 luminance:
388
+ // a visible press-darkening that still clears AA for the white label (~5.9:1).
389
+ ...Object.keys(data.FILL).map(
390
+ (name) => decl(`fillHover-${name}`, `color-mix(in srgb, var(--vx-fill-${name}) 88%, #000)`)
391
+ ),
392
+ // The type scale, emitted from the SAME `TEXT` object `VX.text` reads — CSS modules and the
393
+ // Mantine theme consume these; inline styles / visx read the numbers. One ladder, two forms.
394
+ ...Object.entries(TEXT).map(([step, px]) => decl(`text-${step}`, `${px}px`)),
395
+ decl("area-top", "22%"),
396
+ decl("area-bottom", "1%"),
397
+ decl("good", "color-mix(in srgb, var(--vx-goodSolid) 18%, transparent)"),
398
+ decl("goodSoft", "color-mix(in srgb, var(--vx-goodSolid) 8%, transparent)"),
399
+ decl("bad", "color-mix(in srgb, var(--vx-badSolid) 18%, transparent)"),
400
+ decl("warn", "color-mix(in srgb, var(--vx-warnSolid) 8%, transparent)"),
401
+ decl("goodRef", "color-mix(in srgb, var(--vx-goodSolid) 30%, transparent)"),
402
+ decl("badRef", "color-mix(in srgb, var(--vx-badSolid) 30%, transparent)"),
403
+ decl("warnRef", "color-mix(in srgb, var(--vx-warnSolid) 20%, transparent)")
404
+ ].join("\n");
405
+ }
207
406
  function seriesTokens(map, prefix = "") {
208
407
  const out = {};
209
408
  for (const key of Object.keys(map)) out[key] = `var(--vx-${prefix}${String(key)})`;
@@ -215,35 +414,110 @@ function defineSeries(map) {
215
414
  function groupTokens(name, map) {
216
415
  return seriesTokens(map, `${name}-`);
217
416
  }
218
- function buildPaletteCss(opts = {}) {
417
+ const MANTINE_SCHEME_ATTRIBUTE = "data-mantine-color-scheme";
418
+ const indent = (block) => block.split("\n").map((line) => line === "" ? line : ` ${line}`).join("\n");
419
+ function buildPaletteCss(opts = {}, data = buildPaletteData()) {
219
420
  const groups = opts.groups ?? {};
220
421
  const extraDerived = (opts.derived ?? []).map((d) => ` ${d}`).join("\n");
221
- const derived = extraDerived ? `${FRAMEWORK_DERIVED}
222
- ${extraDerived}` : FRAMEWORK_DERIVED;
422
+ const derivedBlock = frameworkDerived(data, opts.only ?? "all");
423
+ const derived = extraDerived ? `${derivedBlock}
424
+ ${extraDerived}` : derivedBlock;
223
425
  const side = (s) => {
224
426
  const extra = Object.entries(groups).map(([prefix, map]) => groupSide(prefix, map, s)).join("\n");
225
- const framework = frameworkPrimitives(s);
427
+ const framework = frameworkPrimitives(s, data);
226
428
  return extra ? `${framework}
227
429
  ${extra}` : framework;
228
430
  };
229
- return `:root {
431
+ const rootBlock = `:root {
230
432
  ${derived}
231
- }
433
+ }`;
434
+ if (opts.scheme === void 0 && opts.defaultScheme === void 0 && !opts.mediaFallback) {
435
+ return `${rootBlock}
232
436
  :root,
233
437
  html[data-mantine-color-scheme='dark'] {
234
438
  ${side("dark")}
235
439
  }
236
440
  html[data-mantine-color-scheme='light'] {
237
441
  ${side("light")}
442
+ }`;
443
+ }
444
+ const attribute = opts.scheme?.attribute ?? MANTINE_SCHEME_ATTRIBUTE;
445
+ const value = {
446
+ dark: opts.scheme?.darkValue ?? "dark",
447
+ light: opts.scheme?.lightValue ?? "light"
448
+ };
449
+ const defaultScheme = opts.defaultScheme ?? "dark";
450
+ const order = defaultScheme === "light" ? ["light", "dark"] : ["dark", "light"];
451
+ const blocks = [rootBlock];
452
+ for (const s of order) {
453
+ const selector = s === defaultScheme ? `:root,
454
+ :root[${attribute}='${value[s]}']` : `:root[${attribute}='${value[s]}']`;
455
+ if (opts.mediaFallback === true && s !== defaultScheme) {
456
+ blocks.push(`@media (prefers-color-scheme: ${s}) {
457
+ :root {
458
+ ${indent(side(s))}
459
+ }
460
+ }`);
461
+ }
462
+ blocks.push(`${selector} {
463
+ ${side(s)}
464
+ }`);
465
+ }
466
+ return blocks.join("\n");
467
+ }
468
+ const FONT_VAR_NAMES = {
469
+ sans: "--basalt-font-sans",
470
+ head: "--basalt-font-head",
471
+ mono: "--basalt-font-mono"
472
+ };
473
+ function buildFontsCss(fonts) {
474
+ if (!fonts) return "";
475
+ const decls = Object.keys(FONT_VAR_NAMES).filter((key) => fonts[key] !== void 0).map((key) => {
476
+ const value = fonts[key];
477
+ if (/[{};]|\/\*/.test(value)) {
478
+ throw new Error(
479
+ `Invalid fonts.${key}: a font-family stack must not contain "{", "}", ";" or "/*" \u2014 got ${JSON.stringify(value)}`
480
+ );
481
+ }
482
+ return ` ${FONT_VAR_NAMES[key]}: ${value};`;
483
+ });
484
+ if (decls.length === 0) return "";
485
+ return `:root {
486
+ ${decls.join("\n")}
487
+ }`;
488
+ }
489
+ function buildRadiusCss(radius) {
490
+ if (!radius) return "";
491
+ return `:root {
492
+ --vx-radius-card: ${radius.card}px;
493
+ --vx-radius-ctrl: ${radius.ctrl}px;
494
+ --vx-radius-tight: ${radius.tight}px;
495
+ --vx-radius-fine: ${radius.fine}px;
496
+ --vx-radius-floating: ${radius.floating}px;
497
+ }`;
498
+ }
499
+ function buildDensityCss(space) {
500
+ if (!space) return "";
501
+ return `:root {
502
+ ${spaceDecls(space).join("\n")}
238
503
  }`;
239
504
  }
240
505
  export {
241
506
  BP,
507
+ DEFAULT_DERIVE_CONFIG,
242
508
  VX,
243
509
  alpha,
510
+ buildDensityCss,
511
+ buildFontsCss,
244
512
  buildPaletteCss,
513
+ buildRadiusCss,
245
514
  defineSeries,
515
+ deriveRadius,
516
+ deriveSpacing,
517
+ deriveTokens,
246
518
  groupTokens,
247
519
  p,
520
+ pxRem,
521
+ resolveDeriveConfig,
248
522
  seriesTokens
249
523
  };