@botonic/react 0.31.0-alpha.4 → 0.31.0-alpha.6

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 (413) hide show
  1. package/lib/cjs/components/audio.d.ts +8 -7
  2. package/lib/cjs/components/audio.js +7 -4
  3. package/lib/cjs/components/audio.js.map +1 -1
  4. package/lib/cjs/components/button.js +3 -4
  5. package/lib/cjs/components/button.js.map +1 -1
  6. package/lib/cjs/components/carousel.js +2 -2
  7. package/lib/cjs/components/carousel.js.map +1 -1
  8. package/lib/cjs/components/custom-message.d.ts +16 -12
  9. package/lib/cjs/components/custom-message.js +3 -9
  10. package/lib/cjs/components/custom-message.js.map +1 -1
  11. package/lib/cjs/components/document.d.ts +8 -7
  12. package/lib/cjs/components/document.js +5 -5
  13. package/lib/cjs/components/document.js.map +1 -1
  14. package/lib/cjs/components/handoff.js +2 -2
  15. package/lib/cjs/components/handoff.js.map +1 -1
  16. package/lib/cjs/components/image.d.ts +8 -7
  17. package/lib/cjs/components/image.js +5 -5
  18. package/lib/cjs/components/image.js.map +1 -1
  19. package/lib/cjs/components/index-types.d.ts +30 -128
  20. package/lib/cjs/components/index.d.ts +2 -1
  21. package/lib/cjs/components/index.js +4 -1
  22. package/lib/cjs/components/index.js.map +1 -1
  23. package/lib/cjs/components/message/index.js +2 -1
  24. package/lib/cjs/components/message/index.js.map +1 -1
  25. package/lib/cjs/components/message/message-feedback.js +2 -2
  26. package/lib/cjs/components/message/message-feedback.js.map +1 -1
  27. package/lib/cjs/components/message/message-footer.js +2 -2
  28. package/lib/cjs/components/message/message-footer.js.map +1 -1
  29. package/lib/cjs/components/message/message-image.js +2 -2
  30. package/lib/cjs/components/message/message-image.js.map +1 -1
  31. package/lib/cjs/components/message/timestamps.js +2 -2
  32. package/lib/cjs/components/message/timestamps.js.map +1 -1
  33. package/lib/cjs/components/reply.d.ts +7 -6
  34. package/lib/cjs/components/reply.js +10 -6
  35. package/lib/cjs/components/reply.js.map +1 -1
  36. package/lib/cjs/components/video.d.ts +8 -7
  37. package/lib/cjs/components/video.js +2 -3
  38. package/lib/cjs/components/video.js.map +1 -1
  39. package/lib/cjs/components/webchat-settings.d.ts +15 -2
  40. package/lib/cjs/components/webchat-settings.js +2 -2
  41. package/lib/cjs/components/webchat-settings.js.map +1 -1
  42. package/lib/cjs/contexts.d.ts +3 -4
  43. package/lib/cjs/contexts.js +2 -79
  44. package/lib/cjs/contexts.js.map +1 -1
  45. package/lib/cjs/index-types.d.ts +89 -56
  46. package/lib/cjs/index-types.js.map +1 -1
  47. package/lib/cjs/index.d.ts +2 -2
  48. package/lib/cjs/index.js +1 -2
  49. package/lib/cjs/index.js.map +1 -1
  50. package/lib/cjs/msg-to-botonic.d.ts +1 -1
  51. package/lib/cjs/msg-to-botonic.js +5 -8
  52. package/lib/cjs/msg-to-botonic.js.map +1 -1
  53. package/lib/cjs/util/webchat.d.ts +17 -6
  54. package/lib/cjs/util/webchat.js +9 -7
  55. package/lib/cjs/util/webchat.js.map +1 -1
  56. package/lib/cjs/webchat/chat-area/index.js +3 -3
  57. package/lib/cjs/webchat/chat-area/index.js.map +1 -1
  58. package/lib/cjs/webchat/components/conditional-animation.js +2 -2
  59. package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
  60. package/lib/cjs/webchat/components/opened-persistent-menu.js +2 -2
  61. package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -1
  62. package/lib/cjs/webchat/{actions.d.ts → context/actions.d.ts} +2 -0
  63. package/lib/cjs/webchat/{actions.js → context/actions.js} +3 -0
  64. package/lib/cjs/webchat/context/actions.js.map +1 -0
  65. package/lib/cjs/webchat/context/index.d.ts +5 -0
  66. package/lib/cjs/webchat/context/index.js +83 -0
  67. package/lib/cjs/webchat/context/index.js.map +1 -0
  68. package/lib/cjs/webchat/{messages-reducer.d.ts → context/messages-reducer.d.ts} +1 -1
  69. package/lib/cjs/webchat/{messages-reducer.js → context/messages-reducer.js} +3 -1
  70. package/lib/cjs/webchat/context/messages-reducer.js.map +1 -0
  71. package/lib/cjs/webchat/context/types.d.ts +74 -0
  72. package/lib/cjs/webchat/context/types.js +3 -0
  73. package/lib/cjs/webchat/context/types.js.map +1 -0
  74. package/lib/cjs/webchat/{hooks → context}/use-webchat.d.ts +20 -20
  75. package/lib/cjs/webchat/{hooks → context}/use-webchat.js +11 -5
  76. package/lib/cjs/webchat/context/use-webchat.js.map +1 -0
  77. package/lib/cjs/webchat/{webchat-reducer.d.ts → context/webchat-reducer.d.ts} +1 -1
  78. package/lib/cjs/webchat/{webchat-reducer.js → context/webchat-reducer.js} +2 -0
  79. package/lib/cjs/webchat/context/webchat-reducer.js.map +1 -0
  80. package/lib/cjs/webchat/cover-component/index.js +2 -2
  81. package/lib/cjs/webchat/cover-component/index.js.map +1 -1
  82. package/lib/cjs/webchat/header/default-header.d.ts +1 -0
  83. package/lib/cjs/webchat/header/default-header.js +25 -0
  84. package/lib/cjs/webchat/header/default-header.js.map +1 -0
  85. package/lib/cjs/webchat/header/index.d.ts +2 -0
  86. package/lib/cjs/webchat/header/index.js +23 -0
  87. package/lib/cjs/webchat/header/index.js.map +1 -0
  88. package/lib/cjs/webchat/header/styles.d.ts +7 -0
  89. package/lib/cjs/webchat/header/styles.js +59 -0
  90. package/lib/cjs/webchat/header/styles.js.map +1 -0
  91. package/lib/cjs/webchat/hooks/index.d.ts +0 -1
  92. package/lib/cjs/webchat/hooks/index.js +1 -4
  93. package/lib/cjs/webchat/hooks/index.js.map +1 -1
  94. package/lib/cjs/webchat/hooks/use-previous.d.ts +1 -1
  95. package/lib/cjs/webchat/hooks/use-previous.js.map +1 -1
  96. package/lib/cjs/webchat/hooks/use-scrollbar-controller.js +3 -3
  97. package/lib/cjs/webchat/hooks/use-scrollbar-controller.js.map +1 -1
  98. package/lib/cjs/webchat/hooks/use-typing.d.ts +1 -1
  99. package/lib/cjs/webchat/hooks/use-webchat-dimensions.js +2 -2
  100. package/lib/cjs/webchat/hooks/use-webchat-dimensions.js.map +1 -1
  101. package/lib/cjs/webchat/hooks/use-webchat-resizer.js +2 -2
  102. package/lib/cjs/webchat/hooks/use-webchat-resizer.js.map +1 -1
  103. package/lib/cjs/webchat/index-types.d.ts +3 -47
  104. package/lib/cjs/webchat/index.d.ts +1 -0
  105. package/lib/cjs/webchat/index.js +3 -1
  106. package/lib/cjs/webchat/index.js.map +1 -1
  107. package/lib/cjs/webchat/input-panel/attachment.d.ts +1 -1
  108. package/lib/cjs/webchat/input-panel/attachment.js +2 -2
  109. package/lib/cjs/webchat/input-panel/attachment.js.map +1 -1
  110. package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -1
  111. package/lib/cjs/webchat/input-panel/emoji-picker.js +2 -2
  112. package/lib/cjs/webchat/input-panel/emoji-picker.js.map +1 -1
  113. package/lib/cjs/webchat/input-panel/index.d.ts +3 -3
  114. package/lib/cjs/webchat/input-panel/index.js +8 -3
  115. package/lib/cjs/webchat/input-panel/index.js.map +1 -1
  116. package/lib/cjs/webchat/input-panel/persistent-menu.js +2 -2
  117. package/lib/cjs/webchat/input-panel/persistent-menu.js.map +1 -1
  118. package/lib/cjs/webchat/input-panel/send-button.js +2 -2
  119. package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
  120. package/lib/cjs/webchat/input-panel/textarea.d.ts +3 -3
  121. package/lib/cjs/webchat/input-panel/textarea.js +4 -2
  122. package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
  123. package/lib/cjs/webchat/message-list/index.js +5 -7
  124. package/lib/cjs/webchat/message-list/index.js.map +1 -1
  125. package/lib/cjs/webchat/message-list/intro-message.js +2 -2
  126. package/lib/cjs/webchat/message-list/intro-message.js.map +1 -1
  127. package/lib/cjs/webchat/message-list/styles.js +1 -0
  128. package/lib/cjs/webchat/message-list/styles.js.map +1 -1
  129. package/lib/cjs/webchat/message-list/unread-messages-banner.js +2 -2
  130. package/lib/cjs/webchat/message-list/unread-messages-banner.js.map +1 -1
  131. package/lib/cjs/webchat/message-list/use-notifications.js +2 -2
  132. package/lib/cjs/webchat/message-list/use-notifications.js.map +1 -1
  133. package/lib/cjs/webchat/replies/index.d.ts +1 -0
  134. package/lib/cjs/webchat/replies/index.js +32 -0
  135. package/lib/cjs/webchat/replies/index.js.map +1 -0
  136. package/lib/cjs/webchat/replies/styles.d.ts +8 -0
  137. package/lib/cjs/webchat/replies/styles.js +25 -0
  138. package/lib/cjs/webchat/replies/styles.js.map +1 -0
  139. package/lib/cjs/webchat/session-view.js +2 -2
  140. package/lib/cjs/webchat/session-view.js.map +1 -1
  141. package/lib/cjs/webchat/{webchat-typed/styles.d.ts → styles.d.ts} +6 -4
  142. package/lib/cjs/webchat/{webchat-typed/styles.js → styles.js} +1 -1
  143. package/lib/cjs/webchat/styles.js.map +1 -0
  144. package/lib/cjs/webchat/theme/types.d.ts +167 -0
  145. package/lib/cjs/webchat/theme/types.js +3 -0
  146. package/lib/cjs/webchat/theme/types.js.map +1 -0
  147. package/lib/cjs/webchat/trigger-button/index.js +2 -2
  148. package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
  149. package/lib/cjs/webchat/webchat-dev.js +2 -2
  150. package/lib/cjs/webchat/webchat-dev.js.map +1 -1
  151. package/lib/cjs/webchat/webchat.d.ts +4 -2
  152. package/lib/cjs/webchat/webchat.js +85 -108
  153. package/lib/cjs/webchat/webchat.js.map +1 -1
  154. package/lib/cjs/webchat/webview.js +3 -2
  155. package/lib/cjs/webchat/webview.js.map +1 -1
  156. package/lib/cjs/webchat-app.d.ts +14 -80
  157. package/lib/cjs/webchat-app.js +28 -14
  158. package/lib/cjs/webchat-app.js.map +1 -1
  159. package/lib/esm/components/audio.d.ts +8 -7
  160. package/lib/esm/components/audio.js +7 -4
  161. package/lib/esm/components/audio.js.map +1 -1
  162. package/lib/esm/components/button.js +2 -3
  163. package/lib/esm/components/button.js.map +1 -1
  164. package/lib/esm/components/carousel.js +1 -1
  165. package/lib/esm/components/carousel.js.map +1 -1
  166. package/lib/esm/components/custom-message.d.ts +16 -12
  167. package/lib/esm/components/custom-message.js +3 -9
  168. package/lib/esm/components/custom-message.js.map +1 -1
  169. package/lib/esm/components/document.d.ts +8 -7
  170. package/lib/esm/components/document.js +4 -4
  171. package/lib/esm/components/document.js.map +1 -1
  172. package/lib/esm/components/handoff.js +1 -1
  173. package/lib/esm/components/handoff.js.map +1 -1
  174. package/lib/esm/components/image.d.ts +8 -7
  175. package/lib/esm/components/image.js +4 -4
  176. package/lib/esm/components/image.js.map +1 -1
  177. package/lib/esm/components/index-types.d.ts +30 -128
  178. package/lib/esm/components/index.d.ts +2 -1
  179. package/lib/esm/components/index.js +2 -1
  180. package/lib/esm/components/index.js.map +1 -1
  181. package/lib/esm/components/message/index.js +2 -1
  182. package/lib/esm/components/message/index.js.map +1 -1
  183. package/lib/esm/components/message/message-feedback.js +1 -1
  184. package/lib/esm/components/message/message-feedback.js.map +1 -1
  185. package/lib/esm/components/message/message-footer.js +1 -1
  186. package/lib/esm/components/message/message-footer.js.map +1 -1
  187. package/lib/esm/components/message/message-image.js +1 -1
  188. package/lib/esm/components/message/message-image.js.map +1 -1
  189. package/lib/esm/components/message/timestamps.js +1 -1
  190. package/lib/esm/components/message/timestamps.js.map +1 -1
  191. package/lib/esm/components/reply.d.ts +7 -6
  192. package/lib/esm/components/reply.js +9 -5
  193. package/lib/esm/components/reply.js.map +1 -1
  194. package/lib/esm/components/video.d.ts +8 -7
  195. package/lib/esm/components/video.js +2 -3
  196. package/lib/esm/components/video.js.map +1 -1
  197. package/lib/esm/components/webchat-settings.d.ts +15 -2
  198. package/lib/esm/components/webchat-settings.js +1 -1
  199. package/lib/esm/components/webchat-settings.js.map +1 -1
  200. package/lib/esm/contexts.d.ts +3 -4
  201. package/lib/esm/contexts.js +1 -78
  202. package/lib/esm/contexts.js.map +1 -1
  203. package/lib/esm/index-types.d.ts +89 -56
  204. package/lib/esm/index-types.js.map +1 -1
  205. package/lib/esm/index.d.ts +2 -2
  206. package/lib/esm/index.js +1 -1
  207. package/lib/esm/index.js.map +1 -1
  208. package/lib/esm/msg-to-botonic.d.ts +1 -1
  209. package/lib/esm/msg-to-botonic.js +5 -8
  210. package/lib/esm/msg-to-botonic.js.map +1 -1
  211. package/lib/esm/util/webchat.d.ts +17 -6
  212. package/lib/esm/util/webchat.js +9 -7
  213. package/lib/esm/util/webchat.js.map +1 -1
  214. package/lib/esm/webchat/chat-area/index.js +2 -2
  215. package/lib/esm/webchat/chat-area/index.js.map +1 -1
  216. package/lib/esm/webchat/components/conditional-animation.js +1 -1
  217. package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
  218. package/lib/esm/webchat/components/opened-persistent-menu.js +1 -1
  219. package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -1
  220. package/lib/esm/webchat/{actions.d.ts → context/actions.d.ts} +2 -0
  221. package/lib/esm/webchat/{actions.js → context/actions.js} +3 -0
  222. package/lib/esm/webchat/context/actions.js.map +1 -0
  223. package/lib/esm/webchat/context/index.d.ts +5 -0
  224. package/lib/esm/webchat/context/index.js +78 -0
  225. package/lib/esm/webchat/context/index.js.map +1 -0
  226. package/lib/esm/webchat/{messages-reducer.d.ts → context/messages-reducer.d.ts} +1 -1
  227. package/lib/esm/webchat/{messages-reducer.js → context/messages-reducer.js} +3 -1
  228. package/lib/esm/webchat/context/messages-reducer.js.map +1 -0
  229. package/lib/esm/webchat/context/types.d.ts +74 -0
  230. package/lib/esm/webchat/context/types.js +2 -0
  231. package/lib/esm/webchat/context/types.js.map +1 -0
  232. package/lib/esm/webchat/{hooks → context}/use-webchat.d.ts +20 -20
  233. package/lib/esm/webchat/{hooks → context}/use-webchat.js +11 -5
  234. package/lib/esm/webchat/context/use-webchat.js.map +1 -0
  235. package/lib/esm/webchat/{webchat-reducer.d.ts → context/webchat-reducer.d.ts} +1 -1
  236. package/lib/esm/webchat/{webchat-reducer.js → context/webchat-reducer.js} +2 -0
  237. package/lib/esm/webchat/context/webchat-reducer.js.map +1 -0
  238. package/lib/esm/webchat/cover-component/index.js +1 -1
  239. package/lib/esm/webchat/cover-component/index.js.map +1 -1
  240. package/lib/esm/webchat/header/default-header.d.ts +1 -0
  241. package/lib/esm/webchat/header/default-header.js +21 -0
  242. package/lib/esm/webchat/header/default-header.js.map +1 -0
  243. package/lib/esm/webchat/header/index.d.ts +2 -0
  244. package/lib/esm/webchat/header/index.js +20 -0
  245. package/lib/esm/webchat/header/index.js.map +1 -0
  246. package/lib/esm/webchat/header/styles.d.ts +7 -0
  247. package/lib/esm/webchat/header/styles.js +55 -0
  248. package/lib/esm/webchat/header/styles.js.map +1 -0
  249. package/lib/esm/webchat/hooks/index.d.ts +0 -1
  250. package/lib/esm/webchat/hooks/index.js +0 -1
  251. package/lib/esm/webchat/hooks/index.js.map +1 -1
  252. package/lib/esm/webchat/hooks/use-previous.d.ts +1 -1
  253. package/lib/esm/webchat/hooks/use-previous.js.map +1 -1
  254. package/lib/esm/webchat/hooks/use-scrollbar-controller.js +2 -2
  255. package/lib/esm/webchat/hooks/use-scrollbar-controller.js.map +1 -1
  256. package/lib/esm/webchat/hooks/use-typing.d.ts +1 -1
  257. package/lib/esm/webchat/hooks/use-webchat-dimensions.js +1 -1
  258. package/lib/esm/webchat/hooks/use-webchat-dimensions.js.map +1 -1
  259. package/lib/esm/webchat/hooks/use-webchat-resizer.js +1 -1
  260. package/lib/esm/webchat/hooks/use-webchat-resizer.js.map +1 -1
  261. package/lib/esm/webchat/index-types.d.ts +3 -47
  262. package/lib/esm/webchat/index.d.ts +1 -0
  263. package/lib/esm/webchat/index.js +1 -0
  264. package/lib/esm/webchat/index.js.map +1 -1
  265. package/lib/esm/webchat/input-panel/attachment.d.ts +1 -1
  266. package/lib/esm/webchat/input-panel/attachment.js +1 -1
  267. package/lib/esm/webchat/input-panel/attachment.js.map +1 -1
  268. package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -1
  269. package/lib/esm/webchat/input-panel/emoji-picker.js +1 -1
  270. package/lib/esm/webchat/input-panel/emoji-picker.js.map +1 -1
  271. package/lib/esm/webchat/input-panel/index.d.ts +3 -3
  272. package/lib/esm/webchat/input-panel/index.js +7 -2
  273. package/lib/esm/webchat/input-panel/index.js.map +1 -1
  274. package/lib/esm/webchat/input-panel/persistent-menu.js +1 -1
  275. package/lib/esm/webchat/input-panel/persistent-menu.js.map +1 -1
  276. package/lib/esm/webchat/input-panel/send-button.js +1 -1
  277. package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
  278. package/lib/esm/webchat/input-panel/textarea.d.ts +3 -3
  279. package/lib/esm/webchat/input-panel/textarea.js +3 -1
  280. package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
  281. package/lib/esm/webchat/message-list/index.js +4 -6
  282. package/lib/esm/webchat/message-list/index.js.map +1 -1
  283. package/lib/esm/webchat/message-list/intro-message.js +1 -1
  284. package/lib/esm/webchat/message-list/intro-message.js.map +1 -1
  285. package/lib/esm/webchat/message-list/styles.js +1 -0
  286. package/lib/esm/webchat/message-list/styles.js.map +1 -1
  287. package/lib/esm/webchat/message-list/unread-messages-banner.js +1 -1
  288. package/lib/esm/webchat/message-list/unread-messages-banner.js.map +1 -1
  289. package/lib/esm/webchat/message-list/use-notifications.js +1 -1
  290. package/lib/esm/webchat/message-list/use-notifications.js.map +1 -1
  291. package/lib/esm/webchat/replies/index.d.ts +1 -0
  292. package/lib/esm/webchat/replies/index.js +28 -0
  293. package/lib/esm/webchat/replies/index.js.map +1 -0
  294. package/lib/esm/webchat/replies/styles.d.ts +8 -0
  295. package/lib/esm/webchat/replies/styles.js +21 -0
  296. package/lib/esm/webchat/replies/styles.js.map +1 -0
  297. package/lib/esm/webchat/session-view.js +1 -1
  298. package/lib/esm/webchat/session-view.js.map +1 -1
  299. package/lib/esm/webchat/{webchat-typed/styles.d.ts → styles.d.ts} +6 -4
  300. package/lib/esm/webchat/{webchat-typed/styles.js → styles.js} +1 -1
  301. package/lib/esm/webchat/styles.js.map +1 -0
  302. package/lib/esm/webchat/theme/types.d.ts +167 -0
  303. package/lib/esm/webchat/theme/types.js +2 -0
  304. package/lib/esm/webchat/theme/types.js.map +1 -0
  305. package/lib/esm/webchat/trigger-button/index.js +1 -1
  306. package/lib/esm/webchat/trigger-button/index.js.map +1 -1
  307. package/lib/esm/webchat/webchat-dev.js +1 -1
  308. package/lib/esm/webchat/webchat-dev.js.map +1 -1
  309. package/lib/esm/webchat/webchat.d.ts +4 -2
  310. package/lib/esm/webchat/webchat.js +81 -104
  311. package/lib/esm/webchat/webchat.js.map +1 -1
  312. package/lib/esm/webchat/webview.js +2 -1
  313. package/lib/esm/webchat/webview.js.map +1 -1
  314. package/lib/esm/webchat-app.d.ts +14 -80
  315. package/lib/esm/webchat-app.js +28 -14
  316. package/lib/esm/webchat-app.js.map +1 -1
  317. package/package.json +2 -1
  318. package/src/components/{audio.jsx → audio.tsx} +10 -4
  319. package/src/components/button.tsx +1 -3
  320. package/src/components/carousel.jsx +1 -1
  321. package/src/components/{custom-message.jsx → custom-message.tsx} +19 -7
  322. package/src/components/{document.jsx → document.tsx} +5 -3
  323. package/src/components/handoff.jsx +1 -1
  324. package/src/components/{image.jsx → image.tsx} +10 -4
  325. package/src/components/index-types.ts +25 -117
  326. package/src/components/index.ts +6 -1
  327. package/src/components/message/index.jsx +2 -1
  328. package/src/components/message/message-feedback.tsx +1 -1
  329. package/src/components/message/message-footer.tsx +1 -1
  330. package/src/components/message/message-image.tsx +1 -1
  331. package/src/components/message/timestamps.tsx +1 -1
  332. package/src/components/{reply.jsx → reply.tsx} +10 -4
  333. package/src/components/{video.jsx → video.tsx} +3 -2
  334. package/src/components/webchat-settings.tsx +14 -2
  335. package/src/contexts.tsx +5 -83
  336. package/src/index-types.ts +99 -64
  337. package/src/index.ts +2 -6
  338. package/src/msg-to-botonic.jsx +5 -9
  339. package/src/util/{webchat.js → webchat.ts} +15 -9
  340. package/src/webchat/chat-area/index.tsx +2 -4
  341. package/src/webchat/components/conditional-animation.jsx +1 -1
  342. package/src/webchat/components/opened-persistent-menu.jsx +1 -1
  343. package/src/webchat/{actions.ts → context/actions.ts} +3 -0
  344. package/src/webchat/context/index.tsx +81 -0
  345. package/src/webchat/{messages-reducer.ts → context/messages-reducer.ts} +4 -2
  346. package/src/webchat/context/types.ts +84 -0
  347. package/src/webchat/{hooks → context}/use-webchat.ts +62 -13
  348. package/src/webchat/{webchat-reducer.ts → context/webchat-reducer.ts} +3 -1
  349. package/src/webchat/cover-component/index.tsx +1 -1
  350. package/src/webchat/global.d.ts +3 -0
  351. package/src/webchat/header/default-header.tsx +75 -0
  352. package/src/webchat/header/index.tsx +37 -0
  353. package/src/webchat/header/styles.ts +62 -0
  354. package/src/webchat/hooks/index.ts +0 -1
  355. package/src/webchat/hooks/use-previous.ts +1 -1
  356. package/src/webchat/hooks/use-scrollbar-controller.ts +2 -2
  357. package/src/webchat/hooks/use-typing.ts +1 -1
  358. package/src/webchat/hooks/use-webchat-dimensions.ts +1 -1
  359. package/src/webchat/hooks/use-webchat-resizer.ts +1 -1
  360. package/src/webchat/index-types.ts +3 -53
  361. package/src/webchat/index.ts +1 -0
  362. package/src/webchat/input-panel/attachment.tsx +2 -2
  363. package/src/webchat/input-panel/emoji-picker.tsx +2 -2
  364. package/src/webchat/input-panel/index.tsx +9 -5
  365. package/src/webchat/input-panel/persistent-menu.tsx +1 -1
  366. package/src/webchat/input-panel/send-button.tsx +1 -1
  367. package/src/webchat/input-panel/textarea.tsx +6 -4
  368. package/src/webchat/message-list/index.tsx +4 -6
  369. package/src/webchat/message-list/intro-message.tsx +1 -1
  370. package/src/webchat/message-list/styles.ts +1 -0
  371. package/src/webchat/message-list/unread-messages-banner.tsx +1 -1
  372. package/src/webchat/message-list/use-notifications.ts +1 -1
  373. package/src/webchat/replies/index.tsx +47 -0
  374. package/src/webchat/replies/styles.ts +28 -0
  375. package/src/webchat/session-view.jsx +1 -1
  376. package/src/webchat/{webchat-typed/styles.ts → styles.ts} +7 -2
  377. package/src/webchat/theme/types.ts +119 -0
  378. package/src/webchat/trigger-button/index.tsx +1 -1
  379. package/src/webchat/webchat-dev.jsx +1 -1
  380. package/src/webchat/{webchat.jsx → webchat.tsx} +114 -124
  381. package/src/webchat/webview.jsx +2 -1
  382. package/src/webchat-app.tsx +55 -95
  383. package/lib/cjs/webchat/actions.js.map +0 -1
  384. package/lib/cjs/webchat/header.d.ts +0 -3
  385. package/lib/cjs/webchat/header.js +0 -86
  386. package/lib/cjs/webchat/header.js.map +0 -1
  387. package/lib/cjs/webchat/hooks/use-webchat.js.map +0 -1
  388. package/lib/cjs/webchat/messages-reducer.js.map +0 -1
  389. package/lib/cjs/webchat/replies.d.ts +0 -1
  390. package/lib/cjs/webchat/replies.js +0 -47
  391. package/lib/cjs/webchat/replies.js.map +0 -1
  392. package/lib/cjs/webchat/webchat-reducer.js.map +0 -1
  393. package/lib/cjs/webchat/webchat-typed/styles.js.map +0 -1
  394. package/lib/cjs/webchat/webchat-typed/webchat-typed.d.ts +0 -0
  395. package/lib/cjs/webchat/webchat-typed/webchat-typed.js +0 -663
  396. package/lib/cjs/webchat/webchat-typed/webchat-typed.js.map +0 -1
  397. package/lib/esm/webchat/actions.js.map +0 -1
  398. package/lib/esm/webchat/header.d.ts +0 -3
  399. package/lib/esm/webchat/header.js +0 -81
  400. package/lib/esm/webchat/header.js.map +0 -1
  401. package/lib/esm/webchat/hooks/use-webchat.js.map +0 -1
  402. package/lib/esm/webchat/messages-reducer.js.map +0 -1
  403. package/lib/esm/webchat/replies.d.ts +0 -1
  404. package/lib/esm/webchat/replies.js +0 -42
  405. package/lib/esm/webchat/replies.js.map +0 -1
  406. package/lib/esm/webchat/webchat-reducer.js.map +0 -1
  407. package/lib/esm/webchat/webchat-typed/styles.js.map +0 -1
  408. package/lib/esm/webchat/webchat-typed/webchat-typed.d.ts +0 -0
  409. package/lib/esm/webchat/webchat-typed/webchat-typed.js +0 -663
  410. package/lib/esm/webchat/webchat-typed/webchat-typed.js.map +0 -1
  411. package/src/webchat/header.jsx +0 -149
  412. package/src/webchat/replies.jsx +0 -64
  413. package/src/webchat/webchat-typed/webchat-typed.tsx +0 -728
