@zonsh/ui 0.0.0-stage → 0.2.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 (388) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -2
  3. package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
  4. package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
  5. package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
  6. package/assets/illustrations/drawing/bracket-construction.svg +77 -0
  7. package/assets/illustrations/drawing/crescent-dark.svg +28 -0
  8. package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
  9. package/assets/illustrations/drawing/crescent-guides.svg +33 -0
  10. package/assets/illustrations/drawing/crescent.svg +28 -0
  11. package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
  12. package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
  13. package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
  14. package/assets/illustrations/drawing/eclipse.svg +187 -0
  15. package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
  16. package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
  17. package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
  18. package/assets/illustrations/drawing/elevation-guides.svg +31 -0
  19. package/assets/illustrations/drawing/horizon-dark.svg +30 -0
  20. package/assets/illustrations/drawing/horizon.svg +30 -0
  21. package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
  22. package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
  23. package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
  24. package/assets/illustrations/drawing/nib-study.svg +107 -0
  25. package/assets/illustrations/editorial/assistant-640.webp +0 -0
  26. package/assets/illustrations/editorial/assistant.webp +0 -0
  27. package/assets/illustrations/editorial/automation-640.webp +0 -0
  28. package/assets/illustrations/editorial/automation.webp +0 -0
  29. package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
  30. package/assets/illustrations/editorial/bracket-left.webp +0 -0
  31. package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
  32. package/assets/illustrations/editorial/bracket-right.webp +0 -0
  33. package/assets/illustrations/editorial/custom-software-640.webp +0 -0
  34. package/assets/illustrations/editorial/custom-software.webp +0 -0
  35. package/assets/illustrations/editorial/digitalization-640.webp +0 -0
  36. package/assets/illustrations/editorial/digitalization.webp +0 -0
  37. package/assets/illustrations/editorial/integration-640.webp +0 -0
  38. package/assets/illustrations/editorial/integration.webp +0 -0
  39. package/assets/illustrations/editorial/problem-640.webp +0 -0
  40. package/assets/illustrations/editorial/problem.webp +0 -0
  41. package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
  42. package/assets/illustrations/editorial/process-analysis.webp +0 -0
  43. package/assets/illustrations/editorial/process-concept-640.webp +0 -0
  44. package/assets/illustrations/editorial/process-concept.webp +0 -0
  45. package/assets/illustrations/editorial/process-development-640.webp +0 -0
  46. package/assets/illustrations/editorial/process-development.webp +0 -0
  47. package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
  48. package/assets/illustrations/editorial/process-discovery.webp +0 -0
  49. package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
  50. package/assets/illustrations/editorial/process-maintenance.webp +0 -0
  51. package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
  52. package/assets/illustrations/editorial/process-prototype.webp +0 -0
  53. package/assets/illustrations/editorial/process-testing-640.webp +0 -0
  54. package/assets/illustrations/editorial/process-testing.webp +0 -0
  55. package/assets/illustrations/iso/automation-dark.svg +6 -0
  56. package/assets/illustrations/iso/automation.svg +6 -0
  57. package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
  58. package/assets/illustrations/iso/bar-chart.svg +6 -0
  59. package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
  60. package/assets/illustrations/iso/brackets-classic.svg +6 -0
  61. package/assets/illustrations/iso/brackets-dark.svg +6 -0
  62. package/assets/illustrations/iso/brackets.svg +6 -0
  63. package/assets/illustrations/iso/city-dark.svg +6 -0
  64. package/assets/illustrations/iso/city.svg +6 -0
  65. package/assets/illustrations/iso/conveyor-dark.svg +6 -0
  66. package/assets/illustrations/iso/conveyor.svg +6 -0
  67. package/assets/illustrations/iso/database-dark.svg +6 -0
  68. package/assets/illustrations/iso/database.svg +6 -0
  69. package/assets/illustrations/iso/documents-dark.svg +6 -0
  70. package/assets/illustrations/iso/documents.svg +6 -0
  71. package/assets/illustrations/iso/inbox-dark.svg +6 -0
  72. package/assets/illustrations/iso/inbox.svg +6 -0
  73. package/assets/illustrations/iso/laptop-dark.svg +6 -0
  74. package/assets/illustrations/iso/laptop.svg +6 -0
  75. package/assets/illustrations/iso/monitor-dark.svg +6 -0
  76. package/assets/illustrations/iso/monitor.svg +6 -0
  77. package/assets/illustrations/iso/pipeline-dark.svg +6 -0
  78. package/assets/illustrations/iso/pipeline.svg +6 -0
  79. package/assets/illustrations/iso/platform-dark.svg +6 -0
  80. package/assets/illustrations/iso/platform.svg +6 -0
  81. package/assets/illustrations/iso/server-dark.svg +6 -0
  82. package/assets/illustrations/iso/server.svg +6 -0
  83. package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
  84. package/assets/illustrations/iso/spreadsheet.svg +6 -0
  85. package/assets/illustrations/iso/timeline-dark.svg +6 -0
  86. package/assets/illustrations/iso/timeline.svg +6 -0
  87. package/assets/illustrations/sheet/construction.svg +115 -0
  88. package/assets/illustrations/sheet/crescent.svg +40 -0
  89. package/assets/illustrations/sheet/limb.svg +42 -0
  90. package/assets/illustrations/sheet/stress-axis.svg +119 -0
  91. package/assets/illustrations/sheet/totality.svg +215 -0
  92. package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
  93. package/assets/logo-left.svg +1 -0
  94. package/assets/logo-right.svg +1 -0
  95. package/assets/logo.svg +1 -0
  96. package/dist/components/_overlay.d.ts +47 -0
  97. package/dist/components/_overlay.js +59 -0
  98. package/dist/components/accordion.d.ts +32 -0
  99. package/dist/components/accordion.js +39 -0
  100. package/dist/components/alert-dialog.d.ts +45 -0
  101. package/dist/components/alert-dialog.js +56 -0
  102. package/dist/components/alert.d.ts +35 -0
  103. package/dist/components/alert.js +42 -0
  104. package/dist/components/ascii-field.d.ts +34 -0
  105. package/dist/components/ascii-field.js +410 -0
  106. package/dist/components/aspect-ratio.d.ts +14 -0
  107. package/dist/components/aspect-ratio.js +17 -0
  108. package/dist/components/avatar.d.ts +42 -0
  109. package/dist/components/avatar.js +55 -0
  110. package/dist/components/badge.d.ts +70 -0
  111. package/dist/components/badge.js +62 -0
  112. package/dist/components/breadcrumb.d.ts +22 -0
  113. package/dist/components/breadcrumb.js +32 -0
  114. package/dist/components/button-group.d.ts +30 -0
  115. package/dist/components/button-group.js +47 -0
  116. package/dist/components/button.d.ts +53 -0
  117. package/dist/components/button.js +130 -0
  118. package/dist/components/calendar.d.ts +26 -0
  119. package/dist/components/calendar.js +164 -0
  120. package/dist/components/card.d.ts +42 -0
  121. package/dist/components/card.js +76 -0
  122. package/dist/components/carousel.d.ts +90 -0
  123. package/dist/components/carousel.js +213 -0
  124. package/dist/components/chart.d.ts +180 -0
  125. package/dist/components/chart.js +286 -0
  126. package/dist/components/checkbox.d.ts +23 -0
  127. package/dist/components/checkbox.js +43 -0
  128. package/dist/components/code-block.d.ts +45 -0
  129. package/dist/components/code-block.js +58 -0
  130. package/dist/components/code-highlight.d.ts +13 -0
  131. package/dist/components/code-highlight.js +107 -0
  132. package/dist/components/collapsible.d.ts +20 -0
  133. package/dist/components/collapsible.js +32 -0
  134. package/dist/components/color-picker.d.ts +85 -0
  135. package/dist/components/color-picker.js +407 -0
  136. package/dist/components/combobox.d.ts +81 -0
  137. package/dist/components/combobox.js +100 -0
  138. package/dist/components/command.d.ts +112 -0
  139. package/dist/components/command.js +212 -0
  140. package/dist/components/context-menu.d.ts +29 -0
  141. package/dist/components/context-menu.js +35 -0
  142. package/dist/components/conversation.d.ts +27 -0
  143. package/dist/components/conversation.js +293 -0
  144. package/dist/components/copy-button.d.ts +46 -0
  145. package/dist/components/copy-button.js +118 -0
  146. package/dist/components/data-table.d.ts +175 -0
  147. package/dist/components/data-table.js +302 -0
  148. package/dist/components/date-picker.d.ts +91 -0
  149. package/dist/components/date-picker.js +207 -0
  150. package/dist/components/dialog.d.ts +48 -0
  151. package/dist/components/dialog.js +92 -0
  152. package/dist/components/direction.d.ts +16 -0
  153. package/dist/components/direction.js +18 -0
  154. package/dist/components/drawer.d.ts +60 -0
  155. package/dist/components/drawer.js +76 -0
  156. package/dist/components/empty.d.ts +31 -0
  157. package/dist/components/empty.js +50 -0
  158. package/dist/components/feature-list.d.ts +54 -0
  159. package/dist/components/feature-list.js +43 -0
  160. package/dist/components/field.d.ts +15 -0
  161. package/dist/components/field.js +36 -0
  162. package/dist/components/file-drop.d.ts +55 -0
  163. package/dist/components/file-drop.js +197 -0
  164. package/dist/components/filter-bar.d.ts +106 -0
  165. package/dist/components/filter-bar.js +296 -0
  166. package/dist/components/form.d.ts +33 -0
  167. package/dist/components/form.js +34 -0
  168. package/dist/components/graph.d.ts +105 -0
  169. package/dist/components/graph.js +786 -0
  170. package/dist/components/illustration.d.ts +85 -0
  171. package/dist/components/illustration.js +165 -0
  172. package/dist/components/input-group.d.ts +127 -0
  173. package/dist/components/input-group.js +292 -0
  174. package/dist/components/input.d.ts +16 -0
  175. package/dist/components/input.js +25 -0
  176. package/dist/components/item.d.ts +64 -0
  177. package/dist/components/item.js +116 -0
  178. package/dist/components/kbd.d.ts +33 -0
  179. package/dist/components/kbd.js +38 -0
  180. package/dist/components/label.d.ts +12 -0
  181. package/dist/components/label.js +24 -0
  182. package/dist/components/layout.d.ts +136 -0
  183. package/dist/components/layout.js +162 -0
  184. package/dist/components/logo.d.ts +54 -0
  185. package/dist/components/logo.js +96 -0
  186. package/dist/components/menu.d.ts +60 -0
  187. package/dist/components/menu.js +138 -0
  188. package/dist/components/menubar.d.ts +62 -0
  189. package/dist/components/menubar.js +223 -0
  190. package/dist/components/message.d.ts +42 -0
  191. package/dist/components/message.js +56 -0
  192. package/dist/components/meter.d.ts +31 -0
  193. package/dist/components/meter.js +25 -0
  194. package/dist/components/native-select.d.ts +26 -0
  195. package/dist/components/native-select.js +35 -0
  196. package/dist/components/navigation-menu.d.ts +42 -0
  197. package/dist/components/navigation-menu.js +97 -0
  198. package/dist/components/number-field.d.ts +36 -0
  199. package/dist/components/number-field.js +153 -0
  200. package/dist/components/otp-field.d.ts +35 -0
  201. package/dist/components/otp-field.js +94 -0
  202. package/dist/components/pagination.d.ts +31 -0
  203. package/dist/components/pagination.js +70 -0
  204. package/dist/components/pdf-viewer.d.ts +69 -0
  205. package/dist/components/pdf-viewer.js +929 -0
  206. package/dist/components/popover.d.ts +33 -0
  207. package/dist/components/popover.js +48 -0
  208. package/dist/components/preview-card.d.ts +25 -0
  209. package/dist/components/preview-card.js +22 -0
  210. package/dist/components/progress.d.ts +27 -0
  211. package/dist/components/progress.js +23 -0
  212. package/dist/components/prompt-input.d.ts +131 -0
  213. package/dist/components/prompt-input.js +403 -0
  214. package/dist/components/quote.d.ts +22 -0
  215. package/dist/components/quote.js +15 -0
  216. package/dist/components/radio-group.d.ts +18 -0
  217. package/dist/components/radio-group.js +34 -0
  218. package/dist/components/reasoning.d.ts +31 -0
  219. package/dist/components/reasoning.js +70 -0
  220. package/dist/components/resizable.d.ts +38 -0
  221. package/dist/components/resizable.js +41 -0
  222. package/dist/components/response.d.ts +30 -0
  223. package/dist/components/response.js +538 -0
  224. package/dist/components/scroll-area.d.ts +33 -0
  225. package/dist/components/scroll-area.js +31 -0
  226. package/dist/components/select.d.ts +35 -0
  227. package/dist/components/select.js +60 -0
  228. package/dist/components/separator.d.ts +14 -0
  229. package/dist/components/separator.js +17 -0
  230. package/dist/components/sidebar.d.ts +147 -0
  231. package/dist/components/sidebar.js +489 -0
  232. package/dist/components/site-header.d.ts +59 -0
  233. package/dist/components/site-header.js +67 -0
  234. package/dist/components/skeleton.d.ts +31 -0
  235. package/dist/components/skeleton.js +29 -0
  236. package/dist/components/slider.d.ts +24 -0
  237. package/dist/components/slider.js +129 -0
  238. package/dist/components/sources.d.ts +25 -0
  239. package/dist/components/sources.js +35 -0
  240. package/dist/components/spinner.d.ts +36 -0
  241. package/dist/components/spinner.js +72 -0
  242. package/dist/components/suggestions.d.ts +20 -0
  243. package/dist/components/suggestions.js +18 -0
  244. package/dist/components/switch.d.ts +14 -0
  245. package/dist/components/switch.js +26 -0
  246. package/dist/components/table.d.ts +162 -0
  247. package/dist/components/table.js +758 -0
  248. package/dist/components/tabs.d.ts +25 -0
  249. package/dist/components/tabs.js +162 -0
  250. package/dist/components/tag.d.ts +41 -0
  251. package/dist/components/tag.js +88 -0
  252. package/dist/components/tags-input.d.ts +40 -0
  253. package/dist/components/tags-input.js +239 -0
  254. package/dist/components/textarea.d.ts +13 -0
  255. package/dist/components/textarea.js +16 -0
  256. package/dist/components/theme.d.ts +41 -0
  257. package/dist/components/theme.js +112 -0
  258. package/dist/components/time-field.d.ts +51 -0
  259. package/dist/components/time-field.js +437 -0
  260. package/dist/components/timeline.d.ts +76 -0
  261. package/dist/components/timeline.js +99 -0
  262. package/dist/components/toast.d.ts +72 -0
  263. package/dist/components/toast.js +196 -0
  264. package/dist/components/toggle-group.d.ts +41 -0
  265. package/dist/components/toggle-group.js +140 -0
  266. package/dist/components/toggle.d.ts +23 -0
  267. package/dist/components/toggle.js +35 -0
  268. package/dist/components/tool-call.d.ts +52 -0
  269. package/dist/components/tool-call.js +57 -0
  270. package/dist/components/toolbar.d.ts +17 -0
  271. package/dist/components/toolbar.js +34 -0
  272. package/dist/components/tooltip.d.ts +42 -0
  273. package/dist/components/tooltip.js +47 -0
  274. package/dist/components/tree.d.ts +75 -0
  275. package/dist/components/tree.js +636 -0
  276. package/dist/components/typography.d.ts +134 -0
  277. package/dist/components/typography.js +176 -0
  278. package/dist/components/video-player.d.ts +276 -0
  279. package/dist/components/video-player.js +1352 -0
  280. package/dist/components/whiteboard.d.ts +80 -0
  281. package/dist/components/whiteboard.js +389 -0
  282. package/dist/index.d.ts +85 -0
  283. package/dist/index.js +86 -0
  284. package/dist/lib/cn.d.ts +20 -0
  285. package/dist/lib/cn.js +38 -0
  286. package/dist/lib/code-highlight.d.ts +31 -0
  287. package/dist/lib/code-highlight.js +24 -0
  288. package/dist/lib/code-theme.d.ts +19 -0
  289. package/dist/lib/code-theme.js +140 -0
  290. package/dist/lib/collapse-row.d.ts +9 -0
  291. package/dist/lib/collapse-row.js +129 -0
  292. package/dist/lib/digit-roll.d.ts +21 -0
  293. package/dist/lib/digit-roll.js +31 -0
  294. package/dist/lib/editorial-assets.d.ts +16 -0
  295. package/dist/lib/editorial-assets.js +56 -0
  296. package/dist/lib/figure/catalog.d.ts +127 -0
  297. package/dist/lib/figure/catalog.js +130 -0
  298. package/dist/lib/figure/figures/automation.d.ts +7 -0
  299. package/dist/lib/figure/figures/automation.js +143 -0
  300. package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
  301. package/dist/lib/figure/figures/bar-chart.js +99 -0
  302. package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
  303. package/dist/lib/figure/figures/brackets-classic.js +170 -0
  304. package/dist/lib/figure/figures/brackets.d.ts +8 -0
  305. package/dist/lib/figure/figures/brackets.js +84 -0
  306. package/dist/lib/figure/figures/city.d.ts +7 -0
  307. package/dist/lib/figure/figures/city.js +93 -0
  308. package/dist/lib/figure/figures/conveyor.d.ts +7 -0
  309. package/dist/lib/figure/figures/conveyor.js +97 -0
  310. package/dist/lib/figure/figures/database.d.ts +7 -0
  311. package/dist/lib/figure/figures/database.js +65 -0
  312. package/dist/lib/figure/figures/documents.d.ts +7 -0
  313. package/dist/lib/figure/figures/documents.js +83 -0
  314. package/dist/lib/figure/figures/inbox.d.ts +7 -0
  315. package/dist/lib/figure/figures/inbox.js +92 -0
  316. package/dist/lib/figure/figures/laptop.d.ts +7 -0
  317. package/dist/lib/figure/figures/laptop.js +67 -0
  318. package/dist/lib/figure/figures/monitor.d.ts +7 -0
  319. package/dist/lib/figure/figures/monitor.js +59 -0
  320. package/dist/lib/figure/figures/pipeline.d.ts +8 -0
  321. package/dist/lib/figure/figures/pipeline.js +117 -0
  322. package/dist/lib/figure/figures/platform.d.ts +7 -0
  323. package/dist/lib/figure/figures/platform.js +117 -0
  324. package/dist/lib/figure/figures/server.d.ts +7 -0
  325. package/dist/lib/figure/figures/server.js +115 -0
  326. package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
  327. package/dist/lib/figure/figures/spreadsheet.js +87 -0
  328. package/dist/lib/figure/figures/timeline.d.ts +7 -0
  329. package/dist/lib/figure/figures/timeline.js +65 -0
  330. package/dist/lib/figure/kernel.d.ts +152 -0
  331. package/dist/lib/figure/kernel.js +576 -0
  332. package/dist/lib/figure/parts.d.ts +42 -0
  333. package/dist/lib/figure/parts.js +126 -0
  334. package/dist/lib/form-reset.d.ts +11 -0
  335. package/dist/lib/form-reset.js +22 -0
  336. package/dist/lib/glide.d.ts +53 -0
  337. package/dist/lib/glide.js +138 -0
  338. package/dist/lib/graph-layout.d.ts +58 -0
  339. package/dist/lib/graph-layout.js +200 -0
  340. package/dist/lib/illustration-drawings.d.ts +89 -0
  341. package/dist/lib/illustration-drawings.js +539 -0
  342. package/dist/lib/illustration-info.d.ts +37 -0
  343. package/dist/lib/illustration-info.js +22 -0
  344. package/dist/lib/illustration-library.d.ts +87 -0
  345. package/dist/lib/illustration-library.js +352 -0
  346. package/dist/lib/logo-geometry.d.ts +29 -0
  347. package/dist/lib/logo-geometry.js +67 -0
  348. package/dist/lib/markdown-guard.d.ts +16 -0
  349. package/dist/lib/markdown-guard.js +123 -0
  350. package/dist/lib/merge-refs.d.ts +10 -0
  351. package/dist/lib/merge-refs.js +26 -0
  352. package/dist/lib/motion.d.ts +6 -0
  353. package/dist/lib/motion.js +12 -0
  354. package/dist/lib/pdf-worker.d.ts +1 -0
  355. package/dist/lib/pdf-worker.js +6 -0
  356. package/dist/lib/pdf.d.ts +19 -0
  357. package/dist/lib/pdf.js +58 -0
  358. package/dist/lib/platform.d.ts +33 -0
  359. package/dist/lib/platform.js +68 -0
  360. package/dist/lib/room.d.ts +25 -0
  361. package/dist/lib/room.js +46 -0
  362. package/dist/lib/table-fit.d.ts +143 -0
  363. package/dist/lib/table-fit.js +577 -0
  364. package/dist/lib/theme-script.d.ts +18 -0
  365. package/dist/lib/theme-script.js +29 -0
  366. package/dist/styles/expressive.css +188 -0
  367. package/dist/styles/fonts.css +145 -0
  368. package/dist/styles/index.css +206 -0
  369. package/dist/styles/material.css +313 -0
  370. package/dist/styles/parts/ai.css +360 -0
  371. package/dist/styles/parts/brand.css +75 -0
  372. package/dist/styles/parts/controls.css +725 -0
  373. package/dist/styles/parts/data.css +222 -0
  374. package/dist/styles/parts/editorial.css +120 -0
  375. package/dist/styles/parts/feedback.css +273 -0
  376. package/dist/styles/parts/foundations.css +166 -0
  377. package/dist/styles/parts/graph.css +214 -0
  378. package/dist/styles/parts/inputs.css +261 -0
  379. package/dist/styles/parts/isometric.css +124 -0
  380. package/dist/styles/parts/navigation.css +232 -0
  381. package/dist/styles/parts/overlays.css +250 -0
  382. package/dist/styles/parts/pdf.css +154 -0
  383. package/dist/styles/parts/react-flow.css +519 -0
  384. package/dist/styles/parts/whiteboard.css +855 -0
  385. package/dist/styles/tokens.css +290 -0
  386. package/dist/vite.d.ts +116 -0
  387. package/dist/vite.js +129 -0
  388. package/package.json +189 -3
