@42-central/ui-react 0.24.0 → 0.26.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 (294) hide show
  1. package/dist/{chunk-YWTOW7PZ.js → chunk-276RL7FX.js} +10 -10
  2. package/dist/{chunk-YWTOW7PZ.js.map → chunk-276RL7FX.js.map} +1 -1
  3. package/dist/{chunk-FUNTJZX7.js → chunk-2CL3FKEY.js} +3 -3
  4. package/dist/{chunk-FUNTJZX7.js.map → chunk-2CL3FKEY.js.map} +1 -1
  5. package/dist/{chunk-YPFSRZ3T.js → chunk-2NTCQIRP.js} +5 -5
  6. package/dist/{chunk-YPFSRZ3T.js.map → chunk-2NTCQIRP.js.map} +1 -1
  7. package/dist/{chunk-D3JYDAUZ.js → chunk-2TZU4LSX.js} +4 -4
  8. package/dist/{chunk-D3JYDAUZ.js.map → chunk-2TZU4LSX.js.map} +1 -1
  9. package/dist/{chunk-DJLNGWMM.js → chunk-6IRMKF5T.js} +3 -3
  10. package/dist/{chunk-DJLNGWMM.js.map → chunk-6IRMKF5T.js.map} +1 -1
  11. package/dist/{chunk-DT6LKNZF.js → chunk-7247WBTV.js} +5 -4
  12. package/dist/chunk-7247WBTV.js.map +1 -0
  13. package/dist/{chunk-F2FSHVO5.js → chunk-7B44J3CF.js} +7 -7
  14. package/dist/{chunk-F2FSHVO5.js.map → chunk-7B44J3CF.js.map} +1 -1
  15. package/dist/{chunk-6VYGK3Q3.js → chunk-7E7JNWOC.js} +16 -21
  16. package/dist/chunk-7E7JNWOC.js.map +1 -0
  17. package/dist/{chunk-7AQ4MN4M.js → chunk-7OGZT7U2.js} +14 -6
  18. package/dist/chunk-7OGZT7U2.js.map +1 -0
  19. package/dist/{chunk-UAYENYS2.js → chunk-AKXALCUN.js} +3 -3
  20. package/dist/{chunk-UAYENYS2.js.map → chunk-AKXALCUN.js.map} +1 -1
  21. package/dist/{chunk-BE2LWUHY.js → chunk-BMEJBY6H.js} +5 -3
  22. package/dist/chunk-BMEJBY6H.js.map +1 -0
  23. package/dist/{chunk-DHJB4UJD.js → chunk-DMI4KS32.js} +5 -5
  24. package/dist/{chunk-DHJB4UJD.js.map → chunk-DMI4KS32.js.map} +1 -1
  25. package/dist/{chunk-FB2G4LNH.js → chunk-DSZF2TW6.js} +7 -7
  26. package/dist/{chunk-FB2G4LNH.js.map → chunk-DSZF2TW6.js.map} +1 -1
  27. package/dist/{chunk-N66NC6QK.js → chunk-E3XLWMEB.js} +3 -3
  28. package/dist/{chunk-N66NC6QK.js.map → chunk-E3XLWMEB.js.map} +1 -1
  29. package/dist/{chunk-MXAACRWE.js → chunk-E52Z2FKU.js} +5 -5
  30. package/dist/{chunk-MXAACRWE.js.map → chunk-E52Z2FKU.js.map} +1 -1
  31. package/dist/chunk-F374BNL4.js +129 -0
  32. package/dist/chunk-F374BNL4.js.map +1 -0
  33. package/dist/{chunk-3L5GLI67.js → chunk-I4B3N3UX.js} +3 -3
  34. package/dist/{chunk-3L5GLI67.js.map → chunk-I4B3N3UX.js.map} +1 -1
  35. package/dist/{chunk-IPYHTCFL.js → chunk-IUK7OJXZ.js} +3 -3
  36. package/dist/{chunk-IPYHTCFL.js.map → chunk-IUK7OJXZ.js.map} +1 -1
  37. package/dist/{chunk-HRNWWL3Y.js → chunk-J2NW7JID.js} +61 -29
  38. package/dist/chunk-J2NW7JID.js.map +1 -0
  39. package/dist/{chunk-MRAJ45IM.js → chunk-JDPVD2YE.js} +5 -5
  40. package/dist/{chunk-MRAJ45IM.js.map → chunk-JDPVD2YE.js.map} +1 -1
  41. package/dist/{chunk-SZEOTXRZ.js → chunk-JFB6O7IY.js} +5 -5
  42. package/dist/{chunk-SZEOTXRZ.js.map → chunk-JFB6O7IY.js.map} +1 -1
  43. package/dist/{chunk-2MXWEIMD.js → chunk-KKLCHLCZ.js} +12 -11
  44. package/dist/chunk-KKLCHLCZ.js.map +1 -0
  45. package/dist/{chunk-6N6J2DOE.js → chunk-LIZWCWED.js} +3 -3
  46. package/dist/{chunk-6N6J2DOE.js.map → chunk-LIZWCWED.js.map} +1 -1
  47. package/dist/chunk-LJVIZNPE.js +9 -0
  48. package/dist/chunk-LJVIZNPE.js.map +1 -0
  49. package/dist/{chunk-HQPU73WV.js → chunk-LYGOFMXJ.js} +3 -3
  50. package/dist/{chunk-HQPU73WV.js.map → chunk-LYGOFMXJ.js.map} +1 -1
  51. package/dist/{chunk-JVG5ISPT.js → chunk-N42EFOML.js} +4 -4
  52. package/dist/{chunk-JVG5ISPT.js.map → chunk-N42EFOML.js.map} +1 -1
  53. package/dist/{chunk-C4NFRSOR.js → chunk-NF2PBGD3.js} +38 -25
  54. package/dist/chunk-NF2PBGD3.js.map +1 -0
  55. package/dist/{chunk-DA4QII2N.js → chunk-NLSJ6T7V.js} +4 -4
  56. package/dist/{chunk-DA4QII2N.js.map → chunk-NLSJ6T7V.js.map} +1 -1
  57. package/dist/{chunk-UT3TOV2Q.js → chunk-OVT2KZHY.js} +3 -3
  58. package/dist/{chunk-UT3TOV2Q.js.map → chunk-OVT2KZHY.js.map} +1 -1
  59. package/dist/{chunk-MW42XVPD.js → chunk-PBSVX5DB.js} +15 -5
  60. package/dist/chunk-PBSVX5DB.js.map +1 -0
  61. package/dist/{chunk-SVKN5ZHX.js → chunk-PEHFWGTT.js} +16 -13
  62. package/dist/chunk-PEHFWGTT.js.map +1 -0
  63. package/dist/{chunk-J44FJ7PH.js → chunk-PFZMB3US.js} +4 -4
  64. package/dist/{chunk-J44FJ7PH.js.map → chunk-PFZMB3US.js.map} +1 -1
  65. package/dist/{chunk-IRNF274I.js → chunk-PT22KEVD.js} +5 -5
  66. package/dist/{chunk-IRNF274I.js.map → chunk-PT22KEVD.js.map} +1 -1
  67. package/dist/{chunk-OZMSXYBX.js → chunk-QEAF57ZQ.js} +4 -4
  68. package/dist/{chunk-OZMSXYBX.js.map → chunk-QEAF57ZQ.js.map} +1 -1
  69. package/dist/{chunk-SWVUXEBT.js → chunk-SCXXJDKQ.js} +3 -3
  70. package/dist/{chunk-SWVUXEBT.js.map → chunk-SCXXJDKQ.js.map} +1 -1
  71. package/dist/{chunk-E5H3YWZV.js → chunk-SOUDKESO.js} +15 -8
  72. package/dist/chunk-SOUDKESO.js.map +1 -0
  73. package/dist/{chunk-4FEOMQYR.js → chunk-THGJLR5S.js} +6 -6
  74. package/dist/{chunk-4FEOMQYR.js.map → chunk-THGJLR5S.js.map} +1 -1
  75. package/dist/{chunk-TCFB23JT.js → chunk-WERJ44ZN.js} +3 -3
  76. package/dist/{chunk-TCFB23JT.js.map → chunk-WERJ44ZN.js.map} +1 -1
  77. package/dist/{chunk-QNKD2SQM.js → chunk-X3YIHN2U.js} +5 -5
  78. package/dist/{chunk-QNKD2SQM.js.map → chunk-X3YIHN2U.js.map} +1 -1
  79. package/dist/{chunk-VD6PB3VA.js → chunk-X6DESK37.js} +12 -3
  80. package/dist/chunk-X6DESK37.js.map +1 -0
  81. package/dist/{chunk-47LEAR6G.js → chunk-Y2G47ARQ.js} +6 -6
  82. package/dist/{chunk-47LEAR6G.js.map → chunk-Y2G47ARQ.js.map} +1 -1
  83. package/dist/{chunk-O7LS6OZR.js → chunk-YMVUQ2L7.js} +4 -4
  84. package/dist/{chunk-O7LS6OZR.js.map → chunk-YMVUQ2L7.js.map} +1 -1
  85. package/dist/{chunk-F342ZT7O.js → chunk-ZVECQBGG.js} +13 -7
  86. package/dist/chunk-ZVECQBGG.js.map +1 -0
  87. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  88. package/dist/components/action-icon/index.js +1 -1
  89. package/dist/components/alert/index.js +1 -1
  90. package/dist/components/ambient-background/index.js +14 -26
  91. package/dist/components/ambient-background/index.js.map +1 -1
  92. package/dist/components/ambient-background/starfield.d.ts.map +1 -1
  93. package/dist/components/app-shell/app-shell.d.ts +55 -10
  94. package/dist/components/app-shell/app-shell.d.ts.map +1 -1
  95. package/dist/components/app-shell/index.d.ts +1 -1
  96. package/dist/components/app-shell/index.d.ts.map +1 -1
  97. package/dist/components/app-shell/index.js +300 -39
  98. package/dist/components/app-shell/index.js.map +1 -1
  99. package/dist/components/autocomplete/index.js +5 -5
  100. package/dist/components/avatar/avatar.d.ts +1 -1
  101. package/dist/components/avatar/avatar.d.ts.map +1 -1
  102. package/dist/components/avatar/index.js +12 -3
  103. package/dist/components/avatar/index.js.map +1 -1
  104. package/dist/components/badge/badge.d.ts.map +1 -1
  105. package/dist/components/badge/index.js +1 -1
  106. package/dist/components/button/index.js +1 -1
  107. package/dist/components/button-group/button-group.d.ts +10 -2
  108. package/dist/components/button-group/button-group.d.ts.map +1 -1
  109. package/dist/components/button-group/index.js +1 -1
  110. package/dist/components/button-multi-select/index.js +4 -4
  111. package/dist/components/button-select/button-select-control.d.ts +4 -1
  112. package/dist/components/button-select/button-select-control.d.ts.map +1 -1
  113. package/dist/components/button-select/button-select.d.ts +4 -1
  114. package/dist/components/button-select/button-select.d.ts.map +1 -1
  115. package/dist/components/button-select/index.js +4 -4
  116. package/dist/components/calendar/index.js +4 -4
  117. package/dist/components/calendar-heatmap/index.js +2 -2
  118. package/dist/components/camera/index.js +12 -12
  119. package/dist/components/card/card.d.ts.map +1 -1
  120. package/dist/components/card/index.js +1 -1
  121. package/dist/components/carousel/index.js +2 -2
  122. package/dist/components/checkbox/checkbox.d.ts +3 -2
  123. package/dist/components/checkbox/checkbox.d.ts.map +1 -1
  124. package/dist/components/checkbox/index.js +2 -2
  125. package/dist/components/choice-card-group/index.js +2 -2
  126. package/dist/components/choice-card-group/index.js.map +1 -1
  127. package/dist/components/clipboard/index.js +3 -3
  128. package/dist/components/code-block/chrome.js +3 -3
  129. package/dist/components/code-block/code-block.d.ts +6 -3
  130. package/dist/components/code-block/code-block.d.ts.map +1 -1
  131. package/dist/components/code-block/highlighter.d.ts +16 -15
  132. package/dist/components/code-block/highlighter.d.ts.map +1 -1
  133. package/dist/components/code-block/index.d.ts +2 -1
  134. package/dist/components/code-block/index.d.ts.map +1 -1
  135. package/dist/components/code-block/index.js +85 -14
  136. package/dist/components/code-block/index.js.map +1 -1
  137. package/dist/components/code-block/languages.d.ts +61 -0
  138. package/dist/components/code-block/languages.d.ts.map +1 -0
  139. package/dist/components/code-block/static.d.ts +2 -1
  140. package/dist/components/code-block/static.d.ts.map +1 -1
  141. package/dist/components/code-block/static.js +99 -10
  142. package/dist/components/code-block/static.js.map +1 -1
  143. package/dist/components/combobox/index.js +5 -5
  144. package/dist/components/combobox-list/index.js +7 -7
  145. package/dist/components/compare/index.js +2 -2
  146. package/dist/components/data-table/index.js +32 -32
  147. package/dist/components/data-table/index.js.map +1 -1
  148. package/dist/components/date-picker/index.js +14 -14
  149. package/dist/components/download-button/index.js +2 -2
  150. package/dist/components/drawer/index.js +5 -5
  151. package/dist/components/field/field.d.ts +3 -0
  152. package/dist/components/field/field.d.ts.map +1 -1
  153. package/dist/components/field/index.js +1 -1
  154. package/dist/components/file-item/index.js +5 -5
  155. package/dist/components/file-preview/index.js +5 -5
  156. package/dist/components/file-trigger/index.js +2 -2
  157. package/dist/components/file-upload/index.js +6 -6
  158. package/dist/components/gallery/index.js +2 -2
  159. package/dist/components/geodesic/badge-frame.d.ts +13 -1
  160. package/dist/components/geodesic/badge-frame.d.ts.map +1 -1
  161. package/dist/components/geodesic/exam-badge.d.ts +4 -1
  162. package/dist/components/geodesic/exam-badge.d.ts.map +1 -1
  163. package/dist/components/geodesic/geometry.d.ts +14 -9
  164. package/dist/components/geodesic/geometry.d.ts.map +1 -1
  165. package/dist/components/geodesic/index.js +62 -23
  166. package/dist/components/geodesic/index.js.map +1 -1
  167. package/dist/components/geodesic/status.d.ts +8 -6
  168. package/dist/components/geodesic/status.d.ts.map +1 -1
  169. package/dist/components/geodesic/styles.css +15 -2
  170. package/dist/components/hover-card/index.js +2 -2
  171. package/dist/components/image-cropper/index.js +7 -7
  172. package/dist/components/indicator/index.js +24 -9
  173. package/dist/components/indicator/index.js.map +1 -1
  174. package/dist/components/indicator/indicator.d.ts +15 -6
  175. package/dist/components/indicator/indicator.d.ts.map +1 -1
  176. package/dist/components/input/index.js +2 -2
  177. package/dist/components/kbd/index.js +3 -3
  178. package/dist/components/kbd/kbd.d.ts.map +1 -1
  179. package/dist/components/lightbox/index.js +8 -8
  180. package/dist/components/menu/index.js +4 -4
  181. package/dist/components/modal/index.js +5 -5
  182. package/dist/components/multi-combobox-list/index.js +7 -7
  183. package/dist/components/multi-select/index.js +8 -8
  184. package/dist/components/nav-link/index.js +5 -1
  185. package/dist/components/nav-link/nav-link.d.ts.map +1 -1
  186. package/dist/components/nav-link/tanstack.js +5 -1
  187. package/dist/components/nav-link/tanstack.js.map +1 -1
  188. package/dist/components/number-input/index.js +5 -5
  189. package/dist/components/overlays/index.js +7 -7
  190. package/dist/components/password-input/index.js +3 -3
  191. package/dist/components/photo-capture/index.js +16 -16
  192. package/dist/components/pills-input/index.js +5 -5
  193. package/dist/components/pin-input/index.js +2 -2
  194. package/dist/components/popover/index.js +2 -2
  195. package/dist/components/radio-group/index.js +1 -1
  196. package/dist/components/rating/index.js +1 -1
  197. package/dist/components/schedule/index.js +7 -7
  198. package/dist/components/segment-group/index.js +4 -4
  199. package/dist/components/segment-group/segment-group.d.ts +6 -1
  200. package/dist/components/segment-group/segment-group.d.ts.map +1 -1
  201. package/dist/components/select/index.js +6 -6
  202. package/dist/components/slider/index.js +2 -2
  203. package/dist/components/spotlight/index.js +11 -11
  204. package/dist/components/switch/index.js +14 -19
  205. package/dist/components/switch/index.js.map +1 -1
  206. package/dist/components/switch/switch.d.ts +1 -0
  207. package/dist/components/switch/switch.d.ts.map +1 -1
  208. package/dist/components/table/index.js +1 -1
  209. package/dist/components/table/table.d.ts.map +1 -1
  210. package/dist/components/tabs/index.js +3 -3
  211. package/dist/components/tabs/tabs-data.d.ts +4 -1
  212. package/dist/components/tabs/tabs-data.d.ts.map +1 -1
  213. package/dist/components/tabs/tabs.d.ts +4 -1
  214. package/dist/components/tabs/tabs.d.ts.map +1 -1
  215. package/dist/components/tags-input/index.js +7 -7
  216. package/dist/components/text-input/index.js +2 -2
  217. package/dist/components/textarea/index.js +2 -2
  218. package/dist/components/theme-icon/index.js +1 -1
  219. package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
  220. package/dist/components/time-input/index.js +9 -9
  221. package/dist/components/tree-multi-select/index.js +8 -8
  222. package/dist/components/tree-select/index.js +5 -5
  223. package/dist/index.js +4 -4
  224. package/dist/lib/sidebar-rail.d.ts +21 -0
  225. package/dist/lib/sidebar-rail.d.ts.map +1 -0
  226. package/dist/theme.css +35 -35
  227. package/package.json +1 -1
  228. package/src/as-child.contract.test.tsx +6 -0
  229. package/src/components/action-icon/action-icon.tsx +3 -1
  230. package/src/components/ambient-background/starfield.tsx +18 -43
  231. package/src/components/app-shell/app-shell.test.tsx +430 -5
  232. package/src/components/app-shell/app-shell.tsx +484 -24
  233. package/src/components/app-shell/index.ts +2 -0
  234. package/src/components/avatar/avatar.test.tsx +12 -0
  235. package/src/components/avatar/avatar.tsx +9 -0
  236. package/src/components/badge/badge.tsx +11 -6
  237. package/src/components/button/button.tsx +1 -1
  238. package/src/components/button-group/button-group.test.tsx +24 -0
  239. package/src/components/button-group/button-group.tsx +21 -4
  240. package/src/components/button-multi-select/button-multi-select.test.tsx +15 -0
  241. package/src/components/button-select/button-select-control.tsx +5 -0
  242. package/src/components/button-select/button-select.test.tsx +25 -0
  243. package/src/components/button-select/button-select.tsx +13 -2
  244. package/src/components/card/card.tsx +10 -9
  245. package/src/components/checkbox/checkbox.test.tsx +17 -9
  246. package/src/components/checkbox/checkbox.tsx +26 -27
  247. package/src/components/choice-card-group/choice-card-group.tsx +3 -3
  248. package/src/components/code-block/code-block.tsx +7 -4
  249. package/src/components/code-block/highlighter.test.ts +79 -1
  250. package/src/components/code-block/highlighter.ts +76 -30
  251. package/src/components/code-block/index.ts +2 -0
  252. package/src/components/code-block/languages.ts +63 -0
  253. package/src/components/code-block/static.tsx +2 -1
  254. package/src/components/data-table/data-table-pagination.tsx +5 -5
  255. package/src/components/data-table/data-table-stack.tsx +2 -2
  256. package/src/components/field/field.tsx +14 -0
  257. package/src/components/geodesic/badge-frame.tsx +67 -13
  258. package/src/components/geodesic/exam-badge.tsx +8 -4
  259. package/src/components/geodesic/geometry.ts +8 -6
  260. package/src/components/geodesic/status.test.ts +11 -2
  261. package/src/components/geodesic/status.ts +11 -7
  262. package/src/components/geodesic/styles.css +15 -2
  263. package/src/components/indicator/indicator.test.tsx +45 -0
  264. package/src/components/indicator/indicator.tsx +40 -13
  265. package/src/components/kbd/kbd.tsx +2 -1
  266. package/src/components/nav-link/nav-link.test.tsx +121 -1
  267. package/src/components/nav-link/nav-link.tsx +78 -29
  268. package/src/components/segment-group/segment-group.test.tsx +22 -0
  269. package/src/components/segment-group/segment-group.tsx +35 -19
  270. package/src/components/switch/switch.test.tsx +15 -0
  271. package/src/components/switch/switch.tsx +27 -27
  272. package/src/components/table/table.test.tsx +1 -1
  273. package/src/components/table/table.tsx +14 -11
  274. package/src/components/tabs/tabs-data.tsx +5 -1
  275. package/src/components/tabs/tabs.test.tsx +28 -0
  276. package/src/components/tabs/tabs.tsx +14 -4
  277. package/src/components/theme-icon/theme-icon.tsx +46 -12
  278. package/src/lib/sidebar-rail.ts +24 -0
  279. package/src/theme.css +35 -35
  280. package/src/theme.test.ts +0 -1
  281. package/dist/chunk-2MXWEIMD.js.map +0 -1
  282. package/dist/chunk-6VYGK3Q3.js.map +0 -1
  283. package/dist/chunk-7AQ4MN4M.js.map +0 -1
  284. package/dist/chunk-7CNDZZZ6.js +0 -95
  285. package/dist/chunk-7CNDZZZ6.js.map +0 -1
  286. package/dist/chunk-BE2LWUHY.js.map +0 -1
  287. package/dist/chunk-C4NFRSOR.js.map +0 -1
  288. package/dist/chunk-DT6LKNZF.js.map +0 -1
  289. package/dist/chunk-E5H3YWZV.js.map +0 -1
  290. package/dist/chunk-F342ZT7O.js.map +0 -1
  291. package/dist/chunk-HRNWWL3Y.js.map +0 -1
  292. package/dist/chunk-MW42XVPD.js.map +0 -1
  293. package/dist/chunk-SVKN5ZHX.js.map +0 -1
  294. package/dist/chunk-VD6PB3VA.js.map +0 -1