@@ -5,6 +5,7 @@ import {
5
5
  Plugin as CorePlugin,
6
6
  Route as CoreRoute,
7
7
  Routes as CoreRoutes,
8
+ ServerConfig,
8
9
  Session as CoreSession,
9
10
  SessionUser as CoreSessionUser,
10
11
  } from '@botonic/core'
@@ -13,14 +14,16 @@ import React from 'react'
13
14
  import {
14
15
  BlockInputOption,
15
16
  ButtonProps,
16
- CoverComponentOptions,
17
- PersistentMenuTheme,
18
17
  ReplyProps,
19
- ThemeProps,
20
18
  WebchatSettingsProps,
21
- Webview,
22
- } from './components/index-types'
23
- import { WebchatState } from './webchat/index-types'
19
+ } from './components'
20
+ import { CloseWebviewOptions } from './contexts'
21
+ import { UseWebchat } from './webchat/context/use-webchat'
22
+ import {
23
+ CoverComponentOptions,
24
+ PersistentMenuOptionsTheme,
25
+ ThemeProps,
26
+ } from './webchat/theme/types'
24
27
  import { WebchatApp } from './webchat-app'
25
28
 
26
29
  /**
@@ -51,32 +54,91 @@ export interface RequestContextInterface extends ActionRequest {
51
54
  setLocale: (locale: string) => string
52
55
  }
53
56
 
54
- export interface CustomMessageType {
55
- customTypeName: string
57
+ export interface WebchatRef {
58
+ addBotResponse: ({
59
+ response,
60
+ session,
61
+ lastRoutePath,
62
+ }: AddBotResponseArgs) => void
63
+ setTyping: (typing: boolean) => void
64
+ addUserMessage: (message: any) => Promise<void>
65
+ updateUser: (userToUpdate: any) => void
66
+ openWebchat: () => void
67
+ closeWebchat: () => void
68
+ toggleWebchat: () => void
69
+ openCoverComponent: () => void
70
+ closeCoverComponent: () => void
71
+ toggleCoverComponent: () => void
72
+ renderCustomComponent: (customComponent: any) => void
73
+ unmountCustomComponent: () => void
74
+ isOnline: () => boolean
75
+ setOnline: (online: boolean) => void
76
+ getMessages: () => { id: string; ack: number; unsentInput: CoreInput }[] // TODO: define MessagesJSON
77
+ clearMessages: () => void
78
+ getLastMessageUpdate: () => string | undefined
79
+ updateMessageInfo: (msgId: string, messageInfo: any) => void
80
+ updateWebchatSettings: (settings: WebchatSettingsProps) => void
81
+ closeWebview: (options?: CloseWebviewOptions) => Promise<void>
82
+ }
83
+
84
+ interface AddBotResponseArgs {
85
+ response: any
86
+ session?: any
87
+ lastRoutePath?: any
56
88
  }
57
89
 
58
90
  export interface WebchatArgs {
59
- blockInputs?: BlockInputOption[]
91
+ theme?: ThemeProps
92
+ persistentMenu?: PersistentMenuOptionsTheme
60
93
  coverComponent?: CoverComponentOptions
61
- defaultDelay?: number
62
- defaultTyping?: number
63
- enableAnimations?: boolean
64
- enableAttachments?: boolean
94
+ blockInputs?: BlockInputOption[]
65
95
  enableEmojiPicker?: boolean
96
+ enableAttachments?: boolean
66
97
  enableUserInput?: boolean
67
- shadowDOM?: boolean | (() => boolean)
98
+ enableAnimations?: boolean
68
99
  hostId?: string
69
- getString?: (stringId: string, session: CoreSession) => string
70
- onClose?: (app: WebchatApp, args: any) => void
100
+ shadowDOM?: boolean | (() => boolean)
101
+ defaultDelay?: number
102
+ defaultTyping?: number
103
+ storage?: Storage | null
104
+ storageKey?: string
71
105
  onInit?: (app: WebchatApp, args: any) => void
72
- onMessage?: (app: WebchatApp, message: WebchatMessage) => void
73
106
  onOpen?: (app: WebchatApp, args: any) => void
74
- onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void
107
+ onClose?: (app: WebchatApp, args: any) => void
108
+ onMessage?: (app: WebchatApp, message: WebchatMessage) => void
75
109
  onTrackEvent?: TrackEventFunction
76
- persistentMenu?: PersistentMenuTheme
77
- storage?: Storage | null
78
- storageKey?: any
110
+ onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void
111
+ appId?: string
112
+ visibility?: boolean | (() => boolean) | 'dynamic'
113
+ server?: ServerConfig
114
+ }
115
+
116
+ export interface WebchatProps {
117
+ webchatHooks?: UseWebchat
118
+ initialSession?: any
119
+ initialDevSettings?: any
120
+ onStateChange: (args: OnStateChangeArgs) => void
121
+
122
+ shadowDOM?: any
79
123
  theme?: ThemeProps
124
+ persistentMenu?: PersistentMenuOptionsTheme
125
+ coverComponent?: CoverComponentOptions
126
+ blockInputs?: BlockInputOption[]
127
+ enableEmojiPicker?: boolean
128
+ enableAttachments?: boolean
129
+ enableUserInput?: boolean
130
+ enableAnimations?: boolean
131
+ storage?: Storage | null
132
+ storageKey?: string | (() => string)
133
+ defaultDelay?: number
134
+ defaultTyping?: number
135
+ onInit?: (args?: any) => void
136
+ onOpen?: (args?: any) => void
137
+ onClose?: (args?: any) => void
138
+ onUserInput(args: OnUserInputArgs): Promise<void>
139
+ onTrackEvent?: TrackEventFunction
140
+ host?: any
141
+ server?: ServerConfig
80
142
  }
81
143
 
82
144
  export type EventArgs = { [key: string]: any }
@@ -101,19 +163,19 @@ export interface WebchatMessage {
101
163
  ack: 0 | 1
102
164
  blob: boolean
103
165
  buttons: ButtonProps[]
104
- children: any
105
- data: any
166
+ children: any // messageJSON don't have children prop
167
+ data: any // if message.type === 'text' => message.data = {text: string}
106
168
  delay: number
107
169
  display: boolean
108
- enabletimestamps: boolean
170
+ enabletimestamps?: boolean
109
171
  id: string
110
- imagestyle: any
172
+ imagestyle?: any
111
173
  isUnread: boolean
112
174
  json: any
113
- markdown: boolean
175
+ markdown: boolean // 0 | 1
114
176
  replies: ReplyProps[]
115
177
  sentBy: SENDERS
116
- style: any
178
+ style?: any
117
179
  timestamp: string
118
180
  type: CoreInputType
119
181
  typing: number
@@ -123,7 +185,7 @@ export interface OnUserInputArgs {
123
185
  input: CoreInput
124
186
  lastRoutePath?: string
125
187
  session?: CoreSession
126
- user: CoreSessionUser
188
+ user?: CoreSessionUser
127
189
  }
128
190
 
129
191
  export interface OnStateChangeArgs {
@@ -137,44 +199,17 @@ export interface MessageInfo {
137
199
  type: 'update_webchat_settings' | 'sender_action'
138
200
  }
139
201
 
140
- export interface Event {
141
- action?: 'update_message_info'
202
+ export type Event = ConnectionChangeEvent | UpdateMessageInfoEvent
203
+
204
+ interface ConnectionChangeEvent {
205
+ action: 'connectionChange'
206
+ online: boolean
142
207
  isError?: boolean
143
208
  message?: MessageInfo
144
209
  }
145
210
 
146
- // ClientInput: type for sendInput and updateLatestInput function without message_id and bot_interaction_id because backend set this values
147
- export type ClientInput = Omit<CoreInput, 'message_id' | 'bot_interaction_id'>
148
-
149
- export interface WebchatContextProps {
150
- addMessage: (message: WebchatMessage) => void
151
- closeWebview: () => Promise<void>
152
- getThemeProperty: (property: string, defaultValue?: any) => any
153
- openWebview: (webviewComponent: Webview, params?: any) => void
154
- resetUnreadMessages: () => void
155
- resolveCase: () => void
156
- sendAttachment: (attachment: File) => Promise<void>
157
- sendInput: (input: ClientInput) => Promise<void>
158
- sendPayload: (payload: string) => Promise<void>
159
- sendText: (text: string, payload?: string) => Promise<void>
160
- setIsInputFocused: (isInputFocused: boolean) => void
161
- setLastMessageVisible: (isLastMessageVisible: boolean) => void
162
- theme: ThemeProps
163
- toggleWebchat: (toggle: boolean) => void
164
- toggleEmojiPicker: (toggle: boolean) => void
165
- togglePersistentMenu: (toggle: boolean) => void
166
- toggleCoverComponent: (toggle: boolean) => void
167
- updateLatestInput: (input: ClientInput) => void
168
- updateMessage: (message: WebchatMessage) => void
169
- updateReplies: (replies: boolean) => void
170
- updateUser: (user: Partial<CoreSessionUser>) => void
171
- updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
172
- webchatState: WebchatState
173
- trackEvent: TrackEventFunction
174
- webchatRef: React.MutableRefObject<HTMLDivElement | null>
175
- chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
176
- inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
177
- headerRef: React.MutableRefObject<HTMLDivElement | null>
178
- scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
179
- repliesRef: React.MutableRefObject<HTMLDivElement | null>
211
+ interface UpdateMessageInfoEvent {
212
+ action: 'update_message_info'
213
+ message: MessageInfo
214
+ isError?: boolean
180
215
  }
package/src/index.ts CHANGED
@@ -1,15 +1,11 @@
1
1
  export { BotonicInputTester, BotonicOutputTester } from './botonic-tester'
2
2
  export * from './components'
3
- export {
4
- RequestContext,
5
- WebchatContext,
6
- WebviewRequestContext,
7
- } from './contexts'
3
+ export { RequestContext, WebviewRequestContext } from './contexts'
8
4
  export { DevApp } from './dev-app'
9
5
  export * from './index-types'
10
6
  export { msgsToBotonic, msgToBotonic } from './msg-to-botonic'
11
7
  export { NodeApp } from './node-app'
12
8
  export * from './util'
13
9
  export * from './webchat'
14
- export { WebchatApp, WebchatAppProps } from './webchat-app'
10
+ export { WebchatApp } from './webchat-app'
15
11
  export { WebviewApp } from './webview-app'
@@ -32,7 +32,7 @@ import {
32
32
  * @param customMessageTypes {{customTypeName}[]?}
33
33
  * @return {React.ReactNode}
34
34
  */
