@hanzo/ui 4.5.3 → 4.6.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 (419) hide show
  1. package/README-MCP.md +3 -3
  2. package/README.md +229 -0
  3. package/assets/ai-icons.tsx +207 -0
  4. package/assets/crypto.tsx +33 -0
  5. package/assets/file-type-icon.tsx +66 -0
  6. package/assets/file.tsx +45 -0
  7. package/assets/general.tsx +2318 -0
  8. package/assets/hanzo-logo.svg +9 -0
  9. package/assets/hanzo-logo.tsx +15 -0
  10. package/assets/index.ts +8 -0
  11. package/assets/index.tsx +4 -0
  12. package/assets/llm-provider.tsx +1094 -0
  13. package/bin/create-registry.js +1 -1
  14. package/bin/test-mcp.sh +1 -1
  15. package/bin/update-registry.js +2 -2
  16. package/blocks/components/content.tsx +1 -1
  17. package/blocks/components/grid-block/index.tsx +1 -1
  18. package/blocks/components/screenful-block/content.tsx +1 -1
  19. package/blocks/components/screenful-block/poster-background.tsx +1 -1
  20. package/components/index.ts +56 -0
  21. package/dist/button.d.ts +1 -0
  22. package/dist/button.js +1 -0
  23. package/dist/hooks/index.d.ts +7 -0
  24. package/dist/hooks/index.js +7 -0
  25. package/dist/hooks/use-click-away.d.ts +2 -0
  26. package/dist/hooks/use-click-away.js +23 -0
  27. package/dist/hooks/use-combined-refs.d.ts +3 -0
  28. package/dist/hooks/use-combined-refs.js +18 -0
  29. package/dist/hooks/use-copy-clipboard.d.ts +9 -0
  30. package/dist/hooks/use-copy-clipboard.js +21 -0
  31. package/dist/hooks/use-debounce.d.ts +1 -0
  32. package/dist/hooks/use-debounce.js +13 -0
  33. package/dist/hooks/use-fill-ids.d.ts +8 -0
  34. package/dist/hooks/use-fill-ids.js +20 -0
  35. package/dist/hooks/use-map.d.ts +1 -0
  36. package/dist/hooks/use-map.js +20 -0
  37. package/dist/hooks/use-measure.d.ts +8 -0
  38. package/dist/hooks/use-measure.js +25 -0
  39. package/dist/hooks/use-reverse-video-playback.d.ts +1 -0
  40. package/dist/hooks/use-reverse-video-playback.js +41 -0
  41. package/dist/hooks/use-scroll-restoration.d.ts +8 -0
  42. package/dist/hooks/use-scroll-restoration.js +36 -0
  43. package/dist/mcp/enhanced-server.js +3 -3
  44. package/dist/mcp/index.js +1 -1
  45. package/dist/registry/api.d.ts +1 -1
  46. package/dist/registry/api.js +3 -4
  47. package/dist/registry/index.d.ts +348 -4
  48. package/dist/registry/index.js +3 -3
  49. package/dist/utils.d.ts +1 -0
  50. package/dist/utils.js +1 -0
  51. package/helpers/file.ts +33 -0
  52. package/helpers/memoization.ts +40 -0
  53. package/package.json +27 -6
  54. package/primitives/accordion.tsx +53 -45
  55. package/primitives/alert-dialog.tsx +185 -0
  56. package/primitives/alert.tsx +74 -0
  57. package/primitives/apply-typography.tsx +1 -1
  58. package/primitives/avatar.tsx +37 -29
  59. package/primitives/background-beams.tsx +142 -0
  60. package/primitives/badge.tsx +27 -19
  61. package/primitives/breadcrumb.tsx +77 -62
  62. package/primitives/button.tsx +69 -72
  63. package/primitives/card.tsx +73 -59
  64. package/primitives/chat/chat-input-area.tsx +87 -0
  65. package/primitives/chat/chat-input.tsx +71 -0
  66. package/primitives/chat/files-preview.tsx +330 -0
  67. package/primitives/chat/index.ts +6 -0
  68. package/primitives/chat/json-form.tsx +8 -0
  69. package/primitives/chat/message-list.tsx +307 -0
  70. package/primitives/chat/message.tsx +569 -0
  71. package/primitives/chat/sqlite-preview.tsx +215 -0
  72. package/primitives/checkbox.tsx +18 -19
  73. package/primitives/collapsible.tsx +9 -0
  74. package/primitives/command.tsx +75 -83
  75. package/primitives/context-menu.tsx +115 -109
  76. package/primitives/copy-to-clipboard-icon.tsx +60 -0
  77. package/primitives/dialog-video-controller.tsx +1 -1
  78. package/primitives/dialog.tsx +111 -145
  79. package/primitives/dot-pattern.tsx +57 -0
  80. package/primitives/dots-loader.tsx +13 -0
  81. package/primitives/drawer.tsx +59 -87
  82. package/primitives/dropdown-menu.tsx +199 -0
  83. package/primitives/error-message.tsx +19 -0
  84. package/primitives/file-uploader.tsx +200 -0
  85. package/primitives/form.tsx +92 -87
  86. package/primitives/hover-card.tsx +28 -0
  87. package/primitives/icons/github.tsx +1 -1
  88. package/primitives/icons/youtube-logo.tsx +1 -1
  89. package/primitives/index-common.ts +121 -42
  90. package/primitives/index-next.ts +3 -1
  91. package/primitives/input.tsx +115 -20
  92. package/primitives/label.tsx +15 -23
  93. package/primitives/loading-spinner.tsx +1 -1
  94. package/primitives/markdown-preview.tsx +609 -0
  95. package/primitives/mermaid.tsx +196 -0
  96. package/primitives/next/link-element.tsx +1 -1
  97. package/primitives/next/mdx-link.tsx +1 -1
  98. package/primitives/pagination.tsx +117 -0
  99. package/primitives/popover.tsx +20 -25
  100. package/primitives/pretty-json-print.tsx +28 -0
  101. package/primitives/progress.tsx +14 -15
  102. package/primitives/prompt-textarea.tsx +72 -0
  103. package/primitives/qr-code.tsx +112 -0
  104. package/primitives/radio-group.tsx +25 -39
  105. package/primitives/resizable.tsx +47 -0
  106. package/primitives/scroll-area.tsx +35 -25
  107. package/primitives/search-input.tsx +66 -0
  108. package/primitives/select.tsx +62 -109
  109. package/primitives/separator.tsx +22 -26
  110. package/primitives/sheet.tsx +78 -117
  111. package/primitives/skeleton.tsx +13 -16
  112. package/primitives/slider.tsx +50 -60
  113. package/primitives/stepper.tsx +272 -0
  114. package/primitives/switch.tsx +14 -23
  115. package/primitives/table.tsx +65 -77
  116. package/primitives/tabs.tsx +29 -39
  117. package/primitives/text-link.tsx +25 -0
  118. package/primitives/textarea.tsx +61 -0
  119. package/primitives/textfield.tsx +75 -0
  120. package/primitives/toast.tsx +30 -0
  121. package/primitives/toggle-group.tsx +33 -33
  122. package/primitives/toggle.tsx +22 -51
  123. package/primitives/tooltip.tsx +37 -38
  124. package/registry.json +1 -1
  125. package/src/button.ts +1 -0
  126. package/src/hooks/index.ts +7 -0
  127. package/src/hooks/use-click-away.ts +31 -0
  128. package/src/hooks/use-combined-refs.ts +22 -0
  129. package/src/hooks/use-copy-clipboard.ts +30 -0
  130. package/src/hooks/use-debounce.ts +17 -0
  131. package/src/hooks/use-fill-ids.ts +25 -0
  132. package/src/hooks/use-map.ts +26 -0
  133. package/src/hooks/use-measure.ts +42 -0
  134. package/src/hooks/use-reverse-video-playback.ts +43 -0
  135. package/src/hooks/use-scroll-restoration.ts +50 -0
  136. package/{mcp → src/mcp}/README.md +1 -1
  137. package/{mcp → src/mcp}/enhanced-server.ts +2 -2
  138. package/{registry → src/registry}/api.ts +3 -3
  139. package/{registry → src/registry}/index.ts +3 -3
  140. package/src/utils.ts +1 -0
  141. package/style/theme-provider.tsx +1 -1
  142. package/test-imports.mjs +19 -0
  143. package/tsconfig.json +9 -4
  144. package/types/animation-def.ts +1 -1
  145. package/types/button-def.ts +1 -1
  146. package/types/index.ts +1 -1
  147. package/util/blob.ts +28 -0
  148. package/util/copy-to-clipboard.ts +17 -0
  149. package/util/create-shadow-root.ts +22 -0
  150. package/util/date.ts +83 -0
  151. package/util/debounce.ts +11 -0
  152. package/util/file.ts +15 -0
  153. package/util/format-and-abbreviate-as-currency.ts +1 -1
  154. package/util/format-text.ts +33 -0
  155. package/util/index.ts +9 -78
  156. package/util/timing.ts +3 -0
  157. package/util/toasts.tsx +17 -0
  158. package/utils.ts +9 -0
  159. package/dist/blocks/components/accordian-block.d.ts +0 -4
  160. package/dist/blocks/components/accordian-block.jsx +0 -25
  161. package/dist/blocks/components/block-component-props.d.ts +0 -7
  162. package/dist/blocks/components/block-component-props.js +0 -1
  163. package/dist/blocks/components/bullet-cards-block.d.ts +0 -4
  164. package/dist/blocks/components/bullet-cards-block.jsx +0 -25
  165. package/dist/blocks/components/card-block/index.d.ts +0 -6
  166. package/dist/blocks/components/card-block/index.jsx +0 -87
  167. package/dist/blocks/components/card-block/link-out-button.d.ts +0 -6
  168. package/dist/blocks/components/card-block/link-out-button.jsx +0 -4
  169. package/dist/blocks/components/card-block/util.d.ts +0 -4
  170. package/dist/blocks/components/card-block/util.js +0 -6
  171. package/dist/blocks/components/carte-blanche-block/index.d.ts +0 -4
  172. package/dist/blocks/components/carte-blanche-block/index.jsx +0 -82
  173. package/dist/blocks/components/carte-blanche-block/variant-content-left.d.ts +0 -10
  174. package/dist/blocks/components/carte-blanche-block/variant-content-left.jsx +0 -23
  175. package/dist/blocks/components/content.d.ts +0 -10
  176. package/dist/blocks/components/content.jsx +0 -47
  177. package/dist/blocks/components/cta-block.d.ts +0 -12
  178. package/dist/blocks/components/cta-block.jsx +0 -69
  179. package/dist/blocks/components/enh-heading-block.d.ts +0 -7
  180. package/dist/blocks/components/enh-heading-block.jsx +0 -142
  181. package/dist/blocks/components/grid-block/grid-block-mutator.d.ts +0 -5
  182. package/dist/blocks/components/grid-block/grid-block-mutator.js +0 -1
  183. package/dist/blocks/components/grid-block/index.d.ts +0 -9
  184. package/dist/blocks/components/grid-block/index.jsx +0 -56
  185. package/dist/blocks/components/grid-block/mutator-registry.d.ts +0 -3
  186. package/dist/blocks/components/grid-block/mutator-registry.js +0 -5
  187. package/dist/blocks/components/grid-block/table-borders.mutator.d.ts +0 -3
  188. package/dist/blocks/components/grid-block/table-borders.mutator.js +0 -36
  189. package/dist/blocks/components/group-block.d.ts +0 -7
  190. package/dist/blocks/components/group-block.jsx +0 -61
  191. package/dist/blocks/components/heading-block.d.ts +0 -4
  192. package/dist/blocks/components/heading-block.jsx +0 -99
  193. package/dist/blocks/components/image-block.d.ts +0 -7
  194. package/dist/blocks/components/image-block.jsx +0 -69
  195. package/dist/blocks/components/index.d.ts +0 -14
  196. package/dist/blocks/components/index.js +0 -13
  197. package/dist/blocks/components/screenful-block/content.d.ts +0 -8
  198. package/dist/blocks/components/screenful-block/content.jsx +0 -71
  199. package/dist/blocks/components/screenful-block/index.d.ts +0 -12
  200. package/dist/blocks/components/screenful-block/index.jsx +0 -57
  201. package/dist/blocks/components/screenful-block/poster-background.d.ts +0 -7
  202. package/dist/blocks/components/screenful-block/poster-background.jsx +0 -14
  203. package/dist/blocks/components/screenful-block/video-background.d.ts +0 -8
  204. package/dist/blocks/components/screenful-block/video-background.jsx +0 -20
  205. package/dist/blocks/components/space-block.d.ts +0 -4
  206. package/dist/blocks/components/space-block.jsx +0 -42
  207. package/dist/blocks/components/video-block.d.ts +0 -9
  208. package/dist/blocks/components/video-block.jsx +0 -83
  209. package/dist/blocks/def/accordian-block.d.ts +0 -10
  210. package/dist/blocks/def/accordian-block.js +0 -2
  211. package/dist/blocks/def/block.d.ts +0 -4
  212. package/dist/blocks/def/block.js +0 -1
  213. package/dist/blocks/def/bullet-cards-block.d.ts +0 -17
  214. package/dist/blocks/def/bullet-cards-block.js +0 -1
  215. package/dist/blocks/def/card-block.d.ts +0 -17
  216. package/dist/blocks/def/card-block.js +0 -2
  217. package/dist/blocks/def/carte-blanche-block.d.ts +0 -12
  218. package/dist/blocks/def/carte-blanche-block.js +0 -1
  219. package/dist/blocks/def/cta-block.d.ts +0 -8
  220. package/dist/blocks/def/cta-block.js +0 -1
  221. package/dist/blocks/def/element-block.d.ts +0 -7
  222. package/dist/blocks/def/element-block.js +0 -2
  223. package/dist/blocks/def/enh-heading-block.d.ts +0 -22
  224. package/dist/blocks/def/enh-heading-block.js +0 -1
  225. package/dist/blocks/def/grid-block.d.ts +0 -12
  226. package/dist/blocks/def/grid-block.js +0 -1
  227. package/dist/blocks/def/group-block.d.ts +0 -7
  228. package/dist/blocks/def/group-block.js +0 -1
  229. package/dist/blocks/def/heading-block.d.ts +0 -11
  230. package/dist/blocks/def/heading-block.js +0 -1
  231. package/dist/blocks/def/image-block.d.ts +0 -26
  232. package/dist/blocks/def/image-block.js +0 -1
  233. package/dist/blocks/def/index.d.ts +0 -17
  234. package/dist/blocks/def/index.js +0 -2
  235. package/dist/blocks/def/screenful-block.d.ts +0 -41
  236. package/dist/blocks/def/screenful-block.js +0 -1
  237. package/dist/blocks/def/space-block.d.ts +0 -47
  238. package/dist/blocks/def/space-block.js +0 -8
  239. package/dist/blocks/def/video-block.d.ts +0 -5
  240. package/dist/blocks/def/video-block.js +0 -1
  241. package/dist/blocks/index.d.ts +0 -2
  242. package/dist/blocks/index.js +0 -2
  243. package/dist/primitives/accordion.d.ts +0 -10
  244. package/dist/primitives/accordion.jsx +0 -21
  245. package/dist/primitives/action-button.d.ts +0 -9
  246. package/dist/primitives/action-button.jsx +0 -16
  247. package/dist/primitives/apply-typography.d.ts +0 -7
  248. package/dist/primitives/apply-typography.jsx +0 -38
  249. package/dist/primitives/aspect-ratio.d.ts +0 -3
  250. package/dist/primitives/aspect-ratio.jsx +0 -4
  251. package/dist/primitives/avatar.d.ts +0 -6
  252. package/dist/primitives/avatar.jsx +0 -11
  253. package/dist/primitives/badge.d.ts +0 -9
  254. package/dist/primitives/badge.jsx +0 -18
  255. package/dist/primitives/breadcrumb.d.ts +0 -19
  256. package/dist/primitives/breadcrumb.jsx +0 -27
  257. package/dist/primitives/breakpoint-indicator.d.ts +0 -3
  258. package/dist/primitives/breakpoint-indicator.jsx +0 -14
  259. package/dist/primitives/button.d.ts +0 -12
  260. package/dist/primitives/button.jsx +0 -55
  261. package/dist/primitives/calendar.d.ts +0 -8
  262. package/dist/primitives/calendar.jsx +0 -40
  263. package/dist/primitives/card.d.ts +0 -8
  264. package/dist/primitives/card.jsx +0 -18
  265. package/dist/primitives/carousel.d.ts +0 -18
  266. package/dist/primitives/carousel.jsx +0 -106
  267. package/dist/primitives/checkbox.d.ts +0 -4
  268. package/dist/primitives/checkbox.jsx +0 -15
  269. package/dist/primitives/combobox.d.ts +0 -41
  270. package/dist/primitives/combobox.jsx +0 -77
  271. package/dist/primitives/command.d.ts +0 -17
  272. package/dist/primitives/command.jsx +0 -38
  273. package/dist/primitives/context-menu.d.ts +0 -27
  274. package/dist/primitives/context-menu.jsx +0 -57
  275. package/dist/primitives/dialog-video-controller.d.ts +0 -3
  276. package/dist/primitives/dialog-video-controller.jsx +0 -24
  277. package/dist/primitives/dialog.d.ts +0 -28
  278. package/dist/primitives/dialog.jsx +0 -37
  279. package/dist/primitives/drawer.d.ts +0 -29
  280. package/dist/primitives/drawer.jsx +0 -34
  281. package/dist/primitives/form.d.ts +0 -12
  282. package/dist/primitives/form.jsx +0 -69
  283. package/dist/primitives/icons/github.d.ts +0 -4
  284. package/dist/primitives/icons/github.jsx +0 -6
  285. package/dist/primitives/icons/index.d.ts +0 -4
  286. package/dist/primitives/icons/index.js +0 -4
  287. package/dist/primitives/icons/youtube-logo.d.ts +0 -4
  288. package/dist/primitives/icons/youtube-logo.jsx +0 -39
  289. package/dist/primitives/index-common.d.ts +0 -47
  290. package/dist/primitives/index-common.js +0 -46
  291. package/dist/primitives/index-next.d.ts +0 -2
  292. package/dist/primitives/index-next.js +0 -2
  293. package/dist/primitives/input-otp.d.ts +0 -7
  294. package/dist/primitives/input-otp.jsx +0 -24
  295. package/dist/primitives/input.d.ts +0 -5
  296. package/dist/primitives/input.jsx +0 -11
  297. package/dist/primitives/label.d.ts +0 -5
  298. package/dist/primitives/label.jsx +0 -11
  299. package/dist/primitives/list-adaptor.d.ts +0 -9
  300. package/dist/primitives/list-adaptor.js +0 -1
  301. package/dist/primitives/list-box.d.ts +0 -10
  302. package/dist/primitives/list-box.jsx +0 -14
  303. package/dist/primitives/loading-spinner.d.ts +0 -5
  304. package/dist/primitives/loading-spinner.jsx +0 -8
  305. package/dist/primitives/navigation-menu.d.ts +0 -12
  306. package/dist/primitives/navigation-menu.jsx +0 -38
  307. package/dist/primitives/next/image.d.ts +0 -11
  308. package/dist/primitives/next/image.jsx +0 -42
  309. package/dist/primitives/next/index.d.ts +0 -7
  310. package/dist/primitives/next/index.js +0 -7
  311. package/dist/primitives/next/inline-icon.d.ts +0 -13
  312. package/dist/primitives/next/inline-icon.jsx +0 -15
  313. package/dist/primitives/next/link-element.d.ts +0 -23
  314. package/dist/primitives/next/link-element.jsx +0 -56
  315. package/dist/primitives/next/mdx-link.d.ts +0 -3
  316. package/dist/primitives/next/mdx-link.jsx +0 -12
  317. package/dist/primitives/next/media-stack.d.ts +0 -8
  318. package/dist/primitives/next/media-stack.jsx +0 -28
  319. package/dist/primitives/next/nav-items.d.ts +0 -10
  320. package/dist/primitives/next/nav-items.jsx +0 -24
  321. package/dist/primitives/next/youtube-embed.d.ts +0 -11
  322. package/dist/primitives/next/youtube-embed.jsx +0 -23
  323. package/dist/primitives/popover.d.ts +0 -9
  324. package/dist/primitives/popover.jsx +0 -18
  325. package/dist/primitives/progress.d.ts +0 -4
  326. package/dist/primitives/progress.jsx +0 -9
  327. package/dist/primitives/radio-group.d.ts +0 -7
  328. package/dist/primitives/radio-group.jsx +0 -18
  329. package/dist/primitives/scroll-area.d.ts +0 -5
  330. package/dist/primitives/scroll-area.jsx +0 -19
  331. package/dist/primitives/select.d.ts +0 -13
  332. package/dist/primitives/select.jsx +0 -62
  333. package/dist/primitives/separator.d.ts +0 -4
  334. package/dist/primitives/separator.jsx +0 -7
  335. package/dist/primitives/sheet.d.ts +0 -30
  336. package/dist/primitives/sheet.jsx +0 -56
  337. package/dist/primitives/skeleton.d.ts +0 -4
  338. package/dist/primitives/skeleton.jsx +0 -3
  339. package/dist/primitives/slider.d.ts +0 -9
  340. package/dist/primitives/slider.jsx +0 -30
  341. package/dist/primitives/sonner.d.ts +0 -5
  342. package/dist/primitives/sonner.jsx +0 -16
  343. package/dist/primitives/step-indicator.d.ts +0 -9
  344. package/dist/primitives/step-indicator.jsx +0 -23
  345. package/dist/primitives/switch.d.ts +0 -6
  346. package/dist/primitives/switch.jsx +0 -14
  347. package/dist/primitives/table.d.ts +0 -10
  348. package/dist/primitives/table.jsx +0 -21
  349. package/dist/primitives/tabs.d.ts +0 -7
  350. package/dist/primitives/tabs.jsx +0 -18
  351. package/dist/primitives/text-area.d.ts +0 -5
  352. package/dist/primitives/text-area.jsx +0 -9
  353. package/dist/primitives/toggle-group.d.ts +0 -14
  354. package/dist/primitives/toggle-group.jsx +0 -28
  355. package/dist/primitives/toggle.d.ts +0 -14
  356. package/dist/primitives/toggle.jsx +0 -52
  357. package/dist/primitives/tooltip.d.ts +0 -11
  358. package/dist/primitives/tooltip.jsx +0 -18
  359. package/dist/primitives/video-player.d.ts +0 -6
  360. package/dist/primitives/video-player.jsx +0 -8
  361. package/dist/style/theme-provider.d.ts +0 -4
  362. package/dist/style/theme-provider.jsx +0 -11
  363. package/dist/tailwind/fontFamily.tailwind.d.ts +0 -8
  364. package/dist/tailwind/fontFamily.tailwind.js +0 -7
  365. package/dist/tailwind/fontSize.tailwind.d.ts +0 -36
  366. package/dist/tailwind/fontSize.tailwind.js +0 -13
  367. package/dist/tailwind/index.d.ts +0 -3
  368. package/dist/tailwind/index.js +0 -2
  369. package/dist/tailwind/screens.tailwind.d.ts +0 -9
  370. package/dist/tailwind/screens.tailwind.js +0 -8
  371. package/dist/tailwind/tw-font-desc.d.ts +0 -6
  372. package/dist/tailwind/tw-font-desc.js +0 -6
  373. package/dist/types/animation-def.d.ts +0 -2
  374. package/dist/types/animation-def.js +0 -1
  375. package/dist/types/breakpoints.d.ts +0 -4
  376. package/dist/types/breakpoints.js +0 -4
  377. package/dist/types/bullet-item.d.ts +0 -6
  378. package/dist/types/bullet-item.js +0 -2
  379. package/dist/types/button-def.d.ts +0 -29
  380. package/dist/types/button-def.js +0 -2
  381. package/dist/types/dimensions.d.ts +0 -5
  382. package/dist/types/dimensions.js +0 -1
  383. package/dist/types/grid-def.d.ts +0 -36
  384. package/dist/types/grid-def.js +0 -33
  385. package/dist/types/image-def.d.ts +0 -27
  386. package/dist/types/image-def.js +0 -1
  387. package/dist/types/index.d.ts +0 -13
  388. package/dist/types/index.js +0 -2
  389. package/dist/types/link-def.d.ts +0 -44
  390. package/dist/types/link-def.js +0 -1
  391. package/dist/types/media-stack-def.d.ts +0 -25
  392. package/dist/types/media-stack-def.js +0 -1
  393. package/dist/types/t-shirt-size.d.ts +0 -2
  394. package/dist/types/t-shirt-size.js +0 -1
  395. package/dist/types/tshirt-dimensions.d.ts +0 -12
  396. package/dist/types/tshirt-dimensions.js +0 -1
  397. package/dist/types/video-def.d.ts +0 -9
  398. package/dist/types/video-def.js +0 -1
  399. package/dist/util/format-and-abbreviate-as-currency.d.ts +0 -11
  400. package/dist/util/format-and-abbreviate-as-currency.js +0 -91
  401. package/dist/util/format-to-max-char.d.ts +0 -5
  402. package/dist/util/format-to-max-char.js +0 -57
  403. package/dist/util/index-client.d.ts +0 -2
  404. package/dist/util/index-client.js +0 -3
  405. package/dist/util/index.d.ts +0 -17
  406. package/dist/util/index.js +0 -41
  407. package/dist/util/number-abbreviate.d.ts +0 -9
  408. package/dist/util/number-abbreviate.js +0 -30
  409. package/dist/util/specifier.d.ts +0 -7
  410. package/dist/util/specifier.js +0 -31
  411. package/dist/util/spread-to-transform.d.ts +0 -7
  412. package/dist/util/spread-to-transform.js +0 -18
  413. package/dist/util/step-animation.d.ts +0 -5
  414. package/dist/util/step-animation.js +0 -60
  415. package/dist/util/two-way-map.d.ts +0 -8
  416. package/dist/util/two-way-map.js +0 -16
  417. /package/{mcp → src/mcp}/index.ts +0 -0
  418. /package/{mcp → src/mcp}/package.json +0 -0
  419. /package/{registry → src/registry}/package.json +0 -0
