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
@@ -0,0 +1,114 @@
1
+ /**
2
+ * `buildPaletteData` is the pure function `palette.ts`'s static ACCENT/FILL/SURFACE/INK/SEMANTIC/
3
+ * STATUS exports are built from — this locks the two together: the static exports must be exactly
4
+ * `buildPaletteData(DEFAULT_DERIVE_CONFIG)`'s output, not a hand-duplicated snapshot of it.
5
+ */
6
+ import { describe, expect, test } from 'bun:test'
7
+ import { DEFAULT_DERIVE_CONFIG } from './derive'
8
+ import {
9
+ ACCENT,
10
+ buildPaletteData,
11
+ FILL,
12
+ INK,
13
+ NEUTRAL,
14
+ scaleSpace,
15
+ SEMANTIC,
16
+ STATUS,
17
+ SURFACE,
18
+ } from './palette'
19
+
20
+ describe('buildPaletteData(DEFAULT_DERIVE_CONFIG) deep-equals the static exports', () => {
21
+ const data = buildPaletteData(DEFAULT_DERIVE_CONFIG)
22
+
23
+ test('ACCENT', () => expect(data.ACCENT).toEqual(ACCENT))
24
+ test('FILL', () => expect(data.FILL).toEqual(FILL))
25
+ test('SURFACE', () => expect(data.SURFACE).toEqual(SURFACE))
26
+ test('INK', () => expect(data.INK).toEqual(INK))
27
+ test('NEUTRAL', () => expect(data.NEUTRAL).toEqual(NEUTRAL))
28
+ test('SEMANTIC', () => expect(data.SEMANTIC).toEqual(SEMANTIC))
29
+ test('STATUS', () => expect(data.STATUS).toEqual(STATUS))
30
+ })
31
+
32
+ describe('buildPaletteData() defaults to DEFAULT_DERIVE_CONFIG', () => {
33
+ test('same result as an explicit default config', () => {
34
+ expect(buildPaletteData()).toEqual(buildPaletteData(DEFAULT_DERIVE_CONFIG))
35
+ })
36
+ })
37
+
38
+ describe('buildPaletteData is memoized by config value', () => {
39
+ test('two calls with an equal (but not referentially identical) config return the same object', () => {
40
+ const a = buildPaletteData({ ...DEFAULT_DERIVE_CONFIG, accent: '#123456' })
41
+ const b = buildPaletteData({ ...DEFAULT_DERIVE_CONFIG, accent: '#123456' })
42
+ expect(a).toBe(b)
43
+ })
44
+
45
+ test('a different config produces a different, non-default result', () => {
46
+ const custom = buildPaletteData({ ...DEFAULT_DERIVE_CONFIG, accent: '#16a34a' })
47
+ expect(custom).not.toEqual(buildPaletteData(DEFAULT_DERIVE_CONFIG))
48
+ })
49
+ })
50
+
51
+ describe('buildPaletteData rejects a malformed accent seed', () => {
52
+ test('a non-hex color name throws', () => {
53
+ expect(() => buildPaletteData({ ...DEFAULT_DERIVE_CONFIG, accent: 'red' })).toThrow()
54
+ })
55
+
56
+ test('a truncated hex throws', () => {
57
+ expect(() => buildPaletteData({ ...DEFAULT_DERIVE_CONFIG, accent: '#12' })).toThrow()
58
+ })
59
+
60
+ test('a non-hex-digit hex throws', () => {
61
+ expect(() => buildPaletteData({ ...DEFAULT_DERIVE_CONFIG, accent: '#zzzzzz' })).toThrow()
62
+ })
63
+ })
64
+
65
+ describe('the default-config entry is pinned against cache eviction', () => {
66
+ test('buildPaletteData(DEFAULT_DERIVE_CONFIG) stays the same reference past the 32-entry cap', () => {
67
+ const before = buildPaletteData(DEFAULT_DERIVE_CONFIG)
68
+ for (let i = 0; i < 40; i++) {
69
+ buildPaletteData({
70
+ ...DEFAULT_DERIVE_CONFIG,
71
+ accent: `#${(i + 1).toString(16).padStart(6, '0')}`,
72
+ })
73
+ }
74
+ const after = buildPaletteData(DEFAULT_DERIVE_CONFIG)
75
+ expect(after).toBe(before)
76
+ })
77
+ })
78
+
79
+ describe('onAccent stays white under the fill-page contrast clamp', () => {
80
+ test('the default config keeps a white onAccent', () => {
81
+ expect(buildPaletteData(DEFAULT_DERIVE_CONFIG).ACCENT.onAccent.light).toBe('#ffffff')
82
+ })
83
+
84
+ // Previously a high accentBrightness pushed the fill tone light enough to fail the white-label
85
+ // floor and flip onAccent to a dark ink. `derive.ts`'s fill-page contrast clamp now caps the fill
86
+ // tone before that point is ever reached (the fill-vs-page floor is always at least as strict as
87
+ // the fill-vs-white floor for a realistic, non-pure-white page background), so onAccent stays
88
+ // white at every accentBrightness level for the shipped seed/surface config.
89
+ test('a high accentBrightness still keeps onAccent white', () => {
90
+ const data = buildPaletteData({ ...DEFAULT_DERIVE_CONFIG, accentBrightness: 5 })
91
+ expect(data.ACCENT.onAccent.light).toBe('#ffffff')
92
+ })
93
+ })
94
+
95
+ describe('scaleSpace floors a base >= 1 at 1, never lets it round down to 0', () => {
96
+ // No shipped base/level combination reaches this branch — `deriveSpacing`'s shallowest
97
+ // multiplier is 0.7 (level -5), and every current base is an integer >= 1, so
98
+ // `round(value * multiplier)` never drops below 1 on that path (see `scaleSpace`'s doc in
99
+ // `palette.ts`). Drive the clamp directly with a multiplier `deriveSpacing` can never produce,
100
+ // to prove the floor still holds if a base or the level range ever changes.
101
+ test('a value of 1 at a multiplier of 0.3 would round to 0 without the floor', () => {
102
+ expect(scaleSpace(1, -5, 0.3)).toBe(1)
103
+ })
104
+
105
+ test('a larger value at a more aggressive multiplier still floors at 1, not its raw round', () => {
106
+ // round(2 * 0.1) = round(0.2) = 0 without the floor — proves the clamp for a value > 1 too,
107
+ // not just the value-of-1 edge case above.
108
+ expect(scaleSpace(2, -5, 0.1)).toBe(1)
109
+ })
110
+
111
+ test('level 0 bypasses scaling (and therefore the floor) entirely, returning value verbatim', () => {
112
+ expect(scaleSpace(0.4, 0, 0.1)).toBe(0.4)
113
+ })
114
+ })