35
- export function msgToBotonic(msg, customMessageTypes) {
35
+ export function msgToBotonic(msg, customMessageTypes = []) {
36
36
  delete msg.display
37
37
  if (isCustom(msg)) {
38
38
  try {
@@ -56,28 +56,28 @@ export function msgToBotonic(msg, customMessageTypes) {
56
56
  <Image
57
57
  key={msg.key}
58
58
  {...msg}
59
- src={msg.data.image != undefined ? msg.data.image : msg.data}
59
+ src={msg.data.image !== undefined ? msg.data.image : msg.data}
60
60
  />
61
61
  )
62
62
  } else if (isVideo(msg)) {
63
63
  return (
64
64
  <Video
65
65
  {...msg}
66
- src={msg.data.video != undefined ? msg.data.video : msg.data}
66
+ src={msg.data.video !== undefined ? msg.data.video : msg.data}
67
67
  />
68
68
  )
69
69
  } else if (isAudio(msg)) {
70
70
  return (
71
71
  <Audio
72
72
  {...msg}
73
- src={msg.data.audio != undefined ? msg.data.audio : msg.data}
73
+ src={msg.data.audio !== undefined ? msg.data.audio : msg.data}
74
74
  />
75
75
  )
76
76
  } else if (isDocument(msg)) {
77
77
  return (
78
78
  <Document
79
79
  {...msg}
80
- src={msg.data.document != undefined ? msg.data.document : msg.data}
80
+ src={msg.data.document !== undefined ? msg.data.document : msg.data}
81
81
  />
82
82
  )
83
83
  } else if (isLocation(msg)) {
@@ -99,10 +99,6 @@ export function msgToBotonic(msg, customMessageTypes) {
99
99
  return null
100
100
  }
101
101
 
102
- function rndStr() {
103
- return Math.random().toString()
104
- }
105
-
106
102
  /**
107
103
  * @param msgs {object|object[]}
108
104
  * @param customMessageTypes {{customTypeName}[]?}
@@ -3,6 +3,7 @@ import UAParser from 'ua-parser-js'
3
3
  import { v7 as uuidv7 } from 'uuid'
4
4
 
5
5
  import { WEBCHAT } from '../constants'
6
+ import { ThemeProps } from '../webchat/theme/types'
6
7
  import { getProperty } from './objects'
7
8
 
8
9
  /**
@@ -11,13 +12,12 @@ import { getProperty } from './objects'
11
12
  * If property doesn't exist, returns the defaultValue.
12
13
  */
13
14
  export const _getThemeProperty =
14
- theme =>
15
- (property, defaultValue = undefined) => {
16
- for (const [k, v] of Object.entries(WEBCHAT.CUSTOM_PROPERTIES)) {
17
- if (v == property) {
18
- const nestedProperty = getProperty(theme, v)
15
+ (theme: ThemeProps) => (property: string, defaultValue?: any) => {
16
+ for (const [key, value] of Object.entries(WEBCHAT.CUSTOM_PROPERTIES)) {
17
+ if (value === property) {
18
+ const nestedProperty = getProperty(theme, value)
19
19
  if (nestedProperty !== undefined) return nestedProperty
20
- const plainProperty = getProperty(theme, k)
20
+ const plainProperty = getProperty(theme, key)
21
21
  if (plainProperty !== undefined) return plainProperty
22
22
  return defaultValue
23
23
  }
@@ -25,7 +25,10 @@ export const _getThemeProperty =
25
25
  return undefined
26
26
  }
27
27
 
28
- export const createUser = () => {
28
+ export const createUser = (): {
29
+ id: string
30
+ name: string
31
+ } => {
29
32
  const parser = new UAParser()
30
33
  const ua = parser.getResult()
31
34
  let name = `${ua.os.name} ${ua.browser.name}`
@@ -35,9 +38,11 @@ export const createUser = () => {
35
38
  name,
36
39
  }
37
40
  }
38
- export const initSession = session => {
41
+ export const initSession = (
42
+ session: any
43
+ ): { user: { id: string; name: string } } => {
39
44
  if (!session) session = {}
40
- const hasUserId = session.user && session.user.id !== undefined
45
+ const hasUserId = session?.user?.id !== undefined
41
46
  if (!session.user || Object.keys(session.user).length === 0 || !hasUserId)
42
47
  session.user = !hasUserId ? merge(session.user, createUser()) : createUser()
43
48
  return session
@@ -48,6 +53,7 @@ export const shouldKeepSessionOnReload = ({
48
53
  devSettings,
49
54
  }) => !initialDevSettings || (devSettings && devSettings.keepSessionOnReload)
50
55
 
56
+ //TODO: Review param serverConfig if is of type ServerConfig this never have errorMessage
51
57
  export const getServerErrorMessage = serverConfig => {
52
58
  if (!serverConfig || !serverConfig.errorMessage) return 'Connection issues'
53
59
  if (typeof serverConfig.errorMessage === 'function') {
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useEffect, useState } from 'react'
2
2
 
3
- import { WebchatContext } from '../../contexts'
4
3
  import { BotonicContainerId } from '../constants'
4
+ import { WebchatContext } from '../context'
5
5
  import { useWebchatDimensions } from '../hooks'
6
6
  import { WebchatMessageList } from '../message-list'
7
7
  import { WebchatReplies } from '../replies'
@@ -27,9 +27,7 @@ export const ChatArea = () => {
27
27
  height={chatAreaHeight}
28
28
  >
29
29
  <WebchatMessageList />
30
- {replies && Object.keys(replies).length > 0 && (
31
- <WebchatReplies replies={replies} />
32
- )}
30
+ {replies && replies.length > 0 && <WebchatReplies />}
33
31
  </StyledChatArea>
34
32
  )
35
33
  }
@@ -1,9 +1,9 @@
1
1
  import React, { useContext } from 'react'
2
2
 
3
3
  import { WEBCHAT } from '../../constants'
4
- import { WebchatContext } from '../../contexts'
5
4
  import { Scale } from '../../shared/styles'
6
5
  import { ConditionalWrapper } from '../../util/react'
6
+ import { WebchatContext } from '../context'
7
7
 
8
8
  export const ConditionalAnimation = props => {
9
9
  const { getThemeProperty } = useContext(WebchatContext)
@@ -3,7 +3,7 @@ import styled from 'styled-components'
3
3
 
4
4
  import { Button } from '../../components/button'
5
5
  import { ROLES, WEBCHAT } from '../../constants'
6
- import { WebchatContext } from '../../contexts'
6
+ import { WebchatContext } from '../context'
7
7
  import { useComponentVisible } from '../hooks'
8
8
 
9
9
  const ButtonsContainer = styled.div`
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
1
2
  export enum WebchatAction {
2
3
  ADD_MESSAGE = 'addMessage',
3
4
  ADD_MESSAGE_COMPONENT = 'addMessageComponent',
@@ -23,5 +24,7 @@ export enum WebchatAction {
23
24
  UPDATE_THEME = 'updateTheme',
24
25
  UPDATE_TYPING = 'updateTyping',
25
26
  UPDATE_WEBVIEW = 'updateWebview',
27
+ REMOVE_REPLIES = 'removeReplies',
28
+ REMOVE_WEBVIEW = 'removeWebview',
26
29
  SET_IS_INPUT_FOCUSED = 'setIsInputFocused',
27
30
  }
@@ -0,0 +1,81 @@
1
+ import { createContext } from 'react'
2
+
3
+ import { WebchatContextProps } from './types'
4
+ import { webchatInitialState } from './use-webchat'
5
+
6
+ export { WebchatState } from './types'
7
+ export { useWebchat, webchatInitialState } from './use-webchat'
8
+
9
+ export const WebchatContext = createContext<WebchatContextProps>({
10
+ addMessage: () => {
11
+ return
12
+ },
13
+ getThemeProperty: () => {
14
+ return
15
+ }, // used to retrieve a specific property of the theme defined by the developer in his 'webchat/index.js'
16
+ openWebview: () => {
17
+ return
18
+ },
19
+ resolveCase: () => {
20
+ return
21
+ },
22
+ resetUnreadMessages: () => {
23
+ return
24
+ },
25
+ setIsInputFocused: () => {
26
+ return
27
+ },
28
+ setLastMessageVisible: () => {
29
+ return
30
+ },
31
+ sendAttachment: async () => {
32
+ return
33
+ },
34
+ sendInput: async () => {
35
+ return
36
+ },
37
+ sendPayload: async () => {
38
+ return
39
+ },
40
+ sendText: async () => {
41
+ return
42
+ },
43
+ theme: {}, // TODO: Remove this attribute and use allways webchatState.theme
44
+ toggleCoverComponent: () => {
45
+ return
46
+ },
47
+ toggleWebchat: () => {
48
+ return
49
+ },
50
+ toggleEmojiPicker: () => {
51
+ return
52
+ },
53
+ togglePersistentMenu: () => {
54
+ return
55
+ },
56
+ updateLatestInput: () => {
57
+ return
58
+ },
59
+ updateMessage: () => {
60
+ return
61
+ },
62
+ updateReplies: () => {
63
+ return
64
+ },
65
+ updateUser: () => {
66
+ return
67
+ },
68
+ updateWebchatDevSettings: () => {
69
+ return
70
+ },
71
+ webchatState: webchatInitialState,
72
+ trackEvent: async () => {
73
+ return
74
+ },
75
+ webchatRef: { current: null },
76
+ chatAreaRef: { current: null },
77
+ inputPanelRef: { current: null },
78
+ headerRef: { current: null },
79
+ scrollableMessagesListRef: { current: null },
80
+ repliesRef: { current: null },
81
+ })
@@ -1,6 +1,6 @@
1
- import { SENDERS } from '../index-types'
1
+ import { SENDERS } from '../../index-types'
2
2
  import { WebchatAction } from './actions'
3
- import { WebchatState } from './index-types'
3
+ import { WebchatState } from './types'
4
4
 
5
5
  export const messagesReducer = (
6
6
  state: WebchatState,
@@ -15,6 +15,8 @@ export const messagesReducer = (
15
15
  return updateMessageReducer(state, action)
16
16
  case WebchatAction.UPDATE_REPLIES:
17
17
  return { ...state, replies: action.payload }
18
+ case WebchatAction.REMOVE_REPLIES:
19
+ return { ...state, replies: undefined }
18
20
  case WebchatAction.CLEAR_MESSAGES:
19
21
  return {
20
22
  ...state,
@@ -0,0 +1,84 @@
1
+ import {
2
+ Input as CoreInput,
3
+ Session as CoreSession,
4
+ SessionUser as CoreSessionUser,
5
+ } from '@botonic/core'
6
+
7
+ import { Reply, WebchatSettingsProps, Webview } from '../../components'
8
+ import { TrackEventFunction, WebchatMessage } from '../../index-types'
9
+ import { WebchatStateTheme } from '../index-types'
10
+ import { ThemeProps } from '../theme/types'
11
+
12
+ export interface ErrorMessage {
13
+ message?: string
14
+ }
15
+
16
+ export interface DevSettings {
17
+ keepSessionOnReload?: boolean
18
+ showSessionView?: boolean
19
+ }
20
+
21
+ export interface WebchatState {
22
+ width: number // TODO: move this inside webchatState.theme.style
23
+ height: number // TODO: move this inside webchatState.theme.style
24
+ messagesJSON: any[]
25
+ messagesComponents: any[]
26
+ replies?: (typeof Reply)[]
27
+ latestInput: Partial<CoreInput>
28
+ typing: boolean
29
+ webview: Webview | null
30
+ webviewParams: null
31
+ session: Partial<CoreSession>
32
+ lastRoutePath?: string
33
+ handoff: boolean
34
+ theme: WebchatStateTheme // TODO: type this as ThemeProps
35
+ themeUpdates: Partial<WebchatStateTheme> // TODO: type this as Partial<ThemeProps>
36
+ error: ErrorMessage
37
+ online: boolean
38
+ devSettings: DevSettings
39
+ isWebchatOpen: boolean
40
+ isEmojiPickerOpen: boolean
41
+ isPersistentMenuOpen: boolean
42
+ isCoverComponentOpen: boolean
43
+ isCustomComponentRendered: boolean
44
+ lastMessageUpdate?: string
45
+ currentAttachment?: File
46
+ numUnreadMessages: number
47
+ isLastMessageVisible: boolean
48
+ isInputFocused: boolean
49
+ }
50
+
51
+ // ClientInput: type for sendInput and updateLatestInput function without message_id and bot_interaction_id because backend set this values
52
+ export type ClientInput = Omit<CoreInput, 'message_id' | 'bot_interaction_id'>
53
+
54
+ export interface WebchatContextProps {
55
+ addMessage: (message: WebchatMessage) => void
56
+ getThemeProperty: (property: string, defaultValue?: any) => any
57
+ openWebview: (webviewComponent: Webview, params?: any) => void
58
+ resetUnreadMessages: () => void
59
+ resolveCase: () => void
60
+ sendAttachment: (attachment: File) => Promise<void>
61
+ sendInput: (input: ClientInput) => Promise<void>
62
+ sendPayload: (payload: string) => Promise<void>
63
+ sendText: (text: string, payload?: string) => Promise<void>
64
+ setIsInputFocused: (isInputFocused: boolean) => void
65
+ setLastMessageVisible: (isLastMessageVisible: boolean) => void
66
+ theme: ThemeProps // TODO: Remove this attribute and use allways webchatState.theme
67
+ toggleWebchat: (toggle: boolean) => void
68
+ toggleEmojiPicker: (toggle: boolean) => void
69
+ togglePersistentMenu: (toggle: boolean) => void
70
+ toggleCoverComponent: (toggle: boolean) => void
71
+ updateLatestInput: (input: ClientInput) => void
72
+ updateMessage: (message: WebchatMessage) => void
73
+ updateReplies: (replies: (typeof Reply)[]) => void
74
+ updateUser: (user: Partial<CoreSessionUser>) => void
75
+ updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
76
+ trackEvent?: TrackEventFunction
77
+ webchatState: WebchatState
78
+ webchatRef: React.MutableRefObject<HTMLDivElement | null> // Rename this to webchatContainerRef
79
+ chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
80
+ inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
81
+ headerRef: React.MutableRefObject<HTMLDivElement | null>
82
+ scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
83
+ repliesRef: React.MutableRefObject<HTMLDivElement | null>
84
+ }