@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,126 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { Platform, Pressable, StyleSheet } from 'react-native';
5
+ import { ArrowDown } from 'lucide-react-native';
6
+ import { GlassView } from 'expo-glass-effect';
7
+ import { useAIElementsTheme } from '../theme';
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // Types
11
+ // ---------------------------------------------------------------------------
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ // ---------------------------------------------------------------------------
14
+ // Constants
15
+ // ---------------------------------------------------------------------------
16
+
17
+ // Match the PromptInput's CircleButton dimensions exactly so the scroll
18
+ // button visually stacks above the Plus button as a continuation of the
19
+ // same control column.
20
+ const CIRCLE_BUTTON_SIZE = 36;
21
+ const ICON_SIZE = 18;
22
+ const isIOS = Platform.OS === 'ios';
23
+
24
+ // ---------------------------------------------------------------------------
25
+ // Component
26
+ // ---------------------------------------------------------------------------
27
+
28
+ /**
29
+ * A floating circle button that appears when the user has scrolled away
30
+ * from the bottom of a conversation, and disappears when they return.
31
+ *
32
+ * Designed to sit in the chat area's bottom-left corner so it visually
33
+ * stacks above the PromptInput's Plus button — same size, same glass
34
+ * treatment, same press feedback. Pairs with
35
+ * `<Conversation onIsAtBottomChange={...} />`: the parent screen tracks
36
+ * the boolean and passes it as `visible`.
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * const [isAtBottom, setIsAtBottom] = useState(true);
41
+ * const ref = useRef<ConversationRef>(null);
42
+ *
43
+ * <View style={{ flex: 1 }}>
44
+ * <Conversation
45
+ * ref={ref}
46
+ * onIsAtBottomChange={setIsAtBottom}
47
+ * ...
48
+ * />
49
+ * <ConversationScrollButton
50
+ * visible={!isAtBottom}
51
+ * onPress={() => ref.current?.scrollToBottom()}
52
+ * style={{ position: 'absolute', left: 12, bottom: 12 }}
53
+ * />
54
+ * </View>
55
+ * ```
56
+ *
57
+ * **Why no fade animation?**
58
+ * Earlier iterations wrapped this in a Reanimated `Animated.View` for a
59
+ * smooth fade-in/out. On the iOS simulator (and likely device) the
60
+ * `expo-glass-effect` `GlassView` would render correctly on first mount
61
+ * but lose its glass material after a Fast Refresh or reload. Reanimated
62
+ * drives styles on the UI thread via a code path that conflicts with
63
+ * `expo-glass-effect`'s custom native view manager — the prop diff that
64
+ * re-applies the glass layer never reaches the native view. Dropping the
65
+ * animation wrapper and using a plain conditional render keeps the
66
+ * GlassView in exactly the same context as the working `Plus` button
67
+ * inside `PromptInput.CircleButton`.
68
+ */
69
+ export function ConversationScrollButton({
70
+ visible,
71
+ onPress,
72
+ style,
73
+ accessibilityLabel = 'Scroll to latest message'
74
+ }) {
75
+ const theme = useAIElementsTheme();
76
+ if (!visible) return null;
77
+ return /*#__PURE__*/_jsx(GlassView, {
78
+ glassEffectStyle: isIOS ? 'regular' : 'none',
79
+ isInteractive: true,
80
+ colorScheme: theme.dark ? 'dark' : 'light',
81
+ style: [styles.circleButton,
82
+ // On non-iOS GlassView is just a plain View — paint the bg
83
+ // ourselves to match the PromptInput's Plus fallback.
84
+ !isIOS && {
85
+ backgroundColor: theme.colors.secondary
86
+ }, style],
87
+ children: /*#__PURE__*/_jsx(Pressable, {
88
+ onPress: onPress,
89
+ accessibilityRole: "button",
90
+ accessibilityLabel: accessibilityLabel,
91
+ style: ({
92
+ pressed
93
+ }) => [styles.circleButtonInner, {
94
+ opacity: pressed ? 0.6 : 1
95
+ }],
96
+ children: /*#__PURE__*/_jsx(ArrowDown, {
97
+ size: ICON_SIZE,
98
+ color: theme.colors.foreground
99
+ })
100
+ })
101
+ });
102
+ }
103
+ ConversationScrollButton.displayName = 'ConversationScrollButton';
104
+
105
+ // ---------------------------------------------------------------------------
106
+ // Styles — mirror the PromptInput CircleButton's dimensions exactly
107
+ // ---------------------------------------------------------------------------
108
+
109
+ const styles = StyleSheet.create({
110
+ circleButton: {
111
+ width: CIRCLE_BUTTON_SIZE,
112
+ height: CIRCLE_BUTTON_SIZE,
113
+ borderRadius: CIRCLE_BUTTON_SIZE / 2,
114
+ // Clip the GlassView blur (and the non-iOS bg) to the rounded shape.
115
+ overflow: 'hidden',
116
+ alignItems: 'center',
117
+ justifyContent: 'center'
118
+ },
119
+ circleButtonInner: {
120
+ width: '100%',
121
+ height: '100%',
122
+ alignItems: 'center',
123
+ justifyContent: 'center'
124
+ }
125
+ });
126
+ //# sourceMappingURL=ConversationScrollButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Platform","Pressable","StyleSheet","ArrowDown","GlassView","useAIElementsTheme","jsx","_jsx","CIRCLE_BUTTON_SIZE","ICON_SIZE","isIOS","OS","ConversationScrollButton","visible","onPress","style","accessibilityLabel","theme","glassEffectStyle","isInteractive","colorScheme","dark","styles","circleButton","backgroundColor","colors","secondary","children","accessibilityRole","pressed","circleButtonInner","opacity","size","color","foreground","displayName","create","width","height","borderRadius","overflow","alignItems","justifyContent"],"sourceRoot":"../../../src","sources":["chatbot/ConversationScrollButton.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,QAAQ,EACRC,SAAS,EACTC,UAAU,QAGL,cAAc;AACrB,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,kBAAkB,QAAQ,UAAU;;AAE7C;AACA;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAkBA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,SAAS,GAAG,EAAE;AACpB,MAAMC,KAAK,GAAGV,QAAQ,CAACW,EAAE,KAAK,KAAK;;AAEnC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAAC;EACvCC,OAAO;EACPC,OAAO;EACPC,KAAK;EACLC,kBAAkB,GAAG;AACQ,CAAC,EAAE;EAChC,MAAMC,KAAK,GAAGZ,kBAAkB,CAAC,CAAC;EAElC,IAAI,CAACQ,OAAO,EAAE,OAAO,IAAI;EAEzB,oBACEN,IAAA,CAACH,SAAS;IACRc,gBAAgB,EAAER,KAAK,GAAG,SAAS,GAAG,MAAO;IAC7CS,aAAa;IACbC,WAAW,EAAEH,KAAK,CAACI,IAAI,GAAG,MAAM,GAAG,OAAQ;IAC3CN,KAAK,EAAE,CACLO,MAAM,CAACC,YAAY;IACnB;IACA;IACA,CAACb,KAAK,IAAI;MAAEc,eAAe,EAAEP,KAAK,CAACQ,MAAM,CAACC;IAAU,CAAC,EACrDX,KAAK,CACL;IAAAY,QAAA,eAEFpB,IAAA,CAACN,SAAS;MACRa,OAAO,EAAEA,OAAQ;MACjBc,iBAAiB,EAAC,QAAQ;MAC1BZ,kBAAkB,EAAEA,kBAAmB;MACvCD,KAAK,EAAEA,CAAC;QAAEc;MAAQ,CAAC,KAAK,CACtBP,MAAM,CAACQ,iBAAiB,EACxB;QAAEC,OAAO,EAAEF,OAAO,GAAG,GAAG,GAAG;MAAE,CAAC,CAC9B;MAAAF,QAAA,eAEFpB,IAAA,CAACJ,SAAS;QAAC6B,IAAI,EAAEvB,SAAU;QAACwB,KAAK,EAAEhB,KAAK,CAACQ,MAAM,CAACS;MAAW,CAAE;IAAC,CACrD;EAAC,CACH,CAAC;AAEhB;AAEAtB,wBAAwB,CAACuB,WAAW,GAAG,0BAA0B;;AAEjE;AACA;AACA;;AAEA,MAAMb,MAAM,GAAGpB,UAAU,CAACkC,MAAM,CAAC;EAC/Bb,YAAY,EAAE;IACZc,KAAK,EAAE7B,kBAAkB;IACzB8B,MAAM,EAAE9B,kBAAkB;IAC1B+B,YAAY,EAAE/B,kBAAkB,GAAG,CAAC;IACpC;IACAgC,QAAQ,EAAE,QAAQ;IAClBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDZ,iBAAiB,EAAE;IACjBO,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE,MAAM;IACdG,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+
3
+ import React, { createContext, memo, useContext } from 'react';
4
+ import { View, Text, StyleSheet } from 'react-native';
5
+ import { useAIElementsTheme } from '../theme';
6
+ import { StreamingMarkdown } from '../streaming';
7
+
8
+ // ---------------------------------------------------------------------------
9
+ // Types
10
+ // ---------------------------------------------------------------------------
11
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
12
+ // ---------------------------------------------------------------------------
13
+ // Context
14
+ // ---------------------------------------------------------------------------
15
+
16
+ const MessageContext = /*#__PURE__*/createContext(null);
17
+ function useMessageContext() {
18
+ const ctx = useContext(MessageContext);
19
+ if (!ctx) {
20
+ throw new Error('Message compound components must be used within a <Message>.');
21
+ }
22
+ return ctx;
23
+ }
24
+
25
+ // ---------------------------------------------------------------------------
26
+ // Prop types
27
+ // ---------------------------------------------------------------------------
28
+
29
+ // ---------------------------------------------------------------------------
30
+ // Message (root)
31
+ // ---------------------------------------------------------------------------
32
+
33
+ function MessageRoot({
34
+ message,
35
+ isStreaming,
36
+ children,
37
+ style
38
+ }) {
39
+ const theme = useAIElementsTheme();
40
+ const isUser = message.role === 'user';
41
+ return /*#__PURE__*/_jsx(MessageContext.Provider, {
42
+ value: {
43
+ message,
44
+ isStreaming
45
+ },
46
+ children: /*#__PURE__*/_jsx(View, {
47
+ style: [styles.container, {
48
+ alignItems: isUser ? 'flex-end' : 'flex-start',
49
+ paddingHorizontal: theme.spacing.lg,
50
+ marginBottom: theme.spacing.md
51
+ }, style],
52
+ children: children ?? /*#__PURE__*/_jsx(_Fragment, {
53
+ children: /*#__PURE__*/_jsx(MessageContent, {})
54
+ })
55
+ })
56
+ });
57
+ }
58
+
59
+ // ---------------------------------------------------------------------------
60
+ // MessageAvatar
61
+ // ---------------------------------------------------------------------------
62
+
63
+ function MessageAvatarComponent({
64
+ children,
65
+ style
66
+ }) {
67
+ const theme = useAIElementsTheme();
68
+ const {
69
+ message
70
+ } = useMessageContext();
71
+ const isUser = message.role === 'user';
72
+ return /*#__PURE__*/_jsx(View, {
73
+ style: [styles.avatar, {
74
+ backgroundColor: isUser ? theme.colors.primary : theme.colors.muted,
75
+ width: 32,
76
+ height: 32,
77
+ borderRadius: theme.radius.full
78
+ }, style],
79
+ children: children ?? /*#__PURE__*/_jsx(Text, {
80
+ style: [styles.avatarText, {
81
+ color: isUser ? theme.colors.primaryForeground : theme.colors.foreground,
82
+ fontSize: theme.typography.fontSize.sm,
83
+ fontWeight: theme.typography.fontWeight.semibold,
84
+ fontFamily: theme.typography.fontFamily
85
+ }],
86
+ children: isUser ? 'U' : 'AI'
87
+ })
88
+ });
89
+ }
90
+
91
+ // ---------------------------------------------------------------------------
92
+ // MessageContent
93
+ // ---------------------------------------------------------------------------
94
+
95
+ function MessageContentComponent({
96
+ style
97
+ }) {
98
+ const theme = useAIElementsTheme();
99
+ const {
100
+ message,
101
+ isStreaming
102
+ } = useMessageContext();
103
+ const isUser = message.role === 'user';
104
+ const bubbleStyle = getBubbleStyle(isUser, theme);
105
+ return /*#__PURE__*/_jsx(View, {
106
+ style: [styles.bubble, bubbleStyle, style],
107
+ children: isUser ? /*#__PURE__*/_jsx(Text, {
108
+ style: {
109
+ color: theme.colors.primaryForeground,
110
+ fontSize: 12,
111
+ fontFamily: theme.typography.fontFamily,
112
+ lineHeight: 12 * theme.typography.lineHeight.normal
113
+ },
114
+ children: message.content
115
+ }) : /*#__PURE__*/_jsx(StreamingMarkdown, {
116
+ content: message.content,
117
+ isStreaming: isStreaming
118
+ })
119
+ });
120
+ }
121
+
122
+ // ---------------------------------------------------------------------------
123
+ // MessageActions
124
+ // ---------------------------------------------------------------------------
125
+
126
+ function MessageActionsComponent({
127
+ children,
128
+ style
129
+ }) {
130
+ const theme = useAIElementsTheme();
131
+ return /*#__PURE__*/_jsx(View, {
132
+ style: [styles.actions, {
133
+ marginTop: theme.spacing.xs,
134
+ gap: theme.spacing.sm
135
+ }, style],
136
+ children: children
137
+ });
138
+ }
139
+
140
+ // ---------------------------------------------------------------------------
141
+ // Helpers
142
+ // ---------------------------------------------------------------------------
143
+
144
+ function getBubbleStyle(isUser, theme) {
145
+ if (isUser) {
146
+ return {
147
+ backgroundColor: theme.colors.primary,
148
+ borderRadius: theme.radius.lg,
149
+ borderBottomRightRadius: theme.radius.sm,
150
+ paddingHorizontal: theme.spacing.lg,
151
+ paddingVertical: theme.spacing.sm,
152
+ maxWidth: '80%'
153
+ };
154
+ }
155
+ return {
156
+ backgroundColor: theme.colors.card,
157
+ borderColor: theme.colors.border,
158
+ borderWidth: StyleSheet.hairlineWidth,
159
+ borderRadius: theme.radius.lg,
160
+ borderBottomLeftRadius: theme.radius.sm,
161
+ paddingHorizontal: theme.spacing.lg,
162
+ paddingVertical: theme.spacing.md,
163
+ maxWidth: '85%'
164
+ };
165
+ }
166
+
167
+ // ---------------------------------------------------------------------------
168
+ // Styles
169
+ // ---------------------------------------------------------------------------
170
+
171
+ const styles = StyleSheet.create({
172
+ container: {
173
+ flexDirection: 'column',
174
+ width: '100%'
175
+ },
176
+ avatar: {
177
+ alignItems: 'center',
178
+ justifyContent: 'center'
179
+ },
180
+ avatarText: {
181
+ textAlign: 'center'
182
+ },
183
+ bubble: {},
184
+ actions: {
185
+ flexDirection: 'row',
186
+ alignItems: 'center'
187
+ }
188
+ });
189
+
190
+ // ---------------------------------------------------------------------------
191
+ // Exports (memoized)
192
+ // ---------------------------------------------------------------------------
193
+
194
+ export const Message = /*#__PURE__*/memo(MessageRoot);
195
+ export const MessageAvatar = /*#__PURE__*/memo(MessageAvatarComponent);
196
+ export const MessageContent = /*#__PURE__*/memo(MessageContentComponent);
197
+ export const MessageActions = /*#__PURE__*/memo(MessageActionsComponent);
198
+ //# sourceMappingURL=Message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","memo","useContext","View","Text","StyleSheet","useAIElementsTheme","StreamingMarkdown","jsx","_jsx","Fragment","_Fragment","MessageContext","useMessageContext","ctx","Error","MessageRoot","message","isStreaming","children","style","theme","isUser","role","Provider","value","styles","container","alignItems","paddingHorizontal","spacing","lg","marginBottom","md","MessageContent","MessageAvatarComponent","avatar","backgroundColor","colors","primary","muted","width","height","borderRadius","radius","full","avatarText","color","primaryForeground","foreground","fontSize","typography","sm","fontWeight","semibold","fontFamily","MessageContentComponent","bubbleStyle","getBubbleStyle","bubble","lineHeight","normal","content","MessageActionsComponent","actions","marginTop","xs","gap","borderBottomRightRadius","paddingVertical","maxWidth","card","borderColor","border","borderWidth","hairlineWidth","borderBottomLeftRadius","create","flexDirection","justifyContent","textAlign","Message","MessageAvatar","MessageActions"],"sourceRoot":"../../../src","sources":["chatbot/Message.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,aAAa,EACbC,IAAI,EACJC,UAAU,QAEL,OAAO;AACd,SACEC,IAAI,EACJC,IAAI,EACJC,UAAU,QAIL,cAAc;AACrB,SAASC,kBAAkB,QAAQ,UAAU;AAE7C,SAASC,iBAAiB,QAAQ,cAAc;;AAEhD;AACA;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAcA;AACA;AACA;;AAEA,MAAMC,cAAc,gBAAGZ,aAAa,CAA6B,IAAI,CAAC;AAEtE,SAASa,iBAAiBA,CAAA,EAAwB;EAChD,MAAMC,GAAG,GAAGZ,UAAU,CAACU,cAAc,CAAC;EACtC,IAAI,CAACE,GAAG,EAAE;IACR,MAAM,IAAIC,KAAK,CACb,8DACF,CAAC;EACH;EACA,OAAOD,GAAG;AACZ;;AAEA;AACA;AACA;;AAuBA;AACA;AACA;;AAEA,SAASE,WAAWA,CAAC;EAAEC,OAAO;EAAEC,WAAW;EAAEC,QAAQ;EAAEC;AAAoB,CAAC,EAAE;EAC5E,MAAMC,KAAK,GAAGf,kBAAkB,CAAC,CAAC;EAClC,MAAMgB,MAAM,GAAGL,OAAO,CAACM,IAAI,KAAK,MAAM;EAEtC,oBACEd,IAAA,CAACG,cAAc,CAACY,QAAQ;IAACC,KAAK,EAAE;MAAER,OAAO;MAAEC;IAAY,CAAE;IAAAC,QAAA,eACvDV,IAAA,CAACN,IAAI;MACHiB,KAAK,EAAE,CACLM,MAAM,CAACC,SAAS,EAChB;QACEC,UAAU,EAAEN,MAAM,GAAG,UAAU,GAAG,YAAY;QAC9CO,iBAAiB,EAAER,KAAK,CAACS,OAAO,CAACC,EAAE;QACnCC,YAAY,EAAEX,KAAK,CAACS,OAAO,CAACG;MAC9B,CAAC,EACDb,KAAK,CACL;MAAAD,QAAA,EAEDA,QAAQ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C;;AAEF;AACA;AACA;;AAEA,OAAO,MAAMqD,OAAO,gBAAGhF,IAAI,CAACe,WAAW,CAAC;AACxC,OAAO,MAAMkE,aAAa,gBAAGjF,IAAI,CAACkC,sBAAsB,CAAC;AACzD,OAAO,MAAMD,cAAc,gBAAGjC,IAAI,CAACuD,uBAAuB,CAAC;AAC3D,OAAO,MAAM2B,cAAc,gBAAGlF,IAAI,CAAC8D,uBAAuB,CAAC","ignoreList":[]}
@@ -0,0 +1,347 @@
1
+ "use strict";
2
+
3
+ import React, { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react';
4
+ import { ActivityIndicator, Platform, Pressable, StyleSheet, TextInput, View } from 'react-native';
5
+ import { Plus, Mic, ArrowUp, Square, AlertCircle } from 'lucide-react-native';
6
+ import { KeyboardStickyView } from 'react-native-keyboard-controller';
7
+ import { GlassView } from 'expo-glass-effect';
8
+ import { useAIElementsTheme } from '../theme';
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // Types
12
+ // ---------------------------------------------------------------------------
13
+
14
+ /**
15
+ * Lifecycle status of the chat the PromptInput is attached to. Drives the
16
+ * shape of the right-side action button.
17
+ *
18
+ * - `'ready'` — idle. Right action shows mic (empty) or send (has text).
19
+ * - `'submitted'` — request just sent, awaiting first token. Right action
20
+ * shows a spinner.
21
+ * - `'streaming'` — assistant is generating. Right action shows a Stop
22
+ * button (calls `onStop` when pressed).
23
+ * - `'error'` — request failed. Right action shows an error icon; tap
24
+ * re-submits.
25
+ *
26
+ * Inspired by Vercel ai-elements `PromptInputSubmit.status`.
27
+ */
28
+
29
+ /** Imperative handle exposed via ref. */
30
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
31
+ // ---------------------------------------------------------------------------
32
+ // Constants
33
+ // ---------------------------------------------------------------------------
34
+
35
+ const DEFAULT_MIN_HEIGHT = 36;
36
+ const DEFAULT_MAX_HEIGHT = 100;
37
+ const CIRCLE_BUTTON_SIZE = 36;
38
+ const ICON_SIZE = 18;
39
+ const isIOS = Platform.OS === 'ios';
40
+
41
+ // ---------------------------------------------------------------------------
42
+ // CircleButton — lucide icon inside a native iOS glass circle.
43
+ // Uses `expo-glass-effect`'s GlassView, which renders a real
44
+ // UIVisualEffectView on iOS (liquid glass on iOS 26+) and degrades to a
45
+ // plain View on Android/web.
46
+ // ---------------------------------------------------------------------------
47
+
48
+ function CircleButton({
49
+ icon,
50
+ onPress,
51
+ isDisabled = false,
52
+ tintColor,
53
+ dark,
54
+ fallbackBackground,
55
+ accessibilityLabel
56
+ }) {
57
+ return /*#__PURE__*/_jsx(GlassView, {
58
+ glassEffectStyle: isIOS ? 'regular' : 'none',
59
+ tintColor: tintColor,
60
+ isInteractive: true,
61
+ colorScheme: dark ? 'dark' : 'light',
62
+ style: [styles.circleButton,
63
+ // On non-iOS GlassView is just a plain View, so paint the bg
64
+ // ourselves to keep the visible circle.
65
+ !isIOS && {
66
+ backgroundColor: fallbackBackground
67
+ }],
68
+ children: /*#__PURE__*/_jsx(Pressable, {
69
+ onPress: onPress,
70
+ disabled: isDisabled,
71
+ accessibilityLabel: accessibilityLabel,
72
+ accessibilityRole: "button",
73
+ accessibilityState: {
74
+ disabled: isDisabled
75
+ },
76
+ style: ({
77
+ pressed
78
+ }) => [styles.circleButtonInner, {
79
+ opacity: pressed ? 0.6 : isDisabled ? 0.5 : 1
80
+ }],
81
+ children: icon
82
+ })
83
+ });
84
+ }
85
+ CircleButton.displayName = 'PromptInput.CircleButton';
86
+
87
+ // ---------------------------------------------------------------------------
88
+ // Component
89
+ // ---------------------------------------------------------------------------
90
+
91
+ /**
92
+ * The sticky bottom input bar for a chat. Owns its own expanding-textarea
93
+ * height state so keystrokes don't re-render the parent screen. Moves with
94
+ * the keyboard via `KeyboardStickyView` from `react-native-keyboard-controller`.
95
+ *
96
+ * The right-side action is computed from `status`:
97
+ * - `'submitted'` → spinner
98
+ * - `'streaming'` → Stop button (calls `onStop`)
99
+ * - `'error'` → error icon (tap re-submits)
100
+ * - otherwise → Mic (empty input) or Send (has input)
101
+ *
102
+ * @example
103
+ * ```tsx
104
+ * <PromptInput
105
+ * value={input}
106
+ * onChangeText={setInput}
107
+ * onSubmit={sendMessage}
108
+ * onStop={stop}
109
+ * status={isStreaming ? 'streaming' : 'ready'}
110
+ * bottomInset={insets.bottom}
111
+ * suggestions={messages.length === 0 ? <Suggestions /> : null}
112
+ * />
113
+ * ```
114
+ */
115
+ const PromptInputImpl = /*#__PURE__*/forwardRef(function PromptInput({
116
+ value,
117
+ onChangeText,
118
+ onSubmit,
119
+ onStop,
120
+ status = 'ready',
121
+ disabled = false,
122
+ placeholder = 'Ask me anything...',
123
+ minHeight = DEFAULT_MIN_HEIGHT,
124
+ maxHeight = DEFAULT_MAX_HEIGHT,
125
+ bottomInset = 0,
126
+ suggestions,
127
+ leftAction,
128
+ onLeftActionPress,
129
+ rightAction,
130
+ isListening = false,
131
+ onMicPress,
132
+ keyboardAppearance,
133
+ style,
134
+ ...viewProps
135
+ }, ref) {
136
+ const theme = useAIElementsTheme();
137
+ const textInputRef = useRef(null);
138
+ const [inputHeight, setInputHeight] = useState(minHeight);
139
+
140
+ // Default the iOS keyboard to match the current theme. An explicit prop
141
+ // from the caller still wins.
142
+ const effectiveKeyboardAppearance = keyboardAppearance ?? (theme.dark ? 'dark' : 'light');
143
+ const hasText = value.trim().length > 0;
144
+ const canSubmit = hasText && !disabled && status === 'ready';
145
+ useImperativeHandle(ref, () => ({
146
+ focus: () => textInputRef.current?.focus(),
147
+ blur: () => textInputRef.current?.blur(),
148
+ clear: () => {
149
+ onChangeText('');
150
+ setInputHeight(minHeight);
151
+ },
152
+ isFocused: () => textInputRef.current?.isFocused() ?? false
153
+ }), [onChangeText, minHeight]);
154
+ const handleContentSizeChange = useCallback(e => {
155
+ const next = Math.min(Math.max(e.nativeEvent.contentSize.height, minHeight), maxHeight);
156
+ setInputHeight(next);
157
+ }, [minHeight, maxHeight]);
158
+ const handleSubmit = useCallback(() => {
159
+ if (!canSubmit) return;
160
+ onSubmit();
161
+ setInputHeight(minHeight);
162
+ }, [canSubmit, onSubmit, minHeight]);
163
+
164
+ // --- Defaults -----------------------------------------------------------
165
+ // CircleButton wraps a lucide icon inside a real native iOS glass effect
166
+ // (UIVisualEffectView / liquid glass on iOS 26+). On Android/web it
167
+ // degrades to a flat themed circle so behavior is preserved.
168
+
169
+ const defaultLeftAction = /*#__PURE__*/_jsx(CircleButton, {
170
+ icon: /*#__PURE__*/_jsx(Plus, {
171
+ size: ICON_SIZE,
172
+ color: theme.colors.foreground
173
+ }),
174
+ onPress: onLeftActionPress,
175
+ dark: theme.dark,
176
+ fallbackBackground: theme.colors.secondary,
177
+ accessibilityLabel: "More options"
178
+ });
179
+
180
+ // The right-side action is a function of `status` first, then text content.
181
+ const defaultRightAction = (() => {
182
+ if (status === 'streaming') {
183
+ return /*#__PURE__*/_jsx(CircleButton, {
184
+ icon: /*#__PURE__*/_jsx(Square, {
185
+ size: 14,
186
+ color: theme.colors.background,
187
+ fill: theme.colors.background
188
+ }),
189
+ onPress: onStop,
190
+ tintColor: theme.colors.foreground,
191
+ dark: theme.dark,
192
+ fallbackBackground: theme.colors.foreground,
193
+ accessibilityLabel: "Stop generating"
194
+ });
195
+ }
196
+ if (status === 'submitted') {
197
+ return /*#__PURE__*/_jsx(CircleButton, {
198
+ icon: /*#__PURE__*/_jsx(ActivityIndicator, {
199
+ size: "small",
200
+ color: theme.colors.foreground
201
+ }),
202
+ isDisabled: true,
203
+ dark: theme.dark,
204
+ fallbackBackground: theme.colors.secondary,
205
+ accessibilityLabel: "Sending"
206
+ });
207
+ }
208
+ if (status === 'error') {
209
+ return /*#__PURE__*/_jsx(CircleButton, {
210
+ icon: /*#__PURE__*/_jsx(AlertCircle, {
211
+ size: ICON_SIZE,
212
+ color: theme.colors.destructive
213
+ }),
214
+ onPress: hasText && !disabled ? handleSubmit : undefined,
215
+ dark: theme.dark,
216
+ fallbackBackground: theme.colors.secondary,
217
+ accessibilityLabel: "Send failed \u2014 tap to retry"
218
+ });
219
+ }
220
+
221
+ // status === 'ready' — original mic/send behavior.
222
+ if (hasText) {
223
+ return /*#__PURE__*/_jsx(CircleButton, {
224
+ icon: /*#__PURE__*/_jsx(ArrowUp, {
225
+ size: ICON_SIZE,
226
+ color: canSubmit ? theme.colors.background : theme.colors.mutedForeground
227
+ }),
228
+ onPress: canSubmit ? handleSubmit : undefined,
229
+ isDisabled: !canSubmit
230
+ // Tint the glass with the foreground color so the active send
231
+ // button reads as prominent against the muted plus/mic siblings.
232
+ ,
233
+ tintColor: canSubmit ? theme.colors.foreground : undefined,
234
+ dark: theme.dark,
235
+ fallbackBackground: canSubmit ? theme.colors.foreground : theme.colors.secondary,
236
+ accessibilityLabel: "Send message"
237
+ });
238
+ }
239
+
240
+ // Empty input + not streaming → Mic (voice input).
241
+ // While listening, tint the glass with `destructive` and flip the
242
+ // icon color so the recording state is unmissable.
243
+ return /*#__PURE__*/_jsx(CircleButton, {
244
+ icon: /*#__PURE__*/_jsx(Mic, {
245
+ size: ICON_SIZE,
246
+ color: isListening ? theme.colors.destructiveForeground : theme.colors.foreground
247
+ }),
248
+ onPress: onMicPress,
249
+ tintColor: isListening ? theme.colors.destructive : undefined,
250
+ dark: theme.dark,
251
+ fallbackBackground: isListening ? theme.colors.destructive : theme.colors.secondary,
252
+ accessibilityLabel: isListening ? 'Stop voice input' : 'Start voice input'
253
+ });
254
+ })();
255
+ return /*#__PURE__*/_jsxs(KeyboardStickyView, {
256
+ offset: {
257
+ opened: bottomInset,
258
+ closed: 0
259
+ },
260
+ children: [suggestions, /*#__PURE__*/_jsxs(View, {
261
+ ...viewProps,
262
+ style: [styles.row, {
263
+ paddingHorizontal: theme.spacing.md,
264
+ paddingBottom: bottomInset + theme.spacing.sm
265
+ }, style],
266
+ children: [leftAction ?? defaultLeftAction, /*#__PURE__*/_jsx(GlassView, {
267
+ glassEffectStyle: isIOS ? 'regular' : 'none',
268
+ isInteractive: true,
269
+ colorScheme: theme.dark ? 'dark' : 'light',
270
+ style: [styles.inputPill,
271
+ // On iOS, the glass provides its own subtle edge — no border.
272
+ // On Android/web fall back to the original tinted pill.
273
+ isIOS ? null : {
274
+ backgroundColor: theme.colors.secondary,
275
+ borderWidth: 1,
276
+ borderColor: theme.dark ? 'transparent' : theme.colors.border
277
+ }],
278
+ children: /*#__PURE__*/_jsx(TextInput, {
279
+ ref: textInputRef,
280
+ value: value,
281
+ onChangeText: onChangeText,
282
+ placeholder: placeholder,
283
+ placeholderTextColor: theme.colors.mutedForeground,
284
+ multiline: true,
285
+ editable: !disabled,
286
+ keyboardAppearance: effectiveKeyboardAppearance,
287
+ onContentSizeChange: handleContentSizeChange,
288
+ onSubmitEditing: handleSubmit,
289
+ blurOnSubmit: false,
290
+ accessibilityLabel: "Message input",
291
+ style: [styles.textInput, {
292
+ height: inputHeight,
293
+ maxHeight,
294
+ color: theme.colors.foreground,
295
+ fontSize: theme.typography.fontSize.md,
296
+ fontFamily: theme.typography.fontFamily
297
+ }]
298
+ })
299
+ }), rightAction ?? defaultRightAction]
300
+ })]
301
+ });
302
+ });
303
+ PromptInputImpl.displayName = 'PromptInput';
304
+ export const PromptInput = PromptInputImpl;
305
+
306
+ // ---------------------------------------------------------------------------
307
+ // Styles — static so they're not reallocated per render
308
+ // ---------------------------------------------------------------------------
309
+
310
+ const styles = StyleSheet.create({
311
+ row: {
312
+ flexDirection: 'row',
313
+ alignItems: 'flex-end',
314
+ gap: 8
315
+ },
316
+ circleButton: {
317
+ width: CIRCLE_BUTTON_SIZE,
318
+ height: CIRCLE_BUTTON_SIZE,
319
+ borderRadius: CIRCLE_BUTTON_SIZE / 2,
320
+ // Clip the GlassView blur to the rounded shape on iOS, and the
321
+ // background fill on other platforms.
322
+ overflow: 'hidden',
323
+ alignItems: 'center',
324
+ justifyContent: 'center'
325
+ },
326
+ circleButtonInner: {
327
+ width: '100%',
328
+ height: '100%',
329
+ alignItems: 'center',
330
+ justifyContent: 'center'
331
+ },
332
+ inputPill: {
333
+ flex: 1,
334
+ borderRadius: 20,
335
+ paddingHorizontal: 14,
336
+ // Clip the GlassView blur (and the non-iOS background) to the rounded
337
+ // pill shape.
338
+ overflow: 'hidden'
339
+ },
340
+ textInput: {
341
+ textAlignVertical: 'top',
342
+ paddingTop: Platform.OS === 'ios' ? 8 : 6,
343
+ paddingBottom: Platform.OS === 'ios' ? 8 : 6,
344
+ paddingHorizontal: 0
345
+ }
346
+ });
347
+ //# sourceMappingURL=PromptInput.js.map