@@ -70,12 +70,21 @@ const avatarVariants = cva(
70
70
  // `size`/`spacing` pairing (e.g. `md` avatars in a `spacing="xs"`
71
71
  // group) still gets a correctly-sized notch, just more or less
72
72
  // overlap.
73
+ //
74
+ // `2xl` (88px) and `3xl` (128px) sit outside the shared `SIZES` scale
75
+ // in `lib/sizes.ts`, the way Text/Title/Container declare their own
76
+ // extra steps: they're for a person shown as the subject of a screen
77
+ // rather than in a list. They keep `xl`'s proportions — initials at
78
+ // about 0.28× the diameter, the icon at 0.5× — and their own
79
+ // `--avatar-r`. `Avatar.Group`'s `spacing` stays on the shared scale.
73
80
  size: {
74
81
  xs: "size-6 text-[10px] [&_svg]:size-3.5 [--avatar-r:12]",
75
82
  sm: "size-8 text-xs [&_svg]:size-4 [--avatar-r:16]",
76
83
  md: "size-10 text-sm [&_svg]:size-5 [--avatar-r:20]",
77
84
  lg: "size-12 text-base [&_svg]:size-6 [--avatar-r:24]",
78
85
  xl: "size-16 text-lg [&_svg]:size-8 [--avatar-r:32]",
86
+ "2xl": "size-22 text-2xl [&_svg]:size-11 [--avatar-r:44]",
87
+ "3xl": "size-32 text-4xl [&_svg]:size-16 [--avatar-r:64]",
79
88
  },
80
89
  // `--avatar-corner-r` also rides along with `radius`: it's the other
81
90
  // half of `Avatar.Group`'s notch for a non-circular avatar (see
@@ -41,7 +41,13 @@ const badgeVariants = cva(
41
41
  "inline-flex items-center",
42
42
  "whitespace-nowrap select-none",
43
43
  "font-sans font-medium",
44
- "border border-transparent",
44
+ // Figma strokes every badge at 0.5px, inside the box. A CSS border cannot
45
+ // draw that: Chrome rounds any border-width under 1px up to 1px. An inset
46
+ // ring (box-shadow) is not rounded — one device pixel on a 2x screen, a
47
+ // half-strength pixel at 1x, as Figma antialiases it — and takes no layout.
48
+ // Forced colours drop every box-shadow, so there a real 1px border in the
49
+ // system text colour keeps the chip's edge.
50
+ "inset-ring-[0.5px] inset-ring-transparent forced-colors:border forced-colors:border-[CanvasText]",
45
51
  "[&_svg]:shrink-0 [&_svg]:pointer-events-none",
46
52
  // Inert on the default non-focusable <span> — `:focus-visible` never
47
53
  // matches it — and lights up as soon as `asChild` renders Badge onto a
@@ -67,17 +73,16 @@ const badgeVariants = cva(
67
73
  light: [
68
74
  "bg-black/8 dark:bg-white/16",
69
75
  TEXT_COLOR_CLASSES.primary,
70
- "border-black/8 dark:border-white/15",
71
- "data-color:bg-(--c-solid)/30 data-color:text-(--c-text) data-color:border-(--c-solid)",
76
+ "inset-ring-black/8 dark:inset-ring-white/15",
77
+ "data-color:bg-(--c-solid)/30 data-color:text-(--c-text) data-color:inset-ring-(--c-solid)",
72
78
  "data-[color=neutral]:bg-(--c-soft)",
73
79
  ],
74
- outline: "bg-transparent text-(--c-text) border-(--c-solid)",
80
+ outline: "bg-transparent text-(--c-text) inset-ring-(--c-solid)",
75
81
  subtle: "bg-transparent text-(--c-text)",
76
82
  // from-*/to-* are the CSS defaults for --tw-gradient-from/to and the
77
83
  // --tw-gradient-stops composition chain. Props only override the individual
78
84
  // vars they provide — the chain resolves them lazily without JS defaults.
79
- gradient:
80
- "bg-origin-border bg-linear-to-r from-purple-300 to-pink-400 text-black border-white/20",
85
+ gradient: "bg-linear-to-r from-purple-300 to-pink-400 text-black inset-ring-white/20",
81
86
  },
82
87
  // Figma (node 14950-143827) defines sm/md/lg; xs/xl extrapolate one
83
88
  // step past either end. Radius follows Figma on every step
@@ -95,7 +95,7 @@ const buttonVariants = cva(
95
95
  "not-data-loading:hover:bg-(--c-soft-hover) not-data-loading:hover:border-(--c-solid)",
96
96
  ],
97
97
  outline: [
98
- "bg-transparent text-(--c-text) border-(--c-solid)",
98
+ "bg-transparent text-(--c-text) border-(--c-solid)/35",
99
99
  "not-data-loading:hover:bg-(--c-soft)",
100
100
  ],
101
101
  subtle: ["bg-transparent text-(--c-text)", "not-data-loading:hover:bg-(--c-soft)"],
@@ -165,4 +165,28 @@ describe("ButtonGroup", () => {
165
165
  expect(screen.getByTestId("two").getAttribute("data-size")).toBe("xl")
166
166
  expect(screen.getByTestId("three").getAttribute("data-size")).toBe("md")
167
167
  })
168
+
169
+ it("spans the container with an even share per child under `grow`", () => {
170
+ const group = renderGroup(
171
+ <ButtonGroup grow>
172
+ <Button>One</Button>
173
+ <Button>Two</Button>
174
+ </ButtonGroup>,
175
+ )
176
+ expect(group.className).toMatch(/(^|\s)w-full(\s|$)/)
177
+ expect(group.className).toContain("*:flex-1")
178
+ expect(group.className).not.toContain("inline-flex")
179
+ })
180
+
181
+ it("hugs its children without `grow`", () => {
182
+ const group = renderGroup(
183
+ <ButtonGroup>
184
+ <Button>One</Button>
185
+ <Button>Two</Button>
186
+ </ButtonGroup>,
187
+ )
188
+ expect(group.className).toContain("inline-flex")
189
+ expect(group.className).not.toMatch(/(^|\s)w-full(\s|$)/)
190
+ expect(group.className).not.toContain("*:flex-1")
191
+ })
168
192
  })