@@ -0,0 +1,569 @@
1
+ import { zodResolver } from '@hookform/resolvers/zod';
2
+ import { useTranslation } from '@hanzo_network/hanzo-i18n';
3
+ import {
4
+ type ToolArgs,
5
+ ToolStatusType,
6
+ } from '@hanzo_network/hanzo-message-ts/api/general/types';
7
+ import {
8
+ type Artifact,
9
+ type FormattedMessage,
10
+ } from '@hanzo_network/hanzo-node-state/v2/queries/getChatConversation/types';
11
+ import { format } from 'date-fns';
12
+ import { AnimatePresence, motion } from 'framer-motion';
13
+ import { Edit3, Loader2, RotateCcw, XCircle } from 'lucide-react';
14
+ import { InfoCircleIcon } from 'primereact/icons/infocircle';
15
+ import React, { Fragment, memo, useEffect, useMemo, useState } from 'react';
16
+ import { useForm } from 'react-hook-form';
17
+ import { Link } from 'react-router';
18
+ import { z } from 'zod';
19
+
20
+ import { appIcon, ReactJsIcon, ToolsIcon } from '../../assets';
21
+ import { formatText } from '../../helpers/format-text';
22
+ import { cn } from '../src/utils';
23
+ import {
24
+ Accordion,
25
+ AccordionContent,
26
+ AccordionItem,
27
+ AccordionTrigger,
28
+ } from '../accordion';
29
+ import { Avatar, AvatarFallback } from '../avatar';
30
+ import { Button } from '../button';
31
+ import { Card, CardContent } from '../card';
32
+ import { CopyToClipboardIcon } from '../copy-to-clipboard-icon';
33
+ import { DotsLoader } from '../dots-loader';
34
+ import { Form, FormField } from '../form';
35
+ import { MarkdownText } from '../markdown-preview';
36
+ import { PrettyJsonPrint } from '../pretty-json-print';
37
+ import {
38
+ Tooltip,
39
+ TooltipContent,
40
+ TooltipPortal,
41
+ TooltipProvider,
42
+ TooltipTrigger,
43
+ } from '../tooltip';
44
+ import { ChatInputArea } from './chat-input-area';
45
+ import { FileList } from './files-preview';
46
+ // import { PythonCodeRunner } from './python-code-runner/python-code-runner';
47
+
48
+ export const extractErrorPropertyOrContent = (
49
+ content: string,
50
+ property: 'error' | 'error_message',
51
+ ) => {
52
+ try {
53
+ const parsedContent = JSON.parse(content);
54
+ if (property in parsedContent) {
55
+ return parsedContent[property];
56
+ }
57
+ } catch {
58
+ /* ignore */
59
+ }
60
+ return String(content);
61
+ };
62
+
63
+ const containsPythonCode = (content: string): boolean => {
64
+ const pythonCodeRegex = /```python\s[\s\S]*?```/;
65
+ return pythonCodeRegex.test(content);
66
+ };
67
+
68
+ type MessageProps = {
69
+ messageId: string;
70
+ isPending?: boolean;
71
+ message: FormattedMessage;
72
+ handleRetryMessage?: () => void;
73
+ disabledRetry?: boolean;
74
+ disabledEdit?: boolean;
75
+ handleEditMessage?: (message: string) => void;
76
+ messageExtra?: React.ReactNode;
77
+
78
+ artifacts?: Artifact[];
79
+ artifact?: Artifact;
80
+ hidePythonExecution?: boolean;
81
+ };
82
+
83
+ const actionBar = {
84
+ rest: {
85
+ opacity: 0,
86
+ scale: 0.8,
87
+ transition: {
88
+ type: 'spring',
89
+ bounce: 0,
90
+ duration: 0.3,
91
+ },
92
+ },
93
+ hover: {
94
+ opacity: 1,
95
+ scale: 1,
96
+ transition: {
97
+ type: 'spring',
98
+ duration: 0.3,
99
+ bounce: 0,
100
+ },
101
+ },
102
+ };
103
+
104
+ type ArtifactProps = {
105
+ title: string;
106
+ type: string;
107
+ identifier: string;
108
+ loading?: boolean;
109
+ isSelected?: boolean;
110
+ onArtifactClick?: () => void;
111
+ };
112
+ const ArtifactCard = ({
113
+ title,
114
+ loading = true,
115
+ onArtifactClick,
116
+ isSelected,
117
+ identifier,
118
+ }: ArtifactProps) => (
119
+ <Card
120
+ className={cn(
121
+ 'w-full max-w-sm border border-gray-100',
122
+ isSelected && 'border-gray-50 bg-gray-300',
123
+ )}
124
+ onClick={() => {
125
+ onArtifactClick?.();
126
+ }}
127
+ role="button"
128
+ >
129
+ <CardContent className="flex items-center gap-1 p-1 py-1.5">
130
+ <div className="rounded-md p-2">
131
+ {loading ? (
132
+ <Loader2 className="text-text-secondary h-5 w-5 animate-spin" />
133
+ ) : (
134
+ <ReactJsIcon
135
+ className={cn(isSelected ? 'text-gray-50' : 'text-text-secondary')}
136
+ />
137
+ )}
138
+ </div>
139
+ <div className="flex flex-1 flex-col gap-0.5">
140
+ <p className="!mb-0 line-clamp-1 text-sm font-medium text-gray-50">
141
+ {title}
142
+ </p>
143
+ <p className="text-text-secondary !mb-0 text-xs">
144
+ {loading ? 'Generating...' : 'Click to preview'}
145
+ </p>
146
+ </div>
147
+ </CardContent>
148
+ </Card>
149
+ );
150
+
151
+ export const editMessageFormSchema = z.object({
152
+ message: z.string().min(1),
153
+ });
154
+
155
+ type EditMessageFormSchema = z.infer<typeof editMessageFormSchema>;
156
+
157
+ const MessageBase = ({
158
+ message,
159
+ messageId,
160
+ isPending,
161
+ handleRetryMessage,
162
+ disabledRetry,
163
+ disabledEdit,
164
+ handleEditMessage,
165
+ hidePythonExecution,
166
+ }: MessageProps) => {
167
+ const { t } = useTranslation();
168
+
169
+ const [editing, setEditing] = useState(false);
170
+
171
+ const editMessageForm = useForm<EditMessageFormSchema>({
172
+ resolver: zodResolver(editMessageFormSchema),
173
+ defaultValues: {
174
+ message: message.content,
175
+ },
176
+ });
177
+
178
+ const { message: currentMessage } = editMessageForm.watch();
179
+
180
+ const onSubmit = async (data: z.infer<typeof editMessageFormSchema>) => {
181
+ if (message.role === 'user') {
182
+ handleEditMessage?.(data.message);
183
+ setEditing(false);
184
+ }
185
+ };
186
+
187
+ useEffect(() => {
188
+ if (message.role === 'user') {
189
+ editMessageForm.reset({ message: message.content });
190
+ }
191
+ }, [editMessageForm, message.content]);
192
+
193
+ const pythonCode = useMemo(() => {
194
+ if (containsPythonCode(message.content)) {
195
+ const match = message.content.match(/```python\s([\s\S]*?)```/);
196
+ return match ? match[1] : null;
197
+ }
198
+ return null;
199
+ }, [message.content]);
200
+
201
+ return (
202
+ <motion.div
203
+ animate="rest"
204
+ className="pb-10"
205
+ data-testid={`message-${
206
+ message.role === 'user' ? 'local' : 'remote'
207
+ }-${message.messageId}`}
208
+ id={message.messageId}
209
+ initial="rest"
210
+ whileHover="hover"
211
+ >
212
+ <div
213
+ className={cn(
214
+ 'relative flex flex-row space-x-2',
215
+ message.role === 'user' &&
216
+ 'mr-0 ml-auto flex-row-reverse space-x-reverse',
217
+ message.role === 'assistant' && 'mr-auto ml-0 flex-row items-end',
218
+ )}
219
+ >
220
+ <a href={`#${messageId}`}>
221
+ <Avatar className={cn('mt-1 h-8 w-8')}>
222
+ {message.role === 'assistant' ? (
223
+ <img alt="Hanzo AI" src={appIcon} />
224
+ ) : null}
225
+ </Avatar>
226
+ </a>
227
+ <div
228
+ className={cn(
229
+ 'container flex flex-col overflow-hidden bg-transparent text-sm text-white',
230
+ editing && 'w-full py-1',
231
+ )}
232
+ >
233
+ {editing ? (
234
+ <Form {...editMessageForm}>
235
+ <form
236
+ className="relative flex items-center"
237
+ onSubmit={editMessageForm.handleSubmit(onSubmit)}
238
+ >
239
+ <div className="w-full">
240
+ <FormField
241
+ control={editMessageForm.control}
242
+ name="message"
243
+ render={({ field }) => (
244
+ <ChatInputArea
245
+ bottomAddons={
246
+ <div className="flex w-full items-center justify-between px-1">
247
+ <div className="text-text-secondary flex items-center gap-1 text-xs">
248
+ <InfoCircleIcon className="text-text-secondary h-3 w-3" />
249
+ <span>{t('chat.editMessage.warning')}</span>
250
+ </div>
251
+ <div className="flex items-center gap-2">
252
+ <Button
253
+ className="min-w-[90px] rounded-lg"
254
+ onClick={() => setEditing(false)}
255
+ size="sm"
256
+ variant="outline"
257
+ >
258
+ {t('common.cancel')}
259
+ </Button>
260
+ <Button
261
+ className="min-w-[90px] rounded-lg"
262
+ disabled={!currentMessage}
263
+ onClick={editMessageForm.handleSubmit(onSubmit)}
264
+ size="sm"
265
+ >
266
+ {t('common.send')}
267
+ </Button>
268
+ </div>
269
+ </div>
270
+ }
271
+ onChange={field.onChange}
272
+ onSubmit={editMessageForm.handleSubmit(onSubmit)}
273
+ value={field.value}
274
+ />
275
+ )}
276
+ />
277
+ </div>
278
+ </form>
279
+ </Form>
280
+ ) : (
281
+ <Fragment>
282
+ <div
283
+ className={cn(
284
+ 'relative mt-1 flex flex-col rounded-lg bg-black/40 px-3.5 pt-3 text-sm text-white',
285
+ message.role === 'user'
286
+ ? 'rounded-tr-none bg-gray-300'
287
+ : 'rounded-bl-none border-none bg-gray-200',
288
+ !message.content ? 'pb-3' : 'pb-4',
289
+ editing && 'w-full py-1',
290
+ message.role === 'assistant' &&
291
+ isPending &&
292
+ 'relative overflow-hidden pb-4 before:absolute before:right-0 before:bottom-0 before:left-0 before:h-10 before:animate-pulse before:bg-gradient-to-l before:from-gray-200 before:to-gray-200/10',
293
+ )}
294
+ >
295
+ {message.role === 'assistant' &&
296
+ message.toolCalls &&
297
+ message.toolCalls.length > 0 && (
298
+ <Accordion
299
+ className="space-y-1.5 self-baseline pb-3"
300
+ type="multiple"
301
+ >
302
+ {message.toolCalls.map((tool, index) => {
303
+ return (
304
+ <AccordionItem
305
+ className="bg-bg-secondary overflow-hidden rounded-lg"
306
+ disabled={tool.status !== ToolStatusType.Complete}
307
+ key={`${tool.name}-${index}`}
308
+ value={tool.name}
309
+ >
310
+ <AccordionTrigger
311
+ className={cn(
312
+ 'min-w-[10rem] py-0 pr-2 no-underline hover:no-underline',
313
+ 'hover:bg-bg-default [&[data-state=open]]:bg-bg-default transition-colors',
314
+ tool.status !== ToolStatusType.Complete &&
315
+ '[&>svg]:hidden',
316
+ )}
317
+ >
318
+ <ToolCard
319
+ args={tool.args}
320
+ name={tool.name}
321
+ status={tool.status ?? ToolStatusType.Complete}
322
+ toolRouterKey={tool.toolRouterKey}
323
+ />
324
+ </AccordionTrigger>
325
+ <AccordionContent className="bg-gray-450 flex flex-col gap-1 overflow-x-scroll rounded-b-lg px-3 pt-2 pb-3 text-xs">
326
+ {Object.keys(tool.args).length > 0 && (
327
+ <span className="font-medium text-white">
328
+ {tool.name}(
329
+ {Object.keys(tool.args).length > 0 && (
330
+ <span className="text-text-secondary font-mono font-medium">
331
+ {JSON.stringify(tool.args)}
332
+ </span>
333
+ )}
334
+ )
335
+ </span>
336
+ )}
337
+ {tool.result && (
338
+ <div>
339
+ <span>Response:</span>
340
+ <span className="text-text-secondary font-mono break-all">
341
+ <PrettyJsonPrint json={tool.result} />
342
+ </span>
343
+ </div>
344
+ )}
345
+ </AccordionContent>
346
+ </AccordionItem>
347
+ );
348
+ })}
349
+ </Accordion>
350
+ )}
351
+ {message.role === 'assistant' && (
352
+ <MarkdownText
353
+ content={extractErrorPropertyOrContent(
354
+ message.content,
355
+ 'error_message',
356
+ )}
357
+ isRunning={
358
+ !!message.content && message.status.type === 'running'
359
+ }
360
+ />
361
+ )}
362
+
363
+ {message.role === 'user' && (
364
+ <div className="whitespace-pre-line">{message.content}</div>
365
+ )}
366
+
367
+ {message.role === 'assistant' &&
368
+ message.status.type === 'running' &&
369
+ message.content === '' && (
370
+ <div className="pt-1.5 whitespace-pre-line">
371
+ <DotsLoader />
372
+ </div>
373
+ )}
374
+ {/*{pythonCode && !hidePythonExecution && (*/}
375
+ {/* <PythonCodeRunner code={pythonCode} />*/}
376
+ {/*)}*/}
377
+ {message.role === 'user' && !!message.attachments.length && (
378
+ <FileList
379
+ className="mt-2 max-w-[70vw] min-w-[200px]"
380
+ files={message.attachments}
381
+ />
382
+ )}
383
+ </div>
384
+ {!isPending && (
385
+ <motion.div
386
+ className={cn(
387
+ 'absolute -bottom-[34px] flex items-center justify-end gap-3',
388
+ message.role === 'user'
389
+ ? 'right-10 flex-row-reverse'
390
+ : 'left-10 flex-row',
391
+ )}
392
+ variants={actionBar}
393
+ >
394
+ <div className="flex items-center gap-1.5">
395
+ {message.role === 'user' && !disabledEdit && (
396
+ <TooltipProvider delayDuration={0}>
397
+ <Tooltip>
398
+ <TooltipTrigger asChild>
399
+ <button
400
+ className={cn(
401
+ 'text-text-secondary flex h-7 w-7 items-center justify-center rounded-lg border border-gray-200 bg-transparent transition-colors hover:bg-gray-300 hover:text-white [&>svg]:h-3 [&>svg]:w-3',
402
+ )}
403
+ onClick={() => {
404
+ setEditing(true);
405
+ }}
406
+ >
407
+ <Edit3 />
408
+ </button>
409
+ </TooltipTrigger>
410
+ <TooltipPortal>
411
+ <TooltipContent>
412
+ <p>{t('common.editMessage')}</p>
413
+ </TooltipContent>
414
+ </TooltipPortal>
415
+ </Tooltip>
416
+ </TooltipProvider>
417
+ )}
418
+ {message.role === 'assistant' && !disabledRetry && (
419
+ <TooltipProvider delayDuration={0}>
420
+ <Tooltip>
421
+ <TooltipTrigger asChild>
422
+ <button
423
+ className={cn(
424
+ 'text-text-secondary flex h-7 w-7 items-center justify-center rounded-lg border border-gray-200 bg-transparent transition-colors hover:bg-gray-300 hover:text-white [&>svg]:h-3 [&>svg]:w-3',
425
+ )}
426
+ onClick={handleRetryMessage}
427
+ >
428
+ <RotateCcw />
429
+ </button>
430
+ </TooltipTrigger>
431
+ <TooltipPortal>
432
+ <TooltipContent>
433
+ <p>{t('common.retry')}</p>
434
+ </TooltipContent>
435
+ </TooltipPortal>
436
+ </Tooltip>
437
+ </TooltipProvider>
438
+ )}
439
+ <TooltipProvider delayDuration={0}>
440
+ <Tooltip>
441
+ <TooltipTrigger asChild>
442
+ <div>
443
+ <CopyToClipboardIcon
444
+ className={cn(
445
+ 'text-text-secondary h-7 w-7 border border-gray-200 bg-transparent hover:bg-gray-300 [&>svg]:h-3 [&>svg]:w-3',
446
+ )}
447
+ string={extractErrorPropertyOrContent(
448
+ message.content,
449
+ 'error_message',
450
+ )}
451
+ />
452
+ </div>
453
+ </TooltipTrigger>
454
+ <TooltipPortal>
455
+ <TooltipContent>
456
+ <p>{t('common.copy')}</p>
457
+ </TooltipContent>
458
+ </TooltipPortal>
459
+ </Tooltip>
460
+ </TooltipProvider>
461
+ </div>
462
+ <div
463
+ className={cn(
464
+ 'text-text-secondary flex items-center gap-1.5 text-xs',
465
+ )}
466
+ >
467
+ <span>
468
+ {format(new Date(message?.createdAt ?? ''), 'p')}
469
+ </span>
470
+ {message.role === 'assistant' && message?.metadata?.tps && (
471
+ <>
472
+ {' '}
473
+
474
+ <span>
475
+ {Math.round(Number(message?.metadata?.tps) * 10) / 10}{' '}
476
+ tokens/s
477
+ </span>
478
+ </>
479
+ )}
480
+ </div>
481
+ </motion.div>
482
+ )}
483
+ </Fragment>
484
+ )}
485
+ </div>
486
+ </div>
487
+ </motion.div>
488
+ );
489
+ };
490
+
491
+ export const Message = memo(
492
+ MessageBase,
493
+ (prev, next) =>
494
+ prev.messageId === next.messageId &&
495
+ prev.message.content === next.message.content &&
496
+ prev.artifacts?.length === next.artifacts?.length &&
497
+ prev.artifact === next.artifact,
498
+ );
499
+
500
+ const variants = {
501
+ initial: { opacity: 0, y: -25 },
502
+ visible: { opacity: 1, y: 0 },
503
+ exit: { opacity: 0, y: 25 },
504
+ };
505
+
506
+ export function ToolCard({
507
+ name,
508
+ // args,
509
+ status,
510
+ toolRouterKey,
511
+ }: {
512
+ args: ToolArgs;
513
+ status: ToolStatusType;
514
+ name: string;
515
+ toolRouterKey: string;
516
+ }) {
517
+ const renderStatus = () => {
518
+ if (status === ToolStatusType.Complete) {
519
+ return <ToolsIcon className="text-brand size-full" />;
520
+ }
521
+ if (status === ToolStatusType.Incomplete) {
522
+ return <XCircle className="text-text-secondary size-full" />;
523
+ }
524
+ if (status === ToolStatusType.RequiresAction) {
525
+ return <InfoCircleIcon className="text-text-secondary size-full" />;
526
+ }
527
+ return <Loader2 className="text-brand size-full animate-spin" />;
528
+ };
529
+
530
+ const renderLabelText = () => {
531
+ if (status === ToolStatusType.Complete) {
532
+ return 'Tool Used';
533
+ }
534
+ if (status === ToolStatusType.Incomplete) {
535
+ return 'Incomplete';
536
+ }
537
+ if (status === ToolStatusType.RequiresAction) {
538
+ return 'Requires Action';
539
+ }
540
+ return 'Processing Tool';
541
+ };
542
+
543
+ return (
544
+ <AnimatePresence initial={false} mode="popLayout">
545
+ <motion.div
546
+ animate="visible"
547
+ exit="exit"
548
+ initial="initial"
549
+ transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
550
+ variants={variants}
551
+ >
552
+ <div className="flex items-center gap-1 p-[5px]">
553
+ <div className="size-7 shrink-0 px-1.5">{renderStatus()}</div>
554
+ <div className="flex items-center gap-1">
555
+ <span className="text-text-secondary text-em-sm">
556
+ {renderLabelText()}
557
+ </span>
558
+ <Link
559
+ className="text-gray-white text-em-sm font-semibold hover:underline"
560
+ to={`/tools/${toolRouterKey}`}
561
+ >
562
+ {formatText(name)}
563
+ </Link>
564
+ </div>
565
+ </div>
566
+ </motion.div>
567
+ </AnimatePresence>
568
+ );
569
+ }