@repzo/widget-react-native 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (448) hide show
  1. package/README.md +482 -0
  2. package/lib/commonjs/agent-ui-blocks.js +159 -0
  3. package/lib/commonjs/agent-ui-blocks.js.map +1 -0
  4. package/lib/commonjs/api/client.js +267 -0
  5. package/lib/commonjs/api/client.js.map +1 -0
  6. package/lib/commonjs/api/realtime.js +193 -0
  7. package/lib/commonjs/api/realtime.js.map +1 -0
  8. package/lib/commonjs/api/sse-parser.js +58 -0
  9. package/lib/commonjs/api/sse-parser.js.map +1 -0
  10. package/lib/commonjs/controller.js +23 -0
  11. package/lib/commonjs/controller.js.map +1 -0
  12. package/lib/commonjs/device-id.js +75 -0
  13. package/lib/commonjs/device-id.js.map +1 -0
  14. package/lib/commonjs/events.js +49 -0
  15. package/lib/commonjs/events.js.map +1 -0
  16. package/lib/commonjs/i18n.js +106 -0
  17. package/lib/commonjs/i18n.js.map +1 -0
  18. package/lib/commonjs/index.js +98 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/locales.js +85 -0
  21. package/lib/commonjs/locales.js.map +1 -0
  22. package/lib/commonjs/package.json +1 -0
  23. package/lib/commonjs/push/push-notifications.js +208 -0
  24. package/lib/commonjs/push/push-notifications.js.map +1 -0
  25. package/lib/commonjs/state/use-widget-state.js +23 -0
  26. package/lib/commonjs/state/use-widget-state.js.map +1 -0
  27. package/lib/commonjs/state/widget-store.js +1682 -0
  28. package/lib/commonjs/state/widget-store.js.map +1 -0
  29. package/lib/commonjs/storage.js +147 -0
  30. package/lib/commonjs/storage.js.map +1 -0
  31. package/lib/commonjs/types.js +44 -0
  32. package/lib/commonjs/types.js.map +1 -0
  33. package/lib/commonjs/ui/WidgetProvider.js +404 -0
  34. package/lib/commonjs/ui/WidgetProvider.js.map +1 -0
  35. package/lib/commonjs/ui/components/AgentUiBlocks.js +864 -0
  36. package/lib/commonjs/ui/components/AgentUiBlocks.js.map +1 -0
  37. package/lib/commonjs/ui/components/Avatar.js +76 -0
  38. package/lib/commonjs/ui/components/Avatar.js.map +1 -0
  39. package/lib/commonjs/ui/components/ConversationRow.js +155 -0
  40. package/lib/commonjs/ui/components/ConversationRow.js.map +1 -0
  41. package/lib/commonjs/ui/components/ErrorBoundary.js +44 -0
  42. package/lib/commonjs/ui/components/ErrorBoundary.js.map +1 -0
  43. package/lib/commonjs/ui/components/Gradient.js +168 -0
  44. package/lib/commonjs/ui/components/Gradient.js.map +1 -0
  45. package/lib/commonjs/ui/components/Launcher.js +125 -0
  46. package/lib/commonjs/ui/components/Launcher.js.map +1 -0
  47. package/lib/commonjs/ui/components/Markdown.js +257 -0
  48. package/lib/commonjs/ui/components/Markdown.js.map +1 -0
  49. package/lib/commonjs/ui/components/OutboundMessageCard.js +157 -0
  50. package/lib/commonjs/ui/components/OutboundMessageCard.js.map +1 -0
  51. package/lib/commonjs/ui/components/WidgetPanel.js +131 -0
  52. package/lib/commonjs/ui/components/WidgetPanel.js.map +1 -0
  53. package/lib/commonjs/ui/components/icons.js +383 -0
  54. package/lib/commonjs/ui/components/icons.js.map +1 -0
  55. package/lib/commonjs/ui/hooks/use-keyboard-overlap.js +113 -0
  56. package/lib/commonjs/ui/hooks/use-keyboard-overlap.js.map +1 -0
  57. package/lib/commonjs/ui/hooks/use-reduce-motion.js +38 -0
  58. package/lib/commonjs/ui/hooks/use-reduce-motion.js.map +1 -0
  59. package/lib/commonjs/ui/hooks/use-widget-insets.js +41 -0
  60. package/lib/commonjs/ui/hooks/use-widget-insets.js.map +1 -0
  61. package/lib/commonjs/ui/screens/chat/ChatView.js +590 -0
  62. package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -0
  63. package/lib/commonjs/ui/screens/chat/ChatView.styles.js +362 -0
  64. package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -0
  65. package/lib/commonjs/ui/screens/chat/ChatView.types.js +6 -0
  66. package/lib/commonjs/ui/screens/chat/ChatView.types.js.map +1 -0
  67. package/lib/commonjs/ui/screens/conversations/ConversationsList.js +150 -0
  68. package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -0
  69. package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js +118 -0
  70. package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
  71. package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js +6 -0
  72. package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js.map +1 -0
  73. package/lib/commonjs/ui/screens/home/HomeView.js +336 -0
  74. package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -0
  75. package/lib/commonjs/ui/screens/home/HomeView.styles.js +245 -0
  76. package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -0
  77. package/lib/commonjs/ui/screens/home/HomeView.types.js +6 -0
  78. package/lib/commonjs/ui/screens/home/HomeView.types.js.map +1 -0
  79. package/lib/commonjs/ui/screens/home/greeting.js +49 -0
  80. package/lib/commonjs/ui/screens/home/greeting.js.map +1 -0
  81. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js +229 -0
  82. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js.map +1 -0
  83. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js +125 -0
  84. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
  85. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js +6 -0
  86. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
  87. package/lib/commonjs/ui/styles/global.js +55 -0
  88. package/lib/commonjs/ui/styles/global.js.map +1 -0
  89. package/lib/commonjs/ui/styles/theme.js +148 -0
  90. package/lib/commonjs/ui/styles/theme.js.map +1 -0
  91. package/lib/commonjs/ui/utils/conversations.js +125 -0
  92. package/lib/commonjs/ui/utils/conversations.js.map +1 -0
  93. package/lib/commonjs/ui/utils/html.js +44 -0
  94. package/lib/commonjs/ui/utils/html.js.map +1 -0
  95. package/lib/commonjs/ui/utils/native-gradient.js +65 -0
  96. package/lib/commonjs/ui/utils/native-gradient.js.map +1 -0
  97. package/lib/commonjs/ui/utils/rtl.js +56 -0
  98. package/lib/commonjs/ui/utils/rtl.js.map +1 -0
  99. package/lib/commonjs/ui/utils/safe-url.js +67 -0
  100. package/lib/commonjs/ui/utils/safe-url.js.map +1 -0
  101. package/lib/module/agent-ui-blocks.js +152 -0
  102. package/lib/module/agent-ui-blocks.js.map +1 -0
  103. package/lib/module/api/client.js +261 -0
  104. package/lib/module/api/client.js.map +1 -0
  105. package/lib/module/api/realtime.js +189 -0
  106. package/lib/module/api/realtime.js.map +1 -0
  107. package/lib/module/api/sse-parser.js +53 -0
  108. package/lib/module/api/sse-parser.js.map +1 -0
  109. package/lib/module/controller.js +19 -0
  110. package/lib/module/controller.js.map +1 -0
  111. package/lib/module/device-id.js +69 -0
  112. package/lib/module/device-id.js.map +1 -0
  113. package/lib/module/events.js +44 -0
  114. package/lib/module/events.js.map +1 -0
  115. package/lib/module/i18n.js +99 -0
  116. package/lib/module/i18n.js.map +1 -0
  117. package/lib/module/index.js +55 -0
  118. package/lib/module/index.js.map +1 -0
  119. package/lib/module/locales.js +80 -0
  120. package/lib/module/locales.js.map +1 -0
  121. package/lib/module/package.json +1 -0
  122. package/lib/module/push/push-notifications.js +204 -0
  123. package/lib/module/push/push-notifications.js.map +1 -0
  124. package/lib/module/state/use-widget-state.js +18 -0
  125. package/lib/module/state/use-widget-state.js.map +1 -0
  126. package/lib/module/state/widget-store.js +1677 -0
  127. package/lib/module/state/widget-store.js.map +1 -0
  128. package/lib/module/storage.js +141 -0
  129. package/lib/module/storage.js.map +1 -0
  130. package/lib/module/types.js +40 -0
  131. package/lib/module/types.js.map +1 -0
  132. package/lib/module/ui/WidgetProvider.js +400 -0
  133. package/lib/module/ui/WidgetProvider.js.map +1 -0
  134. package/lib/module/ui/components/AgentUiBlocks.js +857 -0
  135. package/lib/module/ui/components/AgentUiBlocks.js.map +1 -0
  136. package/lib/module/ui/components/Avatar.js +71 -0
  137. package/lib/module/ui/components/Avatar.js.map +1 -0
  138. package/lib/module/ui/components/ConversationRow.js +150 -0
  139. package/lib/module/ui/components/ConversationRow.js.map +1 -0
  140. package/lib/module/ui/components/ErrorBoundary.js +39 -0
  141. package/lib/module/ui/components/ErrorBoundary.js.map +1 -0
  142. package/lib/module/ui/components/Gradient.js +165 -0
  143. package/lib/module/ui/components/Gradient.js.map +1 -0
  144. package/lib/module/ui/components/Launcher.js +121 -0
  145. package/lib/module/ui/components/Launcher.js.map +1 -0
  146. package/lib/module/ui/components/Markdown.js +253 -0
  147. package/lib/module/ui/components/Markdown.js.map +1 -0
  148. package/lib/module/ui/components/OutboundMessageCard.js +153 -0
  149. package/lib/module/ui/components/OutboundMessageCard.js.map +1 -0
  150. package/lib/module/ui/components/WidgetPanel.js +127 -0
  151. package/lib/module/ui/components/WidgetPanel.js.map +1 -0
  152. package/lib/module/ui/components/icons.js +370 -0
  153. package/lib/module/ui/components/icons.js.map +1 -0
  154. package/lib/module/ui/hooks/use-keyboard-overlap.js +109 -0
  155. package/lib/module/ui/hooks/use-keyboard-overlap.js.map +1 -0
  156. package/lib/module/ui/hooks/use-reduce-motion.js +34 -0
  157. package/lib/module/ui/hooks/use-reduce-motion.js.map +1 -0
  158. package/lib/module/ui/hooks/use-widget-insets.js +37 -0
  159. package/lib/module/ui/hooks/use-widget-insets.js.map +1 -0
  160. package/lib/module/ui/screens/chat/ChatView.js +586 -0
  161. package/lib/module/ui/screens/chat/ChatView.js.map +1 -0
  162. package/lib/module/ui/screens/chat/ChatView.styles.js +358 -0
  163. package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -0
  164. package/lib/module/ui/screens/chat/ChatView.types.js +4 -0
  165. package/lib/module/ui/screens/chat/ChatView.types.js.map +1 -0
  166. package/lib/module/ui/screens/conversations/ConversationsList.js +146 -0
  167. package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -0
  168. package/lib/module/ui/screens/conversations/ConversationsList.styles.js +114 -0
  169. package/lib/module/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
  170. package/lib/module/ui/screens/conversations/ConversationsList.types.js +4 -0
  171. package/lib/module/ui/screens/conversations/ConversationsList.types.js.map +1 -0
  172. package/lib/module/ui/screens/home/HomeView.js +332 -0
  173. package/lib/module/ui/screens/home/HomeView.js.map +1 -0
  174. package/lib/module/ui/screens/home/HomeView.styles.js +242 -0
  175. package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -0
  176. package/lib/module/ui/screens/home/HomeView.types.js +4 -0
  177. package/lib/module/ui/screens/home/HomeView.types.js.map +1 -0
  178. package/lib/module/ui/screens/home/greeting.js +44 -0
  179. package/lib/module/ui/screens/home/greeting.js.map +1 -0
  180. package/lib/module/ui/screens/pre-chat/PreChatForm.js +225 -0
  181. package/lib/module/ui/screens/pre-chat/PreChatForm.js.map +1 -0
  182. package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js +121 -0
  183. package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
  184. package/lib/module/ui/screens/pre-chat/PreChatForm.types.js +4 -0
  185. package/lib/module/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
  186. package/lib/module/ui/styles/global.js +51 -0
  187. package/lib/module/ui/styles/global.js.map +1 -0
  188. package/lib/module/ui/styles/theme.js +137 -0
  189. package/lib/module/ui/styles/theme.js.map +1 -0
  190. package/lib/module/ui/utils/conversations.js +115 -0
  191. package/lib/module/ui/utils/conversations.js.map +1 -0
  192. package/lib/module/ui/utils/html.js +39 -0
  193. package/lib/module/ui/utils/html.js.map +1 -0
  194. package/lib/module/ui/utils/native-gradient.js +60 -0
  195. package/lib/module/ui/utils/native-gradient.js.map +1 -0
  196. package/lib/module/ui/utils/rtl.js +49 -0
  197. package/lib/module/ui/utils/rtl.js.map +1 -0
  198. package/lib/module/ui/utils/safe-url.js +59 -0
  199. package/lib/module/ui/utils/safe-url.js.map +1 -0
  200. package/lib/typescript/commonjs/agent-ui-blocks.d.ts +20 -0
  201. package/lib/typescript/commonjs/agent-ui-blocks.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/api/client.d.ts +115 -0
  203. package/lib/typescript/commonjs/api/client.d.ts.map +1 -0
  204. package/lib/typescript/commonjs/api/realtime.d.ts +39 -0
  205. package/lib/typescript/commonjs/api/realtime.d.ts.map +1 -0
  206. package/lib/typescript/commonjs/api/sse-parser.d.ts +13 -0
  207. package/lib/typescript/commonjs/api/sse-parser.d.ts.map +1 -0
  208. package/lib/typescript/commonjs/controller.d.ts +15 -0
  209. package/lib/typescript/commonjs/controller.d.ts.map +1 -0
  210. package/lib/typescript/commonjs/device-id.d.ts +15 -0
  211. package/lib/typescript/commonjs/device-id.d.ts.map +1 -0
  212. package/lib/typescript/commonjs/events.d.ts +41 -0
  213. package/lib/typescript/commonjs/events.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/i18n.d.ts +78 -0
  215. package/lib/typescript/commonjs/i18n.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/index.d.ts +103 -0
  217. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/locales.d.ts +18 -0
  219. package/lib/typescript/commonjs/locales.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/package.json +1 -0
  221. package/lib/typescript/commonjs/push/push-notifications.d.ts +71 -0
  222. package/lib/typescript/commonjs/push/push-notifications.d.ts.map +1 -0
  223. package/lib/typescript/commonjs/state/use-widget-state.d.ts +10 -0
  224. package/lib/typescript/commonjs/state/use-widget-state.d.ts.map +1 -0
  225. package/lib/typescript/commonjs/state/widget-store.d.ts +227 -0
  226. package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -0
  227. package/lib/typescript/commonjs/storage.d.ts +42 -0
  228. package/lib/typescript/commonjs/storage.d.ts.map +1 -0
  229. package/lib/typescript/commonjs/types.d.ts +391 -0
  230. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  231. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts +15 -0
  232. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -0
  233. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts +27 -0
  234. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts.map +1 -0
  235. package/lib/typescript/commonjs/ui/components/Avatar.d.ts +19 -0
  236. package/lib/typescript/commonjs/ui/components/Avatar.d.ts.map +1 -0
  237. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +26 -0
  238. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -0
  239. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts +27 -0
  240. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts.map +1 -0
  241. package/lib/typescript/commonjs/ui/components/Gradient.d.ts +33 -0
  242. package/lib/typescript/commonjs/ui/components/Gradient.d.ts.map +1 -0
  243. package/lib/typescript/commonjs/ui/components/Launcher.d.ts +18 -0
  244. package/lib/typescript/commonjs/ui/components/Launcher.d.ts.map +1 -0
  245. package/lib/typescript/commonjs/ui/components/Markdown.d.ts +19 -0
  246. package/lib/typescript/commonjs/ui/components/Markdown.d.ts.map +1 -0
  247. package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts +20 -0
  248. package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts.map +1 -0
  249. package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts +26 -0
  250. package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts.map +1 -0
  251. package/lib/typescript/commonjs/ui/components/icons.d.ts +38 -0
  252. package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -0
  253. package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts +33 -0
  254. package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
  255. package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts +11 -0
  256. package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts.map +1 -0
  257. package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts +16 -0
  258. package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts.map +1 -0
  259. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +11 -0
  260. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -0
  261. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +349 -0
  262. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
  263. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +48 -0
  264. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -0
  265. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts +10 -0
  266. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
  267. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
  268. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
  269. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
  270. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
  271. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +17 -0
  272. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -0
  273. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +227 -0
  274. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -0
  275. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +40 -0
  276. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -0
  277. package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts +19 -0
  278. package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts.map +1 -0
  279. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
  280. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
  281. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
  282. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
  283. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
  284. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
  285. package/lib/typescript/commonjs/ui/styles/global.d.ts +46 -0
  286. package/lib/typescript/commonjs/ui/styles/global.d.ts.map +1 -0
  287. package/lib/typescript/commonjs/ui/styles/theme.d.ts +103 -0
  288. package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -0
  289. package/lib/typescript/commonjs/ui/utils/conversations.d.ts +41 -0
  290. package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -0
  291. package/lib/typescript/commonjs/ui/utils/html.d.ts +10 -0
  292. package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -0
  293. package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts +61 -0
  294. package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts.map +1 -0
  295. package/lib/typescript/commonjs/ui/utils/rtl.d.ts +33 -0
  296. package/lib/typescript/commonjs/ui/utils/rtl.d.ts.map +1 -0
  297. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts +21 -0
  298. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts.map +1 -0
  299. package/lib/typescript/module/agent-ui-blocks.d.ts +20 -0
  300. package/lib/typescript/module/agent-ui-blocks.d.ts.map +1 -0
  301. package/lib/typescript/module/api/client.d.ts +115 -0
  302. package/lib/typescript/module/api/client.d.ts.map +1 -0
  303. package/lib/typescript/module/api/realtime.d.ts +39 -0
  304. package/lib/typescript/module/api/realtime.d.ts.map +1 -0
  305. package/lib/typescript/module/api/sse-parser.d.ts +13 -0
  306. package/lib/typescript/module/api/sse-parser.d.ts.map +1 -0
  307. package/lib/typescript/module/controller.d.ts +15 -0
  308. package/lib/typescript/module/controller.d.ts.map +1 -0
  309. package/lib/typescript/module/device-id.d.ts +15 -0
  310. package/lib/typescript/module/device-id.d.ts.map +1 -0
  311. package/lib/typescript/module/events.d.ts +41 -0
  312. package/lib/typescript/module/events.d.ts.map +1 -0
  313. package/lib/typescript/module/i18n.d.ts +78 -0
  314. package/lib/typescript/module/i18n.d.ts.map +1 -0
  315. package/lib/typescript/module/index.d.ts +103 -0
  316. package/lib/typescript/module/index.d.ts.map +1 -0
  317. package/lib/typescript/module/locales.d.ts +18 -0
  318. package/lib/typescript/module/locales.d.ts.map +1 -0
  319. package/lib/typescript/module/package.json +1 -0
  320. package/lib/typescript/module/push/push-notifications.d.ts +71 -0
  321. package/lib/typescript/module/push/push-notifications.d.ts.map +1 -0
  322. package/lib/typescript/module/state/use-widget-state.d.ts +10 -0
  323. package/lib/typescript/module/state/use-widget-state.d.ts.map +1 -0
  324. package/lib/typescript/module/state/widget-store.d.ts +227 -0
  325. package/lib/typescript/module/state/widget-store.d.ts.map +1 -0
  326. package/lib/typescript/module/storage.d.ts +42 -0
  327. package/lib/typescript/module/storage.d.ts.map +1 -0
  328. package/lib/typescript/module/types.d.ts +391 -0
  329. package/lib/typescript/module/types.d.ts.map +1 -0
  330. package/lib/typescript/module/ui/WidgetProvider.d.ts +15 -0
  331. package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -0
  332. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts +27 -0
  333. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts.map +1 -0
  334. package/lib/typescript/module/ui/components/Avatar.d.ts +19 -0
  335. package/lib/typescript/module/ui/components/Avatar.d.ts.map +1 -0
  336. package/lib/typescript/module/ui/components/ConversationRow.d.ts +26 -0
  337. package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -0
  338. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts +27 -0
  339. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts.map +1 -0
  340. package/lib/typescript/module/ui/components/Gradient.d.ts +33 -0
  341. package/lib/typescript/module/ui/components/Gradient.d.ts.map +1 -0
  342. package/lib/typescript/module/ui/components/Launcher.d.ts +18 -0
  343. package/lib/typescript/module/ui/components/Launcher.d.ts.map +1 -0
  344. package/lib/typescript/module/ui/components/Markdown.d.ts +19 -0
  345. package/lib/typescript/module/ui/components/Markdown.d.ts.map +1 -0
  346. package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts +20 -0
  347. package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts.map +1 -0
  348. package/lib/typescript/module/ui/components/WidgetPanel.d.ts +26 -0
  349. package/lib/typescript/module/ui/components/WidgetPanel.d.ts.map +1 -0
  350. package/lib/typescript/module/ui/components/icons.d.ts +38 -0
  351. package/lib/typescript/module/ui/components/icons.d.ts.map +1 -0
  352. package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts +33 -0
  353. package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
  354. package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts +11 -0
  355. package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts.map +1 -0
  356. package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts +16 -0
  357. package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts.map +1 -0
  358. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +11 -0
  359. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -0
  360. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +349 -0
  361. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
  362. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +48 -0
  363. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -0
  364. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts +10 -0
  365. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
  366. package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
  367. package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
  368. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
  369. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
  370. package/lib/typescript/module/ui/screens/home/HomeView.d.ts +17 -0
  371. package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -0
  372. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +227 -0
  373. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -0
  374. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +40 -0
  375. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -0
  376. package/lib/typescript/module/ui/screens/home/greeting.d.ts +19 -0
  377. package/lib/typescript/module/ui/screens/home/greeting.d.ts.map +1 -0
  378. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
  379. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
  380. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
  381. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
  382. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
  383. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
  384. package/lib/typescript/module/ui/styles/global.d.ts +46 -0
  385. package/lib/typescript/module/ui/styles/global.d.ts.map +1 -0
  386. package/lib/typescript/module/ui/styles/theme.d.ts +103 -0
  387. package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -0
  388. package/lib/typescript/module/ui/utils/conversations.d.ts +41 -0
  389. package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -0
  390. package/lib/typescript/module/ui/utils/html.d.ts +10 -0
  391. package/lib/typescript/module/ui/utils/html.d.ts.map +1 -0
  392. package/lib/typescript/module/ui/utils/native-gradient.d.ts +61 -0
  393. package/lib/typescript/module/ui/utils/native-gradient.d.ts.map +1 -0
  394. package/lib/typescript/module/ui/utils/rtl.d.ts +33 -0
  395. package/lib/typescript/module/ui/utils/rtl.d.ts.map +1 -0
  396. package/lib/typescript/module/ui/utils/safe-url.d.ts +21 -0
  397. package/lib/typescript/module/ui/utils/safe-url.d.ts.map +1 -0
  398. package/metro.js +40 -0
  399. package/package.json +116 -0
  400. package/src/agent-ui-blocks.ts +302 -0
  401. package/src/api/client.ts +332 -0
  402. package/src/api/realtime.ts +225 -0
  403. package/src/api/sse-parser.ts +51 -0
  404. package/src/controller.ts +20 -0
  405. package/src/device-id.ts +71 -0
  406. package/src/events.ts +74 -0
  407. package/src/i18n.ts +114 -0
  408. package/src/index.tsx +199 -0
  409. package/src/locales.ts +80 -0
  410. package/src/push/push-notifications.ts +254 -0
  411. package/src/state/use-widget-state.ts +20 -0
  412. package/src/state/widget-store.ts +1815 -0
  413. package/src/storage.ts +153 -0
  414. package/src/types.ts +445 -0
  415. package/src/ui/WidgetProvider.tsx +434 -0
  416. package/src/ui/components/AgentUiBlocks.tsx +912 -0
  417. package/src/ui/components/Avatar.tsx +86 -0
  418. package/src/ui/components/ConversationRow.tsx +163 -0
  419. package/src/ui/components/ErrorBoundary.tsx +49 -0
  420. package/src/ui/components/Gradient.tsx +165 -0
  421. package/src/ui/components/Launcher.tsx +128 -0
  422. package/src/ui/components/Markdown.tsx +291 -0
  423. package/src/ui/components/OutboundMessageCard.tsx +154 -0
  424. package/src/ui/components/WidgetPanel.tsx +133 -0
  425. package/src/ui/components/icons.tsx +315 -0
  426. package/src/ui/hooks/use-keyboard-overlap.ts +134 -0
  427. package/src/ui/hooks/use-reduce-motion.ts +39 -0
  428. package/src/ui/hooks/use-widget-insets.ts +44 -0
  429. package/src/ui/screens/chat/ChatView.styles.ts +357 -0
  430. package/src/ui/screens/chat/ChatView.tsx +690 -0
  431. package/src/ui/screens/chat/ChatView.types.ts +46 -0
  432. package/src/ui/screens/conversations/ConversationsList.styles.ts +111 -0
  433. package/src/ui/screens/conversations/ConversationsList.tsx +144 -0
  434. package/src/ui/screens/conversations/ConversationsList.types.ts +33 -0
  435. package/src/ui/screens/home/HomeView.styles.ts +246 -0
  436. package/src/ui/screens/home/HomeView.tsx +336 -0
  437. package/src/ui/screens/home/HomeView.types.ts +42 -0
  438. package/src/ui/screens/home/greeting.ts +50 -0
  439. package/src/ui/screens/pre-chat/PreChatForm.styles.ts +120 -0
  440. package/src/ui/screens/pre-chat/PreChatForm.tsx +221 -0
  441. package/src/ui/screens/pre-chat/PreChatForm.types.ts +22 -0
  442. package/src/ui/styles/global.ts +50 -0
  443. package/src/ui/styles/theme.ts +155 -0
  444. package/src/ui/utils/conversations.ts +122 -0
  445. package/src/ui/utils/html.ts +58 -0
  446. package/src/ui/utils/native-gradient.ts +60 -0
  447. package/src/ui/utils/rtl.ts +43 -0
  448. package/src/ui/utils/safe-url.ts +63 -0
