@crafter/rn-ai-elements 0.0.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 (344) hide show
  1. package/lib/commonjs/chatbot/AIImage.js +126 -0
  2. package/lib/commonjs/chatbot/AIImage.js.map +1 -0
  3. package/lib/commonjs/chatbot/Attachments.js +317 -0
  4. package/lib/commonjs/chatbot/Attachments.js.map +1 -0
  5. package/lib/commonjs/chatbot/ChatErrorBoundary.js +201 -0
  6. package/lib/commonjs/chatbot/ChatErrorBoundary.js.map +1 -0
  7. package/lib/commonjs/chatbot/ChatMessageItem.js +169 -0
  8. package/lib/commonjs/chatbot/ChatMessageItem.js.map +1 -0
  9. package/lib/commonjs/chatbot/Conversation.js +415 -0
  10. package/lib/commonjs/chatbot/Conversation.js.map +1 -0
  11. package/lib/commonjs/chatbot/ConversationScrollButton.js +131 -0
  12. package/lib/commonjs/chatbot/ConversationScrollButton.js.map +1 -0
  13. package/lib/commonjs/chatbot/Message.js +203 -0
  14. package/lib/commonjs/chatbot/Message.js.map +1 -0
  15. package/lib/commonjs/chatbot/PromptInput.js +352 -0
  16. package/lib/commonjs/chatbot/PromptInput.js.map +1 -0
  17. package/lib/commonjs/chatbot/Reasoning.js +184 -0
  18. package/lib/commonjs/chatbot/Reasoning.js.map +1 -0
  19. package/lib/commonjs/chatbot/Shimmer.js +116 -0
  20. package/lib/commonjs/chatbot/Shimmer.js.map +1 -0
  21. package/lib/commonjs/chatbot/Sources.js +212 -0
  22. package/lib/commonjs/chatbot/Sources.js.map +1 -0
  23. package/lib/commonjs/chatbot/Suggestion.js +99 -0
  24. package/lib/commonjs/chatbot/Suggestion.js.map +1 -0
  25. package/lib/commonjs/chatbot/Tool.js +307 -0
  26. package/lib/commonjs/chatbot/Tool.js.map +1 -0
  27. package/lib/commonjs/chatbot/adapters/uiMessageAdapter.js +141 -0
  28. package/lib/commonjs/chatbot/adapters/uiMessageAdapter.js.map +1 -0
  29. package/lib/commonjs/chatbot/index.js +140 -0
  30. package/lib/commonjs/chatbot/index.js.map +1 -0
  31. package/lib/commonjs/chatbot/types.js +6 -0
  32. package/lib/commonjs/chatbot/types.js.map +1 -0
  33. package/lib/commonjs/hooks/index.js +34 -0
  34. package/lib/commonjs/hooks/index.js.map +1 -0
  35. package/lib/commonjs/hooks/useAutoScroll.js +39 -0
  36. package/lib/commonjs/hooks/useAutoScroll.js.map +1 -0
  37. package/lib/commonjs/hooks/useClipboard.js +44 -0
  38. package/lib/commonjs/hooks/useClipboard.js.map +1 -0
  39. package/lib/commonjs/hooks/useCollapsible.js +35 -0
  40. package/lib/commonjs/hooks/useCollapsible.js.map +1 -0
  41. package/lib/commonjs/hooks/useStickToBottom.js +68 -0
  42. package/lib/commonjs/hooks/useStickToBottom.js.map +1 -0
  43. package/lib/commonjs/index.js +257 -0
  44. package/lib/commonjs/index.js.map +1 -0
  45. package/lib/commonjs/package.json +1 -0
  46. package/lib/commonjs/primitives/Badge.js +119 -0
  47. package/lib/commonjs/primitives/Badge.js.map +1 -0
  48. package/lib/commonjs/primitives/Button.js +185 -0
  49. package/lib/commonjs/primitives/Button.js.map +1 -0
  50. package/lib/commonjs/primitives/Card.js +166 -0
  51. package/lib/commonjs/primitives/Card.js.map +1 -0
  52. package/lib/commonjs/primitives/Collapsible.js +137 -0
  53. package/lib/commonjs/primitives/Collapsible.js.map +1 -0
  54. package/lib/commonjs/primitives/ScrollArea.js +40 -0
  55. package/lib/commonjs/primitives/ScrollArea.js.map +1 -0
  56. package/lib/commonjs/primitives/index.js +83 -0
  57. package/lib/commonjs/primitives/index.js.map +1 -0
  58. package/lib/commonjs/streaming/StreamingMarkdown.js +252 -0
  59. package/lib/commonjs/streaming/StreamingMarkdown.js.map +1 -0
  60. package/lib/commonjs/streaming/index.js +13 -0
  61. package/lib/commonjs/streaming/index.js.map +1 -0
  62. package/lib/commonjs/streaming/parser.js +482 -0
  63. package/lib/commonjs/streaming/parser.js.map +1 -0
  64. package/lib/commonjs/streaming/renderers/BlockquoteRenderer.js +35 -0
  65. package/lib/commonjs/streaming/renderers/BlockquoteRenderer.js.map +1 -0
  66. package/lib/commonjs/streaming/renderers/CodeRenderer.js +128 -0
  67. package/lib/commonjs/streaming/renderers/CodeRenderer.js.map +1 -0
  68. package/lib/commonjs/streaming/renderers/HeadingRenderer.js +61 -0
  69. package/lib/commonjs/streaming/renderers/HeadingRenderer.js.map +1 -0
  70. package/lib/commonjs/streaming/renderers/ImageRenderer.js +53 -0
  71. package/lib/commonjs/streaming/renderers/ImageRenderer.js.map +1 -0
  72. package/lib/commonjs/streaming/renderers/LinkRenderer.js +49 -0
  73. package/lib/commonjs/streaming/renderers/LinkRenderer.js.map +1 -0
  74. package/lib/commonjs/streaming/renderers/ListRenderer.js +63 -0
  75. package/lib/commonjs/streaming/renderers/ListRenderer.js.map +1 -0
  76. package/lib/commonjs/streaming/renderers/TableRenderer.js +77 -0
  77. package/lib/commonjs/streaming/renderers/TableRenderer.js.map +1 -0
  78. package/lib/commonjs/streaming/renderers/TextRenderer.js +41 -0
  79. package/lib/commonjs/streaming/renderers/TextRenderer.js.map +1 -0
  80. package/lib/commonjs/streaming/renderers/index.js +76 -0
  81. package/lib/commonjs/streaming/renderers/index.js.map +1 -0
  82. package/lib/commonjs/streaming/renderers/renderInlineChildren.js +112 -0
  83. package/lib/commonjs/streaming/renderers/renderInlineChildren.js.map +1 -0
  84. package/lib/commonjs/streaming/renderers/renderNode.js +81 -0
  85. package/lib/commonjs/streaming/renderers/renderNode.js.map +1 -0
  86. package/lib/commonjs/theme/ThemeProvider.js +68 -0
  87. package/lib/commonjs/theme/ThemeProvider.js.map +1 -0
  88. package/lib/commonjs/theme/defaultTheme.js +96 -0
  89. package/lib/commonjs/theme/defaultTheme.js.map +1 -0
  90. package/lib/commonjs/theme/index.js +32 -0
  91. package/lib/commonjs/theme/index.js.map +1 -0
  92. package/lib/commonjs/theme/tokens.js +2 -0
  93. package/lib/commonjs/theme/tokens.js.map +1 -0
  94. package/lib/commonjs/types.d.js +2 -0
  95. package/lib/commonjs/types.d.js.map +1 -0
  96. package/lib/commonjs/voice/index.js +13 -0
  97. package/lib/commonjs/voice/index.js.map +1 -0
  98. package/lib/commonjs/voice/useSpeechRecognition.js +172 -0
  99. package/lib/commonjs/voice/useSpeechRecognition.js.map +1 -0
  100. package/lib/module/chatbot/AIImage.js +121 -0
  101. package/lib/module/chatbot/AIImage.js.map +1 -0
  102. package/lib/module/chatbot/Attachments.js +312 -0
  103. package/lib/module/chatbot/Attachments.js.map +1 -0
  104. package/lib/module/chatbot/ChatErrorBoundary.js +196 -0
  105. package/lib/module/chatbot/ChatErrorBoundary.js.map +1 -0
  106. package/lib/module/chatbot/ChatMessageItem.js +164 -0
  107. package/lib/module/chatbot/ChatMessageItem.js.map +1 -0
  108. package/lib/module/chatbot/Conversation.js +412 -0
  109. package/lib/module/chatbot/Conversation.js.map +1 -0
  110. package/lib/module/chatbot/ConversationScrollButton.js +126 -0
  111. package/lib/module/chatbot/ConversationScrollButton.js.map +1 -0
  112. package/lib/module/chatbot/Message.js +198 -0
  113. package/lib/module/chatbot/Message.js.map +1 -0
  114. package/lib/module/chatbot/PromptInput.js +347 -0
  115. package/lib/module/chatbot/PromptInput.js.map +1 -0
  116. package/lib/module/chatbot/Reasoning.js +179 -0
  117. package/lib/module/chatbot/Reasoning.js.map +1 -0
  118. package/lib/module/chatbot/Shimmer.js +111 -0
  119. package/lib/module/chatbot/Shimmer.js.map +1 -0
  120. package/lib/module/chatbot/Sources.js +207 -0
  121. package/lib/module/chatbot/Sources.js.map +1 -0
  122. package/lib/module/chatbot/Suggestion.js +94 -0
  123. package/lib/module/chatbot/Suggestion.js.map +1 -0
  124. package/lib/module/chatbot/Tool.js +303 -0
  125. package/lib/module/chatbot/Tool.js.map +1 -0
  126. package/lib/module/chatbot/adapters/uiMessageAdapter.js +137 -0
  127. package/lib/module/chatbot/adapters/uiMessageAdapter.js.map +1 -0
  128. package/lib/module/chatbot/index.js +39 -0
  129. package/lib/module/chatbot/index.js.map +1 -0
  130. package/lib/module/chatbot/types.js +4 -0
  131. package/lib/module/chatbot/types.js.map +1 -0
  132. package/lib/module/hooks/index.js +7 -0
  133. package/lib/module/hooks/index.js.map +1 -0
  134. package/lib/module/hooks/useAutoScroll.js +35 -0
  135. package/lib/module/hooks/useAutoScroll.js.map +1 -0
  136. package/lib/module/hooks/useClipboard.js +40 -0
  137. package/lib/module/hooks/useClipboard.js.map +1 -0
  138. package/lib/module/hooks/useCollapsible.js +31 -0
  139. package/lib/module/hooks/useCollapsible.js.map +1 -0
  140. package/lib/module/hooks/useStickToBottom.js +64 -0
  141. package/lib/module/hooks/useStickToBottom.js.map +1 -0
  142. package/lib/module/index.js +19 -0
  143. package/lib/module/index.js.map +1 -0
  144. package/lib/module/package.json +1 -0
  145. package/lib/module/primitives/Badge.js +114 -0
  146. package/lib/module/primitives/Badge.js.map +1 -0
  147. package/lib/module/primitives/Button.js +180 -0
  148. package/lib/module/primitives/Button.js.map +1 -0
  149. package/lib/module/primitives/Card.js +156 -0
  150. package/lib/module/primitives/Card.js.map +1 -0
  151. package/lib/module/primitives/Collapsible.js +130 -0
  152. package/lib/module/primitives/Collapsible.js.map +1 -0
  153. package/lib/module/primitives/ScrollArea.js +35 -0
  154. package/lib/module/primitives/ScrollArea.js.map +1 -0
  155. package/lib/module/primitives/index.js +8 -0
  156. package/lib/module/primitives/index.js.map +1 -0
  157. package/lib/module/streaming/StreamingMarkdown.js +246 -0
  158. package/lib/module/streaming/StreamingMarkdown.js.map +1 -0
  159. package/lib/module/streaming/index.js +4 -0
  160. package/lib/module/streaming/index.js.map +1 -0
  161. package/lib/module/streaming/parser.js +477 -0
  162. package/lib/module/streaming/parser.js.map +1 -0
  163. package/lib/module/streaming/renderers/BlockquoteRenderer.js +30 -0
  164. package/lib/module/streaming/renderers/BlockquoteRenderer.js.map +1 -0
  165. package/lib/module/streaming/renderers/CodeRenderer.js +123 -0
  166. package/lib/module/streaming/renderers/CodeRenderer.js.map +1 -0
  167. package/lib/module/streaming/renderers/HeadingRenderer.js +56 -0
  168. package/lib/module/streaming/renderers/HeadingRenderer.js.map +1 -0
  169. package/lib/module/streaming/renderers/ImageRenderer.js +48 -0
  170. package/lib/module/streaming/renderers/ImageRenderer.js.map +1 -0
  171. package/lib/module/streaming/renderers/LinkRenderer.js +44 -0
  172. package/lib/module/streaming/renderers/LinkRenderer.js.map +1 -0
  173. package/lib/module/streaming/renderers/ListRenderer.js +58 -0
  174. package/lib/module/streaming/renderers/ListRenderer.js.map +1 -0
  175. package/lib/module/streaming/renderers/TableRenderer.js +72 -0
  176. package/lib/module/streaming/renderers/TableRenderer.js.map +1 -0
  177. package/lib/module/streaming/renderers/TextRenderer.js +36 -0
  178. package/lib/module/streaming/renderers/TextRenderer.js.map +1 -0
  179. package/lib/module/streaming/renderers/index.js +13 -0
  180. package/lib/module/streaming/renderers/index.js.map +1 -0
  181. package/lib/module/streaming/renderers/renderInlineChildren.js +107 -0
  182. package/lib/module/streaming/renderers/renderInlineChildren.js.map +1 -0
  183. package/lib/module/streaming/renderers/renderNode.js +78 -0
  184. package/lib/module/streaming/renderers/renderNode.js.map +1 -0
  185. package/lib/module/theme/ThemeProvider.js +62 -0
  186. package/lib/module/theme/ThemeProvider.js.map +1 -0
  187. package/lib/module/theme/defaultTheme.js +92 -0
  188. package/lib/module/theme/defaultTheme.js.map +1 -0
  189. package/lib/module/theme/index.js +5 -0
  190. package/lib/module/theme/index.js.map +1 -0
  191. package/lib/module/theme/tokens.js +2 -0
  192. package/lib/module/theme/tokens.js.map +1 -0
  193. package/lib/module/types.d.js +2 -0
  194. package/lib/module/types.d.js.map +1 -0
  195. package/lib/module/voice/index.js +14 -0
  196. package/lib/module/voice/index.js.map +1 -0
  197. package/lib/module/voice/useSpeechRecognition.js +169 -0
  198. package/lib/module/voice/useSpeechRecognition.js.map +1 -0
  199. package/lib/typescript/src/chatbot/AIImage.d.ts +24 -0
  200. package/lib/typescript/src/chatbot/AIImage.d.ts.map +1 -0
  201. package/lib/typescript/src/chatbot/Attachments.d.ts +20 -0
  202. package/lib/typescript/src/chatbot/Attachments.d.ts.map +1 -0
  203. package/lib/typescript/src/chatbot/ChatErrorBoundary.d.ts +57 -0
  204. package/lib/typescript/src/chatbot/ChatErrorBoundary.d.ts.map +1 -0
  205. package/lib/typescript/src/chatbot/ChatMessageItem.d.ts +45 -0
  206. package/lib/typescript/src/chatbot/ChatMessageItem.d.ts.map +1 -0
  207. package/lib/typescript/src/chatbot/Conversation.d.ts +94 -0
  208. package/lib/typescript/src/chatbot/Conversation.d.ts.map +1 -0
  209. package/lib/typescript/src/chatbot/ConversationScrollButton.d.ts +62 -0
  210. package/lib/typescript/src/chatbot/ConversationScrollButton.d.ts.map +1 -0
  211. package/lib/typescript/src/chatbot/Message.d.ts +39 -0
  212. package/lib/typescript/src/chatbot/Message.d.ts.map +1 -0
  213. package/lib/typescript/src/chatbot/PromptInput.d.ts +93 -0
  214. package/lib/typescript/src/chatbot/PromptInput.d.ts.map +1 -0
  215. package/lib/typescript/src/chatbot/Reasoning.d.ts +14 -0
  216. package/lib/typescript/src/chatbot/Reasoning.d.ts.map +1 -0
  217. package/lib/typescript/src/chatbot/Shimmer.d.ts +13 -0
  218. package/lib/typescript/src/chatbot/Shimmer.d.ts.map +1 -0
  219. package/lib/typescript/src/chatbot/Sources.d.ts +17 -0
  220. package/lib/typescript/src/chatbot/Sources.d.ts.map +1 -0
  221. package/lib/typescript/src/chatbot/Suggestion.d.ts +15 -0
  222. package/lib/typescript/src/chatbot/Suggestion.d.ts.map +1 -0
  223. package/lib/typescript/src/chatbot/Tool.d.ts +30 -0
  224. package/lib/typescript/src/chatbot/Tool.d.ts.map +1 -0
  225. package/lib/typescript/src/chatbot/adapters/uiMessageAdapter.d.ts +24 -0
  226. package/lib/typescript/src/chatbot/adapters/uiMessageAdapter.d.ts.map +1 -0
  227. package/lib/typescript/src/chatbot/index.d.ts +29 -0
  228. package/lib/typescript/src/chatbot/index.d.ts.map +1 -0
  229. package/lib/typescript/src/chatbot/types.d.ts +49 -0
  230. package/lib/typescript/src/chatbot/types.d.ts.map +1 -0
  231. package/lib/typescript/src/hooks/index.d.ts +9 -0
  232. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  233. package/lib/typescript/src/hooks/useAutoScroll.d.ts +23 -0
  234. package/lib/typescript/src/hooks/useAutoScroll.d.ts.map +1 -0
  235. package/lib/typescript/src/hooks/useClipboard.d.ts +22 -0
  236. package/lib/typescript/src/hooks/useClipboard.d.ts.map +1 -0
  237. package/lib/typescript/src/hooks/useCollapsible.d.ts +28 -0
  238. package/lib/typescript/src/hooks/useCollapsible.d.ts.map +1 -0
  239. package/lib/typescript/src/hooks/useStickToBottom.d.ts +39 -0
  240. package/lib/typescript/src/hooks/useStickToBottom.d.ts.map +1 -0
  241. package/lib/typescript/src/index.d.ts +11 -0
  242. package/lib/typescript/src/index.d.ts.map +1 -0
  243. package/lib/typescript/src/primitives/Badge.d.ts +10 -0
  244. package/lib/typescript/src/primitives/Badge.d.ts.map +1 -0
  245. package/lib/typescript/src/primitives/Button.d.ts +16 -0
  246. package/lib/typescript/src/primitives/Button.d.ts.map +1 -0
  247. package/lib/typescript/src/primitives/Card.d.ts +33 -0
  248. package/lib/typescript/src/primitives/Card.d.ts.map +1 -0
  249. package/lib/typescript/src/primitives/Collapsible.d.ts +20 -0
  250. package/lib/typescript/src/primitives/Collapsible.d.ts.map +1 -0
  251. package/lib/typescript/src/primitives/ScrollArea.d.ts +10 -0
  252. package/lib/typescript/src/primitives/ScrollArea.d.ts.map +1 -0
  253. package/lib/typescript/src/primitives/index.d.ts +11 -0
  254. package/lib/typescript/src/primitives/index.d.ts.map +1 -0
  255. package/lib/typescript/src/streaming/StreamingMarkdown.d.ts +47 -0
  256. package/lib/typescript/src/streaming/StreamingMarkdown.d.ts.map +1 -0
  257. package/lib/typescript/src/streaming/index.d.ts +3 -0
  258. package/lib/typescript/src/streaming/index.d.ts.map +1 -0
  259. package/lib/typescript/src/streaming/parser.d.ts +41 -0
  260. package/lib/typescript/src/streaming/parser.d.ts.map +1 -0
  261. package/lib/typescript/src/streaming/renderers/BlockquoteRenderer.d.ts +7 -0
  262. package/lib/typescript/src/streaming/renderers/BlockquoteRenderer.d.ts.map +1 -0
  263. package/lib/typescript/src/streaming/renderers/CodeRenderer.d.ts +7 -0
  264. package/lib/typescript/src/streaming/renderers/CodeRenderer.d.ts.map +1 -0
  265. package/lib/typescript/src/streaming/renderers/HeadingRenderer.d.ts +7 -0
  266. package/lib/typescript/src/streaming/renderers/HeadingRenderer.d.ts.map +1 -0
  267. package/lib/typescript/src/streaming/renderers/ImageRenderer.d.ts +7 -0
  268. package/lib/typescript/src/streaming/renderers/ImageRenderer.d.ts.map +1 -0
  269. package/lib/typescript/src/streaming/renderers/LinkRenderer.d.ts +7 -0
  270. package/lib/typescript/src/streaming/renderers/LinkRenderer.d.ts.map +1 -0
  271. package/lib/typescript/src/streaming/renderers/ListRenderer.d.ts +7 -0
  272. package/lib/typescript/src/streaming/renderers/ListRenderer.d.ts.map +1 -0
  273. package/lib/typescript/src/streaming/renderers/TableRenderer.d.ts +7 -0
  274. package/lib/typescript/src/streaming/renderers/TableRenderer.d.ts.map +1 -0
  275. package/lib/typescript/src/streaming/renderers/TextRenderer.d.ts +7 -0
  276. package/lib/typescript/src/streaming/renderers/TextRenderer.d.ts.map +1 -0
  277. package/lib/typescript/src/streaming/renderers/index.d.ts +19 -0
  278. package/lib/typescript/src/streaming/renderers/index.d.ts.map +1 -0
  279. package/lib/typescript/src/streaming/renderers/renderInlineChildren.d.ts +12 -0
  280. package/lib/typescript/src/streaming/renderers/renderInlineChildren.d.ts.map +1 -0
  281. package/lib/typescript/src/streaming/renderers/renderNode.d.ts +8 -0
  282. package/lib/typescript/src/streaming/renderers/renderNode.d.ts.map +1 -0
  283. package/lib/typescript/src/theme/ThemeProvider.d.ts +14 -0
  284. package/lib/typescript/src/theme/ThemeProvider.d.ts.map +1 -0
  285. package/lib/typescript/src/theme/defaultTheme.d.ts +4 -0
  286. package/lib/typescript/src/theme/defaultTheme.d.ts.map +1 -0
  287. package/lib/typescript/src/theme/index.d.ts +5 -0
  288. package/lib/typescript/src/theme/index.d.ts.map +1 -0
  289. package/lib/typescript/src/theme/tokens.d.ts +66 -0
  290. package/lib/typescript/src/theme/tokens.d.ts.map +1 -0
  291. package/lib/typescript/src/voice/index.d.ts +3 -0
  292. package/lib/typescript/src/voice/index.d.ts.map +1 -0
  293. package/lib/typescript/src/voice/useSpeechRecognition.d.ts +77 -0
  294. package/lib/typescript/src/voice/useSpeechRecognition.d.ts.map +1 -0
  295. package/package.json +132 -0
  296. package/src/chatbot/AIImage.tsx +166 -0
  297. package/src/chatbot/Attachments.tsx +382 -0
  298. package/src/chatbot/ChatErrorBoundary.tsx +230 -0
  299. package/src/chatbot/ChatMessageItem.tsx +195 -0
  300. package/src/chatbot/Conversation.tsx +537 -0
  301. package/src/chatbot/ConversationScrollButton.tsx +149 -0
  302. package/src/chatbot/Message.tsx +266 -0
  303. package/src/chatbot/PromptInput.tsx +532 -0
  304. package/src/chatbot/Reasoning.tsx +198 -0
  305. package/src/chatbot/Shimmer.tsx +146 -0
  306. package/src/chatbot/Sources.tsx +263 -0
  307. package/src/chatbot/Suggestion.tsx +123 -0
  308. package/src/chatbot/Tool.tsx +340 -0
  309. package/src/chatbot/adapters/uiMessageAdapter.ts +177 -0
  310. package/src/chatbot/index.ts +97 -0
  311. package/src/chatbot/types.ts +66 -0
  312. package/src/hooks/index.ts +17 -0
  313. package/src/hooks/useAutoScroll.ts +43 -0
  314. package/src/hooks/useClipboard.ts +46 -0
  315. package/src/hooks/useCollapsible.ts +42 -0
  316. package/src/hooks/useStickToBottom.ts +82 -0
  317. package/src/index.ts +139 -0
  318. package/src/primitives/Badge.tsx +119 -0
  319. package/src/primitives/Button.tsx +213 -0
  320. package/src/primitives/Card.tsx +221 -0
  321. package/src/primitives/Collapsible.tsx +168 -0
  322. package/src/primitives/ScrollArea.tsx +53 -0
  323. package/src/primitives/index.ts +36 -0
  324. package/src/streaming/StreamingMarkdown.tsx +282 -0
  325. package/src/streaming/index.ts +2 -0
  326. package/src/streaming/parser.ts +506 -0
  327. package/src/streaming/renderers/BlockquoteRenderer.tsx +42 -0
  328. package/src/streaming/renderers/CodeRenderer.tsx +158 -0
  329. package/src/streaming/renderers/HeadingRenderer.tsx +64 -0
  330. package/src/streaming/renderers/ImageRenderer.tsx +62 -0
  331. package/src/streaming/renderers/LinkRenderer.tsx +53 -0
  332. package/src/streaming/renderers/ListRenderer.tsx +65 -0
  333. package/src/streaming/renderers/TableRenderer.tsx +103 -0
  334. package/src/streaming/renderers/TextRenderer.tsx +39 -0
  335. package/src/streaming/renderers/index.ts +26 -0
  336. package/src/streaming/renderers/renderInlineChildren.tsx +115 -0
  337. package/src/streaming/renderers/renderNode.tsx +72 -0
  338. package/src/theme/ThemeProvider.tsx +77 -0
  339. package/src/theme/defaultTheme.ts +93 -0
  340. package/src/theme/index.ts +4 -0
  341. package/src/theme/tokens.ts +69 -0
  342. package/src/types.d.ts +71 -0
  343. package/src/voice/index.ts +15 -0
  344. package/src/voice/useSpeechRecognition.ts +230 -0
