@zonsh/ui 0.0.0 → 0.4.1

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 (425) hide show
  1. package/LICENSE +43 -0
  2. package/README.md +81 -1
  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/bottom-nav.d.ts +86 -0
  113. package/dist/components/bottom-nav.js +175 -0
  114. package/dist/components/breadcrumb.d.ts +31 -0
  115. package/dist/components/breadcrumb.js +37 -0
  116. package/dist/components/button-group.d.ts +30 -0
  117. package/dist/components/button-group.js +47 -0
  118. package/dist/components/button.d.ts +53 -0
  119. package/dist/components/button.js +130 -0
  120. package/dist/components/calendar.d.ts +26 -0
  121. package/dist/components/calendar.js +179 -0
  122. package/dist/components/card.d.ts +42 -0
  123. package/dist/components/card.js +76 -0
  124. package/dist/components/carousel.d.ts +109 -0
  125. package/dist/components/carousel.js +231 -0
  126. package/dist/components/chart.d.ts +189 -0
  127. package/dist/components/chart.js +323 -0
  128. package/dist/components/checkbox.d.ts +23 -0
  129. package/dist/components/checkbox.js +43 -0
  130. package/dist/components/code-block.d.ts +55 -0
  131. package/dist/components/code-block.js +100 -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 +107 -0
  135. package/dist/components/color-picker.js +428 -0
  136. package/dist/components/combobox.d.ts +99 -0
  137. package/dist/components/combobox.js +172 -0
  138. package/dist/components/command.d.ts +132 -0
  139. package/dist/components/command.js +257 -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 +36 -0
  143. package/dist/components/conversation.js +303 -0
  144. package/dist/components/copy-button.d.ts +55 -0
  145. package/dist/components/copy-button.js +133 -0
  146. package/dist/components/data-table.d.ts +235 -0
  147. package/dist/components/data-table.js +655 -0
  148. package/dist/components/date-picker.d.ts +160 -0
  149. package/dist/components/date-picker.js +338 -0
  150. package/dist/components/dialog.d.ts +57 -0
  151. package/dist/components/dialog.js +95 -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 +69 -0
  155. package/dist/components/drawer.js +79 -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 +34 -0
  161. package/dist/components/field.js +81 -0
  162. package/dist/components/file-drop.d.ts +77 -0
  163. package/dist/components/file-drop.js +258 -0
  164. package/dist/components/filter-bar.d.ts +153 -0
  165. package/dist/components/filter-bar.js +334 -0
  166. package/dist/components/form.d.ts +35 -0
  167. package/dist/components/form.js +56 -0
  168. package/dist/components/graph.d.ts +146 -0
  169. package/dist/components/graph.js +825 -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 +138 -0
  173. package/dist/components/input-group.js +312 -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 +50 -0
  179. package/dist/components/kbd.js +45 -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/lightbox.d.ts +100 -0
  185. package/dist/components/lightbox.js +439 -0
  186. package/dist/components/locale.d.ts +44 -0
  187. package/dist/components/locale.js +37 -0
  188. package/dist/components/logo.d.ts +54 -0
  189. package/dist/components/logo.js +96 -0
  190. package/dist/components/menu.d.ts +60 -0
  191. package/dist/components/menu.js +140 -0
  192. package/dist/components/menubar.d.ts +62 -0
  193. package/dist/components/menubar.js +223 -0
  194. package/dist/components/message.d.ts +42 -0
  195. package/dist/components/message.js +59 -0
  196. package/dist/components/meter.d.ts +31 -0
  197. package/dist/components/meter.js +27 -0
  198. package/dist/components/money-input.d.ts +80 -0
  199. package/dist/components/money-input.js +253 -0
  200. package/dist/components/native-select.d.ts +26 -0
  201. package/dist/components/native-select.js +35 -0
  202. package/dist/components/navigation-menu.d.ts +42 -0
  203. package/dist/components/navigation-menu.js +97 -0
  204. package/dist/components/number-field.d.ts +55 -0
  205. package/dist/components/number-field.js +164 -0
  206. package/dist/components/otp-field.d.ts +48 -0
  207. package/dist/components/otp-field.js +102 -0
  208. package/dist/components/pagination.d.ts +37 -0
  209. package/dist/components/pagination.js +81 -0
  210. package/dist/components/pdf-viewer.d.ts +134 -0
  211. package/dist/components/pdf-viewer.js +996 -0
  212. package/dist/components/phone-input.d.ts +79 -0
  213. package/dist/components/phone-input.js +282 -0
  214. package/dist/components/popover.d.ts +33 -0
  215. package/dist/components/popover.js +48 -0
  216. package/dist/components/preview-card.d.ts +25 -0
  217. package/dist/components/preview-card.js +22 -0
  218. package/dist/components/progress.d.ts +27 -0
  219. package/dist/components/progress.js +25 -0
  220. package/dist/components/prompt-input.d.ts +156 -0
  221. package/dist/components/prompt-input.js +415 -0
  222. package/dist/components/quote.d.ts +22 -0
  223. package/dist/components/quote.js +15 -0
  224. package/dist/components/radio-group.d.ts +18 -0
  225. package/dist/components/radio-group.js +34 -0
  226. package/dist/components/rating.d.ts +73 -0
  227. package/dist/components/rating.js +124 -0
  228. package/dist/components/reasoning.d.ts +46 -0
  229. package/dist/components/reasoning.js +73 -0
  230. package/dist/components/resizable.d.ts +47 -0
  231. package/dist/components/resizable.js +44 -0
  232. package/dist/components/response.d.ts +41 -0
  233. package/dist/components/response.js +566 -0
  234. package/dist/components/scroll-area.d.ts +33 -0
  235. package/dist/components/scroll-area.js +31 -0
  236. package/dist/components/select.d.ts +35 -0
  237. package/dist/components/select.js +71 -0
  238. package/dist/components/separator.d.ts +14 -0
  239. package/dist/components/separator.js +17 -0
  240. package/dist/components/sidebar.d.ts +163 -0
  241. package/dist/components/sidebar.js +505 -0
  242. package/dist/components/site-header.d.ts +93 -0
  243. package/dist/components/site-header.js +121 -0
  244. package/dist/components/skeleton.d.ts +31 -0
  245. package/dist/components/skeleton.js +29 -0
  246. package/dist/components/slider.d.ts +24 -0
  247. package/dist/components/slider.js +131 -0
  248. package/dist/components/sortable.d.ts +178 -0
  249. package/dist/components/sortable.js +1258 -0
  250. package/dist/components/sources.d.ts +40 -0
  251. package/dist/components/sources.js +42 -0
  252. package/dist/components/spinner.d.ts +48 -0
  253. package/dist/components/spinner.js +75 -0
  254. package/dist/components/stat.d.ts +91 -0
  255. package/dist/components/stat.js +141 -0
  256. package/dist/components/stepper.d.ts +71 -0
  257. package/dist/components/stepper.js +101 -0
  258. package/dist/components/suggestions.d.ts +20 -0
  259. package/dist/components/suggestions.js +18 -0
  260. package/dist/components/switch.d.ts +14 -0
  261. package/dist/components/switch.js +26 -0
  262. package/dist/components/table.d.ts +172 -0
  263. package/dist/components/table.js +895 -0
  264. package/dist/components/tabs.d.ts +25 -0
  265. package/dist/components/tabs.js +162 -0
  266. package/dist/components/tag.d.ts +41 -0
  267. package/dist/components/tag.js +88 -0
  268. package/dist/components/tags-input.d.ts +56 -0
  269. package/dist/components/tags-input.js +271 -0
  270. package/dist/components/textarea.d.ts +13 -0
  271. package/dist/components/textarea.js +16 -0
  272. package/dist/components/theme.d.ts +55 -0
  273. package/dist/components/theme.js +120 -0
  274. package/dist/components/time-field.d.ts +70 -0
  275. package/dist/components/time-field.js +450 -0
  276. package/dist/components/timeline.d.ts +92 -0
  277. package/dist/components/timeline.js +108 -0
  278. package/dist/components/tippy.d.ts +48 -0
  279. package/dist/components/tippy.js +648 -0
  280. package/dist/components/toast.d.ts +88 -0
  281. package/dist/components/toast.js +205 -0
  282. package/dist/components/toggle-group.d.ts +41 -0
  283. package/dist/components/toggle-group.js +140 -0
  284. package/dist/components/toggle.d.ts +23 -0
  285. package/dist/components/toggle.js +35 -0
  286. package/dist/components/tool-call.d.ts +63 -0
  287. package/dist/components/tool-call.js +68 -0
  288. package/dist/components/toolbar.d.ts +17 -0
  289. package/dist/components/toolbar.js +39 -0
  290. package/dist/components/tooltip.d.ts +42 -0
  291. package/dist/components/tooltip.js +47 -0
  292. package/dist/components/tour.d.ts +127 -0
  293. package/dist/components/tour.js +648 -0
  294. package/dist/components/tree.d.ts +75 -0
  295. package/dist/components/tree.js +649 -0
  296. package/dist/components/typography.d.ts +134 -0
  297. package/dist/components/typography.js +176 -0
  298. package/dist/components/video-player.d.ts +284 -0
  299. package/dist/components/video-player.js +1392 -0
  300. package/dist/illustration.d.ts +2 -0
  301. package/dist/illustration.js +7 -0
  302. package/dist/index.d.ts +93 -0
  303. package/dist/index.js +94 -0
  304. package/dist/lib/cn.d.ts +20 -0
  305. package/dist/lib/cn.js +38 -0
  306. package/dist/lib/code-highlight.d.ts +18 -0
  307. package/dist/lib/code-highlight.js +174 -0
  308. package/dist/lib/code-theme.d.ts +19 -0
  309. package/dist/lib/code-theme.js +140 -0
  310. package/dist/lib/collapse-row.d.ts +9 -0
  311. package/dist/lib/collapse-row.js +129 -0
  312. package/dist/lib/digit-roll.d.ts +21 -0
  313. package/dist/lib/digit-roll.js +31 -0
  314. package/dist/lib/editorial-assets.d.ts +16 -0
  315. package/dist/lib/editorial-assets.js +56 -0
  316. package/dist/lib/field-errors.d.ts +28 -0
  317. package/dist/lib/field-errors.js +24 -0
  318. package/dist/lib/field-value.d.ts +13 -0
  319. package/dist/lib/field-value.js +44 -0
  320. package/dist/lib/figure/catalog.d.ts +127 -0
  321. package/dist/lib/figure/catalog.js +130 -0
  322. package/dist/lib/figure/figures/automation.d.ts +7 -0
  323. package/dist/lib/figure/figures/automation.js +143 -0
  324. package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
  325. package/dist/lib/figure/figures/bar-chart.js +99 -0
  326. package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
  327. package/dist/lib/figure/figures/brackets-classic.js +170 -0
  328. package/dist/lib/figure/figures/brackets.d.ts +8 -0
  329. package/dist/lib/figure/figures/brackets.js +84 -0
  330. package/dist/lib/figure/figures/city.d.ts +7 -0
  331. package/dist/lib/figure/figures/city.js +93 -0
  332. package/dist/lib/figure/figures/conveyor.d.ts +7 -0
  333. package/dist/lib/figure/figures/conveyor.js +97 -0
  334. package/dist/lib/figure/figures/database.d.ts +7 -0
  335. package/dist/lib/figure/figures/database.js +65 -0
  336. package/dist/lib/figure/figures/documents.d.ts +7 -0
  337. package/dist/lib/figure/figures/documents.js +83 -0
  338. package/dist/lib/figure/figures/inbox.d.ts +7 -0
  339. package/dist/lib/figure/figures/inbox.js +92 -0
  340. package/dist/lib/figure/figures/laptop.d.ts +7 -0
  341. package/dist/lib/figure/figures/laptop.js +67 -0
  342. package/dist/lib/figure/figures/monitor.d.ts +7 -0
  343. package/dist/lib/figure/figures/monitor.js +59 -0
  344. package/dist/lib/figure/figures/pipeline.d.ts +8 -0
  345. package/dist/lib/figure/figures/pipeline.js +117 -0
  346. package/dist/lib/figure/figures/platform.d.ts +7 -0
  347. package/dist/lib/figure/figures/platform.js +117 -0
  348. package/dist/lib/figure/figures/server.d.ts +7 -0
  349. package/dist/lib/figure/figures/server.js +115 -0
  350. package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
  351. package/dist/lib/figure/figures/spreadsheet.js +87 -0
  352. package/dist/lib/figure/figures/timeline.d.ts +7 -0
  353. package/dist/lib/figure/figures/timeline.js +65 -0
  354. package/dist/lib/figure/kernel.d.ts +152 -0
  355. package/dist/lib/figure/kernel.js +576 -0
  356. package/dist/lib/figure/parts.d.ts +42 -0
  357. package/dist/lib/figure/parts.js +126 -0
  358. package/dist/lib/form-reset.d.ts +11 -0
  359. package/dist/lib/form-reset.js +22 -0
  360. package/dist/lib/glide.d.ts +53 -0
  361. package/dist/lib/glide.js +138 -0
  362. package/dist/lib/graph-layout.d.ts +58 -0
  363. package/dist/lib/graph-layout.js +209 -0
  364. package/dist/lib/illustration-drawings.d.ts +89 -0
  365. package/dist/lib/illustration-drawings.js +539 -0
  366. package/dist/lib/illustration-info.d.ts +37 -0
  367. package/dist/lib/illustration-info.js +22 -0
  368. package/dist/lib/illustration-library.d.ts +87 -0
  369. package/dist/lib/illustration-library.js +352 -0
  370. package/dist/lib/logo-geometry.d.ts +29 -0
  371. package/dist/lib/logo-geometry.js +67 -0
  372. package/dist/lib/markdown-guard.d.ts +16 -0
  373. package/dist/lib/markdown-guard.js +123 -0
  374. package/dist/lib/merge-refs.d.ts +10 -0
  375. package/dist/lib/merge-refs.js +26 -0
  376. package/dist/lib/money.d.ts +73 -0
  377. package/dist/lib/money.js +343 -0
  378. package/dist/lib/motion.d.ts +6 -0
  379. package/dist/lib/motion.js +12 -0
  380. package/dist/lib/pdf-worker.d.ts +1 -0
  381. package/dist/lib/pdf-worker.js +6 -0
  382. package/dist/lib/pdf.d.ts +19 -0
  383. package/dist/lib/pdf.js +58 -0
  384. package/dist/lib/phone-countries.d.ts +1 -0
  385. package/dist/lib/phone-countries.js +281 -0
  386. package/dist/lib/phone.d.ts +90 -0
  387. package/dist/lib/phone.js +286 -0
  388. package/dist/lib/platform.d.ts +38 -0
  389. package/dist/lib/platform.js +75 -0
  390. package/dist/lib/room.d.ts +25 -0
  391. package/dist/lib/room.js +46 -0
  392. package/dist/lib/row-index.d.ts +15 -0
  393. package/dist/lib/row-index.js +136 -0
  394. package/dist/lib/table-fit.d.ts +143 -0
  395. package/dist/lib/table-fit.js +596 -0
  396. package/dist/lib/theme-script.d.ts +31 -0
  397. package/dist/lib/theme-script.js +49 -0
  398. package/dist/lib/tippy/pixels.d.ts +47 -0
  399. package/dist/lib/tippy/pixels.js +187 -0
  400. package/dist/lib/tippy/sprite.d.ts +86 -0
  401. package/dist/lib/tippy/sprite.js +753 -0
  402. package/dist/messages/de.d.ts +12 -0
  403. package/dist/messages/de.js +326 -0
  404. package/dist/styles/expressive.css +203 -0
  405. package/dist/styles/fonts.css +145 -0
  406. package/dist/styles/index.css +207 -0
  407. package/dist/styles/material.css +317 -0
  408. package/dist/styles/parts/ai.css +361 -0
  409. package/dist/styles/parts/brand.css +75 -0
  410. package/dist/styles/parts/controls.css +774 -0
  411. package/dist/styles/parts/data.css +222 -0
  412. package/dist/styles/parts/editorial.css +120 -0
  413. package/dist/styles/parts/feedback.css +340 -0
  414. package/dist/styles/parts/foundations.css +166 -0
  415. package/dist/styles/parts/graph.css +214 -0
  416. package/dist/styles/parts/inputs.css +261 -0
  417. package/dist/styles/parts/isometric.css +124 -0
  418. package/dist/styles/parts/navigation.css +424 -0
  419. package/dist/styles/parts/overlays.css +250 -0
  420. package/dist/styles/parts/pdf.css +154 -0
  421. package/dist/styles/parts/react-flow.css +519 -0
  422. package/dist/styles/tokens.css +299 -0
  423. package/dist/vite.d.ts +66 -0
  424. package/dist/vite.js +29 -0
  425. package/package.json +183 -5
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import { type ButtonProps } from "./button.js";
3
+ export interface ConversationMessages {
4
+ /** ConversationScrollButton's name. */
5
+ scrollToLatest: string;
6
+ }
7
+ declare module "./locale" {
8
+ interface Messages {
9
+ conversation: ConversationMessages;
10
+ }
11
+ }
12
+ export interface ConversationProps extends React.ComponentProps<"div"> {
13
+ }
14
+ /**
15
+ * Conversation — the scrolling column of messages in an AI chat. It sticks to the latest
16
+ * message: while you are at the end, new messages and a reply streaming in keep it there, and the
17
+ * view glides to each new line rather than jumping. Scroll up to read and it stays put, with a
18
+ * `ConversationScrollButton` to come back.
19
+ *
20
+ * The scroller is a `log` region: name it with `aria-label`. Give the conversation a height
21
+ * (it fills a flex column with `flex-1 min-h-0`). The rule people break: scrolling the whole
22
+ * page instead — the prompt bar belongs under the conversation, always in view.
23
+ */
24
+ export declare function Conversation({ className, style, children, ref, onScroll, ...props }: ConversationProps): React.JSX.Element;
25
+ /** The column of messages: 24px apart, padded, at a reading width. */
26
+ export declare function ConversationContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
27
+ export interface ConversationScrollButtonProps extends Omit<ButtonProps, "children"> {
28
+ /** Accessible name. Default `Scroll to the latest message`, or `messages.conversation.scrollToLatest`. */
29
+ label?: string;
30
+ }
31
+ /**
32
+ * A round raised button, centred on the bottom edge of the conversation, that brings back the
33
+ * latest message. It appears only once you have scrolled away from it. Put it inside
34
+ * `Conversation`, after `ConversationContent`.
35
+ */
36
+ export declare function ConversationScrollButton({ label, className, onClick, ...props }: ConversationScrollButtonProps): React.JSX.Element;
@@ -0,0 +1,303 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ArrowDownIcon } from "lucide-react";
4
+ import * as React from "react";
5
+ import { cn, sx } from "../lib/cn.js";
6
+ import { mergeRefs } from "../lib/merge-refs.js";
7
+ import { Button } from "./button.js";
8
+ import { useMessages } from "./locale.js";
9
+ const defaultMessages = { scrollToLatest: "Scroll to the latest message" };
10
+ /** How close to the end (px) still counts as "at the latest message". */
11
+ const STICK_PX = 32;
12
+ const ConversationContext = React.createContext(null);
13
+ const reducedMotion = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
14
+ /**
15
+ * Conversation — the scrolling column of messages in an AI chat. It sticks to the latest
16
+ * message: while you are at the end, new messages and a reply streaming in keep it there, and the
17
+ * view glides to each new line rather than jumping. Scroll up to read and it stays put, with a
18
+ * `ConversationScrollButton` to come back.
19
+ *
20
+ * The scroller is a `log` region: name it with `aria-label`. Give the conversation a height
21
+ * (it fills a flex column with `flex-1 min-h-0`). The rule people break: scrolling the whole
22
+ * page instead — the prompt bar belongs under the conversation, always in view.
23
+ */
24
+ export function Conversation({ className, style, children, ref, onScroll, ...props }) {
25
+ const scroller = React.useRef(null);
26
+ const scrollerRefs = React.useMemo(() => mergeRefs(scroller, ref), [ref]);
27
+ const stuck = React.useRef(true);
28
+ const lastTop = React.useRef(0);
29
+ const lastMax = React.useRef(0);
30
+ const glide = React.useRef({ frame: 0, last: 0 });
31
+ /** Where the glide last put the view: the scroll event that write fires is not the reader's. */
32
+ const glideTop = React.useRef(Number.NaN);
33
+ const [atBottom, setAtBottom] = React.useState(true);
34
+ /**
35
+ * Following the reply, the conversation scrolls itself, and the browser's scroll anchoring would
36
+ * fight the glide (a panel folding above makes the view snap a line). Scrolled away to read,
37
+ * anchoring is back on, so the text being read stays put when something above it changes.
38
+ */
39
+ const setStuck = React.useCallback((value) => {
40
+ stuck.current = value;
41
+ const el = scroller.current;
42
+ if (el)
43
+ el.style.overflowAnchor = value ? "none" : "";
44
+ }, []);
45
+ /**
46
+ * Eases the view to the end: each frame closes most of the distance left, so a line that
47
+ * appears slides into view instead of jumping it. Stops when the reader scrolls away.
48
+ */
49
+ const follow = React.useCallback(() => {
50
+ const el = scroller.current;
51
+ if (!el || !stuck.current)
52
+ return;
53
+ if (reducedMotion()) {
54
+ el.scrollTop = el.scrollHeight;
55
+ glideTop.current = el.scrollTop;
56
+ return;
57
+ }
58
+ if (glide.current.frame)
59
+ return;
60
+ const step = (now) => {
61
+ const g = glide.current;
62
+ const dt = Math.min(64, now - (g.last || now - 16));
63
+ g.last = now;
64
+ const end = el.scrollHeight - el.clientHeight;
65
+ const gap = end - el.scrollTop;
66
+ // Done within a pixel: at a fractional zoom the end can sit up to 1px past the last
67
+ // scrollTop the browser will take.
68
+ if (!stuck.current || gap < 1) {
69
+ if (stuck.current && gap > 0) {
70
+ el.scrollTop = end;
71
+ glideTop.current = el.scrollTop;
72
+ }
73
+ g.frame = 0;
74
+ g.last = 0;
75
+ return;
76
+ }
77
+ const before = el.scrollTop;
78
+ el.scrollTop += Math.max(1, gap * (1 - Math.pow(0.82, dt / 16)));
79
+ glideTop.current = el.scrollTop;
80
+ if (el.scrollTop === before) {
81
+ g.frame = 0;
82
+ g.last = 0;
83
+ return;
84
+ }
85
+ g.frame = requestAnimationFrame(step);
86
+ };
87
+ glide.current.frame = requestAnimationFrame(step);
88
+ }, []);
89
+ const scrollToBottom = React.useCallback((behavior = "smooth") => {
90
+ const el = scroller.current;
91
+ if (!el)
92
+ return;
93
+ setStuck(true);
94
+ setAtBottom(true);
95
+ el.scrollTo({ top: el.scrollHeight, behavior: reducedMotion() ? "auto" : behavior });
96
+ }, [setStuck]);
97
+ const focusLog = React.useCallback(() => scroller.current?.focus({ preventScroll: true }), []);
98
+ React.useEffect(() => () => {
99
+ const g = glide.current;
100
+ cancelAnimationFrame(g.frame);
101
+ g.frame = 0;
102
+ g.last = 0;
103
+ }, []);
104
+ React.useLayoutEffect(() => {
105
+ const el = scroller.current;
106
+ if (!el)
107
+ return;
108
+ el.scrollTop = el.scrollHeight;
109
+ lastTop.current = el.scrollTop;
110
+ lastMax.current = el.scrollHeight - el.clientHeight;
111
+ setStuck(stuck.current);
112
+ const near = () => el.scrollHeight - el.clientHeight - el.scrollTop <= STICK_PX;
113
+ // Content or the log changed size: follow it, or, scrolled away, say whether the end is
114
+ // still in reach (text growing below fires no scroll event to say so). With nothing left to
115
+ // scroll, there is nothing to be away from: it follows again, for the next reply.
116
+ const changed = () => {
117
+ // Where layout left the view is not the reader's doing: when content shrinks and clamps the
118
+ // view, and grows back before the browser fires the scroll event (a slow frame in Firefox),
119
+ // that event must not read as a move up from where the view, or the glide, was before.
120
+ lastTop.current = el.scrollTop;
121
+ lastMax.current = el.scrollHeight - el.clientHeight;
122
+ glideTop.current = Number.NaN;
123
+ if (!stuck.current && el.scrollHeight - el.clientHeight <= 0.5)
124
+ setStuck(true);
125
+ if (stuck.current)
126
+ follow();
127
+ else
128
+ setAtBottom(near());
129
+ };
130
+ const resize = new ResizeObserver(changed);
131
+ // The messages, and the log itself: a prompt bar that grows below it makes it shorter.
132
+ const observeAll = () => {
133
+ resize.disconnect();
134
+ resize.observe(el);
135
+ for (const child of el.children)
136
+ resize.observe(child);
137
+ };
138
+ observeAll();
139
+ const mutations = new MutationObserver(() => {
140
+ observeAll();
141
+ changed();
142
+ });
143
+ mutations.observe(el, { childList: true });
144
+ // The reader's own move up — a wheel, a finger, a key — lets go at once, even mid-glide,
145
+ // where the scroll it makes could be outrun by the glide's; the glide stops there. Only when
146
+ // there is somewhere to go: on a log that does not scroll yet, nothing changes. A move down
147
+ // at the end, where there may be nothing left to scroll, takes it up again.
148
+ let touchX = 0;
149
+ let touchY = 0;
150
+ /** Something inside the log (a message's own scroller) that this move scrolls instead. */
151
+ const inner = (target, up) => {
152
+ for (let node = target; node && node !== el; node = node.parentElement) {
153
+ if (!/(auto|scroll)/.test(getComputedStyle(node).overflowY) ||
154
+ node.scrollHeight <= node.clientHeight + 1)
155
+ continue;
156
+ if (up ? node.scrollTop > 0.5 : node.scrollTop + node.clientHeight < node.scrollHeight - 0.5)
157
+ return true;
158
+ }
159
+ return false;
160
+ };
161
+ const letGo = () => {
162
+ if (el.scrollTop <= 0.5)
163
+ return;
164
+ setStuck(false);
165
+ const g = glide.current;
166
+ cancelAnimationFrame(g.frame);
167
+ g.frame = 0;
168
+ g.last = 0;
169
+ };
170
+ const rejoin = () => {
171
+ if (stuck.current || !near())
172
+ return;
173
+ setStuck(true);
174
+ setAtBottom(true);
175
+ follow();
176
+ };
177
+ // Not a pinch or Ctrl+wheel (that zooms), and not a wheel a message's own scroller takes.
178
+ const wheel = (event) => {
179
+ if (event.ctrlKey || !event.deltaY || inner(event.target, event.deltaY < 0))
180
+ return;
181
+ if (event.deltaY < 0)
182
+ letGo();
183
+ else
184
+ rejoin();
185
+ };
186
+ const touchStart = (event) => {
187
+ touchX = event.touches[0]?.clientX ?? 0;
188
+ touchY = event.touches[0]?.clientY ?? 0;
189
+ };
190
+ // One finger, mostly up or down, past a tap's slop: a finger drifting on the way to a button,
191
+ // a pan along a code block or a pinch is not a scroll of the log. It counts again from each
192
+ // decision, so a drag that turns back is read too.
193
+ const touchMove = (event) => {
194
+ const touch = event.touches[0];
195
+ if (!touch || event.touches.length > 1)
196
+ return;
197
+ const dy = touch.clientY - touchY;
198
+ if (Math.abs(dy) <= 10 || Math.abs(dy) < Math.abs(touch.clientX - touchX))
199
+ return;
200
+ if (!inner(event.target, dy > 0)) {
201
+ if (dy > 0)
202
+ letGo();
203
+ else
204
+ rejoin();
205
+ }
206
+ touchX = touch.clientX;
207
+ touchY = touch.clientY;
208
+ };
209
+ // Keys pressed on a control or a widget inside the log (a button, tabs, a menu, a field)
210
+ // are theirs.
211
+ const OWN_KEYS = "a, button, summary, input, textarea, select, [contenteditable], [role=button], [role=combobox], [role=toolbar], [role=menubar], [role=group], [role=tablist], [role=radiogroup], [role=slider], [role=spinbutton], [role=menu], [role=listbox], [role=grid], [role=tree]";
212
+ const key = (event) => {
213
+ if (event.target !== el && event.target.closest?.(OWN_KEYS))
214
+ return;
215
+ const space = event.key === " ";
216
+ if (["ArrowUp", "PageUp", "Home"].includes(event.key) || (space && event.shiftKey))
217
+ letGo();
218
+ else if (["ArrowDown", "PageDown", "End"].includes(event.key) || space)
219
+ rejoin();
220
+ };
221
+ el.addEventListener("wheel", wheel, { passive: true });
222
+ el.addEventListener("touchstart", touchStart, { passive: true });
223
+ el.addEventListener("touchmove", touchMove, { passive: true });
224
+ el.addEventListener("keydown", key);
225
+ return () => {
226
+ resize.disconnect();
227
+ mutations.disconnect();
228
+ el.removeEventListener("wheel", wheel);
229
+ el.removeEventListener("touchstart", touchStart);
230
+ el.removeEventListener("touchmove", touchMove);
231
+ el.removeEventListener("keydown", key);
232
+ };
233
+ }, [follow, setStuck]);
234
+ const context = React.useMemo(() => ({ atBottom, scrollToBottom, focusLog }), [atBottom, scrollToBottom, focusLog]);
235
+ // The scroll button sits over the conversation, not in the scroller, so it stays on the bottom edge.
236
+ const parts = React.Children.toArray(children);
237
+ const isButton = (child) => React.isValidElement(child) && child.type === ConversationScrollButton;
238
+ return (_jsx(ConversationContext.Provider, { value: context, children: _jsxs("div", { "data-slot": "conversation", className: cn("relative flex min-h-0 flex-1 flex-col", className), style: style, children: [_jsx("div", { role: "log", tabIndex: 0, "data-slot": "conversation-scroller", ...props, ref: scrollerRefs, onScroll: (event) => {
239
+ const el = event.currentTarget;
240
+ const max = el.scrollHeight - el.clientHeight;
241
+ const end = max - el.scrollTop <= STICK_PX;
242
+ // A move in a frame where the log also changed size is layout's — a panel folding
243
+ // above, a line arriving below — not the reader's: it changes nothing. Otherwise a
244
+ // move up, even a few pixels, lets go (the glide only moves down), and a move down
245
+ // into the end takes up following again. The reader's wheel, finger and keys say so
246
+ // at once, too (see the listeners above).
247
+ // The glide's own move is not the reader's either; any other move is measured from where
248
+ // the glide last put the view, so a slow scroll up is not swallowed by its steps.
249
+ const glided = Math.abs(el.scrollTop - glideTop.current) < 0.5;
250
+ const from = !glided && !Number.isNaN(glideTop.current) ? glideTop.current : lastTop.current;
251
+ glideTop.current = Number.NaN;
252
+ const resized = Math.abs(max - lastMax.current) > 0.5;
253
+ // In a resized frame, only a jump further than the end zone (to a find, a focused
254
+ // link) is the reader's; a few pixels, or a clamp to the end, is layout.
255
+ const clamped = max - el.scrollTop < 1;
256
+ const up = !glided && !clamped && el.scrollTop < from - 1 && (!resized || from - el.scrollTop > STICK_PX);
257
+ // Down, and nearer the end than before: layout never does both (anchoring keeps the
258
+ // distance, a clamp moves the view up), so this holds through a resize too.
259
+ const down = !glided &&
260
+ el.scrollTop > lastTop.current + 0.5 &&
261
+ max - el.scrollTop < lastMax.current - lastTop.current - 0.5;
262
+ if (up)
263
+ setStuck(false);
264
+ else if (end && down)
265
+ setStuck(true);
266
+ lastTop.current = el.scrollTop;
267
+ lastMax.current = max;
268
+ setAtBottom(end || stuck.current);
269
+ onScroll?.(event);
270
+ },
271
+ // Its corners are the conversation's: round that (`rounded-t-card` in a card), and the
272
+ // messages, the scrollbar and the focus ring follow, with no `overflow-hidden` to clip them.
273
+ // Its own scrolling is instant, whatever an app sets for `scroll-behavior`: the glide does the easing.
274
+ className: "min-h-0 flex-1 overflow-y-auto overscroll-contain [scroll-behavior:auto] [border-radius:inherit] focus-ring [--scrollbar-inset:var(--radius-card)]", children: parts.filter((child) => !isButton(child)) }), parts.filter(isButton)] }) }));
275
+ }
276
+ /** The column of messages: 24px apart, padded, at a reading width. */
277
+ export function ConversationContent({ className, ...props }) {
278
+ return (_jsx("div", { "data-slot": "conversation-content", className: cn("mx-auto flex w-full max-w-3xl flex-col gap-6 px-4 py-6", className), ...props }));
279
+ }
280
+ /**
281
+ * A round raised button, centred on the bottom edge of the conversation, that brings back the
282
+ * latest message. It appears only once you have scrolled away from it. Put it inside
283
+ * `Conversation`, after `ConversationContent`.
284
+ */
285
+ export function ConversationScrollButton({ label, className, onClick, ...props }) {
286
+ const text = useMessages("conversation", defaultMessages);
287
+ const context = React.useContext(ConversationContext);
288
+ if (!context)
289
+ throw new Error("ConversationScrollButton must be used inside <Conversation>.");
290
+ const visible = !context.atBottom;
291
+ return (_jsx(Button, { "data-slot": "conversation-scroll-button", "data-visible": visible ? "" : undefined, variant: "secondary", size: "icon", "aria-label": label ?? text.scrollToLatest, "aria-hidden": !visible, tabIndex: visible ? 0 : -1, onClick: (event) => {
292
+ onClick?.(event);
293
+ if (event.defaultPrevented)
294
+ return;
295
+ // It hides once at the end: give focus to the log rather than leave it on a hidden button.
296
+ if (event.currentTarget === document.activeElement)
297
+ context.focusLog();
298
+ context.scrollToBottom();
299
+ }, className: sx([
300
+ "absolute bottom-4 left-1/2 -translate-x-1/2 transition-[opacity,translate] duration-(--duration) ease-(--ease)",
301
+ visible ? "opacity-100" : "pointer-events-none translate-y-2 opacity-0",
302
+ ], className), ...props, children: _jsx(ArrowDownIcon, { "aria-hidden": true }) }));
303
+ }
@@ -0,0 +1,55 @@
1
+ import * as React from "react";
2
+ import { type ButtonProps } from "./button.js";
3
+ export interface CopyButtonMessages {
4
+ /** The name at rest. Say what is copied in `labels`: "Copy API key". */
5
+ copy: string;
6
+ /** Announced, and shown on a labelled button, once the text is on the clipboard. */
7
+ copied: string;
8
+ /** Announced when the clipboard refused the text. */
9
+ failed: string;
10
+ }
11
+ declare module "./locale" {
12
+ interface Messages {
13
+ copyButton: CopyButtonMessages;
14
+ }
15
+ }
16
+ export interface CopyButtonProps extends Omit<ButtonProps, "value" | "onCopy" | "render" | "onError"> {
17
+ /**
18
+ * What to copy: a string, or a function that returns it (or a promise of it) at the moment of
19
+ * the click. A function that throws or rejects counts as a failed copy.
20
+ */
21
+ value: string | (() => string | Promise<string>);
22
+ /** Called with the text once it is on the clipboard. */
23
+ onCopy?: (text: string) => void;
24
+ /**
25
+ * Called when the copy failed: the clipboard refused it, or `value` threw or rejected. The
26
+ * button shows a cross and announces the failure.
27
+ */
28
+ onError?: (error: unknown) => void;
29
+ /** How long the check (or the cross) stays, in milliseconds. Default 1500. */
30
+ timeout?: number;
31
+ /**
32
+ * The accessible names: `copy` names the button at rest (default "Copy"), `copied` and `failed`
33
+ * are announced after a click (default "Copied" and "Couldn't copy"). Say what is copied:
34
+ * "Copy API key". A LocaleProvider sets them for every CopyButton (`messages.copyButton`).
35
+ */
36
+ labels?: Partial<CopyButtonMessages>;
37
+ /**
38
+ * Draw another button instead of `Button` — most often `<InputGroupButton size="icon" />` in
39
+ * an `InputGroup`. It receives the click, the accessible name and the icon; its own variant
40
+ * and size stay.
41
+ */
42
+ render?: React.ReactElement<Record<string, unknown>>;
43
+ }
44
+ /**
45
+ * CopyButton — copies a value to the clipboard and says so: the copy icon turns into a check for
46
+ * a moment and a polite live region announces "Copied". If the clipboard refuses, it shows a
47
+ * cross and announces that instead. Icon-only by default (a raised 30px circle); give it
48
+ * children and it becomes a labelled button whose label reads "Copied" for the moment, at the
49
+ * same width.
50
+ *
51
+ * Put it next to the thing it copies: an API key in an `InputGroup` (`render={<InputGroupButton
52
+ * size="icon" />}`), an invite link, an ID in mono. The rule people break: a bare "Copy" name.
53
+ * Say what it copies in `labels.copy` ("Copy invite link"), since a page has several.
54
+ */
55
+ export declare function CopyButton({ value, onCopy, onError, timeout, labels, render, variant, size, onClick, className, children, ...props }: CopyButtonProps): React.JSX.Element;
@@ -0,0 +1,133 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { CheckIcon, CopyIcon, XIcon } from "lucide-react";
4
+ import * as React from "react";
5
+ import { cn } from "../lib/cn.js";
6
+ import { Button } from "./button.js";
7
+ import { useMessages } from "./locale.js";
8
+ const defaultMessages = {
9
+ copy: "Copy",
10
+ copied: "Copied",
11
+ failed: "Couldn't copy",
12
+ };
13
+ /**
14
+ * Writes text to the clipboard: the async Clipboard API where the page may use it, and the old
15
+ * `execCommand("copy")` on a hidden textarea where it may not (an `http:` page, an iframe without
16
+ * the permission). Rejects when neither works.
17
+ */
18
+ async function writeClipboard(text) {
19
+ try {
20
+ if (!navigator.clipboard?.writeText)
21
+ throw new Error("No Clipboard API");
22
+ await navigator.clipboard.writeText(text);
23
+ }
24
+ catch (error) {
25
+ const area = document.createElement("textarea");
26
+ area.value = text;
27
+ area.setAttribute("readonly", "");
28
+ area.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none";
29
+ const active = document.activeElement;
30
+ document.body.append(area);
31
+ area.select();
32
+ let ok = false;
33
+ try {
34
+ ok = document.execCommand("copy");
35
+ }
36
+ finally {
37
+ area.remove();
38
+ active?.focus({ preventScroll: true });
39
+ }
40
+ if (!ok)
41
+ throw error;
42
+ }
43
+ }
44
+ /* Two faces stacked in one grid cell: the one at rest and the one that answers. They cross-fade
45
+ and swap scale on --duration (0 under reduced motion), so the button never changes size. */
46
+ const face = "col-start-1 row-start-1 place-self-center transition-[opacity,scale] duration-(--duration) ease-(--ease)";
47
+ const shown = "scale-100 opacity-100";
48
+ const hidden = "scale-50 opacity-0";
49
+ /**
50
+ * CopyButton — copies a value to the clipboard and says so: the copy icon turns into a check for
51
+ * a moment and a polite live region announces "Copied". If the clipboard refuses, it shows a
52
+ * cross and announces that instead. Icon-only by default (a raised 30px circle); give it
53
+ * children and it becomes a labelled button whose label reads "Copied" for the moment, at the
54
+ * same width.
55
+ *
56
+ * Put it next to the thing it copies: an API key in an `InputGroup` (`render={<InputGroupButton
57
+ * size="icon" />}`), an invite link, an ID in mono. The rule people break: a bare "Copy" name.
58
+ * Say what it copies in `labels.copy` ("Copy invite link"), since a page has several.
59
+ */
60
+ export function CopyButton({ value, onCopy, onError, timeout = 1500, labels, render, variant = "secondary", size, onClick, className, children, ...props }) {
61
+ const [state, setState] = React.useState("idle");
62
+ const timer = React.useRef(undefined);
63
+ // A copy that settles after the button has gone (a slow `value`) leaves no state or timer behind.
64
+ const mounted = React.useRef(false);
65
+ React.useEffect(() => {
66
+ mounted.current = true;
67
+ return () => {
68
+ mounted.current = false;
69
+ clearTimeout(timer.current);
70
+ };
71
+ }, []);
72
+ const settle = (next) => {
73
+ if (!mounted.current)
74
+ return;
75
+ setState(next);
76
+ clearTimeout(timer.current);
77
+ timer.current = setTimeout(() => setState("idle"), timeout);
78
+ };
79
+ const copy = async (event) => {
80
+ // The rendered element's own click handler runs too, then the one passed to CopyButton.
81
+ render?.props.onClick?.(event);
82
+ onClick?.(event);
83
+ if (event.defaultPrevented)
84
+ return;
85
+ // A second click while "Copied" still shows empties the live region first, so it is announced again.
86
+ if (state !== "idle") {
87
+ clearTimeout(timer.current);
88
+ setState("idle");
89
+ }
90
+ let text;
91
+ try {
92
+ const next = typeof value === "function" ? value() : value;
93
+ // A string is written at once, inside the click, as Safari requires; only a promise waits.
94
+ text = typeof next === "string" ? next : await next;
95
+ await writeClipboard(text);
96
+ }
97
+ catch (error) {
98
+ settle("failed");
99
+ onError?.(error);
100
+ return;
101
+ }
102
+ settle("copied");
103
+ onCopy?.(text);
104
+ };
105
+ const text = useMessages("copyButton", defaultMessages, labels);
106
+ const copyLabel = text.copy;
107
+ const copiedLabel = text.copied;
108
+ const failedLabel = text.failed;
109
+ const labelled = children != null;
110
+ const announcement = state === "copied" ? copiedLabel : state === "failed" ? failedLabel : "";
111
+ const buttonSize = size ?? (labelled ? "sm" : "icon-sm");
112
+ // 14px on the dense sizes, as in CodeBlock; otherwise the button's own icon size.
113
+ const iconSize = !render && (buttonSize === "sm" || buttonSize === "icon-sm") ? "size-3.5" : undefined;
114
+ const icons = (_jsxs("span", { "aria-hidden": true, "data-slot": "copy-button-icon", className: "grid", children: [_jsx(CopyIcon, { className: cn(face, iconSize, state === "idle" ? shown : hidden) }), _jsx(CheckIcon, { className: cn(face, iconSize, state === "copied" ? shown : hidden) }), _jsx(XIcon, { className: cn(face, iconSize, state === "failed" ? shown : hidden) })] }));
115
+ const content = labelled ? (_jsxs(_Fragment, { children: [icons, _jsxs("span", { "data-slot": "copy-button-label", className: "grid", children: [_jsx("span", { className: cn(face, state === "copied" ? hidden : shown), children: children }), _jsx("span", { "aria-hidden": true, className: cn(face, state === "copied" ? shown : hidden), children: copiedLabel })] })] })) : (icons);
116
+ const shared = {
117
+ "data-copied": state === "copied" ? "" : undefined,
118
+ "data-copy-failed": state === "failed" ? "" : undefined,
119
+ // A labelled button is named by its visible label; an icon-only one by `labels`. The name stays
120
+ // "Copy": the live region says "Copied", and a name that changed as well would be read twice.
121
+ "aria-label": labelled ? undefined : copyLabel,
122
+ onClick: copy,
123
+ };
124
+ return (_jsxs(_Fragment, { children: [render ? (
125
+ // Keep the rendered button's own slot (an addon pads around `input-group-button`).
126
+ React.cloneElement(render, {
127
+ ...props,
128
+ ...shared,
129
+ ...(className !== undefined && { className }),
130
+ "data-copy-button": "",
131
+ children: content,
132
+ })) : (_jsx(Button, { "data-slot": "copy-button", variant: variant, size: buttonSize, className: className, ...shared, ...props, children: content })), _jsx("span", { "data-slot": "copy-button-status", className: "sr-only", "aria-live": "polite", children: announcement })] }));
133
+ }