@@ -42,6 +42,9 @@ import type { WithTestId } from "../../lib/test-id"
42
42
  * `orientation="horizontal"` (default) flattens the inline edges — logical
43
43
  * `rounded-s` / `rounded-e` + `-ms`, so it flips correctly under RTL — while
44
44
  * `"vertical"` flattens the block edges.
45
+ *
46
+ * `grow` spans the container and gives every child an even share of it
47
+ * (`flex-1`), like a tab bar.
45
48
  */
46
49
  export const buttonGroupVariants = cva(
47
50
  [
@@ -97,6 +100,10 @@ export const buttonGroupVariants = cva(
97
100
  "[&>:is([data-variant=filled],[data-variant=subtle])]:border-x-0",
98
101
  ],
99
102
  },
103
+ // Span the container, with an even share per child. `flex` (not
104
+ // `inline-flex`) so `w-full` resolves against the parent; `cn`'s twMerge
105
+ // drops the base `inline-flex`.
106
+ grow: { true: "flex w-full *:flex-1" },
100
107
  },
101
108
  defaultVariants: { orientation: "horizontal" },
102
109
  },
@@ -107,14 +114,24 @@ export type ButtonGroupOrientation = NonNullable<
107
114
  >
108
115
 
109
116
  export type ButtonGroupProps = HTMLArkProps<"div"> &
