@contui/ui 0.0.0-stage → 0.1.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 (427) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +150 -2
  3. package/cli/contui.mjs +250 -0
  4. package/dist/charts/area-chart.d.ts +8 -0
  5. package/dist/charts/area-chart.js +9 -0
  6. package/dist/charts/bar-chart.d.ts +9 -0
  7. package/dist/charts/bar-chart.js +10 -0
  8. package/dist/charts/bubble-chart.d.ts +60 -0
  9. package/dist/charts/bubble-chart.js +392 -0
  10. package/dist/charts/bullet-chart.d.ts +53 -0
  11. package/dist/charts/bullet-chart.js +123 -0
  12. package/dist/charts/candlestick-chart.d.ts +77 -0
  13. package/dist/charts/candlestick-chart.js +558 -0
  14. package/dist/charts/cartesian.d.ts +121 -0
  15. package/dist/charts/cartesian.js +625 -0
  16. package/dist/charts/chart-card.d.ts +80 -0
  17. package/dist/charts/chart-card.js +114 -0
  18. package/dist/charts/donut-chart.d.ts +40 -0
  19. package/dist/charts/donut-chart.js +88 -0
  20. package/dist/charts/funnel-chart.d.ts +16 -0
  21. package/dist/charts/funnel-chart.js +164 -0
  22. package/dist/charts/horizontal-bar-chart.d.ts +67 -0
  23. package/dist/charts/horizontal-bar-chart.js +481 -0
  24. package/dist/charts/index.d.ts +21 -0
  25. package/dist/charts/index.js +32 -0
  26. package/dist/charts/legend.d.ts +23 -0
  27. package/dist/charts/legend.js +22 -0
  28. package/dist/charts/lib/candlestick-window.d.ts +15 -0
  29. package/dist/charts/lib/candlestick-window.js +23 -0
  30. package/dist/charts/lib/color.d.ts +39 -0
  31. package/dist/charts/lib/color.js +83 -0
  32. package/dist/charts/lib/format.d.ts +11 -0
  33. package/dist/charts/lib/format.js +33 -0
  34. package/dist/charts/lib/frame.d.ts +6 -0
  35. package/dist/charts/lib/frame.js +6 -0
  36. package/dist/charts/lib/layout.d.ts +11 -0
  37. package/dist/charts/lib/layout.js +71 -0
  38. package/dist/charts/lib/path.d.ts +35 -0
  39. package/dist/charts/lib/path.js +203 -0
  40. package/dist/charts/lib/scale.d.ts +41 -0
  41. package/dist/charts/lib/scale.js +80 -0
  42. package/dist/charts/lib/use-active.d.ts +18 -0
  43. package/dist/charts/lib/use-active.js +71 -0
  44. package/dist/charts/lib/use-size.d.ts +9 -0
  45. package/dist/charts/lib/use-size.js +40 -0
  46. package/dist/charts/line-chart.d.ts +7 -0
  47. package/dist/charts/line-chart.js +8 -0
  48. package/dist/charts/radar-chart.d.ts +27 -0
  49. package/dist/charts/radar-chart.js +165 -0
  50. package/dist/charts/rose-chart.d.ts +35 -0
  51. package/dist/charts/rose-chart.js +242 -0
  52. package/dist/charts/sparkline.d.ts +35 -0
  53. package/dist/charts/sparkline.js +110 -0
  54. package/dist/charts/tooltip.d.ts +35 -0
  55. package/dist/charts/tooltip.js +22 -0
  56. package/dist/charts/treemap.d.ts +28 -0
  57. package/dist/charts/treemap.js +103 -0
  58. package/dist/charts/uptime-strip.d.ts +40 -0
  59. package/dist/charts/uptime-strip.js +178 -0
  60. package/dist/components/accordion.d.ts +31 -0
  61. package/dist/components/accordion.js +34 -0
  62. package/dist/components/activity-item.d.ts +12 -0
  63. package/dist/components/activity-item.js +6 -0
  64. package/dist/components/alert.d.ts +21 -0
  65. package/dist/components/alert.js +58 -0
  66. package/dist/components/assistant-answer.d.ts +52 -0
  67. package/dist/components/assistant-answer.js +40 -0
  68. package/dist/components/assistant-prompt.d.ts +63 -0
  69. package/dist/components/assistant-prompt.js +122 -0
  70. package/dist/components/avatar.d.ts +28 -0
  71. package/dist/components/avatar.js +75 -0
  72. package/dist/components/badge.d.ts +16 -0
  73. package/dist/components/badge.js +33 -0
  74. package/dist/components/bar-list.d.ts +65 -0
  75. package/dist/components/bar-list.js +119 -0
  76. package/dist/components/block-slider.d.ts +43 -0
  77. package/dist/components/block-slider.js +63 -0
  78. package/dist/components/branch-graph.d.ts +87 -0
  79. package/dist/components/branch-graph.js +231 -0
  80. package/dist/components/breadcrumb.d.ts +41 -0
  81. package/dist/components/breadcrumb.js +53 -0
  82. package/dist/components/button.d.ts +23 -0
  83. package/dist/components/button.js +108 -0
  84. package/dist/components/calendar.d.ts +5 -0
  85. package/dist/components/calendar.js +90 -0
  86. package/dist/components/card.d.ts +65 -0
  87. package/dist/components/card.js +104 -0
  88. package/dist/components/chat-attachment.d.ts +47 -0
  89. package/dist/components/chat-attachment.js +63 -0
  90. package/dist/components/chat-event.d.ts +7 -0
  91. package/dist/components/chat-event.js +7 -0
  92. package/dist/components/chat-message.d.ts +59 -0
  93. package/dist/components/chat-message.js +91 -0
  94. package/dist/components/chat-reference.d.ts +20 -0
  95. package/dist/components/chat-reference.js +41 -0
  96. package/dist/components/chat-shared.d.ts +21 -0
  97. package/dist/components/chat-shared.js +23 -0
  98. package/dist/components/chat-suggestions.d.ts +59 -0
  99. package/dist/components/chat-suggestions.js +88 -0
  100. package/dist/components/chat-thread.d.ts +39 -0
  101. package/dist/components/chat-thread.js +172 -0
  102. package/dist/components/chat-typing.d.ts +35 -0
  103. package/dist/components/chat-typing.js +66 -0
  104. package/dist/components/checkbox.d.ts +18 -0
  105. package/dist/components/checkbox.js +33 -0
  106. package/dist/components/checklist.d.ts +26 -0
  107. package/dist/components/checklist.js +18 -0
  108. package/dist/components/chip.d.ts +29 -0
  109. package/dist/components/chip.js +61 -0
  110. package/dist/components/code-input.d.ts +40 -0
  111. package/dist/components/code-input.js +285 -0
  112. package/dist/components/color-picker.d.ts +38 -0
  113. package/dist/components/color-picker.js +855 -0
  114. package/dist/components/combobox.d.ts +75 -0
  115. package/dist/components/combobox.js +112 -0
  116. package/dist/components/command-menu.d.ts +58 -0
  117. package/dist/components/command-menu.js +166 -0
  118. package/dist/components/copy-button.d.ts +16 -0
  119. package/dist/components/copy-button.js +31 -0
  120. package/dist/components/data-grid.d.ts +50 -0
  121. package/dist/components/data-grid.js +599 -0
  122. package/dist/components/date-picker.d.ts +109 -0
  123. package/dist/components/date-picker.js +268 -0
  124. package/dist/components/description-list.d.ts +12 -0
  125. package/dist/components/description-list.js +10 -0
  126. package/dist/components/dialog.d.ts +57 -0
  127. package/dist/components/dialog.js +140 -0
  128. package/dist/components/dock.d.ts +45 -0
  129. package/dist/components/dock.js +79 -0
  130. package/dist/components/drop-zone.d.ts +46 -0
  131. package/dist/components/drop-zone.js +101 -0
  132. package/dist/components/dropdown-menu.d.ts +50 -0
  133. package/dist/components/dropdown-menu.js +78 -0
  134. package/dist/components/editable-cell.d.ts +34 -0
  135. package/dist/components/editable-cell.js +89 -0
  136. package/dist/components/empty-state.d.ts +17 -0
  137. package/dist/components/empty-state.js +9 -0
  138. package/dist/components/field.d.ts +43 -0
  139. package/dist/components/field.js +75 -0
  140. package/dist/components/filter-condition.d.ts +188 -0
  141. package/dist/components/filter-condition.js +113 -0
  142. package/dist/components/filter-menu.d.ts +57 -0
  143. package/dist/components/filter-menu.js +46 -0
  144. package/dist/components/header-bar.d.ts +84 -0
  145. package/dist/components/header-bar.js +94 -0
  146. package/dist/components/hold-button.d.ts +15 -0
  147. package/dist/components/hold-button.js +88 -0
  148. package/dist/components/icon-tile.d.ts +12 -0
  149. package/dist/components/icon-tile.js +29 -0
  150. package/dist/components/info-tip.d.ts +13 -0
  151. package/dist/components/info-tip.js +26 -0
  152. package/dist/components/input.d.ts +17 -0
  153. package/dist/components/input.js +83 -0
  154. package/dist/components/kbd.d.ts +6 -0
  155. package/dist/components/kbd.js +7 -0
  156. package/dist/components/menu-item.d.ts +56 -0
  157. package/dist/components/menu-item.js +94 -0
  158. package/dist/components/message-composer.d.ts +75 -0
  159. package/dist/components/message-composer.js +199 -0
  160. package/dist/components/nav-rail.d.ts +31 -0
  161. package/dist/components/nav-rail.js +85 -0
  162. package/dist/components/notice.d.ts +45 -0
  163. package/dist/components/notice.js +66 -0
  164. package/dist/components/optimistic-undo.d.ts +28 -0
  165. package/dist/components/optimistic-undo.js +43 -0
  166. package/dist/components/option-row.d.ts +15 -0
  167. package/dist/components/option-row.js +14 -0
  168. package/dist/components/page-content.d.ts +11 -0
  169. package/dist/components/page-content.js +31 -0
  170. package/dist/components/pagination.d.ts +34 -0
  171. package/dist/components/pagination.js +41 -0
  172. package/dist/components/popover.d.ts +27 -0
  173. package/dist/components/popover.js +25 -0
  174. package/dist/components/progress.d.ts +33 -0
  175. package/dist/components/progress.js +75 -0
  176. package/dist/components/radio-group.d.ts +7 -0
  177. package/dist/components/radio-group.js +33 -0
  178. package/dist/components/readonly-field.d.ts +33 -0
  179. package/dist/components/readonly-field.js +80 -0
  180. package/dist/components/segmented-control.d.ts +21 -0
  181. package/dist/components/segmented-control.js +108 -0
  182. package/dist/components/select.d.ts +42 -0
  183. package/dist/components/select.js +86 -0
  184. package/dist/components/separator.d.ts +10 -0
  185. package/dist/components/separator.js +7 -0
  186. package/dist/components/setting-row.d.ts +53 -0
  187. package/dist/components/setting-row.js +93 -0
  188. package/dist/components/sidebar-switcher.d.ts +47 -0
  189. package/dist/components/sidebar-switcher.js +20 -0
  190. package/dist/components/sidebar.d.ts +220 -0
  191. package/dist/components/sidebar.js +327 -0
  192. package/dist/components/skeleton.d.ts +18 -0
  193. package/dist/components/skeleton.js +23 -0
  194. package/dist/components/slider.d.ts +15 -0
  195. package/dist/components/slider.js +28 -0
  196. package/dist/components/spinner.d.ts +14 -0
  197. package/dist/components/spinner.js +19 -0
  198. package/dist/components/status-dot.d.ts +24 -0
  199. package/dist/components/status-dot.js +35 -0
  200. package/dist/components/stepper.d.ts +60 -0
  201. package/dist/components/stepper.js +197 -0
  202. package/dist/components/switch.d.ts +9 -0
  203. package/dist/components/switch.js +26 -0
  204. package/dist/components/table-cell.d.ts +38 -0
  205. package/dist/components/table-cell.js +107 -0
  206. package/dist/components/table-context.d.ts +48 -0
  207. package/dist/components/table-context.js +69 -0
  208. package/dist/components/table-head.d.ts +42 -0
  209. package/dist/components/table-head.js +188 -0
  210. package/dist/components/table-tree.d.ts +96 -0
  211. package/dist/components/table-tree.js +137 -0
  212. package/dist/components/table.d.ts +78 -0
  213. package/dist/components/table.js +119 -0
  214. package/dist/components/tabs.d.ts +27 -0
  215. package/dist/components/tabs.js +79 -0
  216. package/dist/components/textarea.d.ts +3 -0
  217. package/dist/components/textarea.js +20 -0
  218. package/dist/components/theme.d.ts +41 -0
  219. package/dist/components/theme.js +60 -0
  220. package/dist/components/thinking.d.ts +68 -0
  221. package/dist/components/thinking.js +94 -0
  222. package/dist/components/toast.d.ts +39 -0
  223. package/dist/components/toast.js +110 -0
  224. package/dist/components/toolbar.d.ts +25 -0
  225. package/dist/components/toolbar.js +92 -0
  226. package/dist/components/tooltip.d.ts +23 -0
  227. package/dist/components/tooltip.js +27 -0
  228. package/dist/components/top-nav.d.ts +129 -0
  229. package/dist/components/top-nav.js +211 -0
  230. package/dist/components/truncate.d.ts +29 -0
  231. package/dist/components/truncate.js +138 -0
  232. package/dist/deprecated.d.ts +43 -0
  233. package/dist/deprecated.js +47 -0
  234. package/dist/index.d.ts +93 -0
  235. package/dist/index.js +93 -0
  236. package/dist/lib/cn.d.ts +5 -0
  237. package/dist/lib/cn.js +14 -0
  238. package/dist/lib/color.d.ts +136 -0
  239. package/dist/lib/color.js +307 -0
  240. package/dist/lib/contrast.d.ts +53 -0
  241. package/dist/lib/contrast.js +169 -0
  242. package/dist/lib/create-theme.d.ts +240 -0
  243. package/dist/lib/create-theme.js +461 -0
  244. package/dist/lib/harmony.d.ts +102 -0
  245. package/dist/lib/harmony.js +426 -0
  246. package/dist/lib/import-theme.d.ts +22 -0
  247. package/dist/lib/import-theme.js +221 -0
  248. package/dist/lib/overflow-scroll.d.ts +25 -0
  249. package/dist/lib/overflow-scroll.js +66 -0
  250. package/dist/lib/radio-toggle-render.d.ts +3 -0
  251. package/dist/lib/radio-toggle-render.js +9 -0
  252. package/dist/lib/reorder.d.ts +38 -0
  253. package/dist/lib/reorder.js +193 -0
  254. package/dist/lib/spacing.d.ts +101 -0
  255. package/dist/lib/spacing.js +118 -0
  256. package/dist/lib/tailwind-palette.d.ts +5 -0
  257. package/dist/lib/tailwind-palette.js +351 -0
  258. package/dist/lib/truncate.d.ts +18 -0
  259. package/dist/lib/truncate.js +69 -0
  260. package/dist/lib/use-single-value.d.ts +5 -0
  261. package/dist/lib/use-single-value.js +17 -0
  262. package/dist/styles.css +7988 -0
  263. package/mcp/server.mjs +87590 -0
  264. package/package.json +58 -5
  265. package/skills/continuum-fix-padding/SKILL.md +69 -0
  266. package/skills/continuum-fix-padding/scripts/compute.ts +155 -0
  267. package/skills/continuum-fix-padding/scripts/spacing.ts +189 -0
  268. package/skills/continuum-taste/SKILL.md +186 -0
  269. package/skills/continuum-taste/assets/tokens.css +647 -0
  270. package/skills/continuum-taste/references/charts.md +375 -0
  271. package/skills/continuum-taste/references/components.md +1369 -0
  272. package/skills/continuum-taste/references/foundations.md +539 -0
  273. package/skills/continuum-taste/references/media/canvas.md +75 -0
  274. package/skills/continuum-taste/references/media/css.md +61 -0
  275. package/skills/continuum-taste/references/media/react.md +161 -0
  276. package/skills/continuum-taste/references/method.md +87 -0
  277. package/skills/continuum-taste/references/pages.md +391 -0
  278. package/skills/continuum-taste/references/patterns.md +77 -0
  279. package/skills/continuum-taste/references/screens/agent.tsx +450 -0
  280. package/skills/continuum-taste/references/screens/analytics-overview.tsx +377 -0
  281. package/skills/continuum-taste/references/screens/checkout-funnel.tsx +193 -0
  282. package/skills/continuum-taste/references/screens/customer.tsx +475 -0
  283. package/skills/continuum-taste/references/screens/customers.tsx +608 -0
  284. package/skills/continuum-taste/references/screens/index.tsx +72 -0
  285. package/skills/continuum-taste/references/screens/invoice-editor.tsx +558 -0
  286. package/skills/continuum-taste/references/screens/new-customer.tsx +205 -0
  287. package/skills/continuum-taste/references/screens/overview.tsx +196 -0
  288. package/skills/continuum-taste/references/screens/report-generator.tsx +329 -0
  289. package/skills/continuum-taste/references/screens/risk-report.tsx +577 -0
  290. package/skills/continuum-taste/references/screens/sequence-editor.tsx +455 -0
  291. package/skills/continuum-taste/references/screens/settings.tsx +288 -0
  292. package/skills/continuum-taste/references/screens/shared.tsx +204 -0
  293. package/skills/continuum-taste/references/screens/sign-in.tsx +104 -0
  294. package/skills/continuum-taste/references/screens/workspace.tsx +596 -0
  295. package/skills/continuum-taste/references/theming.md +95 -0
  296. package/src/charts/area-chart.tsx +17 -0
  297. package/src/charts/bar-chart.tsx +15 -0
  298. package/src/charts/bubble-chart.tsx +913 -0
  299. package/src/charts/bullet-chart.tsx +419 -0
  300. package/src/charts/candlestick-chart.tsx +1242 -0
  301. package/src/charts/cartesian.tsx +1437 -0
  302. package/src/charts/chart-card.tsx +394 -0
  303. package/src/charts/donut-chart.tsx +299 -0
  304. package/src/charts/funnel-chart.tsx +373 -0
  305. package/src/charts/horizontal-bar-chart.tsx +991 -0
  306. package/src/charts/index.ts +76 -0
  307. package/src/charts/legend.tsx +59 -0
  308. package/src/charts/lib/candlestick-window.ts +42 -0
  309. package/src/charts/lib/color.ts +110 -0
  310. package/src/charts/lib/format.ts +42 -0
  311. package/src/charts/lib/frame.ts +6 -0
  312. package/src/charts/lib/layout.ts +78 -0
  313. package/src/charts/lib/path.ts +225 -0
  314. package/src/charts/lib/scale.ts +91 -0
  315. package/src/charts/lib/use-active.ts +87 -0
  316. package/src/charts/lib/use-size.ts +45 -0
  317. package/src/charts/line-chart.tsx +16 -0
  318. package/src/charts/radar-chart.tsx +485 -0
  319. package/src/charts/rose-chart.tsx +553 -0
  320. package/src/charts/sparkline.tsx +293 -0
  321. package/src/charts/tooltip.tsx +105 -0
  322. package/src/charts/treemap.tsx +271 -0
  323. package/src/charts/uptime-strip.tsx +469 -0
  324. package/src/components/accordion.tsx +136 -0
  325. package/src/components/activity-item.tsx +43 -0
  326. package/src/components/alert.tsx +135 -0
  327. package/src/components/assistant-answer.tsx +185 -0
  328. package/src/components/assistant-prompt.tsx +352 -0
  329. package/src/components/avatar.tsx +157 -0
  330. package/src/components/badge.tsx +55 -0
  331. package/src/components/bar-list.tsx +350 -0
  332. package/src/components/block-slider.tsx +189 -0
  333. package/src/components/branch-graph.tsx +580 -0
  334. package/src/components/breadcrumb.tsx +173 -0
  335. package/src/components/button.tsx +157 -0
  336. package/src/components/calendar.tsx +154 -0
  337. package/src/components/card.tsx +296 -0
  338. package/src/components/chat-attachment.tsx +255 -0
  339. package/src/components/chat-event.tsx +34 -0
  340. package/src/components/chat-message.tsx +332 -0
  341. package/src/components/chat-reference.tsx +100 -0
  342. package/src/components/chat-shared.ts +41 -0
  343. package/src/components/chat-suggestions.tsx +188 -0
  344. package/src/components/chat-thread.tsx +348 -0
  345. package/src/components/chat-typing.tsx +155 -0
  346. package/src/components/checkbox.tsx +83 -0
  347. package/src/components/checklist.tsx +146 -0
  348. package/src/components/chip.tsx +152 -0
  349. package/src/components/code-input.tsx +406 -0
  350. package/src/components/color-picker.tsx +1385 -0
  351. package/src/components/combobox.tsx +420 -0
  352. package/src/components/command-menu.tsx +405 -0
  353. package/src/components/copy-button.tsx +87 -0
  354. package/src/components/data-grid.tsx +965 -0
  355. package/src/components/date-picker.tsx +652 -0
  356. package/src/components/description-list.tsx +39 -0
  357. package/src/components/dialog.tsx +367 -0
  358. package/src/components/dock.tsx +192 -0
  359. package/src/components/drop-zone.tsx +283 -0
  360. package/src/components/dropdown-menu.tsx +323 -0
  361. package/src/components/editable-cell.tsx +219 -0
  362. package/src/components/empty-state.tsx +50 -0
  363. package/src/components/field.tsx +148 -0
  364. package/src/components/filter-condition.tsx +463 -0
  365. package/src/components/filter-menu.tsx +196 -0
  366. package/src/components/header-bar.tsx +220 -0
  367. package/src/components/hold-button.tsx +146 -0
  368. package/src/components/icon-tile.tsx +43 -0
  369. package/src/components/info-tip.tsx +87 -0
  370. package/src/components/input.tsx +136 -0
  371. package/src/components/kbd.tsx +17 -0
  372. package/src/components/menu-item.tsx +216 -0
  373. package/src/components/message-composer.tsx +458 -0
  374. package/src/components/nav-rail.tsx +235 -0
  375. package/src/components/notice.tsx +133 -0
  376. package/src/components/optimistic-undo.ts +68 -0
  377. package/src/components/option-row.tsx +54 -0
  378. package/src/components/page-content.tsx +44 -0
  379. package/src/components/pagination.tsx +182 -0
  380. package/src/components/popover.tsx +113 -0
  381. package/src/components/progress.tsx +222 -0
  382. package/src/components/radio-group.tsx +80 -0
  383. package/src/components/readonly-field.tsx +251 -0
  384. package/src/components/segmented-control.tsx +205 -0
  385. package/src/components/select.tsx +259 -0
  386. package/src/components/separator.tsx +30 -0
  387. package/src/components/setting-row.tsx +277 -0
  388. package/src/components/sidebar-switcher.tsx +134 -0
  389. package/src/components/sidebar.tsx +804 -0
  390. package/src/components/skeleton.tsx +57 -0
  391. package/src/components/slider.tsx +106 -0
  392. package/src/components/spinner.tsx +43 -0
  393. package/src/components/status-dot.tsx +100 -0
  394. package/src/components/stepper.tsx +459 -0
  395. package/src/components/switch.tsx +54 -0
  396. package/src/components/table-cell.tsx +239 -0
  397. package/src/components/table-context.ts +135 -0
  398. package/src/components/table-head.tsx +393 -0
  399. package/src/components/table-tree.tsx +357 -0
  400. package/src/components/table.tsx +295 -0
  401. package/src/components/tabs.tsx +191 -0
  402. package/src/components/textarea.tsx +44 -0
  403. package/src/components/theme.tsx +120 -0
  404. package/src/components/thinking.tsx +295 -0
  405. package/src/components/toast.tsx +308 -0
  406. package/src/components/toolbar.tsx +166 -0
  407. package/src/components/tooltip.tsx +84 -0
  408. package/src/components/top-nav.tsx +660 -0
  409. package/src/components/truncate.tsx +234 -0
  410. package/src/deprecated.ts +61 -0
  411. package/src/index.ts +184 -0
  412. package/src/lib/cn.ts +22 -0
  413. package/src/lib/color.ts +469 -0
  414. package/src/lib/contrast.ts +220 -0
  415. package/src/lib/create-theme.ts +659 -0
  416. package/src/lib/harmony.ts +609 -0
  417. package/src/lib/import-theme.ts +272 -0
  418. package/src/lib/overflow-scroll.tsx +108 -0
  419. package/src/lib/radio-toggle-render.tsx +15 -0
  420. package/src/lib/reorder.ts +222 -0
  421. package/src/lib/spacing.ts +189 -0
  422. package/src/lib/tailwind-palette.ts +355 -0
  423. package/src/lib/truncate.ts +79 -0
  424. package/src/lib/use-single-value.ts +23 -0
  425. package/src/styles/continuum.css +3 -0
  426. package/src/styles/theme.css +524 -0
  427. package/src/styles/tokens.css +647 -0