@@ -0,0 +1,291 @@
1
+ /**
2
+ * Minimal Markdown renderer for agent replies.
3
+ *
4
+ * The web widget uses react-markdown + remark-gfm; this SDK ships no runtime
5
+ * dependencies, so it supports the subset agents actually emit: paragraphs,
6
+ * bullet/numbered lists, bold, italic, inline code, fenced code and links
7
+ * (including bare URLs, linkified the same way the web widget does).
8
+ */
9
+
10
+ import { Fragment } from 'react';
11
+ import { StyleSheet, Text, View } from 'react-native';
12
+
13
+ import { fontSize, palette, radius, spacing } from '../styles/theme';
14
+ import { openExternalUrl } from '../utils/safe-url';
15
+
16
+ // File-like extensions we should NOT treat as clickable domains (e.g. "report.pdf").
17
+ const NON_LINK_EXTENSIONS = new Set([
18
+ 'pdf',
19
+ 'png',
20
+ 'jpg',
21
+ 'jpeg',
22
+ 'gif',
23
+ 'svg',
24
+ 'webp',
25
+ 'doc',
26
+ 'docx',
27
+ 'xls',
28
+ 'xlsx',
29
+ 'csv',
30
+ 'txt',
31
+ 'zip',
32
+ 'rar',
33
+ 'js',
34
+ 'ts',
35
+ 'tsx',
36
+ 'jsx',
37
+ 'json',
38
+ 'md',
39
+ 'html',
40
+ 'css',
41
+ 'exe',
42
+ 'dmg',
43
+ ]);
44
+
45
+ function linkifyPlainText(text: string): string {
46
+ const urlRe = /((?:https?:\/\/|www\.)[^\s<>()]+|(?:[a-z0-9-]+\.)+[a-z]{2,24}(?:\/[^\s<>()]*)?)/gi;
47
+ return text.replace(urlRe, (match) => {
48
+ const trailingMatch = match.match(/[.,!?;:)\]]+$/);
49
+ const tail = trailingMatch ? trailingMatch[0] : '';
50
+ const core = tail ? match.slice(0, -tail.length) : match;
51
+ const hasScheme = /^https?:\/\//i.test(core);
52
+ if (!hasScheme && !/\//.test(core)) {
53
+ const ext = core.split('.').pop()?.toLowerCase() ?? '';
54
+ if (NON_LINK_EXTENSIONS.has(ext)) return match;
55
+ }
56
+ const href = hasScheme ? core : `https://${core.replace(/^www\./i, '')}`;
57
+ return `[${core}](${href})${tail}`;
58
+ });
59
+ }
60
+
61
+ /** Turn bare URLs into markdown links while leaving code and existing links alone. */
62
+ export function linkifyMarkdown(text: string): string {
63
+ if (!text) return text;
64
+ const protectedPattern = /(```[\s\S]*?```|`[^`]*`|!?\[[^\]]*\]\([^)]*\))/g;
65
+ return text
66
+ .split(protectedPattern)
67
+ .map((segment, index) => (index % 2 === 1 ? segment : linkifyPlainText(segment)))
68
+ .join('');
69
+ }
70
+
71
+ const INLINE_PATTERN =
72
+ /(\*\*[^*]+\*\*|__[^_]+__|\*[^*\n]+\*|_[^_\n]+_|`[^`]+`|!?\[[^\]]*\]\([^)]*\))/g;
73
+
74
+ function openLink(href: string) {
75
+ void openExternalUrl(href);
76
+ }
77
+
78
+ /** Renders one line of markdown into nested <Text> runs. */
79
+ function InlineMarkdown({ content, color }: { content: string; color: string }) {
80
+ const parts = content.split(INLINE_PATTERN).filter((part) => part !== undefined && part !== '');
81
+
82
+ return (
83
+ <>
84
+ {parts.map((part, index) => {
85
+ const key = `${index}-${part.slice(0, 8)}`;
86
+
87
+ if (/^(\*\*|__)[\s\S]+(\*\*|__)$/.test(part)) {
88
+ return (
89
+ <Text key={key} style={styles.bold}>
90
+ {part.slice(2, -2)}
91
+ </Text>
92
+ );
93
+ }
94
+ if (/^[*_][^*_][\s\S]*[*_]$/.test(part) && part.length > 2) {
95
+ return (
96
+ <Text key={key} style={styles.italic}>
97
+ {part.slice(1, -1)}
98
+ </Text>
99
+ );
100
+ }
101
+ if (/^`[^`]+`$/.test(part)) {
102
+ return (
103
+ <Text key={key} style={styles.inlineCode}>
104
+ {part.slice(1, -1)}
105
+ </Text>
106
+ );
107
+ }
108
+
109
+ const link = /^!?\[([^\]]*)\]\(([^)]*)\)$/.exec(part);
110
+ if (link) {
111
+ const label = link[1] || link[2] || '';
112
+ const href = link[2] || '';
113
+ return (
114
+ <Text
115
+ key={key}
116
+ style={[styles.link, { color }]}
117
+ onPress={href ? () => openLink(href) : undefined}>
118
+ {label}
119
+ </Text>
120
+ );
121
+ }
122
+
123
+ return <Fragment key={key}>{part}</Fragment>;
124
+ })}
125
+ </>
126
+ );
127
+ }
128
+
129
+ interface MarkdownProps {
130
+ content: string;
131
+ color: string;
132
+ /** Link color — defaults to the text color with an underline. */
133
+ linkColor?: string;
134
+ }
135
+
136
+ export function Markdown({ content, color, linkColor }: MarkdownProps) {
137
+ const blocks = parseBlocks(linkifyMarkdown(content));
138
+ const effectiveLinkColor = linkColor ?? color;
139
+
140
+ return (
141
+ <View>
142
+ {blocks.map((block, index) => {
143
+ const key = `block-${index}`;
144
+
145
+ if (block.type === 'code') {
146
+ return (
147
+ <View key={key} style={styles.codeBlock}>
148
+ <Text style={styles.codeBlockText}>{block.lines.join('\n')}</Text>
149
+ </View>
150
+ );
151
+ }
152
+
153
+ if (block.type === 'list') {
154
+ return (
155
+ <View key={key} style={styles.list}>
156
+ {block.items.map((item, itemIndex) => (
157
+ <View key={`${key}-${itemIndex}`} style={styles.listItem}>
158
+ <Text style={[styles.listMarker, { color }]}>
159
+ {block.ordered ? `${itemIndex + 1}.` : '•'}
160
+ </Text>
161
+ <Text style={[styles.text, styles.listItemText, { color }]}>
162
+ <InlineMarkdown content={item} color={effectiveLinkColor} />
163
+ </Text>
164
+ </View>
165
+ ))}
166
+ </View>
167
+ );
168
+ }
169
+
170
+ return (
171
+ <Text key={key} style={[styles.text, index > 0 && styles.paragraphSpacing, { color }]}>
172
+ <InlineMarkdown content={block.lines.join('\n')} color={effectiveLinkColor} />
173
+ </Text>
174
+ );
175
+ })}
176
+ </View>
177
+ );
178
+ }
179
+
180
+ type Block =
181
+ | { type: 'paragraph'; lines: string[] }
182
+ | { type: 'code'; lines: string[] }
183
+ | { type: 'list'; ordered: boolean; items: string[] };
184
+
185
+ function parseBlocks(content: string): Block[] {
186
+ const lines = content.split('\n');
187
+ const blocks: Block[] = [];
188
+ let paragraph: string[] = [];
189
+
190
+ const flushParagraph = () => {
191
+ if (paragraph.length > 0) {
192
+ blocks.push({ type: 'paragraph', lines: paragraph });
193
+ paragraph = [];
194
+ }
195
+ };
196
+
197
+ for (let index = 0; index < lines.length; index += 1) {
198
+ const line = lines[index] as string;
199
+
200
+ if (line.trim().startsWith('```')) {
201
+ flushParagraph();
202
+ const code: string[] = [];
203
+ index += 1;
204
+ while (index < lines.length && !(lines[index] as string).trim().startsWith('```')) {
205
+ code.push(lines[index] as string);
206
+ index += 1;
207
+ }
208
+ blocks.push({ type: 'code', lines: code });
209
+ continue;
210
+ }
211
+
212
+ const bullet = /^\s*[-*+]\s+(.*)$/.exec(line);
213
+ const ordered = /^\s*\d+[.)]\s+(.*)$/.exec(line);
214
+ if (bullet || ordered) {
215
+ flushParagraph();
216
+ const isOrdered = !!ordered;
217
+ const items: string[] = [(bullet?.[1] ?? ordered?.[1] ?? '').trim()];
218
+ while (index + 1 < lines.length) {
219
+ const nextLine = lines[index + 1] as string;
220
+ const nextMatch = isOrdered
221
+ ? /^\s*\d+[.)]\s+(.*)$/.exec(nextLine)
222
+ : /^\s*[-*+]\s+(.*)$/.exec(nextLine);
223
+ if (!nextMatch) break;
224
+ items.push((nextMatch[1] ?? '').trim());
225
+ index += 1;
226
+ }
227
+ blocks.push({ type: 'list', ordered: isOrdered, items });
228
+ continue;
229
+ }
230
+
231
+ if (line.trim() === '') {
232
+ flushParagraph();
233
+ continue;
234
+ }
235
+
236
+ // Headings render as emphasised paragraphs — the bubble is already small.
237
+ paragraph.push(line.replace(/^#{1,6}\s+/, ''));
238
+ }
239
+
240
+ flushParagraph();
241
+ return blocks;
242
+ }
243
+
244
+ const styles = StyleSheet.create({
245
+ text: {
246
+ fontSize: fontSize.body,
247
+ lineHeight: fontSize.body * 1.45,
248
+ },
249
+ paragraphSpacing: {
250
+ marginTop: spacing.sm,
251
+ },
252
+ bold: {
253
+ fontWeight: '700',
254
+ },
255
+ italic: {
256
+ fontStyle: 'italic',
257
+ },
258
+ link: {
259
+ textDecorationLine: 'underline',
260
+ },
261
+ inlineCode: {
262
+ fontFamily: 'Courier',
263
+ fontSize: fontSize.meta,
264
+ },
265
+ codeBlock: {
266
+ marginTop: spacing.sm,
267
+ padding: spacing.sm,
268
+ borderRadius: radius.sm,
269
+ backgroundColor: 'rgba(0,0,0,0.06)',
270
+ },
271
+ codeBlockText: {
272
+ fontFamily: 'Courier',
273
+ fontSize: fontSize.meta,
274
+ color: palette.text,
275
+ },
276
+ list: {
277
+ marginTop: spacing.xs,
278
+ },
279
+ listItem: {
280
+ flexDirection: 'row',
281
+ marginBottom: spacing.xs,
282
+ },
283
+ listItemText: {
284
+ flex: 1,
285
+ },
286
+ listMarker: {
287
+ fontSize: fontSize.body,
288
+ lineHeight: fontSize.body * 1.45,
289
+ width: 20,
290
+ },
291
+ });
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Proactive / campaign card shown above the home + messages spaces.
3
+ * Port of `client/src/widget/components/OutboundMessageCard.tsx`.
4
+ */
5
+
6
+ import { Image, Pressable, StyleSheet, Text, View } from 'react-native';
7
+
8
+ import type { OutboundMessage } from '../../types';
9
+ import { htmlToText } from '../utils/html';
10
+ import { openExternalUrl } from '../utils/safe-url';
11
+ import { CloseIcon } from './icons';
12
+ import { START_ALIGN } from '../utils/rtl';
13
+ import { fontSize, palette, radius, shadows, spacing } from '../styles/theme';
14
+
15
+ interface OutboundMessageCardProps {
16
+ message: OutboundMessage;
17
+ color: string;
18
+ labels: { title: string; cta: string; dismiss: string };
19
+ onDismiss: () => void;
20
+ onStartChat: (prefill?: string) => void;
21
+ onTrack?: (event: string, metadata?: Record<string, unknown>) => void;
22
+ }
23
+
24
+ export function OutboundMessageCard({
25
+ message,
26
+ color,
27
+ labels,
28
+ onDismiss,
29
+ onStartChat,
30
+ onTrack,
31
+ }: OutboundMessageCardProps) {
32
+ const ctaLabel = message.ctaLabel || labels.cta;
33
+ const body = message.body || htmlToText(message.bodyHtml || '');
34
+
35
+ const handlePress = () => {
36
+ onTrack?.('widget_outbound_clicked', {
37
+ outboundId: message.id,
38
+ type: message.type,
39
+ hasCtaUrl: !!message.ctaUrl,
40
+ });
41
+
42
+ if (message.ctaUrl) {
43
+ void openExternalUrl(message.ctaUrl);
44
+ return;
45
+ }
46
+ onStartChat(htmlToText(message.prefill || '') || body);
47
+ };
48
+
49
+ return (
50
+ <View style={styles.wrapper}>
51
+ <View style={styles.card}>
52
+ {message.imageUrl ? (
53
+ <Image
54
+ source={{ uri: message.imageUrl }}
55
+ style={styles.image}
56
+ resizeMode="cover"
57
+ accessibilityIgnoresInvertColors
58
+ />
59
+ ) : null}
60
+ <View style={styles.body}>
61
+ <View style={styles.header}>
62
+ <View style={styles.headerCopy}>
63
+ <Text style={styles.title}>{message.title || labels.title}</Text>
64
+ {body ? <Text style={styles.description}>{body}</Text> : null}
65
+ </View>
66
+ <Pressable
67
+ onPress={onDismiss}
68
+ accessibilityRole="button"
69
+ accessibilityLabel={labels.dismiss}
70
+ hitSlop={12}
71
+ style={styles.dismiss}>
72
+ <CloseIcon size={16} color={palette.textSubtle} />
73
+ </Pressable>
74
+ </View>
75
+ <Pressable
76
+ onPress={handlePress}
77
+ accessibilityRole="button"
78
+ style={({ pressed }) => [
79
+ styles.cta,
80
+ { backgroundColor: color },
81
+ pressed && styles.ctaPressed,
82
+ ]}>
83
+ <Text style={styles.ctaLabel}>{ctaLabel}</Text>
84
+ </Pressable>
85
+ </View>
86
+ </View>
87
+ </View>
88
+ );
89
+ }
90
+
91
+ const styles = StyleSheet.create({
92
+ wrapper: {
93
+ padding: spacing.md + 2,
94
+ backgroundColor: palette.white,
95
+ borderBottomWidth: StyleSheet.hairlineWidth,
96
+ borderBottomColor: palette.borderSoft,
97
+ },
98
+ card: {
99
+ borderWidth: StyleSheet.hairlineWidth,
100
+ borderColor: palette.border,
101
+ borderRadius: radius.xl,
102
+ overflow: 'hidden',
103
+ backgroundColor: palette.white,
104
+ ...shadows.card,
105
+ },
106
+ image: {
107
+ width: '100%',
108
+ height: 150,
109
+ },
110
+ body: {
111
+ padding: spacing.lg,
112
+ },
113
+ header: {
114
+ flexDirection: 'row',
115
+ alignItems: 'flex-start',
116
+ gap: spacing.sm + 2,
117
+ },
118
+ headerCopy: {
119
+ flex: 1,
120
+ minWidth: 0,
121
+ },
122
+ title: {
123
+ textAlign: START_ALIGN,
124
+ fontSize: fontSize.title,
125
+ fontWeight: '600',
126
+ color: palette.ink,
127
+ },
128
+ description: {
129
+ textAlign: START_ALIGN,
130
+ marginTop: 5,
131
+ fontSize: fontSize.meta,
132
+ lineHeight: fontSize.meta * 1.45,
133
+ color: palette.textMuted,
134
+ },
135
+ dismiss: {
136
+ padding: spacing.xs,
137
+ },
138
+ cta: {
139
+ marginTop: spacing.md,
140
+ borderRadius: radius.pill,
141
+ alignItems: 'center',
142
+ justifyContent: 'center',
143
+ paddingVertical: spacing.md,
144
+ minHeight: 44,
145
+ },
146
+ ctaPressed: {
147
+ opacity: 0.85,
148
+ },
149
+ ctaLabel: {
150
+ color: palette.white,
151
+ fontSize: fontSize.meta,
152
+ fontWeight: '600',
153
+ },
154
+ });
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Panel chrome: the colored header (with the assigned agent) and the bottom
3
+ * space switcher. Port of `client/src/widget/components/WidgetPanel.tsx`; the
4
+ * fixed-size floating card becomes a full-height sheet because the RN host is
5
+ * a modal, not an iframe pinned to a corner.
6
+ */
7
+
8
+ import type { ReactNode } from 'react';
9
+ import { Pressable, StyleSheet, Text, View } from 'react-native';
10
+
11
+ import type { WidgetSpace, WidgetSpaceType } from '../../types';
12
+ import { globalStyles } from '../styles/global';
13
+ import { fontSize, palette, spacing } from '../styles/theme';
14
+ import { ChatOutlineIcon, HomeIcon } from './icons';
15
+
16
+ const SPACE_META: Record<
17
+ WidgetSpaceType,
18
+ { labelKey: 'home' | 'messages'; icon: (props: { size: number; color: string }) => ReactNode }
19
+ > = {
20
+ home: { labelKey: 'home', icon: (props) => <HomeIcon {...props} /> },
21
+ messages: { labelKey: 'messages', icon: (props) => <ChatOutlineIcon {...props} /> },
22
+ };
23
+
24
+ interface WidgetPanelProps {
25
+ color: string;
26
+ children: ReactNode;
27
+ activeTab: WidgetSpaceType;
28
+ onTabChange: (tab: WidgetSpaceType) => void;
29
+ showTabs: boolean;
30
+ spaces: WidgetSpace[];
31
+ /** Messages received while the panel sat on another surface. */
32
+ unreadCount?: number;
33
+ labels: { home: string; messages: string; unread: string };
34
+ }
35
+
36
+ export function WidgetPanel({
37
+ color,
38
+ children,
39
+ activeTab,
40
+ onTabChange,
41
+ showTabs,
42
+ spaces,
43
+ unreadCount = 0,
44
+ labels,
45
+ }: WidgetPanelProps) {
46
+ const enabledSpaces = spaces.filter((space) => space.enabled);
47
+
48
+ return (
49
+ <View style={globalStyles.screen}>
50
+ <View style={globalStyles.fill}>{children}</View>
51
+
52
+ {showTabs && enabledSpaces.length > 1 && (
53
+ <View style={styles.tabBar}>
54
+ {enabledSpaces.map((space) => {
55
+ const meta = SPACE_META[space.type];
56
+ if (!meta) return null;
57
+ const active = activeTab === space.type;
58
+ const showBadge = space.type === 'messages' && unreadCount > 0;
59
+ return (
60
+ <Pressable
61
+ key={space.type}
62
+ onPress={() => onTabChange(space.type)}
63
+ accessibilityRole="tab"
64
+ accessibilityState={{ selected: active }}
65
+ accessibilityLabel={
66
+ showBadge ? `${labels[meta.labelKey]}, ${labels.unread}` : undefined
67
+ }
68
+ style={styles.tab}>
69
+ <View style={styles.tabIconWrap}>
70
+ {meta.icon({ size: 22, color: active ? color : palette.textSubtle })}
71
+ {showBadge ? (
72
+ <View style={styles.tabBadge} pointerEvents="none">
73
+ <Text style={styles.tabBadgeLabel}>
74
+ {unreadCount > 9 ? '9+' : unreadCount}
75
+ </Text>
76
+ </View>
77
+ ) : null}
78
+ </View>
79
+ <Text style={[styles.tabLabel, { color: active ? color : palette.textSubtle }]}>
80
+ {labels[meta.labelKey]}
81
+ </Text>
82
+ </Pressable>
83
+ );
84
+ })}
85
+ </View>
86
+ )}
87
+ </View>
88
+ );
89
+ }
90
+
91
+ const styles = StyleSheet.create({
92
+ tabIconWrap: {
93
+ position: 'relative',
94
+ },
95
+ tabBadge: {
96
+ position: 'absolute',
97
+ top: -5,
98
+ end: -12,
99
+ minWidth: 18,
100
+ height: 18,
101
+ borderRadius: 9,
102
+ paddingHorizontal: spacing.xs,
103
+ backgroundColor: palette.danger,
104
+ alignItems: 'center',
105
+ justifyContent: 'center',
106
+ borderWidth: 2,
107
+ borderColor: palette.white,
108
+ },
109
+ tabBadgeLabel: {
110
+ fontSize: fontSize.micro,
111
+ fontWeight: '700',
112
+ color: palette.white,
113
+ },
114
+ tabBar: {
115
+ flexDirection: 'row',
116
+ borderTopWidth: StyleSheet.hairlineWidth,
117
+ borderTopColor: palette.border,
118
+ backgroundColor: palette.white,
119
+ },
120
+ tab: {
121
+ flex: 1,
122
+ alignItems: 'center',
123
+ justifyContent: 'center',
124
+ gap: 2,
125
+ paddingVertical: spacing.sm,
126
+ minHeight: 52,
127
+ },
128
+ tabLabel: {
129
+ fontSize: fontSize.caption,
130
+ // Weight stays constant across states — only color signals the active tab.
131
+ fontWeight: '600',
132
+ },
133
+ });