110
- VariantProps<typeof buttonGroupVariants> &
111
- WithTestId
117
+ Omit<VariantProps<typeof buttonGroupVariants>, "grow"> &
118
+ WithTestId & {
119
+ /** Span the container and give every child an even share of it, like a
120
+ * tab bar. Without it the group hugs its children. */
121
+ grow?: boolean
122
+ }
112
123
 
113
- export const ButtonGroup = ({ className, orientation, testId, ...rest }: ButtonGroupProps) => (
124
+ export const ButtonGroup = ({
125
+ className,
126
+ orientation,
127
+ grow,
128
+ testId,
129
+ ...rest
130
+ }: ButtonGroupProps) => (
114
131
  <ark.div
115
132
  role="group"
116
133
  data-orientation={orientation ?? "horizontal"}
117
- className={cn(buttonGroupVariants({ orientation }), className)}
134
+ className={cn(buttonGroupVariants({ orientation, grow }), className)}
118
135
  {...props({ "data-testid": testId })}
119
136
  {...rest}
120
137
  />
@@ -132,6 +132,21 @@ describe("ButtonMultiSelect", () => {
132
132
  fireEvent.click(toggle("Italic"))
133
133
  await waitFor(() => expect(toggle("Italic").getAttribute("data-variant")).toBe("light"))
134
134
  })
135
+
136
+ it("spans the container under `grow`", () => {
137
+ render(<ButtonMultiSelect data={DAYS} testId="days" grow />)
138
+ const root = screen.getByTestId("days")
139
+ expect(root.className).toMatch(/(^|\s)w-full(\s|$)/)
140
+ expect(root.className).not.toContain("w-fit")
141
+ expect(root.className).toContain("*:flex-1")
142
+ })
143
+
144
+ it("hugs its items without `grow`", () => {
145
+ render(<ButtonMultiSelect data={DAYS} testId="days" />)
146
+ const root = screen.getByTestId("days")
147
+ expect(root.className).toContain("w-fit")
148
+ expect(root.className).not.toContain("*:flex-1")
149
+ })
135
150
  })