@@ -0,0 +1,580 @@
1
+ 'use client';
2
+
3
+ import { Tag } from 'lucide-react';
4
+ import {
5
+ type ComponentProps,
6
+ type KeyboardEvent,
7
+ type ReactNode,
8
+ useLayoutEffect,
9
+ useMemo,
10
+ useRef,
11
+ useState,
12
+ } from 'react';
13
+ import { cn } from '../lib/cn';
14
+
15
+ /* ---------- Data ---------- */
16
+
17
+ export type BranchGraphRef = {
18
+ name: string;
19
+ /** A branch moves with the work; a tag marks one commit for good. */
20
+ kind?: 'branch' | 'tag';
21
+ /** The branch checked out: its label is set in full ink. */
22
+ current?: boolean;
23
+ /** A remote's copy of a branch (`origin/main`): its label is muted. */
24
+ remote?: boolean;
25
+ };
26
+
27
+ export type BranchGraphCommit = {
28
+ id: string;
29
+ /** The commits this one was made on: none for the first, one for most, two or more for a merge. */
30
+ parents: readonly string[];
31
+ message: ReactNode;
32
+ author?: ReactNode;
33
+ time?: Date;
34
+ refs?: readonly BranchGraphRef[];
35
+ };
36
+
37
+ export type BranchGraphColumn = 'author' | 'hash' | 'time';
38
+
39
+ export type BranchGraphProps = Omit<ComponentProps<'div'>, 'onSelect'> & {
40
+ /** Names the list for a screen reader. */
41
+ 'aria-label': string;
42
+ /**
43
+ * Newest first, every commit above the commits it was made on, as `git log --topo-order`
44
+ * gives them. A parent that is not in the list (history cut short) keeps its lane running
45
+ * off the foot.
46
+ */
47
+ commits: readonly BranchGraphCommit[];
48
+ /** 34 rows for a long log, 41 for a short one read closely. */
49
+ density?: 'compact' | 'default';
50
+ /** The columns after the message, in this order. */
51
+ columns?: readonly BranchGraphColumn[];
52
+ /** The selected commit's id. With `onSelectedChange`, rows are picked by click or keyboard. */
53
+ selected?: string | null;
54
+ onSelectedChange?: (id: string) => void;
55
+ /** Writes a commit's time; "12 Nov, 14:03" unless given. */
56
+ formatTime?: (time: Date) => ReactNode;
57
+ /** How many refs a row shows before it folds the rest into "+N". */
58
+ maxRefs?: number;
59
+ /**
60
+ * The branch everything else is made from: its line keeps the leftmost lane, in neutral ink,
61
+ * and the branches take the colours beside it. `main` or `master` when a commit carries one;
62
+ * `null` for none.
63
+ */
64
+ trunk?: string | null;
65
+ /**
66
+ * A hairline frame on the surface, for the history as the page's list; off where a card or a
67
+ * sheet already frames it.
68
+ */
69
+ framed?: boolean;
70
+ };
71
+
72
+ /* ---------- Lanes ---------- */
73
+
74
+ type Edge = { lane: number };
75
+
76
+ type RowGraph = {
77
+ lane: number;
78
+ /** Lanes running past this commit, top to foot. */
79
+ through: number[];
80
+ /** A child above runs down into the dot. */
81
+ top: boolean;
82
+ /** The first parent runs on down from the dot. */
83
+ bottom: boolean;
84
+ /** Lanes coming down that end here, turning in to the dot along its row: branches made from it. */
85
+ joins: Edge[];
86
+ /** Lanes leaving the dot along its row and turning down: the other parents of a merge. */
87
+ splits: Edge[];
88
+ merge: boolean;
89
+ };
90
+
91
+ /** Holds the leftmost lane for the trunk until its first commit comes. */
92
+ const RESERVED = '\u0000trunk';
93
+
94
+ /** The trunk's commits: its branch's commit and that commit's first parents, down the list. */
95
+ const trunkOf = (commits: readonly BranchGraphCommit[], trunk: string | null) => {
96
+ const ids = new Set<string>();
97
+ if (!trunk) return ids;
98
+ const byId = new Map(commits.map(commit => [commit.id, commit]));
99
+ let at = commits.find(commit =>
100
+ commit.refs?.some(ref => ref.name === trunk && ref.kind !== 'tag'),
101
+ );
102
+ while (at && !ids.has(at.id)) {
103
+ ids.add(at.id);
104
+ const first = at.parents[0];
105
+ at = first ? byId.get(first) : undefined;
106
+ }
107
+ return ids;
108
+ };
109
+
110
+ /**
111
+ * Gives each commit a lane. A lane holds the commit it is waiting for; a commit takes the leftmost
112
+ * lane waiting for it (or the first free one, at a branch tip), its first parent carries the lane on,
113
+ * and every other parent of a merge takes the lane already waiting for it or a free one. The trunk's
114
+ * commits keep the leftmost lane, so the line everything branches from runs straight down the edge.
115
+ */
116
+ export const layoutBranchGraph = (
117
+ commits: readonly BranchGraphCommit[],
118
+ trunk: string | null = null,
119
+ ) => {
120
+ const onTrunk = trunkOf(commits, trunk);
121
+ const lanes: (string | null)[] = onTrunk.size > 0 ? [RESERVED] : [];
122
+ let width = 1;
123
+
124
+ const freeLane = (taken: readonly number[]) => {
125
+ const index = lanes.findIndex((id, i) => id === null && !taken.includes(i));
126
+ if (index >= 0) return index;
127
+ lanes.push(null);
128
+ return lanes.length - 1;
129
+ };
130
+
131
+ const rows = commits.map((commit): RowGraph => {
132
+ const waiting = lanes.flatMap((id, i) => (id === commit.id ? [i] : []));
133
+ const lane = onTrunk.has(commit.id) ? 0 : (waiting[0] ?? freeLane([]));
134
+ const before = [...lanes];
135
+ const top = lanes[lane] === commit.id;
136
+ const joining = waiting.filter(index => index !== lane);
137
+
138
+ const [first, ...rest] = commit.parents;
139
+ lanes[lane] = first ?? null;
140
+
141
+ const splits: Edge[] = [];
142
+ for (const parent of rest) {
143
+ const found = lanes.indexOf(parent);
144
+ if (found === lane) continue;
145
+ // Not in a lane freed on this very row, so a lane coming in and one going out never share a stretch.
146
+ const target =
147
+ found >= 0
148
+ ? found
149
+ : onTrunk.has(parent) && lanes[0] === RESERVED
150
+ ? 0
151
+ : freeLane([lane, ...joining]);
152
+ lanes[target] = parent;
153
+ splits.push({ lane: target });
154
+ }
155
+ for (const index of joining) lanes[index] = null;
156
+
157
+ const through = before.flatMap((id, i) =>
158
+ id !== null && id !== RESERVED && i !== lane && !joining.includes(i) ? [i] : [],
159
+ );
160
+
161
+ while (lanes.length > 0 && lanes[lanes.length - 1] === null) lanes.pop();
162
+ width = Math.max(width, before.length, lanes.length, lane + 1);
163
+
164
+ return {
165
+ lane,
166
+ through,
167
+ top,
168
+ bottom: first != null,
169
+ joins: joining.map(index => ({ lane: index })),
170
+ splits,
171
+ merge: commit.parents.length > 1,
172
+ };
173
+ });
174
+
175
+ return { rows, width };
176
+ };
177
+
178
+ /* ---------- Drawing ---------- */
179
+
180
+ /** From the frame's edge to the first lane's centre. */
181
+ const INSET = 16;
182
+ /** Between two lanes' centres. */
183
+ const PITCH = 16;
184
+ /** The corner where a line turns from its row into a lane. */
185
+ const TURN = 6;
186
+ const DOT = 4;
187
+ /** The break a line along a row leaves where it crosses a lane. */
188
+ const BREAK = 3;
189
+ const STROKE = 1.5;
190
+
191
+ const LANE_COLORS = [
192
+ 'var(--color-neutral-400)',
193
+ 'var(--color-chart-series-1)',
194
+ 'var(--color-chart-series-2)',
195
+ 'var(--color-chart-series-3)',
196
+ 'var(--color-chart-series-4)',
197
+ ];
198
+
199
+ /**
200
+ * A lane's colour, by its place: the leftmost lane, where the line the log was read from runs, is
201
+ * the neutral ink, and the lanes beside it take the series colours in turn.
202
+ */
203
+ const laneColor = (lane: number) =>
204
+ lane === 0 ? LANE_COLORS[0] : LANE_COLORS[1 + ((lane - 1) % (LANE_COLORS.length - 1))];
205
+
206
+ const laneX = (lane: number) => INSET + lane * PITCH;
207
+
208
+ /** A line along the dot's row from `from` to `to`, broken where it crosses a lane running past. */
209
+ const rowLine = (
210
+ from: number,
211
+ to: number,
212
+ cy: number,
213
+ crossing: readonly number[],
214
+ move = true,
215
+ ) => {
216
+ const dir = Math.sign(to - from);
217
+ const stops = crossing
218
+ .map(laneX)
219
+ .filter(x => (x - from) * dir > 0 && (to - x) * dir > 0)
220
+ .sort((a, b) => (a - b) * dir);
221
+ let d = move ? `M${from} ${cy}` : '';
222
+ for (const x of stops) d += ` H${x - dir * BREAK} M${x + dir * BREAK} ${cy}`;
223
+ return `${d} H${to}`;
224
+ };
225
+
226
+ const RowGraphic = ({
227
+ row,
228
+ width,
229
+ height,
230
+ selected,
231
+ }: {
232
+ row: RowGraph;
233
+ width: number;
234
+ height: number;
235
+ selected: boolean;
236
+ }) => {
237
+ const cy = height / 2;
238
+ const x = laneX(row.lane);
239
+ const ink = laneColor(row.lane);
240
+ const line = { fill: 'none', strokeWidth: STROKE, strokeLinecap: 'round' } as const;
241
+
242
+ return (
243
+ <svg
244
+ aria-hidden="true"
245
+ className="block shrink-0 overflow-visible"
246
+ height={height}
247
+ width={width}
248
+ >
249
+ {row.joins.map(({ lane }) => {
250
+ const lx = laneX(lane);
251
+ const dir = Math.sign(x - lx);
252
+ return (
253
+ <path
254
+ {...line}
255
+ d={`M${lx} 0 V${cy - TURN} Q${lx} ${cy} ${lx + dir * TURN} ${cy}${rowLine(lx + dir * TURN, x - dir * DOT, cy, row.through, false)}`}
256
+ key={`j${lane}`}
257
+ stroke={laneColor(lane)}
258
+ />
259
+ );
260
+ })}
261
+ {row.splits.map(({ lane }) => {
262
+ const lx = laneX(lane);
263
+ const dir = Math.sign(lx - x);
264
+ return (
265
+ <path
266
+ {...line}
267
+ d={`${rowLine(x + dir * DOT, lx - dir * TURN, cy, row.through)} Q${lx} ${cy} ${lx} ${cy + TURN} V${height}`}
268
+ key={`s${lane}`}
269
+ stroke={laneColor(lane)}
270
+ />
271
+ );
272
+ })}
273
+ {row.through.map(lane => (
274
+ <path
275
+ {...line}
276
+ d={`M${laneX(lane)} 0 V${height}`}
277
+ key={`t${lane}`}
278
+ stroke={laneColor(lane)}
279
+ />
280
+ ))}
281
+ {row.top && <path {...line} d={`M${x} 0 V${cy - DOT}`} stroke={ink} />}
282
+ {row.bottom && <path {...line} d={`M${x} ${cy + DOT} V${height}`} stroke={ink} />}
283
+ {selected && (
284
+ <circle
285
+ cx={x}
286
+ cy={cy}
287
+ fill={`color-mix(in oklab, ${ink} 22%, transparent)`}
288
+ r={DOT + 4}
289
+ />
290
+ )}
291
+ {row.merge ? (
292
+ <circle
293
+ cx={x}
294
+ cy={cy}
295
+ fill="none"
296
+ r={DOT - STROKE / 2}
297
+ stroke={ink}
298
+ strokeWidth={STROKE}
299
+ />
300
+ ) : (
301
+ <circle cx={x} cy={cy} fill={ink} r={DOT} />
302
+ )}
303
+ </svg>
304
+ );
305
+ };
306
+
307
+ /* ---------- Refs ---------- */
308
+
309
+ /** The refs a row has no room for, as a count; their names in the native tooltip and to a screen reader. */
310
+ const FoldedRefs = ({
311
+ refs,
312
+ className,
313
+ }: {
314
+ refs: readonly BranchGraphRef[];
315
+ className?: string;
316
+ }) =>
317
+ refs.length > 0 ? (
318
+ <span
319
+ className={cn(
320
+ 'inline-flex h-5 shrink-0 items-center rounded-chip px-1 font-medium text-neutral-600 text-xxs tabular-nums',
321
+ className,
322
+ )}
323
+ title={refs.map(ref => ref.name).join(', ')}
324
+ >
325
+ +{refs.length}
326
+ <span className="sr-only">: {refs.map(ref => ref.name).join(', ')}</span>
327
+ </span>
328
+ ) : null;
329
+
330
+ const RefLabel = ({
331
+ label,
332
+ lane,
333
+ className,
334
+ }: {
335
+ label: BranchGraphRef;
336
+ lane: number;
337
+ className?: string;
338
+ }) => (
339
+ <span
340
+ className={cn(
341
+ 'inline-flex h-5 min-w-0 max-w-40 shrink items-center gap-1 rounded-chip bg-neutral-950/5 px-1.5 font-medium text-xxs',
342
+ label.current
343
+ ? 'text-neutral-950'
344
+ : label.remote
345
+ ? 'text-neutral-600'
346
+ : 'text-neutral-800',
347
+ label.current && 'shadow-[inset_0_0_0_1px_var(--color-neutral-300)]',
348
+ className,
349
+ )}
350
+ data-slot="branch-graph-ref"
351
+ >
352
+ {label.kind === 'tag' ? (
353
+ <Tag className="size-3 shrink-0 text-neutral-600" strokeWidth={2} />
354
+ ) : (
355
+ <span
356
+ className="size-1.5 shrink-0 rounded-full"
357
+ style={{ background: laneColor(lane) }}
358
+ />
359
+ )}
360
+ <span className="truncate">{label.name}</span>
361
+ </span>
362
+ );
363
+
364
+ /* ---------- The list ---------- */
365
+
366
+ const writeTime = (time: Date) =>
367
+ `${time.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })}, ${time.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' })}`;
368
+
369
+ const NOMINAL_HEIGHT = { compact: 34, default: 41 } as const;
370
+
371
+ /**
372
+ * A commit history: a row per commit, newest first, and beside the rows the lanes the commits sit on.
373
+ * A branch leaves the commit it was made from along that commit's row and turns up into a lane of its
374
+ * own; a merge reaches out along its row to the branch it took in. Lines only run down a lane or along
375
+ * a dot's row, so a busy history still reads as rows.
376
+ */
377
+ export const BranchGraph = ({
378
+ commits,
379
+ density = 'compact',
380
+ columns = ['author', 'hash', 'time'],
381
+ selected = null,
382
+ onSelectedChange,
383
+ formatTime = writeTime,
384
+ maxRefs = 2,
385
+ trunk,
386
+ framed = true,
387
+ className,
388
+ style,
389
+ ...props
390
+ }: BranchGraphProps) => {
391
+ const trunkName =
392
+ trunk === undefined
393
+ ? (commits
394
+ .flatMap(commit => commit.refs ?? [])
395
+ .find(
396
+ ref =>
397
+ !ref.remote &&
398
+ ref.kind !== 'tag' &&
399
+ (ref.name === 'main' || ref.name === 'master'),
400
+ )?.name ?? null)
401
+ : trunk;
402
+ const { rows, width } = useMemo(
403
+ () => layoutBranchGraph(commits, trunkName),
404
+ [commits, trunkName],
405
+ );
406
+ const graphWidth = laneX(width - 1) + DOT;
407
+ const interactive = onSelectedChange != null;
408
+
409
+ // The row's height comes from the theme's height scale, so it is read off the first row.
410
+ const firstRow = useRef<HTMLDivElement>(null);
411
+ const [height, setHeight] = useState<number>(NOMINAL_HEIGHT[density]);
412
+ useLayoutEffect(() => {
413
+ const node = firstRow.current;
414
+ if (!node) return;
415
+ const read = () =>
416
+ setHeight(node.getBoundingClientRect().height || NOMINAL_HEIGHT[density]);
417
+ read();
418
+ const observer = new ResizeObserver(read);
419
+ observer.observe(node);
420
+ return () => observer.disconnect();
421
+ }, [density]);
422
+
423
+ const listRef = useRef<HTMLDivElement>(null);
424
+ const [focusId, setFocusId] = useState<string | null>(null);
425
+ const tabStop = focusId ?? selected ?? commits[0]?.id;
426
+
427
+ const move = (event: KeyboardEvent<HTMLDivElement>, index: number) => {
428
+ const last = commits.length - 1;
429
+ const to =
430
+ event.key === 'ArrowDown'
431
+ ? Math.min(index + 1, last)
432
+ : event.key === 'ArrowUp'
433
+ ? Math.max(index - 1, 0)
434
+ : event.key === 'Home'
435
+ ? 0
436
+ : event.key === 'End'
437
+ ? last
438
+ : null;
439
+ if (to !== null) {
440
+ event.preventDefault();
441
+ const target = commits[to];
442
+ if (!target) return;
443
+ setFocusId(target.id);
444
+ listRef.current
445
+ ?.querySelector<HTMLElement>(`[data-index="${to}"]`)
446
+ ?.focus({ preventScroll: false });
447
+ return;
448
+ }
449
+ if (event.key === 'Enter' || event.key === ' ') {
450
+ event.preventDefault();
451
+ const commit = commits[index];
452
+ if (commit) onSelectedChange?.(commit.id);
453
+ }
454
+ };
455
+
456
+ return (
457
+ // The frame is its own container, so the list answers the room it is given: under 560 the
458
+ // author and the hash go and the message keeps its line.
459
+ <div
460
+ className={cn(
461
+ '@container/branch-graph flex w-full flex-col overflow-hidden',
462
+ framed && 'rounded-control border border-neutral-200 bg-neutral-50 shadow-card',
463
+ className,
464
+ )}
465
+ data-slot="branch-graph"
466
+ style={style}
467
+ >
468
+ <div
469
+ className="grid min-h-0 w-full flex-1 content-start overflow-y-auto overflow-x-hidden text-xs"
470
+ data-slot="branch-graph-list"
471
+ ref={listRef}
472
+ role={interactive ? 'listbox' : 'list'}
473
+ style={{
474
+ gridTemplateColumns: [
475
+ `${graphWidth}px`,
476
+ 'minmax(0, 1fr)',
477
+ ...columns.map(() => 'auto'),
478
+ ].join(' '),
479
+ }}
480
+ {...props}
481
+ >
482
+ {commits.map((commit, index) => {
483
+ const row = rows[index] as RowGraph;
484
+ const isSelected = selected === commit.id;
485
+ const refs = commit.refs ?? [];
486
+ const shown = refs.slice(0, maxRefs);
487
+ const folded = refs.slice(maxRefs);
488
+ return (
489
+ <div
490
+ {...(interactive
491
+ ? { role: 'option', 'aria-selected': isSelected }
492
+ : { role: 'listitem' })}
493
+ className={cn(
494
+ 'col-span-full grid grid-cols-subgrid items-center pr-4',
495
+ density === 'compact' ? 'h-control' : 'h-table-row',
496
+ interactive &&
497
+ 'cursor-default outline-none transition-colors duration-150 focus-visible:outline-2 focus-visible:outline-focus focus-visible:outline-solid focus-visible:-outline-offset-2',
498
+ interactive && !isSelected && 'hover:bg-neutral-950/3',
499
+ isSelected && 'bg-selected',
500
+ )}
501
+ data-index={index}
502
+ data-selected={isSelected || undefined}
503
+ data-slot="branch-graph-row"
504
+ key={commit.id}
505
+ onClick={interactive ? () => onSelectedChange(commit.id) : undefined}
506
+ onFocus={interactive ? () => setFocusId(commit.id) : undefined}
507
+ onKeyDown={interactive ? event => move(event, index) : undefined}
508
+ ref={index === 0 ? firstRow : undefined}
509
+ tabIndex={interactive ? (tabStop === commit.id ? 0 : -1) : undefined}
510
+ >
511
+ <RowGraphic
512
+ height={height}
513
+ row={row}
514
+ selected={isSelected}
515
+ width={graphWidth}
516
+ />
517
+ <span className="flex min-w-0 items-center gap-2 pl-4">
518
+ {shown.length > 0 && (
519
+ <span className="flex min-w-0 @max-[560px]/branch-graph:max-w-[45%] max-w-[60%] shrink-0 items-center gap-1">
520
+ {shown.map((ref, at) => (
521
+ <RefLabel
522
+ // A narrow list keeps the first ref only, so the message still reads.
523
+ className={cn(
524
+ at > 0 && '@max-[560px]/branch-graph:hidden',
525
+ )}
526
+ key={`${ref.kind}:${ref.name}`}
527
+ label={ref}
528
+ lane={row.lane}
529
+ />
530
+ ))}
531
+ <FoldedRefs
532
+ className="@max-[560px]/branch-graph:hidden"
533
+ refs={folded}
534
+ />
535
+ <FoldedRefs
536
+ className="@min-[560px]/branch-graph:hidden"
537
+ refs={refs.slice(1)}
538
+ />
539
+ </span>
540
+ )}
541
+ <span
542
+ className={cn(
543
+ 'min-w-0 truncate',
544
+ row.merge ? 'text-neutral-600' : 'text-neutral-900',
545
+ )}
546
+ >
547
+ {commit.message}
548
+ </span>
549
+ </span>
550
+ {columns.map(column =>
551
+ column === 'author' ? (
552
+ <span
553
+ className="@max-[560px]/branch-graph:hidden max-w-40 truncate pl-4 text-neutral-700"
554
+ key={column}
555
+ >
556
+ {commit.author}
557
+ </span>
558
+ ) : column === 'hash' ? (
559
+ <span
560
+ className="@max-[560px]/branch-graph:hidden pl-4 font-mono text-neutral-600 text-xxs"
561
+ key={column}
562
+ >
563
+ {commit.id.slice(0, 7)}
564
+ </span>
565
+ ) : (
566
+ <span
567
+ className="whitespace-nowrap pl-4 text-right text-neutral-600 tabular-nums"
568
+ key={column}
569
+ >
570
+ {commit.time ? formatTime(commit.time) : null}
571
+ </span>
572
+ ),
573
+ )}
574
+ </div>
575
+ );
576
+ })}
577
+ </div>
578
+ </div>
579
+ );
580
+ };