@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,65 @@
1
+ import { useRender } from '@base-ui/react/use-render';
2
+ import { type VariantProps } from 'class-variance-authority';
3
+ import { type ComponentProps, type ReactNode } from 'react';
4
+ export declare const barListRowVariants: (props?: ({
5
+ interactive?: boolean | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ export declare const barListFillVariants: (props?: ({
8
+ tone?: "neutral" | "chart" | null | undefined;
9
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
10
+ type ShowMoreState = {
11
+ expanded: boolean;
12
+ /** Rows held back by `limit`; zero once expanded. */
13
+ hiddenCount: number;
14
+ total: number;
15
+ toggle: () => void;
16
+ };
17
+ export type BarListProps = Omit<ComponentProps<'div'>, 'title'> & VariantProps<typeof barListFillVariants> & {
18
+ /** Left of the heading row, e.g. "Top pages". Also names the list for screen readers. */
19
+ title?: ReactNode;
20
+ /** Right of the heading row, over the values, e.g. "Visitors". */
21
+ valueLabel?: ReactNode;
22
+ /** The value a full bar stands for. Defaults to the largest item value, hidden rows included. */
23
+ max?: number;
24
+ /** Rows shown before "Show more"; the rest wait until the list is expanded. */
25
+ limit?: number;
26
+ expanded?: boolean;
27
+ defaultExpanded?: boolean;
28
+ onExpandedChange?: (expanded: boolean) => void;
29
+ /**
30
+ * Replaces the default show more toggle: a node, or a function of the list's state, e.g. to
31
+ * open the full list in a dialog instead of expanding in place.
32
+ */
33
+ footer?: ReactNode | ((state: ShowMoreState) => ReactNode);
34
+ /** Shown in place of the rows when there are none. */
35
+ empty?: ReactNode;
36
+ };
37
+ /**
38
+ * Ranked rows with a bar behind each label, sized to its value, under an optional heading row; the
39
+ * analytics card's top pages, countries, sources and devices.
40
+ */
41
+ export declare const BarList: ({ title, valueLabel, max, limit, expanded: expandedProp, defaultExpanded, onExpandedChange, footer, empty, tone, className, children, ...props }: BarListProps) => import("react").JSX.Element;
42
+ export type BarListItemProps = Omit<useRender.ComponentProps<'div'>, 'children'> & {
43
+ value: number;
44
+ /** The label; truncates rather than wraps. */
45
+ children?: ReactNode;
46
+ /** A 16px icon, flag or favicon before the label. */
47
+ icon?: ReactNode;
48
+ /** Shown in place of `value`, e.g. "1.2k" or "33%". */
49
+ displayValue?: ReactNode;
50
+ /** Makes the row a link. */
51
+ href?: string;
52
+ /** Makes the row a button, e.g. to filter the page by this item. */
53
+ onClick?: ComponentProps<'button'>['onClick'];
54
+ disabled?: boolean;
55
+ /** Classes for the list item that wraps the row. */
56
+ itemClassName?: string;
57
+ /**
58
+ * Where a long text label cuts. `end` by default; `middle` for paths and URLs, whose last part
59
+ * tells the rows apart (`/docs/…/webhooks`).
60
+ */
61
+ truncate?: 'end' | 'middle';
62
+ };
63
+ /** One ranked row: icon, label and value over a bar sized to the value. Interactive with `href`, `onClick` or `render`. */
64
+ export declare const BarListItem: ({ value, icon, displayValue, href, onClick, disabled, render, ref, className, itemClassName, truncate, children, ...props }: BarListItemProps) => import("react").JSX.Element;
65
+ export {};
@@ -0,0 +1,119 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { mergeProps } from '@base-ui/react/merge-props';
4
+ import { useRender } from '@base-ui/react/use-render';
5
+ import { cva } from 'class-variance-authority';
6
+ import { Children, createContext, isValidElement, useContext, useId, useState, } from 'react';
7
+ import { cn } from '../lib/cn.js';
8
+ import { focusRing } from './button.js';
9
+ import { Truncate } from './truncate.js';
10
+ const BarListContext = createContext({ max: 0, tone: 'neutral' });
11
+ // A fixed locale: the runtime's own would let a server render "1,234" and the browser hydrate "1.234".
12
+ const numberFormat = new Intl.NumberFormat('en-GB');
13
+ export const barListRowVariants = cva([
14
+ // The control row's 34px, the height of a nav item and a button.
15
+ 'relative isolate flex h-control w-full min-w-0 items-center gap-2 overflow-hidden rounded-item text-left text-xs',
16
+ 'bg-neutral-950/3 px-2.5',
17
+ '[&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0',
18
+ ], {
19
+ variants: {
20
+ interactive: {
21
+ false: '',
22
+ true: [
23
+ 'cursor-pointer transition-[background-color,color] duration-150 hover:bg-neutral-950/5',
24
+ // A row used as a filter toggle: the wash alone barely moves over the track, so a
25
+ // pressed row takes the coloured selection and a medium label.
26
+ 'aria-pressed:bg-tint aria-pressed:hover:bg-tint aria-pressed:**:data-[slot=bar-list-label]:font-medium aria-pressed:**:data-[slot=bar-list-label]:text-tint-fg',
27
+ 'aria-disabled:pointer-events-none aria-disabled:opacity-50 disabled:pointer-events-none disabled:opacity-50',
28
+ focusRing,
29
+ ],
30
+ },
31
+ },
32
+ defaultVariants: { interactive: false },
33
+ });
34
+ export const barListFillVariants = cva(
35
+ // The fill animates its width only: it is absolutely placed, so nothing beside it reflows.
36
+ 'pointer-events-none absolute inset-y-0 left-0 -z-10 rounded-item transition-[width] duration-200 ease-out-strong motion-reduce:transition-none', {
37
+ variants: {
38
+ tone: {
39
+ // Translucent neutral-950 rather than a ramp step, so the bar reads on any surface and in dark mode.
40
+ neutral: 'bg-neutral-950/7',
41
+ chart: 'bg-chart-1/20',
42
+ },
43
+ },
44
+ defaultVariants: { tone: 'neutral' },
45
+ });
46
+ const itemValue = (child) => isValidElement(child) && typeof child.props.value === 'number'
47
+ ? child.props.value
48
+ : 0;
49
+ /**
50
+ * Ranked rows with a bar behind each label, sized to its value, under an optional heading row; the
51
+ * analytics card's top pages, countries, sources and devices.
52
+ */
53
+ export const BarList = ({ title, valueLabel, max, limit, expanded: expandedProp, defaultExpanded = false, onExpandedChange, footer, empty = 'No data yet', tone = 'neutral', className, children, ...props }) => {
54
+ const id = useId();
55
+ const titleId = `${id}-title`;
56
+ const listId = `${id}-list`;
57
+ const [uncontrolled, setUncontrolled] = useState(defaultExpanded);
58
+ const expanded = expandedProp ?? uncontrolled;
59
+ const items = Children.toArray(children).filter(isValidElement);
60
+ // Scale against every item, not just the visible ones, so the bars keep their length on expand.
61
+ const scale = max ?? Math.max(0, ...items.map(itemValue));
62
+ const canCollapse = limit !== undefined && items.length > limit;
63
+ const visible = canCollapse && !expanded ? items.slice(0, limit) : items;
64
+ const hiddenCount = items.length - visible.length;
65
+ const toggle = () => {
66
+ const next = !expanded;
67
+ if (expandedProp === undefined)
68
+ setUncontrolled(next);
69
+ onExpandedChange?.(next);
70
+ };
71
+ const footerNode = typeof footer === 'function'
72
+ ? footer({ expanded, hiddenCount, total: items.length, toggle })
73
+ : (footer ??
74
+ (canCollapse && (_jsx("button", { "aria-controls": listId, "aria-expanded": expanded, className: cn('h-segment cursor-pointer self-start rounded-item px-2 font-medium text-neutral-600 text-xs transition-[background-color,color] duration-150 hover:bg-neutral-950/5 hover:text-neutral-800', focusRing), "data-slot": "bar-list-more", onClick: toggle, type: "button", children: expanded ? 'Show less' : `Show ${hiddenCount} more` }))));
75
+ const headed = Boolean(title || valueLabel);
76
+ return (_jsxs("div", { className: cn('flex min-w-0 flex-col gap-[var(--bar-list-gap,calc(var(--spacing)*2))]',
77
+ /*
78
+ * With a heading, the list is a titled card's head and stage (theme.css): framed, the
79
+ * heading stands on the card's frame and the rows on its stage, with no gap between,
80
+ * the stage filling the card when a row of cards stretches it. Only as a card's own
81
+ * child, though: anywhere else the list is no card's content, so it turns the theme's
82
+ * switch off for itself.
83
+ */
84
+ headed &&
85
+ '[--bar-list-gap:var(--cards-framed)_0px] [--cards-framed:initial] [.card-frame>&]:flex-1 [.card-frame>&]:[--cards-framed:inherit]', className), "data-expanded": expanded || undefined, "data-slot": "bar-list", ...props, children: [headed && (
86
+ // Same side padding as a row, so the heading sits over the labels and the values.
87
+ _jsxs("div", { className: "card-head flex items-baseline justify-between gap-3 text-xs [--card-head-pad:0_calc(var(--spacing)*2.5)]", "data-slot": "bar-list-header", children: [_jsx("span", { className: "min-w-0 truncate font-normal text-neutral-600", "data-slot": "bar-list-title", id: titleId, children: title }), valueLabel && (
88
+ // Truncates as the title does, rather than pushing out of a narrow card.
89
+ _jsx("span", { className: "min-w-0 truncate font-normal text-neutral-600", "data-slot": "bar-list-value-label", children: valueLabel }))] })), _jsxs("div", { className: cn('flex min-w-0 flex-col gap-2', headed && 'card-stage flex-1'), "data-slot": "bar-list-body", children: [items.length === 0 ? (_jsx("p", { className: "flex h-control items-center rounded-item bg-neutral-950/3 px-2.5 text-neutral-600 text-xs", "data-slot": "bar-list-empty", children: empty })) : (_jsx(BarListContext.Provider, { value: { max: scale, tone: tone ?? 'neutral' }, children: _jsx("ul", { "aria-labelledby": title ? titleId : undefined, className: "flex flex-col gap-1.5", "data-slot": "bar-list-items", id: listId, children: visible }) })), footerNode && (_jsx("div", { className: "flex flex-col", "data-slot": "bar-list-footer", children: footerNode }))] })] }));
90
+ };
91
+ /** One ranked row: icon, label and value over a bar sized to the value. Interactive with `href`, `onClick` or `render`. */
92
+ export const BarListItem = ({ value, icon, displayValue, href, onClick, disabled, render, ref, className, itemClassName, truncate = 'end', children, ...props }) => {
93
+ const { max, tone } = useContext(BarListContext);
94
+ const share = max > 0 ? Math.min(Math.max(value / max, 0), 1) : 0;
95
+ const interactive = Boolean(href || onClick || render);
96
+ // A link or a button unless the caller passes its own element (a router link). A disabled link
97
+ // drops its href, which also takes it out of the tab order.
98
+ const element = render ??
99
+ (href ? (
100
+ // biome-ignore lint/a11y/useAnchorContent: useRender fills the anchor with the row's content
101
+ _jsx("a", { href: disabled ? undefined : href })) : onClick ? (_jsx("button", { type: "button" })) : undefined);
102
+ const row = useRender({
103
+ defaultTagName: 'div',
104
+ render: element,
105
+ ref,
106
+ state: { slot: 'bar-list-row' },
107
+ props: mergeProps({
108
+ className: cn(barListRowVariants({ interactive }), className),
109
+ onClick: disabled ? undefined : onClick,
110
+ // A link cannot be disabled natively, so aria-disabled keeps it out of reach for both.
111
+ 'aria-disabled': interactive && disabled ? true : undefined,
112
+ ...(!render && !href && onClick ? { disabled } : {}),
113
+ children: (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: barListFillVariants({ tone }), "data-slot": "bar-list-fill",
114
+ // A sliver for any value above zero, so a row of 1 still shows it was counted.
115
+ style: { width: share > 0 ? `max(${share * 100}%, 4px)` : 0 } }), icon && (_jsx("span", { className: "flex size-4 shrink-0 items-center justify-center overflow-hidden text-neutral-600 [&_img]:size-4 [&_img]:object-cover", "data-slot": "bar-list-icon", children: icon })), _jsx("span", { className: "min-w-0 flex-1 truncate font-normal text-neutral-950", "data-slot": "bar-list-label", children: truncate === 'middle' && typeof children === 'string' ? (_jsx(Truncate, { at: "middle", children: children })) : (children) }), _jsx("span", { className: "shrink-0 font-normal text-neutral-600 tabular-nums", "data-slot": "bar-list-value", children: displayValue ?? numberFormat.format(value) })] })),
116
+ }, props),
117
+ });
118
+ return (_jsx("li", { className: cn('flex min-w-0', itemClassName), "data-slot": "bar-list-item", children: row }));
119
+ };
@@ -0,0 +1,43 @@
1
+ import { Slider as SliderPrimitive } from '@base-ui/react/slider';
2
+ import { type ReactNode } from 'react';
3
+ import { type WithClassName } from '../lib/cn.js';
4
+ /** The box height, and a grip line that keeps the same share of it. */
5
+ declare const sizes: {
6
+ readonly sm: {
7
+ readonly box: "h-control";
8
+ readonly grip: "after:h-3.5";
9
+ };
10
+ readonly md: {
11
+ readonly box: "h-control-lg";
12
+ readonly grip: "after:h-4";
13
+ };
14
+ readonly lg: {
15
+ readonly box: "h-control-xl";
16
+ readonly grip: "after:h-5";
17
+ };
18
+ };
19
+ type BlockSliderProps = Omit<WithClassName<SliderPrimitive.Root.Props<readonly number[]>>, 'value' | 'defaultValue' | 'onValueChange' | 'onValueCommitted'> & {
20
+ /** One entry per grip, so a range is two values. */
21
+ value?: readonly number[];
22
+ defaultValue?: readonly number[];
23
+ onValueChange?: (value: number[], details: SliderPrimitive.Root.ChangeEventDetails) => void;
24
+ onValueCommitted?: (value: number[], details: SliderPrimitive.Root.CommitEventDetails) => void;
25
+ /** Written inside the box on the left, with the value on the right. Names the slider too. */
26
+ label?: ReactNode;
27
+ /** How the value reads on the right; a range joins its ends with a dash by default. */
28
+ format?: (value: number[]) => ReactNode;
29
+ /** sm 34px and md 38px sit in a row of controls; lg 48px stands on its own. */
30
+ size?: keyof typeof sizes;
31
+ /** A divider every this many units, counted from min, to show what the value lines up with. */
32
+ marks?: number;
33
+ /** Moves the value from divider to divider only, by dragging and by keyboard alike. */
34
+ snap?: boolean;
35
+ };
36
+ /**
37
+ * A slider as a box (34, 38 or 48px): a hairline container, 2px of padding, and a
38
+ * grey fill with nested corners growing inside it. The whole box takes the
39
+ * pointer; the grip line shows on hover, while dragging and on focus. With a
40
+ * label, the box reads the setting on the left and its value on the right.
41
+ */
42
+ export declare const BlockSlider: ({ className, id, disabled, value, defaultValue, onValueChange, onValueCommitted, label, format, size, min, max, step, marks, snap, "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": ariaInvalid, ...props }: BlockSliderProps) => import("react").JSX.Element;
43
+ export {};
@@ -0,0 +1,63 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Slider as SliderPrimitive } from '@base-ui/react/slider';
4
+ import { useId, useState } from 'react';
5
+ import { cn } from '../lib/cn.js';
6
+ import { useField, useFieldControl } from './field.js';
7
+ /** Base UI hands back a bare number for one knob; callers always get an array. */
8
+ const toArray = (value) => typeof value === 'number' ? [value] : [...value];
9
+ /** The box height, and a grip line that keeps the same share of it. */
10
+ const sizes = {
11
+ // Level with a button, and with a large one or a field-row input.
12
+ sm: { box: 'h-control', grip: 'after:h-3.5' },
13
+ md: { box: 'h-control-lg', grip: 'after:h-4' },
14
+ lg: { box: 'h-control-xl', grip: 'after:h-5' },
15
+ };
16
+ /**
17
+ * A slider as a box (34, 38 or 48px): a hairline container, 2px of padding, and a
18
+ * grey fill with nested corners growing inside it. The whole box takes the
19
+ * pointer; the grip line shows on hover, while dragging and on focus. With a
20
+ * label, the box reads the setting on the left and its value on the right.
21
+ */
22
+ export const BlockSlider = ({ className, id, disabled, value, defaultValue, onValueChange, onValueCommitted, label, format = values => values.join(' – '), size = 'lg', min = 0, max = 100, step, marks, snap = false, 'aria-label': ariaLabel, 'aria-labelledby': labelledBy, 'aria-describedby': describedBy, 'aria-invalid': ariaInvalid, ...props }) => {
23
+ const field = useField();
24
+ const labelId = useId();
25
+ const { invalid: _invalid, ...control } = useFieldControl({
26
+ id,
27
+ disabled,
28
+ 'aria-describedby': describedBy,
29
+ 'aria-invalid': ariaInvalid,
30
+ });
31
+ // Kept here as well so the value on the right follows an uncontrolled slider.
32
+ const [uncontrolled, setUncontrolled] = useState(() => toArray(defaultValue ?? [0]));
33
+ const current = value ?? uncontrolled;
34
+ const thumbs = current.length;
35
+ // The dividers between the ends; the ends are the box itself.
36
+ const dividers = [];
37
+ if (marks && marks > 0) {
38
+ for (let at = min + marks; at < max; at += marks) {
39
+ dividers.push(((at - min) / (max - min)) * 100);
40
+ }
41
+ }
42
+ return (_jsx(SliderPrimitive.Root, { className: cn('group/block-slider w-full data-disabled:cursor-not-allowed data-disabled:opacity-50', className), "data-slot": "block-slider", defaultValue: defaultValue, disabled: control.disabled, id: control.id, max: max, min: min, step: snap && marks ? marks : step, "aria-labelledby": labelledBy ?? (ariaLabel ? undefined : label ? labelId : field?.labelId), "aria-invalid": control['aria-invalid'],
43
+ // Centred on the value, so an empty slider shows no fill and a full one fills the box.
44
+ thumbAlignment: "center", value: value, onValueChange: (next, details) => {
45
+ setUncontrolled(toArray(next));
46
+ onValueChange?.(toArray(next), details);
47
+ }, onValueCommitted: onValueCommitted && ((next, details) => onValueCommitted(toArray(next), details)), ...props, children: _jsx(SliderPrimitive.Control, { className: cn('relative flex w-full cursor-pointer touch-none select-none rounded-control border border-neutral-200 p-[2px] transition-[border-color] duration-150 hover:border-neutral-300 group-data-disabled/block-slider:cursor-not-allowed group-data-disabled/block-slider:hover:border-neutral-200', sizes[size].box), "data-size": size, "data-slot": "block-slider-control", children: _jsxs(SliderPrimitive.Track, { className: "relative h-full grow", "data-slot": "block-slider-track", children: [dividers.map(at => (_jsx("span", { "aria-hidden": true,
48
+ // A notch in the box's bottom hairline: it crosses the padding to meet the
49
+ // border, shares its colour and hover, and sits under the fill.
50
+ className: "pointer-events-none absolute bottom-[-2px] h-2 w-px -translate-x-1/2 bg-neutral-200 transition-[background-color] duration-150 group-hover/block-slider:bg-neutral-300 group-data-disabled/block-slider:bg-neutral-200", "data-slot": "block-slider-mark", style: { left: `${at}%` } }, at))), _jsx(SliderPrimitive.Indicator
51
+ // The box's corner less its fixed 2px inset, which a spacing unit never moves.
52
+ , {
53
+ // The box's corner less its fixed 2px inset, which a spacing unit never moves.
54
+ className: "h-full rounded-[calc(var(--radius-control)-2px)] bg-neutral-200", "data-slot": "block-slider-range" }), label !== undefined && (_jsxs("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-between gap-3 px-2.5 text-xs", "data-slot": "block-slider-info", children: [_jsx("span", { className: "truncate text-neutral-600", id: labelId, children: label }), _jsx("span", { className: "shrink-0 text-neutral-950 tabular-nums", children: format([...current]) })] })), Array.from({ length: thumbs }, (_, index) => (_jsx(SliderPrimitive.Thumb
55
+ // A label on the slider names each grip's input, which is what takes focus.
56
+ , { "aria-describedby": control['aria-describedby'], "aria-label": ariaLabel, className: cn(
57
+ // A 12px hit area round a 2px grip line at the edge of the fill.
58
+ 'flex h-full w-3 cursor-grab items-center justify-center rounded-chip active:cursor-grabbing data-dragging:cursor-grabbing', sizes[size].grip, 'after:w-0.5 after:rounded-full after:bg-neutral-500 after:opacity-0 after:transition-[opacity,background-color] after:duration-150', 'group-hover/block-slider:after:opacity-100 has-focus-visible:after:opacity-100 data-dragging:after:bg-neutral-950 data-dragging:after:opacity-100',
59
+ // A touch screen has no hover to reveal it, so there the grip always shows.
60
+ 'pointer-coarse:after:opacity-100', 'group-data-disabled/block-slider:cursor-not-allowed group-data-disabled/block-slider:after:opacity-0',
61
+ // Focus lands on the hidden input inside the grip, so the ring follows it.
62
+ 'outline-none has-focus-visible:outline-2 has-focus-visible:outline-focus has-focus-visible:outline-solid has-focus-visible:outline-offset-2'), "data-slot": "block-slider-thumb", index: index }, index)))] }) }) }));
63
+ };
@@ -0,0 +1,87 @@
1
+ import { type ComponentProps, type ReactNode } from 'react';
2
+ export type BranchGraphRef = {
3
+ name: string;
4
+ /** A branch moves with the work; a tag marks one commit for good. */
5
+ kind?: 'branch' | 'tag';
6
+ /** The branch checked out: its label is set in full ink. */
7
+ current?: boolean;
8
+ /** A remote's copy of a branch (`origin/main`): its label is muted. */
9
+ remote?: boolean;
10
+ };
11
+ export type BranchGraphCommit = {
12
+ id: string;
13
+ /** The commits this one was made on: none for the first, one for most, two or more for a merge. */
14
+ parents: readonly string[];
15
+ message: ReactNode;
16
+ author?: ReactNode;
17
+ time?: Date;
18
+ refs?: readonly BranchGraphRef[];
19
+ };
20
+ export type BranchGraphColumn = 'author' | 'hash' | 'time';
21
+ export type BranchGraphProps = Omit<ComponentProps<'div'>, 'onSelect'> & {
22
+ /** Names the list for a screen reader. */
23
+ 'aria-label': string;
24
+ /**
25
+ * Newest first, every commit above the commits it was made on, as `git log --topo-order`
26
+ * gives them. A parent that is not in the list (history cut short) keeps its lane running
27
+ * off the foot.
28
+ */
29
+ commits: readonly BranchGraphCommit[];
30
+ /** 34 rows for a long log, 41 for a short one read closely. */
31
+ density?: 'compact' | 'default';
32
+ /** The columns after the message, in this order. */
33
+ columns?: readonly BranchGraphColumn[];
34
+ /** The selected commit's id. With `onSelectedChange`, rows are picked by click or keyboard. */
35
+ selected?: string | null;
36
+ onSelectedChange?: (id: string) => void;
37
+ /** Writes a commit's time; "12 Nov, 14:03" unless given. */
38
+ formatTime?: (time: Date) => ReactNode;
39
+ /** How many refs a row shows before it folds the rest into "+N". */
40
+ maxRefs?: number;
41
+ /**
42
+ * The branch everything else is made from: its line keeps the leftmost lane, in neutral ink,
43
+ * and the branches take the colours beside it. `main` or `master` when a commit carries one;
44
+ * `null` for none.
45
+ */
46
+ trunk?: string | null;
47
+ /**
48
+ * A hairline frame on the surface, for the history as the page's list; off where a card or a
49
+ * sheet already frames it.
50
+ */
51
+ framed?: boolean;
52
+ };
53
+ type Edge = {
54
+ lane: number;
55
+ };
56
+ type RowGraph = {
57
+ lane: number;
58
+ /** Lanes running past this commit, top to foot. */
59
+ through: number[];
60
+ /** A child above runs down into the dot. */
61
+ top: boolean;
62
+ /** The first parent runs on down from the dot. */
63
+ bottom: boolean;
64
+ /** Lanes coming down that end here, turning in to the dot along its row: branches made from it. */
65
+ joins: Edge[];
66
+ /** Lanes leaving the dot along its row and turning down: the other parents of a merge. */
67
+ splits: Edge[];
68
+ merge: boolean;
69
+ };
70
+ /**
71
+ * Gives each commit a lane. A lane holds the commit it is waiting for; a commit takes the leftmost
72
+ * lane waiting for it (or the first free one, at a branch tip), its first parent carries the lane on,
73
+ * and every other parent of a merge takes the lane already waiting for it or a free one. The trunk's
74
+ * commits keep the leftmost lane, so the line everything branches from runs straight down the edge.
75
+ */
76
+ export declare const layoutBranchGraph: (commits: readonly BranchGraphCommit[], trunk?: string | null) => {
77
+ rows: RowGraph[];
78
+ width: number;
79
+ };
80
+ /**
81
+ * A commit history: a row per commit, newest first, and beside the rows the lanes the commits sit on.
82
+ * A branch leaves the commit it was made from along that commit's row and turns up into a lane of its
83
+ * own; a merge reaches out along its row to the branch it took in. Lines only run down a lane or along
84
+ * a dot's row, so a busy history still reads as rows.
85
+ */
86
+ export declare const BranchGraph: ({ commits, density, columns, selected, onSelectedChange, formatTime, maxRefs, trunk, framed, className, style, ...props }: BranchGraphProps) => import("react").JSX.Element;
87
+ export {};
@@ -0,0 +1,231 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { createElement as _createElement } from "react";
4
+ import { Tag } from 'lucide-react';
5
+ import { useLayoutEffect, useMemo, useRef, useState, } from 'react';
6
+ import { cn } from '../lib/cn.js';
7
+ /** Holds the leftmost lane for the trunk until its first commit comes. */
8
+ const RESERVED = '\u0000trunk';
9
+ /** The trunk's commits: its branch's commit and that commit's first parents, down the list. */
10
+ const trunkOf = (commits, trunk) => {
11
+ const ids = new Set();
12
+ if (!trunk)
13
+ return ids;
14
+ const byId = new Map(commits.map(commit => [commit.id, commit]));
15
+ let at = commits.find(commit => commit.refs?.some(ref => ref.name === trunk && ref.kind !== 'tag'));
16
+ while (at && !ids.has(at.id)) {
17
+ ids.add(at.id);
18
+ const first = at.parents[0];
19
+ at = first ? byId.get(first) : undefined;
20
+ }
21
+ return ids;
22
+ };
23
+ /**
24
+ * Gives each commit a lane. A lane holds the commit it is waiting for; a commit takes the leftmost
25
+ * lane waiting for it (or the first free one, at a branch tip), its first parent carries the lane on,
26
+ * and every other parent of a merge takes the lane already waiting for it or a free one. The trunk's
27
+ * commits keep the leftmost lane, so the line everything branches from runs straight down the edge.
28
+ */
29
+ export const layoutBranchGraph = (commits, trunk = null) => {
30
+ const onTrunk = trunkOf(commits, trunk);
31
+ const lanes = onTrunk.size > 0 ? [RESERVED] : [];
32
+ let width = 1;
33
+ const freeLane = (taken) => {
34
+ const index = lanes.findIndex((id, i) => id === null && !taken.includes(i));
35
+ if (index >= 0)
36
+ return index;
37
+ lanes.push(null);
38
+ return lanes.length - 1;
39
+ };
40
+ const rows = commits.map((commit) => {
41
+ const waiting = lanes.flatMap((id, i) => (id === commit.id ? [i] : []));
42
+ const lane = onTrunk.has(commit.id) ? 0 : (waiting[0] ?? freeLane([]));
43
+ const before = [...lanes];
44
+ const top = lanes[lane] === commit.id;
45
+ const joining = waiting.filter(index => index !== lane);
46
+ const [first, ...rest] = commit.parents;
47
+ lanes[lane] = first ?? null;
48
+ const splits = [];
49
+ for (const parent of rest) {
50
+ const found = lanes.indexOf(parent);
51
+ if (found === lane)
52
+ continue;
53
+ // Not in a lane freed on this very row, so a lane coming in and one going out never share a stretch.
54
+ const target = found >= 0
55
+ ? found
56
+ : onTrunk.has(parent) && lanes[0] === RESERVED
57
+ ? 0
58
+ : freeLane([lane, ...joining]);
59
+ lanes[target] = parent;
60
+ splits.push({ lane: target });
61
+ }
62
+ for (const index of joining)
63
+ lanes[index] = null;
64
+ const through = before.flatMap((id, i) => id !== null && id !== RESERVED && i !== lane && !joining.includes(i) ? [i] : []);
65
+ while (lanes.length > 0 && lanes[lanes.length - 1] === null)
66
+ lanes.pop();
67
+ width = Math.max(width, before.length, lanes.length, lane + 1);
68
+ return {
69
+ lane,
70
+ through,
71
+ top,
72
+ bottom: first != null,
73
+ joins: joining.map(index => ({ lane: index })),
74
+ splits,
75
+ merge: commit.parents.length > 1,
76
+ };
77
+ });
78
+ return { rows, width };
79
+ };
80
+ /* ---------- Drawing ---------- */
81
+ /** From the frame's edge to the first lane's centre. */
82
+ const INSET = 16;
83
+ /** Between two lanes' centres. */
84
+ const PITCH = 16;
85
+ /** The corner where a line turns from its row into a lane. */
86
+ const TURN = 6;
87
+ const DOT = 4;
88
+ /** The break a line along a row leaves where it crosses a lane. */
89
+ const BREAK = 3;
90
+ const STROKE = 1.5;
91
+ const LANE_COLORS = [
92
+ 'var(--color-neutral-400)',
93
+ 'var(--color-chart-series-1)',
94
+ 'var(--color-chart-series-2)',
95
+ 'var(--color-chart-series-3)',
96
+ 'var(--color-chart-series-4)',
97
+ ];
98
+ /**
99
+ * A lane's colour, by its place: the leftmost lane, where the line the log was read from runs, is
100
+ * the neutral ink, and the lanes beside it take the series colours in turn.
101
+ */
102
+ const laneColor = (lane) => lane === 0 ? LANE_COLORS[0] : LANE_COLORS[1 + ((lane - 1) % (LANE_COLORS.length - 1))];
103
+ const laneX = (lane) => INSET + lane * PITCH;
104
+ /** A line along the dot's row from `from` to `to`, broken where it crosses a lane running past. */
105
+ const rowLine = (from, to, cy, crossing, move = true) => {
106
+ const dir = Math.sign(to - from);
107
+ const stops = crossing
108
+ .map(laneX)
109
+ .filter(x => (x - from) * dir > 0 && (to - x) * dir > 0)
110
+ .sort((a, b) => (a - b) * dir);
111
+ let d = move ? `M${from} ${cy}` : '';
112
+ for (const x of stops)
113
+ d += ` H${x - dir * BREAK} M${x + dir * BREAK} ${cy}`;
114
+ return `${d} H${to}`;
115
+ };
116
+ const RowGraphic = ({ row, width, height, selected, }) => {
117
+ const cy = height / 2;
118
+ const x = laneX(row.lane);
119
+ const ink = laneColor(row.lane);
120
+ const line = { fill: 'none', strokeWidth: STROKE, strokeLinecap: 'round' };
121
+ return (_jsxs("svg", { "aria-hidden": "true", className: "block shrink-0 overflow-visible", height: height, width: width, children: [row.joins.map(({ lane }) => {
122
+ const lx = laneX(lane);
123
+ const dir = Math.sign(x - lx);
124
+ return (_createElement("path", { ...line, 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)}`, key: `j${lane}`, stroke: laneColor(lane) }));
125
+ }), row.splits.map(({ lane }) => {
126
+ const lx = laneX(lane);
127
+ const dir = Math.sign(lx - x);
128
+ return (_createElement("path", { ...line, d: `${rowLine(x + dir * DOT, lx - dir * TURN, cy, row.through)} Q${lx} ${cy} ${lx} ${cy + TURN} V${height}`, key: `s${lane}`, stroke: laneColor(lane) }));
129
+ }), row.through.map(lane => (_createElement("path", { ...line, d: `M${laneX(lane)} 0 V${height}`, key: `t${lane}`, stroke: laneColor(lane) }))), row.top && _jsx("path", { ...line, d: `M${x} 0 V${cy - DOT}`, stroke: ink }), row.bottom && _jsx("path", { ...line, d: `M${x} ${cy + DOT} V${height}`, stroke: ink }), selected && (_jsx("circle", { cx: x, cy: cy, fill: `color-mix(in oklab, ${ink} 22%, transparent)`, r: DOT + 4 })), row.merge ? (_jsx("circle", { cx: x, cy: cy, fill: "none", r: DOT - STROKE / 2, stroke: ink, strokeWidth: STROKE })) : (_jsx("circle", { cx: x, cy: cy, fill: ink, r: DOT }))] }));
130
+ };
131
+ /* ---------- Refs ---------- */
132
+ /** The refs a row has no room for, as a count; their names in the native tooltip and to a screen reader. */
133
+ const FoldedRefs = ({ refs, className, }) => refs.length > 0 ? (_jsxs("span", { className: cn('inline-flex h-5 shrink-0 items-center rounded-chip px-1 font-medium text-neutral-600 text-xxs tabular-nums', className), title: refs.map(ref => ref.name).join(', '), children: ["+", refs.length, _jsxs("span", { className: "sr-only", children: [": ", refs.map(ref => ref.name).join(', ')] })] })) : null;
134
+ const RefLabel = ({ label, lane, className, }) => (_jsxs("span", { className: cn('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', label.current
135
+ ? 'text-neutral-950'
136
+ : label.remote
137
+ ? 'text-neutral-600'
138
+ : 'text-neutral-800', label.current && 'shadow-[inset_0_0_0_1px_var(--color-neutral-300)]', className), "data-slot": "branch-graph-ref", children: [label.kind === 'tag' ? (_jsx(Tag, { className: "size-3 shrink-0 text-neutral-600", strokeWidth: 2 })) : (_jsx("span", { className: "size-1.5 shrink-0 rounded-full", style: { background: laneColor(lane) } })), _jsx("span", { className: "truncate", children: label.name })] }));
139
+ /* ---------- The list ---------- */
140
+ const writeTime = (time) => `${time.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })}, ${time.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' })}`;
141
+ const NOMINAL_HEIGHT = { compact: 34, default: 41 };
142
+ /**
143
+ * A commit history: a row per commit, newest first, and beside the rows the lanes the commits sit on.
144
+ * A branch leaves the commit it was made from along that commit's row and turns up into a lane of its
145
+ * own; a merge reaches out along its row to the branch it took in. Lines only run down a lane or along
146
+ * a dot's row, so a busy history still reads as rows.
147
+ */
148
+ export const BranchGraph = ({ commits, density = 'compact', columns = ['author', 'hash', 'time'], selected = null, onSelectedChange, formatTime = writeTime, maxRefs = 2, trunk, framed = true, className, style, ...props }) => {
149
+ const trunkName = trunk === undefined
150
+ ? (commits
151
+ .flatMap(commit => commit.refs ?? [])
152
+ .find(ref => !ref.remote &&
153
+ ref.kind !== 'tag' &&
154
+ (ref.name === 'main' || ref.name === 'master'))?.name ?? null)
155
+ : trunk;
156
+ const { rows, width } = useMemo(() => layoutBranchGraph(commits, trunkName), [commits, trunkName]);
157
+ const graphWidth = laneX(width - 1) + DOT;
158
+ const interactive = onSelectedChange != null;
159
+ // The row's height comes from the theme's height scale, so it is read off the first row.
160
+ const firstRow = useRef(null);
161
+ const [height, setHeight] = useState(NOMINAL_HEIGHT[density]);
162
+ useLayoutEffect(() => {
163
+ const node = firstRow.current;
164
+ if (!node)
165
+ return;
166
+ const read = () => setHeight(node.getBoundingClientRect().height || NOMINAL_HEIGHT[density]);
167
+ read();
168
+ const observer = new ResizeObserver(read);
169
+ observer.observe(node);
170
+ return () => observer.disconnect();
171
+ }, [density]);
172
+ const listRef = useRef(null);
173
+ const [focusId, setFocusId] = useState(null);
174
+ const tabStop = focusId ?? selected ?? commits[0]?.id;
175
+ const move = (event, index) => {
176
+ const last = commits.length - 1;
177
+ const to = event.key === 'ArrowDown'
178
+ ? Math.min(index + 1, last)
179
+ : event.key === 'ArrowUp'
180
+ ? Math.max(index - 1, 0)
181
+ : event.key === 'Home'
182
+ ? 0
183
+ : event.key === 'End'
184
+ ? last
185
+ : null;
186
+ if (to !== null) {
187
+ event.preventDefault();
188
+ const target = commits[to];
189
+ if (!target)
190
+ return;
191
+ setFocusId(target.id);
192
+ listRef.current
193
+ ?.querySelector(`[data-index="${to}"]`)
194
+ ?.focus({ preventScroll: false });
195
+ return;
196
+ }
197
+ if (event.key === 'Enter' || event.key === ' ') {
198
+ event.preventDefault();
199
+ const commit = commits[index];
200
+ if (commit)
201
+ onSelectedChange?.(commit.id);
202
+ }
203
+ };
204
+ return (
205
+ // The frame is its own container, so the list answers the room it is given: under 560 the
206
+ // author and the hash go and the message keeps its line.
207
+ _jsx("div", { className: cn('@container/branch-graph flex w-full flex-col overflow-hidden', framed && 'rounded-control border border-neutral-200 bg-neutral-50 shadow-card', className), "data-slot": "branch-graph", style: style, children: _jsx("div", { className: "grid min-h-0 w-full flex-1 content-start overflow-y-auto overflow-x-hidden text-xs", "data-slot": "branch-graph-list", ref: listRef, role: interactive ? 'listbox' : 'list', style: {
208
+ gridTemplateColumns: [
209
+ `${graphWidth}px`,
210
+ 'minmax(0, 1fr)',
211
+ ...columns.map(() => 'auto'),
212
+ ].join(' '),
213
+ }, ...props, children: commits.map((commit, index) => {
214
+ const row = rows[index];
215
+ const isSelected = selected === commit.id;
216
+ const refs = commit.refs ?? [];
217
+ const shown = refs.slice(0, maxRefs);
218
+ const folded = refs.slice(maxRefs);
219
+ return (_createElement("div", { ...(interactive
220
+ ? { role: 'option', 'aria-selected': isSelected }
221
+ : { role: 'listitem' }), className: cn('col-span-full grid grid-cols-subgrid items-center pr-4', density === 'compact' ? 'h-control' : 'h-table-row', interactive &&
222
+ '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', interactive && !isSelected && 'hover:bg-neutral-950/3', isSelected && 'bg-selected'), "data-index": index, "data-selected": isSelected || undefined, "data-slot": "branch-graph-row", key: commit.id, onClick: interactive ? () => onSelectedChange(commit.id) : undefined, onFocus: interactive ? () => setFocusId(commit.id) : undefined, onKeyDown: interactive ? event => move(event, index) : undefined, ref: index === 0 ? firstRow : undefined, tabIndex: interactive ? (tabStop === commit.id ? 0 : -1) : undefined },
223
+ _jsx(RowGraphic, { height: height, row: row, selected: isSelected, width: graphWidth }),
224
+ _jsxs("span", { className: "flex min-w-0 items-center gap-2 pl-4", children: [shown.length > 0 && (_jsxs("span", { className: "flex min-w-0 @max-[560px]/branch-graph:max-w-[45%] max-w-[60%] shrink-0 items-center gap-1", children: [shown.map((ref, at) => (_jsx(RefLabel
225
+ // A narrow list keeps the first ref only, so the message still reads.
226
+ , {
227
+ // A narrow list keeps the first ref only, so the message still reads.
228
+ className: cn(at > 0 && '@max-[560px]/branch-graph:hidden'), label: ref, lane: row.lane }, `${ref.kind}:${ref.name}`))), _jsx(FoldedRefs, { className: "@max-[560px]/branch-graph:hidden", refs: folded }), _jsx(FoldedRefs, { className: "@min-[560px]/branch-graph:hidden", refs: refs.slice(1) })] })), _jsx("span", { className: cn('min-w-0 truncate', row.merge ? 'text-neutral-600' : 'text-neutral-900'), children: commit.message })] }),
229
+ columns.map(column => column === 'author' ? (_jsx("span", { className: "@max-[560px]/branch-graph:hidden max-w-40 truncate pl-4 text-neutral-700", children: commit.author }, column)) : column === 'hash' ? (_jsx("span", { className: "@max-[560px]/branch-graph:hidden pl-4 font-mono text-neutral-600 text-xxs", children: commit.id.slice(0, 7) }, column)) : (_jsx("span", { className: "whitespace-nowrap pl-4 text-right text-neutral-600 tabular-nums", children: commit.time ? formatTime(commit.time) : null }, column)))));
230
+ }) }) }));
231
+ };