136
151
 
137
152
  describe("ButtonMultiSelect types", () => {
@@ -36,6 +36,9 @@ export type ButtonSelectBaseProps<Data extends ButtonSelectData> = Pick<
36
36
  orientation?: "horizontal" | "vertical"
37
37
  /** Red invalid state, independent of (and OR'd with) `error`. */
38
38
  invalid?: boolean
39
+ /** Span the container and give every item an even share of it, like a tab
40
+ * bar. Without it the group hugs its items. */
41
+ grow?: boolean
39
42
  /** Dims and blocks every item. */
40
43
  disabled?: boolean
41
44
  size?: ButtonSize
@@ -70,6 +73,7 @@ export const ButtonSelectControl = ({
70
73
  renderItem,
71
74
  orientation,
72
75
  invalid,
76
+ grow,
73
77
  disabled,
74
78
  required,
75
79
  size = "md",
@@ -116,6 +120,7 @@ export const ButtonSelectControl = ({
116
120
  orientation={orientation}
117
121
  disabled={disabled}
118
122
  invalid={isInvalid}
123
+ grow={grow}
119
124
  size={size}
120
125
  variant={variant}
121
126
  selectedVariant={selectedVariant}
@@ -207,6 +207,31 @@ describe("ButtonSelect", () => {
207
207
  await waitFor(() => expect(onChange).toHaveBeenLastCalledWith("right"))
208
208
  expect(radio("Right").getAttribute("data-variant")).toBe("filled")
209
209
  })
210
+
211
+ it("spans the container under `grow`, the invalid ring with it", () => {
212
+ render(<ButtonSelect data={ITEMS} testId="range" grow invalid />)
213
+ const root = screen.getByTestId("range")
214
+ expect(root.className).toMatch(/(^|\s)w-full(\s|$)/)
215
+ expect(root.className).not.toContain("w-fit")
216
+ expect(root.className).toContain("*:flex-1")
217
+ })
218
+
219
+ it("hugs its items without `grow`", () => {
220
+ render(<ButtonSelect data={ITEMS} testId="range" />)
221
+ const root = screen.getByTestId("range")
222
+ expect(root.className).toContain("w-fit")
223
+ expect(root.className).not.toMatch(/(^|\s)w-full(\s|$)/)
224
+ expect(root.className).not.toContain("*:flex-1")
225
+ })
226
+
227
+ it("spans the container under `grow` on the composable Root", () => {
228
+ render(
229
+ <ButtonSelect.Root grow testId="root">
230
+ <ButtonSelect.Item value="a">A</ButtonSelect.Item>
231
+ </ButtonSelect.Root>,
232
+ )
233
+ expect(screen.getByTestId("root").className).toContain("*:flex-1")
234
+ })
210
235
  })
211
236
 
212
237
  describe("ButtonSelect types", () => {
@@ -63,7 +63,9 @@ const ButtonSelectStyleContext = createContext<StyleContextValue>({
63
63
  * seams out-specify a per-item border anyway. A `ring` (box-shadow) is used, not
64
64
  * an `outline`, because the machine writes `outline: none` inline on the root.
65
65
  * `w-fit` keeps that ring hugging the items: inside `Field`'s flex column the
66
- * root would otherwise stretch to the field's full width.
66
+ * root would otherwise stretch to the field's full width. Under `grow` the root
67
+ * spans that width on purpose, so `w-full` overrides it and the ring spans the
68
+ * row with it.
67
69
  */
68
70
  const invalidRing =
69
71
  "w-fit rounded-button data-invalid:ring-1 data-invalid:ring-red-500 data-invalid:ring-offset-2 data-invalid:ring-offset-brand-50 dark:data-invalid:ring-offset-brand-950"
@@ -82,6 +84,9 @@ type BaseRootProps = Omit<
82
84
  size?: ButtonSize
83
85
  /** Red invalid ring around the group. */
84
86
  invalid?: boolean
87
+ /** Span the container and give every item an even share of it, like a tab
88
+ * bar. Without it the group hugs its items. */
89
+ grow?: boolean
85
90
  /** Lands on the group root, which forwards focus to its active item. Ark's
86
91
  * prop types carry no `ref`, so it is declared here. */
87
92
  ref?: Ref<HTMLDivElement>
@@ -152,6 +157,7 @@ export const RootBase = ({
152
157
  selectedVariant = "filled",
153
158
  size = "md",
154
159
  invalid,
160
+ grow,
155
161
  loopFocus = true,
156
162
  className,
157
163
  testId,
@@ -190,7 +196,12 @@ export const RootBase = ({
190
196
  data-color={color}
191
197
  {...props({ "aria-invalid": invalid, "data-invalid": invalid, "data-testid": testId })}
192
198
  {...fieldA11yProps(field)}
193
- className={cn(buttonGroupVariants({ orientation }), invalidRing, className)}
199
+ className={cn(
200
+ buttonGroupVariants({ orientation, grow }),
201
+ invalidRing,
202
+ grow && "w-full",
203
+ className,
204
+ )}
194
205
  {...rest}
195
206
  >
196
207
  {children}
@@ -23,14 +23,15 @@ const cardVariants = cva("flex flex-col rounded-card border", {
23
23
  // behind it rather than imposing a flat hue — used here in both
24
24
  // themes for a consistently subtle surface.
25
25
  //
26
- // The border is the kit's hairline, `border-brand-900/20
27
- // dark:border-white/15` — the same pair `Input`'s shell,
28
- // `SegmentGroup` and `ChoiceCardGroup` draw. It used to sit at
29
- // /30 ÷ /10, brand-tinted but off by an opacity step from everything
30
- // else, left over from an earlier partial alignment pass.
26
+ // The border is Figma's card hairline, `border-primary` — white at 8 %
27
+ // in the dark theme (`dark:border-white/8`), shared with
28
+ // `ChoiceCardGroup` and with the dividers of `Card.Header` /
29
+ // `Card.Description` / `Card.Footer`. It sat at /15, the kit's form
30
+ // hairline (`Input`'s shell, `SegmentGroup`), which drew every card
31
+ // twice as marked as the mockups.
31
32
  default: [
32
33
  "bg-white/4 text-brand-950 border-brand-900/20",
33
- "dark:text-white dark:border-white/15",
34
+ "dark:text-white dark:border-white/8",
34
35
  ],
35
36
  filled: "bg-(--c-solid) text-(--c-on-solid) border-(--c-solid)",
36
37
  light: "bg-(--c-soft) text-(--c-text) border-(--c-soft)",
@@ -151,7 +152,7 @@ const CardHeader = ({ className, withBorder, testId, ...rest }: CardHeaderProps)
151
152
  <ark.div
152
153
  className={cn(
153
154
  "flex flex-col gap-1 px-4 py-3",
154
- { "border-b border-brand-900/20 dark:border-white/15": withBorder },
155
+ { "border-b border-brand-900/20 dark:border-white/8": withBorder },
155
156
  className,
156
157
  )}
157
158
  {...props({ "data-testid": testId })}
@@ -176,7 +177,7 @@ const CardDescription = ({ className, withBorder, testId, ...rest }: CardDescrip
176
177
  className={cn(
177
178
  "text-sm",
178
179
  TEXT_COLOR_CLASSES.muted,
179
- { "border-t border-brand-900/20 dark:border-white/15": withBorder },
180
+ { "border-t border-brand-900/20 dark:border-white/8": withBorder },
180
181
  className,
181
182
  )}
182
183
  {...props({ "data-testid": testId })}
@@ -200,7 +201,7 @@ const CardFooter = ({ className, withBorder, testId, ...rest }: CardFooterProps)
200
201
  <ark.div
201
202
  className={cn(
202
203
  "flex items-center justify-end gap-2 px-4 py-3",
203
- { "border-t border-brand-900/20 dark:border-white/15": withBorder },
204
+ { "border-t border-brand-900/20 dark:border-white/8": withBorder },
204
205
  className,
205
206
  )}
206
207
  {...props({ "data-testid": testId })}
@@ -51,6 +51,23 @@ describe("Checkbox", () => {
51
51
  expect(screen.getByText("Select row").className).toContain("sr-only")
52
52
  })
53
53
 
54
+ it("aligns the control to the label line when a description sits below", () => {
55
+ const { container } = render(
56
+ <Checkbox label="Airplane mode" description="Disables all radios" />,
57
+ )
58
+ const root = container.querySelector("label") as HTMLElement
59
+ // A grid root with control, label and field as direct cells: the control
60
+ // centers on the label row, and the field hangs under the label.
61
+ expect(root.className).toContain("inline-grid")
62
+ expect(Array.from(root.children).map((el) => el.tagName)).toEqual(["DIV", "SPAN", "DIV"])
63
+ expect(root.lastElementChild?.className).toContain("col-start-2")
64
+ })
65
+
66
+ it("keeps a label-only root as an inline row", () => {
67
+ const { container } = render(<Checkbox label="Airplane mode" />)
68
+ expect((container.querySelector("label") as HTMLElement).className).toContain("inline-flex")
69
+ })
70
+
54
71
  it("renders a sr-only label with no extra wrapper around it", () => {
55
72
  const { container } = render(<Checkbox label="Select row" classNames={{ label: "sr-only" }} />)
56
73
  const root = container.querySelector("label") as HTMLElement
@@ -65,15 +82,6 @@ describe("Checkbox", () => {
65
82
  expect(Array.from(root.children).map((el) => el.tagName)).toEqual(["DIV", "SPAN", "INPUT"])
66
83
  })
67
84
 
68
- it("stacks a visible label above its description in one wrapper", () => {
69
- const { container } = render(<Checkbox label="Notify" description="Weekly digest" />)
70
- const label = screen.getByText("Notify")
71
- const description = screen.getByText("Weekly digest")
72
- const stack = label.parentElement as HTMLElement
73
- expect(stack).toBe((container.querySelector("label") as HTMLElement).children[1])
74
- expect(stack.contains(description)).toBe(true)
75
- })
76
-
77
85
  it("renders testId as data-testid on the root label, not the hidden input", () => {
78
86
  render(<Checkbox label="Accept terms" testId="accept-terms" />)
79
87
  const el = screen.getByTestId("accept-terms")
@@ -10,7 +10,13 @@ import { type IconMap, iconStroke, mergeIcons } from "../../lib/icons"
10
10
  import { props } from "../../lib/props"
11
11
  import type { Size } from "../../lib/sizes"
12
12
  import type { WithTestId } from "../../lib/test-id"
13
- import { FieldShell, fieldA11yProps, fieldLabel, fieldRoot, requiredMark } from "../field/field"
13
+ import {
14
+ FieldShell,
15
+ fieldA11yProps,
16
+ fieldInlineStack,
17
+ fieldLabel,
18
+ requiredMark,
19
+ } from "../field/field"
14
20
  import { CheckIcon } from "../popover/icons"
15
21
  import { type ControlIndicatorVariant, controlIndicator } from "./control"
16
22
 
@@ -22,8 +28,8 @@ import { type ControlIndicatorVariant, controlIndicator } from "./control"
22
28
  * layout footprint when it's visually hidden (e.g. `classNames.label:
23
29
  * "sr-only"`): an absolutely-positioned flex child isn't a flex item at all,
24
30
  * so it can't pick up the root's `gap-2`. `description` / `error` live below
25
- * it via the shared `Field` scaffold, so a `Checkbox` is accessible and
26
- * complete on its own. Implements the kit's `FormControlProps` contract: the
31
+ * the label via the shared `Field` scaffold, with the box centered on the
32
+ * label line, so a `Checkbox` is accessible and complete on its own. Implements the kit's `FormControlProps` contract: the
27
33
  * `ref` and `onBlur` land on the submittable hidden `<input>`, and `name`
28
34
  * wires it into native form submission.
29
35
  *
@@ -90,6 +96,7 @@ export type CheckboxProps = WithTestId & {
90
96
  root?: string
91
97
  control?: string
92
98
  label?: string
99
+ /** The description / error field, under the label. */
93
100
  field?: string
94
101
  }
95
102
  }
@@ -136,9 +143,10 @@ export const Checkbox = ({
136
143
  // library can flip it from `fieldState.invalid` (see FormControlProps).
137
144
  const isInvalid = invalid || error != null
138
145
 
139
- // A visible label above description/error needs the two grouped into one
140
- // flex-col item, or they'd land side by side in the root's row instead of
141
- // stacked. Label-only (incl. sr-only) never needs this extra wrapper.
146
+ // A visible label above description/error switches the root to a grid: the
147
+ // control centers on the label's row alone (not on the whole text stack),
148
+ // and the field hangs under the label in the second column. Label-only
149
+ // (incl. sr-only) stays a plain inline row.
142
150
  const hasStack = label != null && (description != null || error != null)
143
151
 
144
152
  const labelNode = label != null && (
@@ -171,7 +179,9 @@ export const Checkbox = ({
171
179
  // `relative` contains the absolutely positioned hidden input, which would
172
180
  // otherwise escape any scroller this control sits in.
173
181
  className={cn(
174
- "relative inline-flex items-center gap-2 select-none",
182
+ hasStack
183
+ ? fieldInlineStack({ size })
184
+ : "relative inline-flex items-center gap-2 select-none",
175
185
  className,
176
186
  classNames?.root,
177
187
  )}
@@ -181,26 +191,15 @@ export const Checkbox = ({
181
191
  <Ark.Indicator indeterminate>{icons.indeterminate}</Ark.Indicator>
182
192
  </Ark.Control>
183
193
 
184
- {hasStack ? (
185
- <div className={cn(fieldRoot({ size }), classNames?.field)}>
186
- {labelNode}
187
- <FieldShell description={description} error={error} size={size}>
188
- <CheckboxHiddenInput ref={ref} onBlur={onBlur} />
189
- </FieldShell>
190
- </div>
191
- ) : (
192
- <>
193
- {labelNode}
194
- <FieldShell
195
- description={description}
196
- error={error}
197
- size={size}
198
- className={classNames?.field}
199
- >
200
- <CheckboxHiddenInput ref={ref} onBlur={onBlur} />
201
- </FieldShell>
202
- </>
203
- )}
194
+ {labelNode}
195
+ <FieldShell
196
+ description={description}
197
+ error={error}
198
+ size={size}
199
+ className={cn(hasStack && "col-start-2", classNames?.field)}
200
+ >
201
+ <CheckboxHiddenInput ref={ref} onBlur={onBlur} />
202
+ </FieldShell>
204
203
  </Ark.Root>
205
204
  )
206
205
  }
@@ -177,8 +177,8 @@ export type ChoiceCardGroupProps<Data extends ChoiceCardGroupData = ChoiceCardIt
177
177
 
178
178
  /**
179
179
  * The card surface. Neutral at rest on the kit's translucent surface — the same
180
- * `bg-white/4` + `border-brand-900/20 dark:border-white/15` recipe as `Input`'s
181
- * `default` shell (also used by `Card` and `SegmentGroup`): a fixed opaque
180
+ * `bg-white/4` + `border-brand-900/20 dark:border-white/8` recipe as `Card`
181
+ * (Figma's `border-primary`, the card hairline): a fixed opaque
182
182
  * gray fill can vanish or over-assert depending on the host background, so the
183
183
  * fill carries no ground of its own. The selected treatment follows the
184
184
  * `variant`, mirroring `Checkbox` / `RadioGroup`:
@@ -198,7 +198,7 @@ const choiceCard = cva(
198
198
  "relative flex w-full cursor-pointer rounded-card border text-start select-none transition-[background-color,border-color,box-shadow]",
199
199
  "bg-white/4",
200
200
  TEXT_COLOR_CLASSES.primary,
201
- "border-brand-900/20 dark:border-white/15",
201
+ "border-brand-900/20 dark:border-white/8",
202
202
  "hover:border-brand-900/30 dark:hover:border-white/25",
203
203
  // Keyboard focus ring on the whole card — the kit's standard brand ring,
204
204
  // matching Checkbox / Radio regardless of palette.
@@ -13,6 +13,7 @@ import {
13
13
  } from "./chrome"
14
14
  import type { CodeBlockGutterColumn } from "./gutters"
15
15
  import { type CodeBlockTagStyle, highlightCode } from "./highlighter"
16
+ import type { CodeBlockLanguage } from "./languages"
16
17
  import { type ParsedNotation, parseNotation } from "./notation"
17
18
 
18
19
  export type {
@@ -60,8 +61,10 @@ export type { CodeBlockTagStyle } from "./highlighter"
60
61
  export type CodeBlockProps = WithTestId & {
61
62
  /** Source text to highlight. No `children` slot — content is Shiki-derived. */
62
63
  code: string
63
- /** Shiki-bundled language id (e.g. "tsx", "bash", "json"). Omit → plain "text" grammar, no async load. */
64
- language?: string
64
+ /** A bundled language id or alias (e.g. "tsx", "bash", "json"), or a name
65
+ * registered through `registerLanguage`. An unknown name renders as plain
66
+ * text, with a dev-only warning. Omit → plain "text" grammar, no async load. */
67
+ language?: CodeBlockLanguage
65
68
  /** Override the light/dark Shiki theme pair. @default { light: "github-light", dark: "github-dark-default" } */
66
69
  themes?: { light: string; dark: string }
67
70
  /** Notation-tag → styling lookup — a line carrying `// [!code removed]`
@@ -75,7 +78,7 @@ export type CodeBlockProps = WithTestId & {
75
78
  * run after the internal notation transformer — the escape hatch for
76
79
  * extending Shiki's own capabilities. See also `registerLanguage`/
77
80
  * `registerTheme` (exported from `@42/ui-react/code-block`) for
78
- * registering a custom language/theme the bundled set doesn't ship. */
81
+ * registering a language/theme the bundled set doesn't ship. */
79
82
  transformers?: ShikiTransformer[]
80
83
  /** Parse `// [!code tag]` markers. `false` renders them verbatim instead —
81
84
  * for a snippet that teaches the notation itself. @default true */
@@ -114,7 +117,7 @@ export type CodeBlockProps = WithTestId & {
114
117
 
115
118
  type HighlightedPreProps = {
116
119
  code: string
117
- lang?: string
120
+ lang?: CodeBlockLanguage
118
121
  themes?: { light: string; dark: string }
119
122
  tags?: Record<string, CodeBlockTagStyle>
120
123
  gutters?: CodeBlockGutterColumn[]
@@ -1,5 +1,6 @@
1
- import { describe, expect, it } from "vitest"
1
+ import { afterEach, beforeEach, describe, expect, it, type MockInstance, vi } from "vitest"
2
2
  import { highlightCode, registerLanguage, registerTheme } from "./highlighter"
3
+ import { LANGUAGES } from "./languages"
3
4
  import { parseNotation } from "./notation"
4
5
 
5
6
  describe("highlightCode", () => {
@@ -259,3 +260,80 @@ describe("highlightCode", () => {
259
260
  expect(html).toContain("shiki")
260
261
  })
261
262
  })
263
+
264
+ /** One sample per bundled grammar. Running each through the real
265
+ * highlighter catches a grammar the JavaScript regex engine can't compile:
266
+ * it would throw, or fall back to unstyled tokens. */
267
+ const SAMPLES: Record<string, string> = {
268
+ c: "int main(void) { return 0; }",
269
+ cpp: "template <typename T> T id(T x) { return x; }",
270
+ python: "def f(x):\n return x + 1",
271
+ shellscript: 'for f in *.c; do echo "$f"; done',
272
+ javascript: "const x = () => 1",
273
+ typescript: "const x: number = 1",
274
+ jsx: 'const a = <div className="x">hi</div>',
275
+ tsx: "const a: JSX.Element = <div>hi</div>",
276
+ json: '{ "a": [1, true, null] }',
277
+ yaml: "key: value\nlist:\n - 1",
278
+ markdown: "# Title\n\n**bold** and `code`",
279
+ html: '<p class="x">hi</p><script>let a = 1</script>',
280
+ css: ".a { color: red; }",
281
+ sql: "SELECT id FROM users WHERE id = 1;",
282
+ go: "func main() { fmt.Println(1) }",
283
+ rust: "fn main() { let x: u8 = 1; }",
284
+ java: "class A { int x = 1; }",
285
+ make: "all: $(NAME)\n\tcc -o $@ $^",
286
+ docker: "FROM node:22\nRUN pnpm install",
287
+ diff: "--- a\n+++ b\n-old\n+new",
288
+ }
289
+
290
+ describe("bundled languages", () => {
291
+ let warn: MockInstance<typeof console.warn>
292
+ beforeEach(() => {
293
+ warn = vi.spyOn(console, "warn").mockImplementation(() => {})
294
+ })
295
+ afterEach(() => warn.mockRestore())
296
+
297
+ it.each(Object.keys(LANGUAGES))("%s highlights with colored tokens", async (lang) => {
298
+ const loaded = (await LANGUAGES[lang as keyof typeof LANGUAGES]()).default
299
+ const name = loaded[loaded.length - 1]?.name ?? lang
300
+ const html = await highlightCode(SAMPLES[name] ?? "x", { lang })
301
+ // more than one distinct token color → the grammar actually tokenized
302
+ const colors = new Set(html.match(/--shiki-light:#[0-9a-fA-F]+/g))
303
+ expect(colors.size).toBeGreaterThan(1)
304
+ expect(warn).not.toHaveBeenCalled()
305
+ })
306
+
307
+ it("renders an unknown language as plain text and warns once", async () => {
308
+ const a = await highlightCode("let x = 1", { lang: "not-a-language" })
309
+ await highlightCode("let y = 2", { lang: "not-a-language" })
310
+ expect(a).toContain("let x = 1")
311
+ expect(new Set(a.match(/--shiki-light:#[0-9a-fA-F]+/g)).size).toBeLessThanOrEqual(1)
312
+ expect(warn).toHaveBeenCalledTimes(1)
313
+ expect(warn.mock.calls[0]?.[0]).toContain('"not-a-language"')
314
+ expect(warn.mock.calls[0]?.[0]).toContain("registerLanguage")
315
+ })
316
+
317
+ it("does not load a Shiki grammar outside the map by name", async () => {
318
+ await highlightCode("main = print 1", { lang: "haskell" })
319
+ expect(warn).toHaveBeenCalledTimes(1)
320
+ })
321
+
322
+ it("falls back to the default theme for an unregistered theme name", async () => {
323
+ const fallback = await highlightCode("const x = 1", {
324
+ lang: "ts",
325
+ themes: { light: "nord", dark: "github-dark-default" },
326
+ })
327
+ const defaults = await highlightCode("const x = 1", { lang: "ts" })
328
+ expect(fallback).toBe(defaults)
329
+ expect(warn).toHaveBeenCalledTimes(1)
330
+ expect(warn.mock.calls[0]?.[0]).toContain('"nord"')
331
+ })
332
+
333
+ it("uses a registered Shiki grammar the map doesn't bundle", async () => {
334
+ await registerLanguage((await import("shiki/langs/haskell.mjs")).default)
335
+ const html = await highlightCode("main = print 1", { lang: "haskell" })
336
+ expect(new Set(html.match(/--shiki-light:#[0-9a-fA-F]+/g)).size).toBeGreaterThan(1)
337
+ expect(warn).not.toHaveBeenCalled()
338
+ })
339
+ })