@@ -0,0 +1,286 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import * as RechartsPrimitive from "recharts";
5
+ import { cn } from "../lib/cn.js";
6
+ const ChartContext = React.createContext(null);
7
+ /** The config of the nearest `ChartContainer`. For custom tooltip or legend content. */
8
+ export function useChart() {
9
+ const context = React.useContext(ChartContext);
10
+ if (!context)
11
+ throw new Error("useChart must be used inside <ChartContainer>.");
12
+ return context;
13
+ }
14
+ /**
15
+ * A series key as it is written in a CSS name, after `--color-`: letters, digits, `-`, `_` and
16
+ * anything past ASCII stay as they are, anything else is escaped as `CSS.escape` would ("New York"
17
+ * → `New\ York`), so it parses wherever the name is read — and no `</style` survives in it.
18
+ */
19
+ function cssKey(key) {
20
+ let out = "";
21
+ for (const ch of key) {
22
+ const code = ch.codePointAt(0);
23
+ if (code === 0)
24
+ out += "\uFFFD";
25
+ else if (code < 0x20 || code === 0x7f)
26
+ out += `\\${code.toString(16)} `;
27
+ else if (code >= 0x80 || /[\w-]/.test(ch))
28
+ out += ch;
29
+ else
30
+ out += `\\${ch}`;
31
+ }
32
+ return out;
33
+ }
34
+ /**
35
+ * chartColor — a series' colour as CSS: `var(--color-<key>)`, with the key escaped. Use it for a
36
+ * key that is not a plain CSS name — `stroke={chartColor("New York")}`, a `Cell`'s `fill`, the
37
+ * `color` of a `ChartGradient` or `ChartHatch`; for a plain key it is the same as writing the `var()`.
38
+ */
39
+ export function chartColor(key) {
40
+ return `var(--color-${cssKey(key)})`;
41
+ }
42
+ /* ── Container ─────────────────────────────────────────────────────────────── */
43
+ /* The category tones in the order that keeps neighbours apart. */
44
+ const TONES = ["blue", "orange", "aqua", "magenta", "lime", "violet"];
45
+ /**
46
+ * ChartContainer — the frame every chart sits in. It sizes the Recharts chart responsively
47
+ * (16:9 by default; set a height with `className="aspect-auto h-60"`), writes one
48
+ * `--color-<key>` variable per series from `config`, and themes Recharts in the zon
49
+ * material: 11px Licht Mono muted ticks, `--grid-line` hairlines (horizontal only by
50
+ * default), a hairline cursor, 1.5px lines with no dots except the active one.
51
+ *
52
+ * Series are monochrome by default: the `--chart-1…5` ramp, told apart by value plus dash,
53
+ * hatch or opacity. `palette="tones"` colours them with the category tones when the categories
54
+ * themselves are the point (a share by kind, one line per region). The rule people break:
55
+ * colour without a legend, or a rainbow for one series. Five series at most in grey, six in
56
+ * tones; fold the rest into "Other".
57
+ */
58
+ export function ChartContainer({ id, config, palette = "mono", grid = "horizontal", className, style, children, ...props }) {
59
+ const uid = React.useId();
60
+ const chartId = `chart-${(id ?? uid).replace(/[^a-zA-Z0-9_-]/g, "")}`;
61
+ const { vars, rules } = React.useMemo(() => {
62
+ const vars = {};
63
+ let rules = "";
64
+ Object.entries(config).forEach(([key, series], index) => {
65
+ const color = series.color ??
66
+ (palette === "tones"
67
+ ? `var(--tone-${TONES[index % TONES.length]})`
68
+ : `var(--chart-${Math.min(index, 4) + 1})`);
69
+ const name = cssKey(key);
70
+ if (name === key)
71
+ vars[`--color-${key}`] = color;
72
+ else {
73
+ // An escaped name cannot be an inline style's: the server writes it as text and the browser
74
+ // sets it as it is. A rule names it, and takes the colour from an inline variable.
75
+ vars[`--chart-key-${index}`] = color;
76
+ rules += `--color-${name}:var(--chart-key-${index});`;
77
+ }
78
+ });
79
+ return { vars, rules };
80
+ }, [config, palette]);
81
+ const value = React.useMemo(() => ({ config }), [config]);
82
+ // Pies lift the slice under the pointer (ChartActiveSector): know where it is from the start.
83
+ React.useEffect(track, []);
84
+ return (_jsx(ChartContext.Provider, { value: value, children: _jsxs("div", { "data-slot": "chart", role: props["aria-label"] || props["aria-labelledby"] ? "figure" : undefined, "data-chart": chartId, "data-grid": grid, className: cn("relative flex aspect-video w-full min-w-0 justify-center font-body text-xs text-foreground-soft", className), style: { ...vars, ...style }, ...props, children: [rules ? _jsx("style", { children: `[data-chart="${chartId}"]{${rules}}` }) : null, _jsx(RechartsPrimitive.ResponsiveContainer, { initialDimension: { width: 320, height: 180 }, children: children })] }) }));
85
+ }
86
+ /**
87
+ * ChartGradient — the soft vertical fill under an area: the series colour fading to nothing.
88
+ * Put it inside the chart (`<AreaChart>`) and reference it with `fill="url(#id)"`.
89
+ */
90
+ export function ChartGradient({ id, color, from = 0.24, to = 0.02 }) {
91
+ return (_jsx("defs", { children: _jsxs("linearGradient", { id: id, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "0%", stopColor: color, stopOpacity: from }), _jsx("stop", { offset: "100%", stopColor: color, stopOpacity: to })] }) }));
92
+ }
93
+ /**
94
+ * ChartHatch — a diagonal hatch fill, the second channel that separates monochrome series
95
+ * in print, forced colours and for readers who cannot tell two greys apart. Put it inside the
96
+ * chart and reference it with `fill="url(#id)"`; set `pattern: "hatch"` on the series config
97
+ * so the tooltip and legend swatches match.
98
+ */
99
+ export function ChartHatch({ id, color, angle = 45 }) {
100
+ return (_jsx("defs", { children: _jsxs("pattern", { id: id, width: "5", height: "5", patternUnits: "userSpaceOnUse", patternTransform: `rotate(${angle})`, children: [_jsx("rect", { width: "5", height: "5", fill: color, fillOpacity: 0.14 }), _jsx("line", { x1: "0", y1: "0", x2: "0", y2: "5", stroke: color, strokeWidth: "2" })] }) }));
101
+ }
102
+ /* ── Pie: the active slice ─────────────────────────────────────────────────── */
103
+ const LIFT_PX = 4;
104
+ const SECTOR = ".recharts-pie-sector";
105
+ /* Where the pointer is, for every pie on the page: one passive listener, started by the first
106
+ ChartContainer. `pointerover` too: entering an element is not always preceded by a move. */
107
+ let pointer = { x: -1, y: -1 };
108
+ let tracking = false;
109
+ const track = () => {
110
+ if (tracking || typeof document === "undefined")
111
+ return;
112
+ tracking = true;
113
+ const note = (e) => (pointer = { x: e.clientX, y: e.clientY });
114
+ for (const type of ["pointermove", "pointerover", "pointerdown"])
115
+ document.addEventListener(type, note, { passive: true, capture: true });
116
+ };
117
+ /** The slice under the pointer, looking through the tooltip's cursor and anything else drawn over the pie. */
118
+ const underPointer = () => {
119
+ for (const el of document.elementsFromPoint(pointer.x, pointer.y)) {
120
+ const sector = el.closest(SECTOR);
121
+ if (sector)
122
+ return sector;
123
+ }
124
+ return null;
125
+ };
126
+ /** Lift the slice under the pointer (once ChartActiveSector has given it a direction) and lower the rest. */
127
+ const lift = (chart, sector) => {
128
+ for (const other of chart.querySelectorAll(`${SECTOR}[data-lifted]`))
129
+ if (other !== sector)
130
+ other.removeAttribute("data-lifted");
131
+ if (sector instanceof SVGElement && sector.style.getPropertyValue("--lift-x"))
132
+ sector.setAttribute("data-lifted", "");
133
+ };
134
+ /* The chart follows the pointer itself: Recharts stops rendering once the tooltip has settled. */
135
+ const bind = (chart) => {
136
+ if (chart.hasAttribute("data-lift-bound"))
137
+ return;
138
+ chart.setAttribute("data-lift-bound", "");
139
+ chart.addEventListener("pointermove", () => lift(chart, underPointer()), { passive: true });
140
+ chart.addEventListener("pointerleave", () => lift(chart, null));
141
+ };
142
+ /**
143
+ * ChartActiveSector — lifts the slice under the pointer: it moves 4px out from the centre and
144
+ * grows 3%, on `--duration`, and settles back when the pointer leaves. Pass it as `activeShape`
145
+ * on `Pie`. Recharts calls it as a plain function, re-creates its element on every render and
146
+ * keeps the slice active after the pointer has gone, so the motion cannot live on it: it gives
147
+ * the slice's group, which persists, its direction and the pie's centre, and the chart lifts
148
+ * whichever marked slice the pointer is over; `data-lifted` carries the transition
149
+ * (parts/data.css).
150
+ */
151
+ export function ChartActiveSector(props) {
152
+ const { cx = 0, cy = 0, midAngle = 0 } = props;
153
+ const angle = (-midAngle * Math.PI) / 180;
154
+ const place = (el) => {
155
+ const sector = el?.closest(SECTOR);
156
+ const chart = sector?.closest(".recharts-wrapper");
157
+ if (!sector || !chart)
158
+ return;
159
+ track();
160
+ bind(chart);
161
+ sector.style.setProperty("--lift-x", `${Math.cos(angle) * LIFT_PX}px`);
162
+ sector.style.setProperty("--lift-y", `${Math.sin(angle) * LIFT_PX}px`);
163
+ sector.style.transformOrigin = `${cx}px ${cy}px`;
164
+ lift(chart, underPointer());
165
+ };
166
+ return (_jsx("g", { ref: place, "data-slot": "chart-active-sector", children: _jsx(RechartsPrimitive.Sector, { ...props }) }));
167
+ }
168
+ /* ── Swatch (internal) ─────────────────────────────────────────────────────── */
169
+ function ChartSwatch({ shape, color, dash, pattern, }) {
170
+ if (shape === "line") {
171
+ return (_jsx("svg", { "aria-hidden": true, "data-slot": "chart-swatch", viewBox: "0 0 14 8", className: "h-2 w-3.5 shrink-0 overflow-visible", children: _jsx("line", { x1: "0.75", y1: "4", x2: "13.25", y2: "4", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeDasharray: dash }) }));
172
+ }
173
+ return (_jsx("span", { "aria-hidden": true, "data-slot": "chart-swatch", className: "size-2 shrink-0 rounded-full", style: pattern === "hatch"
174
+ ? {
175
+ backgroundImage: `repeating-linear-gradient(45deg, ${color} 0 1.5px, transparent 1.5px 3.5px)`,
176
+ boxShadow: `inset 0 0 0 1px ${color}`,
177
+ }
178
+ : { backgroundColor: color } }));
179
+ }
180
+ /** Find the config entry for a tooltip or legend item. */
181
+ function getSeriesConfig(config, item, nameKey) {
182
+ const payload = item.payload && typeof item.payload === "object" ? item.payload : undefined;
183
+ const candidates = [
184
+ nameKey ? payload?.[nameKey] : undefined,
185
+ nameKey ? item[nameKey] : undefined,
186
+ item.dataKey,
187
+ item.name,
188
+ ];
189
+ for (const candidate of candidates) {
190
+ if ((typeof candidate === "string" || typeof candidate === "number") && String(candidate) in config) {
191
+ return [String(candidate), config[String(candidate)]];
192
+ }
193
+ }
194
+ const fallback = String(item.dataKey ?? item.name ?? "value");
195
+ return [fallback, config[fallback]];
196
+ }
197
+ /**
198
+ * ChartCursor — the tooltip's cursor, drawn so it glides from point to point instead of jumping:
199
+ * the hairline on lines and areas and the band on bars keep their shape and move by a transform
200
+ * the browser can ease (`--duration`, so still under reduced motion). `ChartTooltip` uses it by
201
+ * default.
202
+ */
203
+ export function ChartCursor(props) {
204
+ const { points, x, y, width, height, cx, className } = props;
205
+ if (points && points.length === 2) {
206
+ const [a, b] = points;
207
+ return (_jsx("line", { "data-slot": "chart-cursor", className: className, x1: 0, y1: 0, x2: b.x - a.x, y2: b.y - a.y, style: { transform: `translate(${a.x}px, ${a.y}px)` } }));
208
+ }
209
+ if (cx == null && x != null && y != null && width != null && height != null) {
210
+ return (_jsx("rect", { "data-slot": "chart-cursor", className: className, width: width, height: height, style: { transform: `translate(${x}px, ${y}px)` } }));
211
+ }
212
+ // Radial and scatter charts: Recharts' own sector and crosshair.
213
+ return cx != null ? (_jsx(RechartsPrimitive.Sector, { ...props })) : (_jsx(RechartsPrimitive.Cross, { ...props }));
214
+ }
215
+ /**
216
+ * ChartTooltip — Recharts' `Tooltip`. Pass `content={<ChartTooltipContent />}`. The cursor is a
217
+ * hairline on lines and areas and a quiet `--control-hover` band on bars, and it glides from
218
+ * point to point (`ChartCursor`); pass `cursor` to draw your own, or `false` for none.
219
+ */
220
+ export function ChartTooltip(props) {
221
+ return _jsx(RechartsPrimitive.Tooltip, { cursor: _jsx(ChartCursor, {}), ...props });
222
+ }
223
+ /**
224
+ * ChartTooltipContent — the tooltip body: menu material at 12px, the category or date in
225
+ * Licht Sans, one row per series with a small swatch, its label and a mono tabular value.
226
+ * Text stays in text tokens; only the swatch carries the series colour.
227
+ */
228
+ export function ChartTooltipContent({ active, payload, label, indicator = "dot", hideLabel = false, hideIndicator = false, labelFormatter, valueFormatter, nameKey, labelKey, className, }) {
229
+ const { config } = useChart();
230
+ if (!active || !payload?.length)
231
+ return null;
232
+ const items = payload.filter((item) => item.type !== "none" && !item.hide);
233
+ if (!items.length)
234
+ return null;
235
+ let heading = null;
236
+ if (!hideLabel) {
237
+ const firstPayload = items[0]?.payload;
238
+ const raw = labelKey
239
+ ? (config[labelKey]?.label ?? firstPayload?.[labelKey] ?? label)
240
+ : typeof label === "string" && config[label]?.label != null
241
+ ? config[label]?.label
242
+ : label;
243
+ heading = labelFormatter ? labelFormatter(raw, payload) : raw;
244
+ }
245
+ return (_jsxs("div", { "data-slot": "chart-tooltip", className: cn("grid min-w-36 gap-1.5 rounded-button material-menu px-3 py-2 font-body text-[13px] leading-none", className), children: [heading != null && heading !== "" ? (_jsx("div", { "data-slot": "chart-tooltip-label", className: "pb-0.5 font-medium text-foreground", children: heading })) : null, _jsx("div", { className: "grid gap-1.5", children: items.map((item, index) => {
246
+ const [key, series] = getSeriesConfig(config, item, nameKey);
247
+ const color = series
248
+ ? chartColor(key)
249
+ : (item.color ?? item.payload?.fill ?? "currentColor");
250
+ const name = series?.label ?? item.name ?? key;
251
+ const dash = indicator === "dashed" ? "3 2" : (series?.dash ?? item.strokeDasharray?.toString());
252
+ const Icon = series?.icon;
253
+ return (_jsxs("div", { "data-slot": "chart-tooltip-item", className: "flex min-h-4 items-center gap-2", children: [hideIndicator ? null : Icon ? (_jsx(Icon, { className: "size-3 shrink-0 text-muted-foreground" })) : (_jsx(ChartSwatch, { shape: indicator === "dot" ? "dot" : "line", color: color, dash: dash, pattern: series?.pattern })), _jsx("span", { className: "text-foreground-soft", children: name }), item.value != null ? (_jsx("span", { className: "ml-auto pl-4 font-mono text-xs text-foreground tabular-nums", children: valueFormatter
254
+ ? valueFormatter(item.value, name, item)
255
+ : typeof item.value === "number"
256
+ ? item.value.toLocaleString()
257
+ : String(item.value) })) : null] }, `${key}-${index}`));
258
+ }) })] }));
259
+ }
260
+ /* ── Legend ────────────────────────────────────────────────────────────────── */
261
+ /**
262
+ * ChartLegend — Recharts' `Legend`. Pass `content={<ChartLegendContent />}`. Items keep the
263
+ * order the series are drawn in (Recharts sorts them alphabetically by default).
264
+ */
265
+ export function ChartLegend({ itemSorter = null, ...props }) {
266
+ return _jsx(RechartsPrimitive.Legend, { itemSorter: itemSorter, ...props });
267
+ }
268
+ /**
269
+ * ChartLegendContent — one swatch and a mono 11px label per series. Always show it for two
270
+ * or more series; a single series is named by the chart's title instead.
271
+ */
272
+ export function ChartLegendContent({ payload, verticalAlign = "bottom", hideIcon = false, nameKey, className, }) {
273
+ const { config } = useChart();
274
+ if (!payload?.length)
275
+ return null;
276
+ return (_jsx("ul", { "data-slot": "chart-legend", className: cn("m-0 flex list-none flex-wrap items-center justify-center gap-x-4 gap-y-1.5 p-0", verticalAlign === "top" ? "pb-3" : "pt-3", className), children: payload
277
+ .filter((item) => item.type !== "none")
278
+ .map((item, index) => {
279
+ const [key, series] = getSeriesConfig(config, { dataKey: item.dataKey, name: item.value, payload: item.payload }, nameKey);
280
+ const color = series ? chartColor(key) : (item.color ?? "currentColor");
281
+ const itemPayload = item.payload;
282
+ const dash = series?.dash ?? itemPayload?.strokeDasharray?.toString();
283
+ const Icon = series?.icon;
284
+ return (_jsxs("li", { "data-slot": "chart-legend-item", "data-inactive": item.inactive ? "" : undefined, className: "flex items-center gap-1.5 font-mono text-[11px] leading-none text-muted-foreground data-inactive:opacity-50", children: [hideIcon ? null : Icon ? (_jsx(Icon, { className: "size-3 shrink-0" })) : (_jsx(ChartSwatch, { shape: item.type === "line" || series?.dash ? "line" : "dot", color: color, dash: dash, pattern: series?.pattern })), series?.label ?? item.value] }, `${key}-${index}`));
285
+ }) }));
286
+ }
@@ -0,0 +1,23 @@
1
+ import { Checkbox as BaseCheckbox } from "@base-ui/react/checkbox";
2
+ import { CheckboxGroup as BaseCheckboxGroup } from "@base-ui/react/checkbox-group";
3
+ import * as React from "react";
4
+ export interface CheckboxProps extends BaseCheckbox.Root.Props {
5
+ }
6
+ /**
7
+ * Checkbox — an 18 × 18px box with 5px corners. Recessed like a field while unticked; ticked
8
+ * (or indeterminate) it takes the primary fill with a fine edge and soft top/bottom shading.
9
+ * Ticking draws the check in; unticking draws it back out (parts/controls.css).
10
+ *
11
+ * Use it for independent on/off choices and consent. Wrap it in `<FieldLabel>` (inside a
12
+ * `<Field>`) so the label text is clickable. The rule people break: a checkbox with no visible
13
+ * label — every checkbox needs readable text beside it, not just an `aria-label`.
14
+ */
15
+ export declare function Checkbox({ className, ref, ...props }: CheckboxProps): React.JSX.Element;
16
+ export interface CheckboxGroupProps extends BaseCheckboxGroup.Props {
17
+ }
18
+ /**
19
+ * CheckboxGroup — shared state for a list of checkboxes; its value is the array of ticked
20
+ * `value`s. Render it through `<Fieldset render={<CheckboxGroup />}>` inside a `<Field name>`
21
+ * so the group gets a legend and joins form validation. Each checkbox needs its own `value`.
22
+ */
23
+ export declare function CheckboxGroup({ className, ref, ...props }: CheckboxGroupProps): React.JSX.Element;
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Checkbox as BaseCheckbox } from "@base-ui/react/checkbox";
4
+ import { CheckboxGroup as BaseCheckboxGroup } from "@base-ui/react/checkbox-group";
5
+ import { CheckIcon, MinusIcon } from "lucide-react";
6
+ import * as React from "react";
7
+ import { sx } from "../lib/cn.js";
8
+ import { useFormReset } from "../lib/form-reset.js";
9
+ import { mergeRefs } from "../lib/merge-refs.js";
10
+ /**
11
+ * Checkbox — an 18 × 18px box with 5px corners. Recessed like a field while unticked; ticked
12
+ * (or indeterminate) it takes the primary fill with a fine edge and soft top/bottom shading.
13
+ * Ticking draws the check in; unticking draws it back out (parts/controls.css).
14
+ *
15
+ * Use it for independent on/off choices and consent. Wrap it in `<FieldLabel>` (inside a
16
+ * `<Field>`) so the label text is clickable. The rule people break: a checkbox with no visible
17
+ * label — every checkbox needs readable text beside it, not just an `aria-label`.
18
+ */
19
+ export function Checkbox({ className, ref, ...props }) {
20
+ // A form's reset remounts it from its defaults (lib/form-reset).
21
+ const [resetKey, formRef] = useFormReset();
22
+ const refs = React.useMemo(() => mergeRefs(formRef, ref), [formRef, ref]);
23
+ return (_jsx(BaseCheckbox.Root, { ref: refs, "data-slot": "checkbox", className: sx([
24
+ "group/checkbox relative inline-flex size-[18px] shrink-0 material-field cursor-pointer items-center justify-center rounded-checkbox p-0",
25
+ "data-checked:border-transparent data-checked:bg-primary data-checked:bg-none data-checked:text-primary-foreground data-checked:shadow-checked",
26
+ "data-indeterminate:border-transparent data-indeterminate:bg-primary data-indeterminate:bg-none data-indeterminate:text-primary-foreground data-indeterminate:shadow-checked",
27
+ "data-readonly:cursor-default",
28
+ ], className), ...props, children: _jsxs(BaseCheckbox.Indicator, { "data-slot": "checkbox-indicator",
29
+ // Its own ink: unticking drops the box's text colour at once, and the check must stay
30
+ // visible on the still-dark fill while it undraws.
31
+ className: "pointer-events-none flex items-center justify-center text-primary-foreground", children: [_jsx(CheckIcon, { className: "size-3.5 group-data-indeterminate/checkbox:hidden", strokeWidth: 3 }), _jsx(MinusIcon, { className: "hidden size-3.5 group-data-indeterminate/checkbox:block", strokeWidth: 3 })] }) }, resetKey));
32
+ }
33
+ /**
34
+ * CheckboxGroup — shared state for a list of checkboxes; its value is the array of ticked
35
+ * `value`s. Render it through `<Fieldset render={<CheckboxGroup />}>` inside a `<Field name>`
36
+ * so the group gets a legend and joins form validation. Each checkbox needs its own `value`.
37
+ */
38
+ export function CheckboxGroup({ className, ref, ...props }) {
39
+ // A form's reset remounts the group, and its checkboxes, from its defaults (lib/form-reset).
40
+ const [resetKey, formRef] = useFormReset();
41
+ const refs = React.useMemo(() => mergeRefs(formRef, ref), [formRef, ref]);
42
+ return (_jsx(BaseCheckboxGroup, { ref: refs, "data-slot": "checkbox-group", className: sx("flex flex-col items-start gap-3", className), ...props }, resetKey));
43
+ }
@@ -0,0 +1,45 @@
1
+ import * as React from "react";
2
+ export interface CodeBlockProps extends Omit<React.ComponentProps<"figure">, "children"> {
3
+ /** The source to show. Alternatively pass it as the child string. */
4
+ code?: string;
5
+ children?: string;
6
+ /** `region` (default): square, part of the page. `card`: a 20px object, e.g. a standalone snippet. */
7
+ variant?: "region" | "card";
8
+ /** A filename or eyebrow shown in the header, e.g. `"vite.config.ts"`. */
9
+ filename?: React.ReactNode;
10
+ /**
11
+ * The language, e.g. `"tsx"`: shown at the end of the header, and the grammar `highlight`
12
+ * colours the code with.
13
+ */
14
+ language?: string;
15
+ /**
16
+ * Colour the code by its `language`, in the zon theme. Needs a `CodeHighlightProvider` (from
17
+ * `@zonsh/ui/code-highlight`) above it; without one, or for an unknown language, it stays mono.
18
+ */
19
+ highlight?: boolean;
20
+ /** Show muted, mono line numbers. */
21
+ lineNumbers?: boolean;
22
+ /** Wrap long lines instead of scrolling sideways, for prose such as a prompt. */
23
+ wrap?: boolean;
24
+ /** Show the copy button. Defaults to `true`. */
25
+ copyable?: boolean;
26
+ /** Accessible names for the copy button and its confirmation (see `CopyButton`). */
27
+ labels?: {
28
+ copy?: string;
29
+ copied?: string;
30
+ failed?: string;
31
+ };
32
+ }
33
+ /**
34
+ * CodeBlock — source code in Licht Mono 13px, 1.75 line height, `white-space: pre`, tab size 2,
35
+ * scrolling horizontally rather than wrapping. Give it a height or a max height and the code
36
+ * scrolls under the header. Monochrome by default; `highlight` colours it by its `language` in
37
+ * the zon theme, inside a `CodeHighlightProvider`.
38
+ *
39
+ * A **region** by default (square `surface-container`, part of the page); `variant="card"`
40
+ * makes it a 20px object for a snippet that stands on its own. An optional header carries a
41
+ * filename eyebrow over a hairline, and a raised copy button confirms with a check. The rule
42
+ * people break: a theme of their own. Syntax colours are kinds of token, so they come from the
43
+ * category tones (`--code-*`), never a palette brought in from an editor.
44
+ */
45
+ export declare function CodeBlock({ code, children, variant, filename, language, lineNumbers, wrap, highlight, copyable, labels, className, ...props }: CodeBlockProps): React.JSX.Element;
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { useCodeTokens } from "../lib/code-highlight.js";
5
+ import { cn } from "../lib/cn.js";
6
+ import { CopyButton } from "./copy-button.js";
7
+ /**
8
+ * CodeBlock — source code in Licht Mono 13px, 1.75 line height, `white-space: pre`, tab size 2,
9
+ * scrolling horizontally rather than wrapping. Give it a height or a max height and the code
10
+ * scrolls under the header. Monochrome by default; `highlight` colours it by its `language` in
11
+ * the zon theme, inside a `CodeHighlightProvider`.
12
+ *
13
+ * A **region** by default (square `surface-container`, part of the page); `variant="card"`
14
+ * makes it a 20px object for a snippet that stands on its own. An optional header carries a
15
+ * filename eyebrow over a hairline, and a raised copy button confirms with a check. The rule
16
+ * people break: a theme of their own. Syntax colours are kinds of token, so they come from the
17
+ * category tones (`--code-*`), never a palette brought in from an editor.
18
+ */
19
+ export function CodeBlock({ code, children, variant = "region", filename, language, lineNumbers = false, wrap = false, highlight = false, copyable = true, labels, className, ...props }) {
20
+ const source = (code ?? children ?? "").replace(/\n$/, "");
21
+ const { tokens, pending } = useCodeTokens(source, language, highlight);
22
+ const lines = React.useMemo(() => (tokens ? tokens.map(renderTokens) : source.split("\n")), [tokens, source]);
23
+ const hasHeader = filename != null || language != null;
24
+ const copyButton = copyable && (_jsx(CopyButton, { value: source, labels: { ...labels, copy: labels?.copy ?? "Copy code" }, "data-slot": "code-block-copy", className: cn(!hasHeader && "absolute top-3 right-3 z-10") }));
25
+ return (_jsxs("figure", { "data-slot": "code-block", "data-variant": variant, "data-highlighted": tokens ? "" : undefined, "data-highlight-pending": pending ? "" : undefined, className: cn("relative m-0 flex min-w-0 flex-col overflow-hidden text-foreground", variant === "card" ? "surface-card [--card-padding:0]" : "rounded-none surface-container", className), ...props, children: [hasHeader && (_jsxs("figcaption", { "data-slot": "code-block-header", className: cn("flex min-h-(--control-h) shrink-0 items-center justify-between gap-3 border-b border-border/60 pl-4",
26
+ // With the copy button, the header is the button plus the same 8px above, below and
27
+ // to the right, so the button sits as far from the top edge as from the right edge.
28
+ copyable ? "py-2 pr-2" : "pr-4"), children: [_jsx("span", { className: "min-w-0 truncate eyebrow text-[11px] tracking-[0.12em] normal-case", children: filename }), _jsxs("span", { className: "flex shrink-0 items-center gap-3", children: [language && _jsx("span", { className: "eyebrow text-[11px]", children: language }), copyButton] })] })), !hasHeader && copyButton, _jsx("pre", { "data-slot": "code-block-pre",
29
+ // Code reads left to right on a right-to-left page too: its brackets and commas stay put.
30
+ dir: "ltr", tabIndex: 0, className: cn(
31
+ // A height or max height on the block scrolls the code under the header, both ways.
32
+ "m-0 min-h-0 grow overflow-auto bg-transparent px-4 py-4 font-mono text-[13px] leading-[1.75] [tab-size:2] focus-ring", wrap ? "[overflow-wrap:anywhere] whitespace-pre-wrap" : "whitespace-pre", !hasHeader && copyable && "pr-14"), children: _jsx("code", { className: cn("font-[inherit]", lineNumbers && "table min-w-full"), children: lineNumbers
33
+ ? lines.map((line, i) => (_jsxs("span", { className: "table-row", children: [_jsx("span", { "aria-hidden": true, className: "table-cell w-[1%] pr-5 text-right text-control-muted tabular-nums select-none", children: i + 1 }), _jsx("span", { className: "table-cell", children: isEmpty(line) ? "\n" : line })] }, i)))
34
+ : tokens
35
+ ? lines.map((line, i) => (_jsxs(React.Fragment, { children: [i > 0 && "\n", line] }, i)))
36
+ : source }) })] }));
37
+ }
38
+ const isEmpty = (line) => line === "" || (Array.isArray(line) && line.length === 0);
39
+ /**
40
+ * Lines already drawn, by their tokens. The highlighter hands back the same tokens for lines that
41
+ * did not change (code streaming in), and the same elements let React skip them.
42
+ */
43
+ const drawn = new WeakMap();
44
+ /** One line of tokens as coloured spans; the colours are the zon theme's `var(--code-…)`. */
45
+ function renderTokens(line) {
46
+ let node = drawn.get(line);
47
+ if (node === undefined)
48
+ drawn.set(line, (node = drawLine(line)));
49
+ return node;
50
+ }
51
+ function drawLine(line) {
52
+ return line.map((token, i) => (_jsx("span", { style: {
53
+ color: token.color,
54
+ fontStyle: token.fontStyle && token.fontStyle & 1 ? "italic" : undefined,
55
+ fontWeight: token.fontStyle && token.fontStyle & 2 ? 600 : undefined,
56
+ textDecoration: token.fontStyle && token.fontStyle & 4 ? "underline" : undefined,
57
+ }, children: token.content }, i)));
58
+ }
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import { zonCodeTheme } from "../lib/code-theme.js";
3
+ export { zonCodeTheme };
4
+ /**
5
+ * CodeHighlightProvider — lets CodeBlocks inside it colour their code: a block with `highlight`
6
+ * and a `language` is tokenised with Shiki, VS Code's own grammars, in the zon theme. Shiki and
7
+ * each language load the first time a block needs them; until then, and for a language Shiki does
8
+ * not know, the block stays plain mono. It is its own entry (`@zonsh/ui/code-highlight`) so the
9
+ * main entry never pulls Shiki in; install `shiki` to use it.
10
+ */
11
+ export declare function CodeHighlightProvider({ children }: {
12
+ children?: React.ReactNode;
13
+ }): React.JSX.Element;
@@ -0,0 +1,107 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { CodeHighlighterContext } from "../lib/code-highlight.js";
5
+ import { zonCodeTheme } from "../lib/code-theme.js";
6
+ export { zonCodeTheme };
7
+ /* One highlighter for the page, made on first use: Shiki's core, its JavaScript regex engine (no
8
+ WebAssembly to fetch) and the grammars, each loaded only when a block asks for its language. */
9
+ let core;
10
+ const languages = new Map();
11
+ const getCore = () => (core ??= Promise.all([import("shiki/core"), import("shiki/engine/javascript"), import("shiki/langs")]).then(async ([{ createHighlighterCore }, { createJavaScriptRegexEngine }, { bundledLanguages }]) => ({
12
+ highlighter: await createHighlighterCore({
13
+ themes: [zonCodeTheme],
14
+ langs: [],
15
+ engine: createJavaScriptRegexEngine({ forgiving: true }),
16
+ }),
17
+ langs: bundledLanguages,
18
+ })));
19
+ let ready;
20
+ const loadedLanguages = new Set();
21
+ /** Longer lines stay mono, as in VS Code: a minified file or a data URL would take the page with it. */
22
+ const MAX_LINE = 5000;
23
+ /**
24
+ * The last few blocks coloured. Code that grows — a reply streaming in — keeps the lines it had:
25
+ * only the new ones, and the last (still being written), are tokenised again.
26
+ */
27
+ const recent = [];
28
+ /** `code`'s lines as tokens, and the state after them, going on from `state`. */
29
+ function tokenizeLines(highlighter, code, lang, state) {
30
+ const tokens = highlighter.codeToTokensBase(code, {
31
+ lang,
32
+ theme: "zon",
33
+ tokenizeMaxLineLength: MAX_LINE,
34
+ grammarState: state,
35
+ });
36
+ const lines = tokens.map((line) => line.map((token) => ({
37
+ content: token.content,
38
+ color: token.color,
39
+ fontStyle: token.fontStyle,
40
+ })));
41
+ return { lines, state: highlighter.getLastGrammarState(tokens) ?? state };
42
+ }
43
+ const shiki = {
44
+ load(language) {
45
+ const lang = language.toLowerCase();
46
+ let loading = languages.get(lang);
47
+ if (!loading) {
48
+ loading = getCore()
49
+ .then(async ({ highlighter, langs }) => {
50
+ // Its own keys only: a fence named `constructor` or `__proto__` is no grammar.
51
+ const grammar = Object.hasOwn(langs, lang) ? langs[lang] : undefined;
52
+ if (!grammar)
53
+ return false;
54
+ await highlighter.loadLanguage(grammar);
55
+ ready = highlighter;
56
+ loadedLanguages.add(lang);
57
+ return true;
58
+ })
59
+ .catch(() => false);
60
+ languages.set(lang, loading);
61
+ }
62
+ return loading;
63
+ },
64
+ tokenize(code, language) {
65
+ const lang = language.toLowerCase();
66
+ if (!ready || !loadedLanguages.has(lang))
67
+ return null;
68
+ try {
69
+ const cut = code.lastIndexOf("\n");
70
+ const head = cut === -1 ? "" : code.slice(0, cut);
71
+ const at = recent.findIndex((r) => r.lang === lang && (head === r.head || head.startsWith(`${r.head}\n`)));
72
+ let lines = [];
73
+ let state;
74
+ if (at !== -1) {
75
+ const [hit] = recent.splice(at, 1);
76
+ ({ lines, state } = hit);
77
+ if (head !== hit.head) {
78
+ const more = tokenizeLines(ready, head.slice(hit.head.length + 1), lang, state);
79
+ lines = [...lines, ...more.lines];
80
+ state = more.state;
81
+ }
82
+ }
83
+ else if (cut !== -1) {
84
+ ({ lines, state } = tokenizeLines(ready, head, lang, undefined));
85
+ }
86
+ if (cut !== -1) {
87
+ recent.unshift({ lang, head, lines, state });
88
+ recent.length = Math.min(recent.length, 8);
89
+ }
90
+ return [...lines, ...tokenizeLines(ready, code.slice(cut + 1), lang, state).lines];
91
+ }
92
+ catch {
93
+ // A grammar that cannot take this code: it stays mono rather than taking the page down.
94
+ return null;
95
+ }
96
+ },
97
+ };
98
+ /**
99
+ * CodeHighlightProvider — lets CodeBlocks inside it colour their code: a block with `highlight`
100
+ * and a `language` is tokenised with Shiki, VS Code's own grammars, in the zon theme. Shiki and
101
+ * each language load the first time a block needs them; until then, and for a language Shiki does
102
+ * not know, the block stays plain mono. It is its own entry (`@zonsh/ui/code-highlight`) so the
103
+ * main entry never pulls Shiki in; install `shiki` to use it.
104
+ */
105
+ export function CodeHighlightProvider({ children }) {
106
+ return _jsx(CodeHighlighterContext.Provider, { value: shiki, children: children });
107
+ }
@@ -0,0 +1,20 @@
1
+ import { Collapsible as BaseCollapsible } from "@base-ui/react/collapsible";
2
+ /**
3
+ * Collapsible — one region that can be shown and hidden by a trigger.
4
+ *
5
+ * Use it for secondary detail ("Show technical notes"), not for a list of questions —
6
+ * that is an `Accordion`. The rule people break: hiding content people need to complete
7
+ * the task. Collapse what is optional, never what is required.
8
+ *
9
+ * The root is full width, so it never shrink-wraps to the open panel: opening and closing
10
+ * only grows and shrinks the panel, and the trigger stays exactly where it is.
11
+ */
12
+ export declare function Collapsible({ className, ...props }: BaseCollapsible.Root.Props): import("react").JSX.Element;
13
+ export interface CollapsibleTriggerProps extends BaseCollapsible.Trigger.Props {
14
+ /** Show the chevron that rotates when open. Defaults to `true`. */
15
+ showIcon?: boolean;
16
+ }
17
+ /** A mono text trigger with a rotating chevron. Use `render` to swap in a `Button`. */
18
+ export declare function CollapsibleTrigger({ showIcon, className, children, ...props }: CollapsibleTriggerProps): import("react").JSX.Element;
19
+ /** The hidden content. Height animates from `--collapsible-panel-height`. */
20
+ export declare function CollapsiblePanel({ className, ...props }: BaseCollapsible.Panel.Props): import("react").JSX.Element;
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Collapsible as BaseCollapsible } from "@base-ui/react/collapsible";
4
+ import { ChevronRightIcon } from "lucide-react";
5
+ import { sx } from "../lib/cn.js";
6
+ /**
7
+ * Collapsible — one region that can be shown and hidden by a trigger.
8
+ *
9
+ * Use it for secondary detail ("Show technical notes"), not for a list of questions —
10
+ * that is an `Accordion`. The rule people break: hiding content people need to complete
11
+ * the task. Collapse what is optional, never what is required.
12
+ *
13
+ * The root is full width, so it never shrink-wraps to the open panel: opening and closing
14
+ * only grows and shrinks the panel, and the trigger stays exactly where it is.
15
+ */
16
+ export function Collapsible({ className, ...props }) {
17
+ return (_jsx(BaseCollapsible.Root, { "data-slot": "collapsible", className: sx("flex w-full flex-col", className), ...props }));
18
+ }
19
+ /** A mono text trigger with a rotating chevron. Use `render` to swap in a `Button`. */
20
+ export function CollapsibleTrigger({ showIcon = true, className, children, ...props }) {
21
+ return (_jsxs(BaseCollapsible.Trigger, { "data-slot": "collapsible-trigger", className: sx([
22
+ "group/collapsible-trigger inline-flex w-fit cursor-pointer items-center gap-2 py-1 font-mono text-[13px] text-foreground-soft focus-ring select-none",
23
+ "transition-colors duration-(--duration) ease-(--ease) hover:text-foreground data-panel-open:text-foreground",
24
+ "data-disabled:pointer-events-none data-disabled:opacity-50",
25
+ ], className), ...props, children: [showIcon && (_jsx(ChevronRightIcon, { "aria-hidden": true,
26
+ // Points along the line of reading: mirrored right to left, and down once open.
27
+ className: "size-3.5 shrink-0 transition-[rotate] duration-(--duration) ease-(--ease) group-data-panel-open/collapsible-trigger:rotate-90 rtl:-scale-x-100 rtl:group-data-panel-open/collapsible-trigger:-rotate-90" })), children] }));
28
+ }
29
+ /** The hidden content. Height animates from `--collapsible-panel-height`. */
30
+ export function CollapsiblePanel({ className, ...props }) {
31
+ return (_jsx(BaseCollapsible.Panel, { "data-slot": "collapsible-panel", className: sx("h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-(--duration) ease-(--ease) data-ending-style:h-0 data-starting-style:h-0", className), ...props }));
32
+ }