@@ -0,0 +1,303 @@
1
+ "use strict";
2
+
3
+ import React, { createContext, memo, useContext } from 'react';
4
+ import { StyleSheet, Text, View } from 'react-native';
5
+ import { CheckCircle, Loader, AlertCircle, Clock, Wrench } from 'lucide-react-native';
6
+ import { useAIElementsTheme } from '../theme';
7
+ import { Badge } from '../primitives';
8
+ import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '../primitives';
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // Types
12
+ // ---------------------------------------------------------------------------
13
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
14
+ // ---------------------------------------------------------------------------
15
+ // Context
16
+ // ---------------------------------------------------------------------------
17
+
18
+ const ToolContext = /*#__PURE__*/createContext(null);
19
+ function useToolContext() {
20
+ const ctx = useContext(ToolContext);
21
+ if (!ctx) {
22
+ throw new Error('Tool compound components must be used within a <Tool>.');
23
+ }
24
+ return ctx;
25
+ }
26
+
27
+ // ---------------------------------------------------------------------------
28
+ // Status helpers
29
+ // ---------------------------------------------------------------------------
30
+
31
+ function getStatusBadgeVariant(status) {
32
+ switch (status) {
33
+ case 'pending':
34
+ return 'secondary';
35
+ case 'running':
36
+ return 'warning';
37
+ case 'completed':
38
+ return 'success';
39
+ case 'failed':
40
+ return 'destructive';
41
+ }
42
+ }
43
+ function getStatusIcon(status, theme) {
44
+ const size = 14;
45
+ switch (status) {
46
+ case 'pending':
47
+ return /*#__PURE__*/_jsx(Clock, {
48
+ size: size,
49
+ color: theme.colors.mutedForeground
50
+ });
51
+ case 'running':
52
+ return /*#__PURE__*/_jsx(Loader, {
53
+ size: size,
54
+ color: theme.colors.warning
55
+ });
56
+ case 'completed':
57
+ return /*#__PURE__*/_jsx(CheckCircle, {
58
+ size: size,
59
+ color: theme.colors.success
60
+ });
61
+ case 'failed':
62
+ return /*#__PURE__*/_jsx(AlertCircle, {
63
+ size: size,
64
+ color: theme.colors.destructive
65
+ });
66
+ }
67
+ }
68
+ function getStatusLabel(status) {
69
+ switch (status) {
70
+ case 'pending':
71
+ return 'Pending';
72
+ case 'running':
73
+ return 'Running';
74
+ case 'completed':
75
+ return 'Completed';
76
+ case 'failed':
77
+ return 'Failed';
78
+ }
79
+ }
80
+
81
+ // ---------------------------------------------------------------------------
82
+ // Tool (root)
83
+ // ---------------------------------------------------------------------------
84
+
85
+ function ToolRoot({
86
+ name,
87
+ status,
88
+ args,
89
+ result,
90
+ children,
91
+ style
92
+ }) {
93
+ const theme = useAIElementsTheme();
94
+ return /*#__PURE__*/_jsx(ToolContext.Provider, {
95
+ value: {
96
+ name,
97
+ status,
98
+ args,
99
+ result
100
+ },
101
+ children: /*#__PURE__*/_jsx(View, {
102
+ style: [styles.container, {
103
+ backgroundColor: theme.colors.card,
104
+ borderColor: theme.colors.border,
105
+ borderRadius: theme.radius.md,
106
+ padding: theme.spacing.md
107
+ }, style],
108
+ children: children ?? /*#__PURE__*/_jsxs(_Fragment, {
109
+ children: [/*#__PURE__*/_jsx(ToolHeader, {}), args && Object.keys(args).length > 0 && /*#__PURE__*/_jsx(ToolArgs, {}), result && /*#__PURE__*/_jsx(ToolResult, {})]
110
+ })
111
+ })
112
+ });
113
+ }
114
+
115
+ // ---------------------------------------------------------------------------
116
+ // ToolHeader
117
+ // ---------------------------------------------------------------------------
118
+
119
+ function ToolHeaderComponent({
120
+ style
121
+ }) {
122
+ const theme = useAIElementsTheme();
123
+ const {
124
+ name,
125
+ status
126
+ } = useToolContext();
127
+ const nameStyle = {
128
+ color: theme.colors.foreground,
129
+ fontSize: theme.typography.fontSize.sm,
130
+ fontWeight: theme.typography.fontWeight.semibold,
131
+ fontFamily: theme.typography.fontFamily
132
+ };
133
+ return /*#__PURE__*/_jsxs(View, {
134
+ style: [styles.header, {
135
+ gap: theme.spacing.sm
136
+ }, style],
137
+ children: [/*#__PURE__*/_jsx(Wrench, {
138
+ size: 16,
139
+ color: theme.colors.mutedForeground
140
+ }), /*#__PURE__*/_jsx(Text, {
141
+ style: nameStyle,
142
+ numberOfLines: 1,
143
+ children: name
144
+ }), /*#__PURE__*/_jsx(Badge, {
145
+ variant: getStatusBadgeVariant(status),
146
+ children: /*#__PURE__*/_jsxs(View, {
147
+ style: [styles.badgeContent, {
148
+ gap: theme.spacing.xs
149
+ }],
150
+ children: [getStatusIcon(status, theme), /*#__PURE__*/_jsx(Text, {
151
+ style: {
152
+ color: status === 'completed' ? theme.colors.successForeground : status === 'failed' ? theme.colors.destructiveForeground : status === 'running' ? theme.colors.warningForeground : theme.colors.secondaryForeground,
153
+ fontSize: theme.typography.fontSize.xs,
154
+ fontWeight: theme.typography.fontWeight.semibold,
155
+ fontFamily: theme.typography.fontFamily,
156
+ // Pin the text's line box to the 14px icon height so
157
+ // `alignItems: center` in the row produces pixel-aligned
158
+ // cross-axis centering between glyph and icon.
159
+ lineHeight: 14,
160
+ includeFontPadding: false,
161
+ textAlignVertical: 'center'
162
+ },
163
+ children: getStatusLabel(status)
164
+ })]
165
+ })
166
+ })]
167
+ });
168
+ }
169
+
170
+ // ---------------------------------------------------------------------------
171
+ // ToolArgs
172
+ // ---------------------------------------------------------------------------
173
+
174
+ function ToolArgsComponent({
175
+ style
176
+ }) {
177
+ const theme = useAIElementsTheme();
178
+ const {
179
+ args
180
+ } = useToolContext();
181
+ if (!args || Object.keys(args).length === 0) {
182
+ return null;
183
+ }
184
+ const labelStyle = {
185
+ color: theme.colors.mutedForeground,
186
+ fontSize: theme.typography.fontSize.xs,
187
+ fontWeight: theme.typography.fontWeight.medium,
188
+ fontFamily: theme.typography.fontFamily
189
+ };
190
+ const codeStyle = {
191
+ color: theme.colors.foreground,
192
+ fontSize: theme.typography.fontSize.xs,
193
+ fontFamily: theme.typography.monoFontFamily,
194
+ lineHeight: theme.typography.fontSize.xs * theme.typography.lineHeight.relaxed
195
+ };
196
+ return /*#__PURE__*/_jsxs(Collapsible, {
197
+ style: [{
198
+ marginTop: theme.spacing.sm
199
+ }, style],
200
+ children: [/*#__PURE__*/_jsx(CollapsibleTrigger, {
201
+ children: /*#__PURE__*/_jsx(Text, {
202
+ style: labelStyle,
203
+ children: "Arguments"
204
+ })
205
+ }), /*#__PURE__*/_jsx(CollapsibleContent, {
206
+ children: /*#__PURE__*/_jsx(View, {
207
+ style: [styles.codeBlock, {
208
+ backgroundColor: theme.colors.muted,
209
+ borderRadius: theme.radius.sm,
210
+ padding: theme.spacing.sm,
211
+ marginTop: theme.spacing.xs
212
+ }],
213
+ children: /*#__PURE__*/_jsx(Text, {
214
+ style: codeStyle,
215
+ children: JSON.stringify(args, null, 2)
216
+ })
217
+ })
218
+ })]
219
+ });
220
+ }
221
+
222
+ // ---------------------------------------------------------------------------
223
+ // ToolResult
224
+ // ---------------------------------------------------------------------------
225
+
226
+ function ToolResultComponent({
227
+ style
228
+ }) {
229
+ const theme = useAIElementsTheme();
230
+ const {
231
+ result
232
+ } = useToolContext();
233
+ if (!result) {
234
+ return null;
235
+ }
236
+ const labelStyle = {
237
+ color: theme.colors.mutedForeground,
238
+ fontSize: theme.typography.fontSize.xs,
239
+ fontWeight: theme.typography.fontWeight.medium,
240
+ fontFamily: theme.typography.fontFamily
241
+ };
242
+ const resultTextStyle = {
243
+ color: theme.colors.foreground,
244
+ fontSize: theme.typography.fontSize.xs,
245
+ fontFamily: theme.typography.monoFontFamily,
246
+ lineHeight: theme.typography.fontSize.xs * theme.typography.lineHeight.relaxed
247
+ };
248
+ return /*#__PURE__*/_jsxs(Collapsible, {
249
+ style: [{
250
+ marginTop: theme.spacing.sm
251
+ }, style],
252
+ children: [/*#__PURE__*/_jsx(CollapsibleTrigger, {
253
+ children: /*#__PURE__*/_jsx(Text, {
254
+ style: labelStyle,
255
+ children: "Result"
256
+ })
257
+ }), /*#__PURE__*/_jsx(CollapsibleContent, {
258
+ children: /*#__PURE__*/_jsx(View, {
259
+ style: [styles.codeBlock, {
260
+ backgroundColor: theme.colors.muted,
261
+ borderRadius: theme.radius.sm,
262
+ padding: theme.spacing.sm,
263
+ marginTop: theme.spacing.xs
264
+ }],
265
+ children: /*#__PURE__*/_jsx(Text, {
266
+ style: resultTextStyle,
267
+ children: result
268
+ })
269
+ })
270
+ })]
271
+ });
272
+ }
273
+
274
+ // ---------------------------------------------------------------------------
275
+ // Styles
276
+ // ---------------------------------------------------------------------------
277
+
278
+ const styles = StyleSheet.create({
279
+ container: {
280
+ borderWidth: 1
281
+ },
282
+ header: {
283
+ flexDirection: 'row',
284
+ alignItems: 'center'
285
+ },
286
+ badgeContent: {
287
+ flexDirection: 'row',
288
+ alignItems: 'center'
289
+ },
290
+ codeBlock: {
291
+ overflow: 'hidden'
292
+ }
293
+ });
294
+
295
+ // ---------------------------------------------------------------------------
296
+ // Exports
297
+ // ---------------------------------------------------------------------------
298
+
299
+ export const Tool = /*#__PURE__*/memo(ToolRoot);
300
+ export const ToolHeader = /*#__PURE__*/memo(ToolHeaderComponent);
301
+ export const ToolArgs = /*#__PURE__*/memo(ToolArgsComponent);
302
+ export const ToolResult = /*#__PURE__*/memo(ToolResultComponent);
303
+ //# sourceMappingURL=Tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","memo","useContext","StyleSheet","Text","View","CheckCircle","Loader","AlertCircle","Clock","Wrench","useAIElementsTheme","Badge","Collapsible","CollapsibleTrigger","CollapsibleContent","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ToolContext","useToolContext","ctx","Error","getStatusBadgeVariant","status","getStatusIcon","theme","size","color","colors","mutedForeground","warning","success","destructive","getStatusLabel","ToolRoot","name","args","result","children","style","Provider","value","styles","container","backgroundColor","card","borderColor","border","borderRadius","radius","md","padding","spacing","ToolHeader","Object","keys","length","ToolArgs","ToolResult","ToolHeaderComponent","nameStyle","foreground","fontSize","typography","sm","fontWeight","semibold","fontFamily","header","gap","numberOfLines","variant","badgeContent","xs","successForeground","destructiveForeground","warningForeground","secondaryForeground","lineHeight","includeFontPadding","textAlignVertical","ToolArgsComponent","labelStyle","medium","codeStyle","monoFontFamily","relaxed","marginTop","codeBlock","muted","JSON","stringify","ToolResultComponent","resultTextStyle","create","borderWidth","flexDirection","alignItems","overflow","Tool"],"sourceRoot":"../../../src","sources":["chatbot/Tool.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,IAAI,EAAEC,UAAU,QAAwB,OAAO;AAC9E,SACEC,UAAU,EACVC,IAAI,EACJC,IAAI,QAIC,cAAc;AACrB,SACEC,WAAW,EACXC,MAAM,EACNC,WAAW,EACXC,KAAK,EACLC,MAAM,QACD,qBAAqB;AAC5B,SAASC,kBAAkB,QAAQ,UAAU;AAE7C,SAASC,KAAK,QAA2B,eAAe;AACxD,SACEC,WAAW,EACXC,kBAAkB,EAClBC,kBAAkB,QACb,eAAe;;AAEtB;AACA;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAA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UACnCzC,YAAY,EAAEvB,KAAK,CAACwB,MAAM,CAACe,EAAE;UAC7Bb,OAAO,EAAE1B,KAAK,CAAC2B,OAAO,CAACY,EAAE;UACzBuB,SAAS,EAAE9D,KAAK,CAAC2B,OAAO,CAACqB;QAC3B,CAAC,CACD;QAAAnC,QAAA,eAEFzB,IAAA,CAACb,IAAI;UAACuC,KAAK,EAAEsD,eAAgB;UAAAvD,QAAA,EAAED;QAAM,CAAO;MAAC,CACzC;IAAC,CACW,CAAC;EAAA,CACV,CAAC;AAElB;;AAEA;AACA;AACA;;AAEA,MAAMK,MAAM,GAAG3C,UAAU,CAAC+F,MAAM,CAAC;EAC/BnD,SAAS,EAAE;IACToD,WAAW,EAAE;EACf,CAAC;EACD3B,MAAM,EAAE;IACN4B,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE;EACd,CAAC;EACDzB,YAAY,EAAE;IACZwB,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE;EACd,CAAC;EACDT,SAAS,EAAE;IACTU,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC;;AAEF;AACA;AACA;;AAEA,OAAO,MAAMC,IAAI,gBAAGtG,IAAI,CAACqC,QAAQ,CAAC;AAClC,OAAO,MAAMmB,UAAU,gBAAGxD,IAAI,CAAC8D,mBAAmB,CAAC;AACnD,OAAO,MAAMF,QAAQ,gBAAG5D,IAAI,CAACoF,iBAAiB,CAAC;AAC/C,OAAO,MAAMvB,UAAU,gBAAG7D,IAAI,CAAC+F,mBAAmB,CAAC","ignoreList":[]}
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ // ---------------------------------------------------------------------------
4
+ // UIMessage → ChatMessageData
5
+ // ---------------------------------------------------------------------------
6
+ //
7
+ // `@ai-sdk/react`'s `useChat()` returns messages in the canonical Vercel AI
8
+ // SDK shape: each message has a `parts` array, where each part is a tagged
9
+ // union (`text` / `reasoning` / `tool-*` / `source-url` / etc). Our
10
+ // `ChatMessageItem` consumes a flatter `ChatMessageData` shape, so this file
11
+ // provides the (small) adapter every consumer of `useChat` will need.
12
+ //
13
+ // The adapter is intentionally tolerant: missing parts are mapped to
14
+ // `undefined` and the renderer skips them.
15
+ //
16
+ // **Why `import type` only?** `ai` is an optional peer dependency of this
17
+ // package — consumers who don't use `@ai-sdk/react` shouldn't have to
18
+ // install it. All imports from `ai` are type-only here, so they're erased
19
+ // at runtime and the adapter function itself is plain JS that operates on
20
+ // structural-shaped inputs.
21
+ // ---------------------------------------------------------------------------
22
+
23
+ const isTextPart = p => p.type === 'text';
24
+ const isReasoningPart = p => p.type === 'reasoning';
25
+ const isSourceUrlPart = p => p.type === 'source-url';
26
+
27
+ /**
28
+ * Type guard for any tool part — covers both static `tool-${name}` parts
29
+ * and the `dynamic-tool` part. Both expose `state`, `toolCallId`, `input`,
30
+ * and (when complete) `output` / `errorText`.
31
+ */
32
+ function isAnyToolPart(p) {
33
+ return p.type.startsWith('tool-') || p.type === 'dynamic-tool';
34
+ }
35
+
36
+ /** Extract the tool name from a `tool-${name}` part type, or fall back. */
37
+ function getToolName(part) {
38
+ if (part.type === 'dynamic-tool' && typeof part.toolName === 'string') {
39
+ return part.toolName;
40
+ }
41
+ if (part.type.startsWith('tool-')) {
42
+ return part.type.slice('tool-'.length);
43
+ }
44
+ return 'tool';
45
+ }
46
+
47
+ /**
48
+ * Map the AI SDK's tool-call lifecycle (`'input-streaming'` → `'output-error'`)
49
+ * onto our `ToolStatus` (`'pending' | 'running' | 'completed' | 'failed'`).
50
+ */
51
+ function mapToolState(state) {
52
+ switch (state) {
53
+ case 'input-streaming':
54
+ case 'input-available':
55
+ case 'approval-requested':
56
+ case 'approval-responded':
57
+ return 'running';
58
+ case 'output-available':
59
+ return 'completed';
60
+ case 'output-error':
61
+ case 'output-denied':
62
+ return 'failed';
63
+ default:
64
+ return 'pending';
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Convert an `@ai-sdk/react` `UIMessage` into the canonical
70
+ * {@link ChatMessageData} shape consumed by `<ChatMessageItem>`.
71
+ *
72
+ * Behavior:
73
+ * - All `text` parts are concatenated in document order.
74
+ * - The first **non-empty** `reasoning` part wins (most messages only
75
+ * have one); `isStreaming` follows the part's `state` field. Empty
76
+ * reasoning shells (no deltas ever emitted) are filtered out so the UI
77
+ * doesn't render a "Thinking..." ghost with nothing inside.
78
+ * - The first tool part wins (we only render one tool block per message
79
+ * today — multi-tool messages can be added later).
80
+ * - All `source-url` parts are collected into the sources array.
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * const data = uiMessageToChatMessageData(message);
85
+ * return <ChatMessageItem item={data} />;
86
+ * ```
87
+ */
88
+ export function uiMessageToChatMessageData(message) {
89
+ // The `parts` array is generic over data + tool maps; we treat it as the
90
+ // base discriminated union here so the type guards stay simple.
91
+ const parts = message.parts;
92
+
93
+ // Concatenate every text part.
94
+ const content = parts.filter(isTextPart).map(p => p.text).join('');
95
+
96
+ // First non-empty reasoning part. A provider (or the AI SDK) may emit
97
+ // `reasoning-start` / `reasoning-end` markers without any deltas in
98
+ // between — for example when a reasoning model hasn't been opted into
99
+ // emitting summaries via `providerOptions.openai.reasoningSummary`.
100
+ // We filter those empty shells out so the UI doesn't render a
101
+ // "Thinking..." ghost with nothing inside.
102
+ const reasoningPart = parts.find(p => isReasoningPart(p) && p.text.length > 0);
103
+ const reasoning = reasoningPart ? {
104
+ content: reasoningPart.text,
105
+ isStreaming: reasoningPart.state === 'streaming'
106
+ } : undefined;
107
+
108
+ // First tool part.
109
+ const toolPart = parts.find(isAnyToolPart);
110
+ let tool;
111
+ if (toolPart) {
112
+ // The discriminated union splits across many state shapes; cast to a
113
+ // permissive view since we only read a small subset of fields.
114
+ const t = toolPart;
115
+ tool = {
116
+ name: getToolName(t),
117
+ status: mapToolState(t.state),
118
+ args: t.input && typeof t.input === 'object' ? t.input : undefined,
119
+ result: t.errorText ?? (t.output != null ? typeof t.output === 'string' ? t.output : JSON.stringify(t.output) : undefined)
120
+ };
121
+ }
122
+
123
+ // All source-url parts (we ignore source-document for now).
124
+ const sources = parts.filter(isSourceUrlPart).map(p => ({
125
+ title: p.title ?? p.url,
126
+ url: p.url
127
+ }));
128
+ return {
129
+ id: message.id,
130
+ role: message.role,
131
+ content,
132
+ reasoning,
133
+ tool,
134
+ sources: sources.length > 0 ? sources : undefined
135
+ };
136
+ }
137
+ //# sourceMappingURL=uiMessageAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isTextPart","p","type","isReasoningPart","isSourceUrlPart","isAnyToolPart","startsWith","getToolName","part","toolName","slice","length","mapToolState","state","uiMessageToChatMessageData","message","parts","content","filter","map","text","join","reasoningPart","find","reasoning","isStreaming","undefined","toolPart","tool","t","name","status","args","input","result","errorText","output","JSON","stringify","sources","title","url","id","role"],"sourceRoot":"../../../../src","sources":["chatbot/adapters/uiMessageAdapter.ts"],"mappings":";;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,UAAU,GAAIC,CAA8B,IAChDA,CAAC,CAACC,IAAI,KAAK,MAAM;AAEnB,MAAMC,eAAe,GACnBF,CAA8B,IACLA,CAAC,CAACC,IAAI,KAAK,WAAW;AAEjD,MAAME,eAAe,GACnBH,CAA8B,IACLA,CAAC,CAACC,IAAI,KAAK,YAAY;;AAElD;AACA;AACA;AACA;AACA;AACA,SAASG,aAAaA,CAACJ,CAA8B,EAGnD;EACA,OAAOA,CAAC,CAACC,IAAI,CAACI,UAAU,CAAC,OAAO,CAAC,IAAIL,CAAC,CAACC,IAAI,KAAK,cAAc;AAChE;;AAEA;AACA,SAASK,WAAWA,CAACC,IAAyC,EAAU;EACtE,IAAIA,IAAI,CAACN,IAAI,KAAK,cAAc,IAAI,OAAOM,IAAI,CAACC,QAAQ,KAAK,QAAQ,EAAE;IACrE,OAAOD,IAAI,CAACC,QAAQ;EACtB;EACA,IAAID,IAAI,CAACN,IAAI,CAACI,UAAU,CAAC,OAAO,CAAC,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ACA,MAAME,CAAC,GAAGF,QAOT;IACDC,IAAI,GAAG;MACLE,IAAI,EAAEvB,WAAW,CAACsB,CAAC,CAAC;MACpBE,MAAM,EAAEnB,YAAY,CAACiB,CAAC,CAAChB,KAAK,CAAC;MAC7BmB,IAAI,EACFH,CAAC,CAACI,KAAK,IAAI,OAAOJ,CAAC,CAACI,KAAK,KAAK,QAAQ,GACjCJ,CAAC,CAACI,KAAK,GACRP,SAAS;MACfQ,MAAM,EACJL,CAAC,CAACM,SAAS,KACVN,CAAC,CAACO,MAAM,IAAI,IAAI,GACb,OAAOP,CAAC,CAACO,MAAM,KAAK,QAAQ,GAC1BP,CAAC,CAACO,MAAM,GACRC,IAAI,CAACC,SAAS,CAACT,CAAC,CAACO,MAAM,CAAC,GAC1BV,SAAS;IACjB,CAAC;EACH;;EAEA;EACA,MAAMa,OAAO,GAAGvB,KAAK,CAACE,MAAM,CAACd,eAAe,CAAC,CAACe,GAAG,CAAElB,CAAC,KAAM;IACxDuC,KAAK,EAAEvC,CAAC,CAACuC,KAAK,IAAIvC,CAAC,CAACwC,GAAG;IACvBA,GAAG,EAAExC,CAAC,CAACwC;EACT,CAAC,CAAC,CAAC;EAEH,OAAO;IACLC,EAAE,EAAE3B,OAAO,CAAC2B,EAAE;IACdC,IAAI,EAAE5B,OAAO,CAAC4B,IAAI;IAClB1B,OAAO;IACPO,SAAS;IACTI,IAAI;IACJW,OAAO,EAAEA,OAAO,CAAC5B,MAAM,GAAG,CAAC,GAAG4B,OAAO,GAAGb;EAC1C,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ // ---------------------------------------------------------------------------
4
+ // @crafter/rn-ai-elements/chatbot — public surface
5
+ // ---------------------------------------------------------------------------
6
+
7
+ // --- Conversation (generic list wrapper) -----------------------------------
8
+ export { Conversation } from './Conversation';
9
+ // --- ConversationScrollButton (floating "scroll to latest" affordance) -----
10
+ export { ConversationScrollButton } from './ConversationScrollButton';
11
+ // --- ChatMessageItem (default assistant/user message composition) ---------
12
+ export { ChatMessageItem } from './ChatMessageItem';
13
+ // --- ChatErrorBoundary (per-message error containment) --------------------
14
+ export { ChatErrorBoundary } from './ChatErrorBoundary';
15
+
16
+ // --- Canonical chat data types (consumed by ChatMessageItem) --------------
17
+
18
+ // --- AI SDK adapter -------------------------------------------------------
19
+ export { uiMessageToChatMessageData } from './adapters/uiMessageAdapter';
20
+
21
+ // --- Message compound (user bubbles + default content rendering) ----------
22
+ export { Message, MessageAvatar, MessageContent, MessageActions } from './Message';
23
+ // --- PromptInput (sticky bottom input bar) --------------------------------
24
+ export { PromptInput } from './PromptInput';
25
+ // --- Reasoning ------------------------------------------------------------
26
+ export { Reasoning } from './Reasoning';
27
+ // --- Suggestion -----------------------------------------------------------
28
+ export { Suggestion } from './Suggestion';
29
+ // --- Shimmer --------------------------------------------------------------
30
+ export { Shimmer } from './Shimmer';
31
+ // --- Tool -----------------------------------------------------------------
32
+ export { Tool, ToolHeader, ToolArgs, ToolResult } from './Tool';
33
+ // --- Sources --------------------------------------------------------------
34
+ export { Sources } from './Sources';
35
+ // --- Attachments ----------------------------------------------------------
36
+ export { Attachments } from './Attachments';
37
+ // --- AIImage --------------------------------------------------------------
38
+ export { AIImage } from './AIImage';
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Conversation","ConversationScrollButton","ChatMessageItem","ChatErrorBoundary","uiMessageToChatMessageData","Message","MessageAvatar","MessageContent","MessageActions","PromptInput","Reasoning","Suggestion","Shimmer","Tool","ToolHeader","ToolArgs","ToolResult","Sources","Attachments","AIImage"],"sourceRoot":"../../../src","sources":["chatbot/index.ts"],"mappings":";;AAAA;AACA;AACA;;AAEA;AACA,SAASA,YAAY,QAAQ,gBAAgB;AAS7C;AACA,SAASC,wBAAwB,QAAQ,4BAA4B;AAGrE;AACA,SAASC,eAAe,QAAQ,mBAAmB;AAGnD;AACA,SAASC,iBAAiB,QAAQ,qBAAqB;;AAGvD;;AAOA;AACA,SAASC,0BAA0B,QAAQ,6BAA6B;;AAExE;AACA,SACEC,OAAO,EACPC,aAAa,EACbC,cAAc,EACdC,cAAc,QACT,WAAW;AAUlB;AACA,SAASC,WAAW,QAAQ,eAAe;AAO3C;AACA,SAASC,SAAS,QAAQ,aAAa;AAGvC;AACA,SAASC,UAAU,QAAQ,cAAc;AAGzC;AACA,SAASC,OAAO,QAAQ,WAAW;AAGnC;AACA,SAASC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,QAAQ;AAS/D;AACA,SAASC,OAAO,QAAQ,WAAW;AAGnC;AACA,SAASC,WAAW,QAAQ,eAAe;AAO3C;AACA,SAASC,OAAO,QAAQ,WAAW","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["chatbot/types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ export { useAutoScroll } from './useAutoScroll';
4
+ export { useClipboard } from './useClipboard';
5
+ export { useStickToBottom } from './useStickToBottom';
6
+ export { useCollapsible } from './useCollapsible';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useAutoScroll","useClipboard","useStickToBottom","useCollapsible"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAG/C,SAASC,YAAY,QAAQ,gBAAgB;AAG7C,SAASC,gBAAgB,QAAQ,oBAAoB;AAMrD,SAASC,cAAc,QAAQ,kBAAkB","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ import { useCallback, useRef } from 'react';
4
+ /**
5
+ * Provides a FlatList ref and helpers that keep the list pinned to the bottom.
6
+ *
7
+ * ```tsx
8
+ * const { ref, onContentSizeChange } = useAutoScroll();
9
+ * <FlatList ref={ref} onContentSizeChange={onContentSizeChange} ... />
10
+ * ```
11
+ */
12
+ export function useAutoScroll(options = {}) {
13
+ const {
14
+ enabled = true
15
+ } = options;
16
+ const ref = useRef(null);
17
+ const scrollToEnd = useCallback(() => {
18
+ ref.current?.scrollToEnd({
19
+ animated: true
20
+ });
21
+ }, []);
22
+ const onContentSizeChange = useCallback(() => {
23
+ if (enabled) {
24
+ ref.current?.scrollToEnd({
25
+ animated: true
26
+ });
27
+ }
28
+ }, [enabled]);
29
+ return {
30
+ ref,
31
+ scrollToEnd,
32
+ onContentSizeChange
33
+ };
34
+ }
35
+ //# sourceMappingURL=useAutoScroll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useRef","useAutoScroll","options","enabled","ref","scrollToEnd","current","animated","onContentSizeChange"],"sourceRoot":"../../../src","sources":["hooks/useAutoScroll.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAiB3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BC,OAA6B,GAAG,CAAC,CAAC,EACV;EACxB,MAAM;IAAEC,OAAO,GAAG;EAAK,CAAC,GAAGD,OAAO;EAClC,MAAME,GAAG,GAAGJ,MAAM,CAAc,IAAI,CAAC;EAErC,MAAMK,WAAW,GAAGN,WAAW,CAAC,MAAM;IACpCK,GAAG,CAACE,OAAO,EAAED,WAAW,CAAC;MAAEE,QAAQ,EAAE;IAAK,CAAC,CAAC;EAC9C,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,mBAAmB,GAAGT,WAAW,CAAC,MAAM;IAC5C,IAAII,OAAO,EAAE;MACXC,GAAG,CAACE,OAAO,EAAED,WAAW,CAAC;QAAEE,QAAQ,EAAE;MAAK,CAAC,CAAC;IAC9C;EACF,CAAC,EAAE,CAACJ,OAAO,CAAC,CAAC;EAEb,OAAO;IAAEC,GAAG;IAAEC,WAAW;IAAEG;EAAoB,CAAC;AAClD","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ import { useCallback, useRef, useState } from 'react';
4
+ import { Clipboard } from 'react-native';
5
+ const RESET_DELAY_MS = 2_000;
6
+
7
+ /**
8
+ * Thin wrapper around the system clipboard with a transient `copied` flag.
9
+ *
10
+ * Uses the built-in `react-native` Clipboard API. The implementation is
11
+ * isolated so it can be swapped for `@react-native-clipboard/clipboard`
12
+ * without changing the public interface.
13
+ *
14
+ * ```tsx
15
+ * const { copy, copied } = useClipboard();
16
+ * <Pressable onPress={() => copy(code)}>
17
+ * <Text>{copied ? 'Copied!' : 'Copy'}</Text>
18
+ * </Pressable>
19
+ * ```
20
+ */
21
+ export function useClipboard() {
22
+ const [copied, setCopied] = useState(false);
23
+ const timerRef = useRef(null);
24
+ const copy = useCallback(async text => {
25
+ Clipboard.setString(text);
26
+ setCopied(true);
27
+ if (timerRef.current !== null) {
28
+ clearTimeout(timerRef.current);
29
+ }
30
+ timerRef.current = setTimeout(() => {
31
+ setCopied(false);
32
+ timerRef.current = null;
33
+ }, RESET_DELAY_MS);
34
+ }, []);
35
+ return {
36
+ copy,
37
+ copied
38
+ };
39
+ }
40
+ //# sourceMappingURL=useClipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useRef","useState","Clipboard","RESET_DELAY_MS","useClipboard","copied","setCopied","timerRef","copy","text","setString","current","clearTimeout","setTimeout"],"sourceRoot":"../../../src","sources":["hooks/useClipboard.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACrD,SAASC,SAAS,QAAQ,cAAc;AASxC,MAAMC,cAAc,GAAG,KAAK;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAA,EAAuB;EACjD,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGL,QAAQ,CAAC,KAAK,CAAC;EAC3C,MAAMM,QAAQ,GAAGP,MAAM,CAAuC,IAAI,CAAC;EAEnE,MAAMQ,IAAI,GAAGT,WAAW,CAAC,MAAOU,IAAY,IAAoB;IAC9DP,SAAS,CAACQ,SAAS,CAACD,IAAI,CAAC;IACzBH,SAAS,CAAC,IAAI,CAAC;IAEf,IAAIC,QAAQ,CAACI,OAAO,KAAK,IAAI,EAAE;MAC7BC,YAAY,CAACL,QAAQ,CAACI,OAAO,CAAC;IAChC;IAEAJ,QAAQ,CAACI,OAAO,GAAGE,UAAU,CAAC,MAAM;MAClCP,SAAS,CAAC,KAAK,CAAC;MAChBC,QAAQ,CAACI,OAAO,GAAG,IAAI;IACzB,CAAC,EAAER,cAAc,CAAC;EACpB,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IAAEK,IAAI;IAAEH;EAAO,CAAC;AACzB","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ import { useCallback, useState } from 'react';
4
+ /**
5
+ * Minimal state hook for a collapsible section.
6
+ *
7
+ * ```tsx
8
+ * const { isOpen, toggle } = useCollapsible({ defaultOpen: true });
9
+ *
10
+ * <Pressable onPress={toggle}>
11
+ * <Text>{isOpen ? 'Hide' : 'Show'}</Text>
12
+ * </Pressable>
13
+ * {isOpen && <View>...</View>}
14
+ * ```
15
+ */
16
+ export function useCollapsible(options = {}) {
17
+ const {
18
+ defaultOpen = false
19
+ } = options;
20
+ const [isOpen, setIsOpen] = useState(defaultOpen);
21
+ const toggle = useCallback(() => setIsOpen(prev => !prev), []);
22
+ const open = useCallback(() => setIsOpen(true), []);
23
+ const close = useCallback(() => setIsOpen(false), []);
24
+ return {
25
+ isOpen,
26
+ toggle,
27
+ open,
28
+ close
29
+ };
30
+ }
31
+ //# sourceMappingURL=useCollapsible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useState","useCollapsible","options","defaultOpen","isOpen","setIsOpen","toggle","prev","open","close"],"sourceRoot":"../../../src","sources":["hooks/useCollapsible.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAkB7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,OAA8B,GAAG,CAAC,CAAC,EACb;EACtB,MAAM;IAAEC,WAAW,GAAG;EAAM,CAAC,GAAGD,OAAO;EACvC,MAAM,CAACE,MAAM,EAAEC,SAAS,CAAC,GAAGL,QAAQ,CAACG,WAAW,CAAC;EAEjD,MAAMG,MAAM,GAAGP,WAAW,CAAC,MAAMM,SAAS,CAAEE,IAAa,IAAK,CAACA,IAAI,CAAC,EAAE,EAAE,CAAC;EACzE,MAAMC,IAAI,GAAGT,WAAW,CAAC,MAAMM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;EACnD,MAAMI,KAAK,GAAGV,WAAW,CAAC,MAAMM,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;EAErD,OAAO;IAAED,MAAM;IAAEE,MAAM;IAAEE,IAAI;IAAEC;EAAM,CAAC;AACxC","ignoreList":[]}