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

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 (399) 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 +33 -4
  20. package/lib/cjs/components/message/index.js +2 -1
  21. package/lib/cjs/components/message/index.js.map +1 -1
  22. package/lib/cjs/components/message/message-feedback.js +2 -2
  23. package/lib/cjs/components/message/message-feedback.js.map +1 -1
  24. package/lib/cjs/components/message/message-footer.js +2 -2
  25. package/lib/cjs/components/message/message-footer.js.map +1 -1
  26. package/lib/cjs/components/message/message-image.js +2 -2
  27. package/lib/cjs/components/message/message-image.js.map +1 -1
  28. package/lib/cjs/components/message/timestamps.js +2 -2
  29. package/lib/cjs/components/message/timestamps.js.map +1 -1
  30. package/lib/cjs/components/reply.d.ts +7 -6
  31. package/lib/cjs/components/reply.js +10 -6
  32. package/lib/cjs/components/reply.js.map +1 -1
  33. package/lib/cjs/components/video.d.ts +8 -7
  34. package/lib/cjs/components/video.js +2 -3
  35. package/lib/cjs/components/video.js.map +1 -1
  36. package/lib/cjs/components/webchat-settings.d.ts +1 -1
  37. package/lib/cjs/components/webchat-settings.js +2 -2
  38. package/lib/cjs/components/webchat-settings.js.map +1 -1
  39. package/lib/cjs/contexts.d.ts +3 -4
  40. package/lib/cjs/contexts.js +2 -79
  41. package/lib/cjs/contexts.js.map +1 -1
  42. package/lib/cjs/index-types.d.ts +87 -55
  43. package/lib/cjs/index-types.js.map +1 -1
  44. package/lib/cjs/index.d.ts +2 -2
  45. package/lib/cjs/index.js +1 -2
  46. package/lib/cjs/index.js.map +1 -1
  47. package/lib/cjs/msg-to-botonic.d.ts +1 -1
  48. package/lib/cjs/msg-to-botonic.js +5 -8
  49. package/lib/cjs/msg-to-botonic.js.map +1 -1
  50. package/lib/cjs/util/webchat.d.ts +17 -6
  51. package/lib/cjs/util/webchat.js +9 -7
  52. package/lib/cjs/util/webchat.js.map +1 -1
  53. package/lib/cjs/webchat/chat-area/index.js +3 -3
  54. package/lib/cjs/webchat/chat-area/index.js.map +1 -1
  55. package/lib/cjs/webchat/components/conditional-animation.js +2 -2
  56. package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
  57. package/lib/cjs/webchat/components/opened-persistent-menu.js +2 -2
  58. package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -1
  59. package/lib/cjs/webchat/{actions.d.ts → context/actions.d.ts} +2 -0
  60. package/lib/cjs/webchat/{actions.js → context/actions.js} +3 -0
  61. package/lib/cjs/webchat/context/actions.js.map +1 -0
  62. package/lib/cjs/webchat/context/index.d.ts +5 -0
  63. package/lib/cjs/webchat/context/index.js +83 -0
  64. package/lib/cjs/webchat/context/index.js.map +1 -0
  65. package/lib/cjs/webchat/{messages-reducer.d.ts → context/messages-reducer.d.ts} +1 -1
  66. package/lib/cjs/webchat/{messages-reducer.js → context/messages-reducer.js} +3 -1
  67. package/lib/cjs/webchat/context/messages-reducer.js.map +1 -0
  68. package/lib/cjs/webchat/context/types.d.ts +74 -0
  69. package/lib/cjs/webchat/context/types.js +3 -0
  70. package/lib/cjs/webchat/context/types.js.map +1 -0
  71. package/lib/cjs/webchat/{hooks → context}/use-webchat.d.ts +18 -19
  72. package/lib/cjs/webchat/{hooks → context}/use-webchat.js +10 -5
  73. package/lib/cjs/webchat/context/use-webchat.js.map +1 -0
  74. package/lib/cjs/webchat/{webchat-reducer.d.ts → context/webchat-reducer.d.ts} +1 -1
  75. package/lib/cjs/webchat/{webchat-reducer.js → context/webchat-reducer.js} +2 -0
  76. package/lib/cjs/webchat/context/webchat-reducer.js.map +1 -0
  77. package/lib/cjs/webchat/cover-component/index.js +2 -2
  78. package/lib/cjs/webchat/cover-component/index.js.map +1 -1
  79. package/lib/cjs/webchat/header/default-header.d.ts +1 -0
  80. package/lib/cjs/webchat/header/default-header.js +25 -0
  81. package/lib/cjs/webchat/header/default-header.js.map +1 -0
  82. package/lib/cjs/webchat/header/index.d.ts +2 -0
  83. package/lib/cjs/webchat/header/index.js +23 -0
  84. package/lib/cjs/webchat/header/index.js.map +1 -0
  85. package/lib/cjs/webchat/header/styles.d.ts +7 -0
  86. package/lib/cjs/webchat/header/styles.js +59 -0
  87. package/lib/cjs/webchat/header/styles.js.map +1 -0
  88. package/lib/cjs/webchat/hooks/index.d.ts +0 -1
  89. package/lib/cjs/webchat/hooks/index.js +1 -4
  90. package/lib/cjs/webchat/hooks/index.js.map +1 -1
  91. package/lib/cjs/webchat/hooks/use-previous.d.ts +1 -1
  92. package/lib/cjs/webchat/hooks/use-previous.js.map +1 -1
  93. package/lib/cjs/webchat/hooks/use-scrollbar-controller.js +3 -3
  94. package/lib/cjs/webchat/hooks/use-scrollbar-controller.js.map +1 -1
  95. package/lib/cjs/webchat/hooks/use-typing.d.ts +1 -1
  96. package/lib/cjs/webchat/hooks/use-webchat-dimensions.js +2 -2
  97. package/lib/cjs/webchat/hooks/use-webchat-dimensions.js.map +1 -1
  98. package/lib/cjs/webchat/hooks/use-webchat-resizer.js +2 -2
  99. package/lib/cjs/webchat/hooks/use-webchat-resizer.js.map +1 -1
  100. package/lib/cjs/webchat/index-types.d.ts +3 -44
  101. package/lib/cjs/webchat/index.d.ts +1 -0
  102. package/lib/cjs/webchat/index.js +3 -1
  103. package/lib/cjs/webchat/index.js.map +1 -1
  104. package/lib/cjs/webchat/input-panel/attachment.d.ts +1 -1
  105. package/lib/cjs/webchat/input-panel/attachment.js +2 -2
  106. package/lib/cjs/webchat/input-panel/attachment.js.map +1 -1
  107. package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -1
  108. package/lib/cjs/webchat/input-panel/emoji-picker.js +2 -2
  109. package/lib/cjs/webchat/input-panel/emoji-picker.js.map +1 -1
  110. package/lib/cjs/webchat/input-panel/index.d.ts +3 -3
  111. package/lib/cjs/webchat/input-panel/index.js +8 -3
  112. package/lib/cjs/webchat/input-panel/index.js.map +1 -1
  113. package/lib/cjs/webchat/input-panel/persistent-menu.js +2 -2
  114. package/lib/cjs/webchat/input-panel/persistent-menu.js.map +1 -1
  115. package/lib/cjs/webchat/input-panel/send-button.js +2 -2
  116. package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
  117. package/lib/cjs/webchat/input-panel/textarea.d.ts +1 -1
  118. package/lib/cjs/webchat/input-panel/textarea.js +4 -2
  119. package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
  120. package/lib/cjs/webchat/message-list/index.js +5 -7
  121. package/lib/cjs/webchat/message-list/index.js.map +1 -1
  122. package/lib/cjs/webchat/message-list/intro-message.js +2 -2
  123. package/lib/cjs/webchat/message-list/intro-message.js.map +1 -1
  124. package/lib/cjs/webchat/message-list/styles.js +1 -0
  125. package/lib/cjs/webchat/message-list/styles.js.map +1 -1
  126. package/lib/cjs/webchat/message-list/unread-messages-banner.js +2 -2
  127. package/lib/cjs/webchat/message-list/unread-messages-banner.js.map +1 -1
  128. package/lib/cjs/webchat/message-list/use-notifications.js +2 -2
  129. package/lib/cjs/webchat/message-list/use-notifications.js.map +1 -1
  130. package/lib/cjs/webchat/replies/index.d.ts +1 -0
  131. package/lib/cjs/webchat/replies/index.js +32 -0
  132. package/lib/cjs/webchat/replies/index.js.map +1 -0
  133. package/lib/cjs/webchat/replies/styles.d.ts +8 -0
  134. package/lib/cjs/webchat/replies/styles.js +25 -0
  135. package/lib/cjs/webchat/replies/styles.js.map +1 -0
  136. package/lib/cjs/webchat/session-view.js +2 -2
  137. package/lib/cjs/webchat/session-view.js.map +1 -1
  138. package/lib/cjs/webchat/{webchat-typed/styles.d.ts → styles.d.ts} +6 -4
  139. package/lib/cjs/webchat/{webchat-typed/styles.js → styles.js} +1 -1
  140. package/lib/cjs/webchat/styles.js.map +1 -0
  141. package/lib/cjs/webchat/trigger-button/index.js +2 -2
  142. package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
  143. package/lib/cjs/webchat/webchat-dev.js +2 -2
  144. package/lib/cjs/webchat/webchat-dev.js.map +1 -1
  145. package/lib/cjs/webchat/webchat.d.ts +4 -2
  146. package/lib/cjs/webchat/webchat.js +82 -103
  147. package/lib/cjs/webchat/webchat.js.map +1 -1
  148. package/lib/cjs/webchat/webview.js +3 -2
  149. package/lib/cjs/webchat/webview.js.map +1 -1
  150. package/lib/cjs/webchat-app.d.ts +11 -78
  151. package/lib/cjs/webchat-app.js +28 -14
  152. package/lib/cjs/webchat-app.js.map +1 -1
  153. package/lib/esm/components/audio.d.ts +8 -7
  154. package/lib/esm/components/audio.js +7 -4
  155. package/lib/esm/components/audio.js.map +1 -1
  156. package/lib/esm/components/button.js +2 -3
  157. package/lib/esm/components/button.js.map +1 -1
  158. package/lib/esm/components/carousel.js +1 -1
  159. package/lib/esm/components/carousel.js.map +1 -1
  160. package/lib/esm/components/custom-message.d.ts +16 -12
  161. package/lib/esm/components/custom-message.js +3 -9
  162. package/lib/esm/components/custom-message.js.map +1 -1
  163. package/lib/esm/components/document.d.ts +8 -7
  164. package/lib/esm/components/document.js +4 -4
  165. package/lib/esm/components/document.js.map +1 -1
  166. package/lib/esm/components/handoff.js +1 -1
  167. package/lib/esm/components/handoff.js.map +1 -1
  168. package/lib/esm/components/image.d.ts +8 -7
  169. package/lib/esm/components/image.js +4 -4
  170. package/lib/esm/components/image.js.map +1 -1
  171. package/lib/esm/components/index-types.d.ts +33 -4
  172. package/lib/esm/components/message/index.js +2 -1
  173. package/lib/esm/components/message/index.js.map +1 -1
  174. package/lib/esm/components/message/message-feedback.js +1 -1
  175. package/lib/esm/components/message/message-feedback.js.map +1 -1
  176. package/lib/esm/components/message/message-footer.js +1 -1
  177. package/lib/esm/components/message/message-footer.js.map +1 -1
  178. package/lib/esm/components/message/message-image.js +1 -1
  179. package/lib/esm/components/message/message-image.js.map +1 -1
  180. package/lib/esm/components/message/timestamps.js +1 -1
  181. package/lib/esm/components/message/timestamps.js.map +1 -1
  182. package/lib/esm/components/reply.d.ts +7 -6
  183. package/lib/esm/components/reply.js +9 -5
  184. package/lib/esm/components/reply.js.map +1 -1
  185. package/lib/esm/components/video.d.ts +8 -7
  186. package/lib/esm/components/video.js +2 -3
  187. package/lib/esm/components/video.js.map +1 -1
  188. package/lib/esm/components/webchat-settings.d.ts +1 -1
  189. package/lib/esm/components/webchat-settings.js +1 -1
  190. package/lib/esm/components/webchat-settings.js.map +1 -1
  191. package/lib/esm/contexts.d.ts +3 -4
  192. package/lib/esm/contexts.js +1 -78
  193. package/lib/esm/contexts.js.map +1 -1
  194. package/lib/esm/index-types.d.ts +87 -55
  195. package/lib/esm/index-types.js.map +1 -1
  196. package/lib/esm/index.d.ts +2 -2
  197. package/lib/esm/index.js +1 -1
  198. package/lib/esm/index.js.map +1 -1
  199. package/lib/esm/msg-to-botonic.d.ts +1 -1
  200. package/lib/esm/msg-to-botonic.js +5 -8
  201. package/lib/esm/msg-to-botonic.js.map +1 -1
  202. package/lib/esm/util/webchat.d.ts +17 -6
  203. package/lib/esm/util/webchat.js +9 -7
  204. package/lib/esm/util/webchat.js.map +1 -1
  205. package/lib/esm/webchat/chat-area/index.js +2 -2
  206. package/lib/esm/webchat/chat-area/index.js.map +1 -1
  207. package/lib/esm/webchat/components/conditional-animation.js +1 -1
  208. package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
  209. package/lib/esm/webchat/components/opened-persistent-menu.js +1 -1
  210. package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -1
  211. package/lib/esm/webchat/{actions.d.ts → context/actions.d.ts} +2 -0
  212. package/lib/esm/webchat/{actions.js → context/actions.js} +3 -0
  213. package/lib/esm/webchat/context/actions.js.map +1 -0
  214. package/lib/esm/webchat/context/index.d.ts +5 -0
  215. package/lib/esm/webchat/context/index.js +78 -0
  216. package/lib/esm/webchat/context/index.js.map +1 -0
  217. package/lib/esm/webchat/{messages-reducer.d.ts → context/messages-reducer.d.ts} +1 -1
  218. package/lib/esm/webchat/{messages-reducer.js → context/messages-reducer.js} +3 -1
  219. package/lib/esm/webchat/context/messages-reducer.js.map +1 -0
  220. package/lib/esm/webchat/context/types.d.ts +74 -0
  221. package/lib/esm/webchat/context/types.js +2 -0
  222. package/lib/esm/webchat/context/types.js.map +1 -0
  223. package/lib/esm/webchat/{hooks → context}/use-webchat.d.ts +18 -19
  224. package/lib/esm/webchat/{hooks → context}/use-webchat.js +10 -5
  225. package/lib/esm/webchat/context/use-webchat.js.map +1 -0
  226. package/lib/esm/webchat/{webchat-reducer.d.ts → context/webchat-reducer.d.ts} +1 -1
  227. package/lib/esm/webchat/{webchat-reducer.js → context/webchat-reducer.js} +2 -0
  228. package/lib/esm/webchat/context/webchat-reducer.js.map +1 -0
  229. package/lib/esm/webchat/cover-component/index.js +1 -1
  230. package/lib/esm/webchat/cover-component/index.js.map +1 -1
  231. package/lib/esm/webchat/header/default-header.d.ts +1 -0
  232. package/lib/esm/webchat/header/default-header.js +21 -0
  233. package/lib/esm/webchat/header/default-header.js.map +1 -0
  234. package/lib/esm/webchat/header/index.d.ts +2 -0
  235. package/lib/esm/webchat/header/index.js +20 -0
  236. package/lib/esm/webchat/header/index.js.map +1 -0
  237. package/lib/esm/webchat/header/styles.d.ts +7 -0
  238. package/lib/esm/webchat/header/styles.js +55 -0
  239. package/lib/esm/webchat/header/styles.js.map +1 -0
  240. package/lib/esm/webchat/hooks/index.d.ts +0 -1
  241. package/lib/esm/webchat/hooks/index.js +0 -1
  242. package/lib/esm/webchat/hooks/index.js.map +1 -1
  243. package/lib/esm/webchat/hooks/use-previous.d.ts +1 -1
  244. package/lib/esm/webchat/hooks/use-previous.js.map +1 -1
  245. package/lib/esm/webchat/hooks/use-scrollbar-controller.js +2 -2
  246. package/lib/esm/webchat/hooks/use-scrollbar-controller.js.map +1 -1
  247. package/lib/esm/webchat/hooks/use-typing.d.ts +1 -1
  248. package/lib/esm/webchat/hooks/use-webchat-dimensions.js +1 -1
  249. package/lib/esm/webchat/hooks/use-webchat-dimensions.js.map +1 -1
  250. package/lib/esm/webchat/hooks/use-webchat-resizer.js +1 -1
  251. package/lib/esm/webchat/hooks/use-webchat-resizer.js.map +1 -1
  252. package/lib/esm/webchat/index-types.d.ts +3 -44
  253. package/lib/esm/webchat/index.d.ts +1 -0
  254. package/lib/esm/webchat/index.js +1 -0
  255. package/lib/esm/webchat/index.js.map +1 -1
  256. package/lib/esm/webchat/input-panel/attachment.d.ts +1 -1
  257. package/lib/esm/webchat/input-panel/attachment.js +1 -1
  258. package/lib/esm/webchat/input-panel/attachment.js.map +1 -1
  259. package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -1
  260. package/lib/esm/webchat/input-panel/emoji-picker.js +1 -1
  261. package/lib/esm/webchat/input-panel/emoji-picker.js.map +1 -1
  262. package/lib/esm/webchat/input-panel/index.d.ts +3 -3
  263. package/lib/esm/webchat/input-panel/index.js +7 -2
  264. package/lib/esm/webchat/input-panel/index.js.map +1 -1
  265. package/lib/esm/webchat/input-panel/persistent-menu.js +1 -1
  266. package/lib/esm/webchat/input-panel/persistent-menu.js.map +1 -1
  267. package/lib/esm/webchat/input-panel/send-button.js +1 -1
  268. package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
  269. package/lib/esm/webchat/input-panel/textarea.d.ts +1 -1
  270. package/lib/esm/webchat/input-panel/textarea.js +3 -1
  271. package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
  272. package/lib/esm/webchat/message-list/index.js +4 -6
  273. package/lib/esm/webchat/message-list/index.js.map +1 -1
  274. package/lib/esm/webchat/message-list/intro-message.js +1 -1
  275. package/lib/esm/webchat/message-list/intro-message.js.map +1 -1
  276. package/lib/esm/webchat/message-list/styles.js +1 -0
  277. package/lib/esm/webchat/message-list/styles.js.map +1 -1
  278. package/lib/esm/webchat/message-list/unread-messages-banner.js +1 -1
  279. package/lib/esm/webchat/message-list/unread-messages-banner.js.map +1 -1
  280. package/lib/esm/webchat/message-list/use-notifications.js +1 -1
  281. package/lib/esm/webchat/message-list/use-notifications.js.map +1 -1
  282. package/lib/esm/webchat/replies/index.d.ts +1 -0
  283. package/lib/esm/webchat/replies/index.js +28 -0
  284. package/lib/esm/webchat/replies/index.js.map +1 -0
  285. package/lib/esm/webchat/replies/styles.d.ts +8 -0
  286. package/lib/esm/webchat/replies/styles.js +21 -0
  287. package/lib/esm/webchat/replies/styles.js.map +1 -0
  288. package/lib/esm/webchat/session-view.js +1 -1
  289. package/lib/esm/webchat/session-view.js.map +1 -1
  290. package/lib/esm/webchat/{webchat-typed/styles.d.ts → styles.d.ts} +6 -4
  291. package/lib/esm/webchat/{webchat-typed/styles.js → styles.js} +1 -1
  292. package/lib/esm/webchat/styles.js.map +1 -0
  293. package/lib/esm/webchat/trigger-button/index.js +1 -1
  294. package/lib/esm/webchat/trigger-button/index.js.map +1 -1
  295. package/lib/esm/webchat/webchat-dev.js +1 -1
  296. package/lib/esm/webchat/webchat-dev.js.map +1 -1
  297. package/lib/esm/webchat/webchat.d.ts +4 -2
  298. package/lib/esm/webchat/webchat.js +81 -102
  299. package/lib/esm/webchat/webchat.js.map +1 -1
  300. package/lib/esm/webchat/webview.js +2 -1
  301. package/lib/esm/webchat/webview.js.map +1 -1
  302. package/lib/esm/webchat-app.d.ts +11 -78
  303. package/lib/esm/webchat-app.js +28 -14
  304. package/lib/esm/webchat-app.js.map +1 -1
  305. package/package.json +2 -1
  306. package/src/components/{audio.jsx → audio.tsx} +10 -4
  307. package/src/components/button.tsx +1 -3
  308. package/src/components/carousel.jsx +1 -1
  309. package/src/components/{custom-message.jsx → custom-message.tsx} +19 -7
  310. package/src/components/{document.jsx → document.tsx} +5 -3
  311. package/src/components/handoff.jsx +1 -1
  312. package/src/components/{image.jsx → image.tsx} +10 -4
  313. package/src/components/index-types.ts +29 -4
  314. package/src/components/message/index.jsx +2 -1
  315. package/src/components/message/message-feedback.tsx +1 -1
  316. package/src/components/message/message-footer.tsx +1 -1
  317. package/src/components/message/message-image.tsx +1 -1
  318. package/src/components/message/timestamps.tsx +1 -1
  319. package/src/components/{reply.jsx → reply.tsx} +10 -4
  320. package/src/components/{video.jsx → video.tsx} +3 -2
  321. package/src/components/webchat-settings.tsx +2 -2
  322. package/src/contexts.tsx +5 -83
  323. package/src/index-types.ts +92 -59
  324. package/src/index.ts +2 -6
  325. package/src/msg-to-botonic.jsx +5 -9
  326. package/src/util/{webchat.js → webchat.ts} +15 -9
  327. package/src/webchat/chat-area/index.tsx +2 -4
  328. package/src/webchat/components/conditional-animation.jsx +1 -1
  329. package/src/webchat/components/opened-persistent-menu.jsx +1 -1
  330. package/src/webchat/{actions.ts → context/actions.ts} +3 -0
  331. package/src/webchat/context/index.tsx +81 -0
  332. package/src/webchat/{messages-reducer.ts → context/messages-reducer.ts} +4 -2
  333. package/src/webchat/context/types.ts +88 -0
  334. package/src/webchat/{hooks → context}/use-webchat.ts +59 -12
  335. package/src/webchat/{webchat-reducer.ts → context/webchat-reducer.ts} +3 -1
  336. package/src/webchat/cover-component/index.tsx +1 -1
  337. package/src/webchat/global.d.ts +3 -0
  338. package/src/webchat/header/default-header.tsx +75 -0
  339. package/src/webchat/header/index.tsx +37 -0
  340. package/src/webchat/header/styles.ts +62 -0
  341. package/src/webchat/hooks/index.ts +0 -1
  342. package/src/webchat/hooks/use-previous.ts +1 -1
  343. package/src/webchat/hooks/use-scrollbar-controller.ts +2 -2
  344. package/src/webchat/hooks/use-typing.ts +1 -1
  345. package/src/webchat/hooks/use-webchat-dimensions.ts +1 -1
  346. package/src/webchat/hooks/use-webchat-resizer.ts +1 -1
  347. package/src/webchat/index-types.ts +3 -49
  348. package/src/webchat/index.ts +1 -0
  349. package/src/webchat/input-panel/attachment.tsx +2 -2
  350. package/src/webchat/input-panel/emoji-picker.tsx +2 -2
  351. package/src/webchat/input-panel/index.tsx +9 -5
  352. package/src/webchat/input-panel/persistent-menu.tsx +1 -1
  353. package/src/webchat/input-panel/send-button.tsx +1 -1
  354. package/src/webchat/input-panel/textarea.tsx +4 -2
  355. package/src/webchat/message-list/index.tsx +4 -6
  356. package/src/webchat/message-list/intro-message.tsx +1 -1
  357. package/src/webchat/message-list/styles.ts +1 -0
  358. package/src/webchat/message-list/unread-messages-banner.tsx +1 -1
  359. package/src/webchat/message-list/use-notifications.ts +1 -1
  360. package/src/webchat/replies/index.tsx +47 -0
  361. package/src/webchat/replies/styles.ts +28 -0
  362. package/src/webchat/session-view.jsx +1 -1
  363. package/src/webchat/{webchat-typed/styles.ts → styles.ts} +7 -2
  364. package/src/webchat/trigger-button/index.tsx +1 -1
  365. package/src/webchat/webchat-dev.jsx +1 -1
  366. package/src/webchat/{webchat.jsx → webchat.tsx} +112 -122
  367. package/src/webchat/webview.jsx +2 -1
  368. package/src/webchat-app.tsx +48 -87
  369. package/lib/cjs/webchat/actions.js.map +0 -1
  370. package/lib/cjs/webchat/header.d.ts +0 -3
  371. package/lib/cjs/webchat/header.js +0 -86
  372. package/lib/cjs/webchat/header.js.map +0 -1
  373. package/lib/cjs/webchat/hooks/use-webchat.js.map +0 -1
  374. package/lib/cjs/webchat/messages-reducer.js.map +0 -1
  375. package/lib/cjs/webchat/replies.d.ts +0 -1
  376. package/lib/cjs/webchat/replies.js +0 -47
  377. package/lib/cjs/webchat/replies.js.map +0 -1
  378. package/lib/cjs/webchat/webchat-reducer.js.map +0 -1
  379. package/lib/cjs/webchat/webchat-typed/styles.js.map +0 -1
  380. package/lib/cjs/webchat/webchat-typed/webchat-typed.d.ts +0 -0
  381. package/lib/cjs/webchat/webchat-typed/webchat-typed.js +0 -663
  382. package/lib/cjs/webchat/webchat-typed/webchat-typed.js.map +0 -1
  383. package/lib/esm/webchat/actions.js.map +0 -1
  384. package/lib/esm/webchat/header.d.ts +0 -3
  385. package/lib/esm/webchat/header.js +0 -81
  386. package/lib/esm/webchat/header.js.map +0 -1
  387. package/lib/esm/webchat/hooks/use-webchat.js.map +0 -1
  388. package/lib/esm/webchat/messages-reducer.js.map +0 -1
  389. package/lib/esm/webchat/replies.d.ts +0 -1
  390. package/lib/esm/webchat/replies.js +0 -42
  391. package/lib/esm/webchat/replies.js.map +0 -1
  392. package/lib/esm/webchat/webchat-reducer.js.map +0 -1
  393. package/lib/esm/webchat/webchat-typed/styles.js.map +0 -1
  394. package/lib/esm/webchat/webchat-typed/webchat-typed.d.ts +0 -0
  395. package/lib/esm/webchat/webchat-typed/webchat-typed.js +0 -663
  396. package/lib/esm/webchat/webchat-typed/webchat-typed.js.map +0 -1
  397. package/src/webchat/header.jsx +0 -149
  398. package/src/webchat/replies.jsx +0 -64
  399. package/src/webchat/webchat-typed/webchat-typed.tsx +0 -728
@@ -1,12 +1,13 @@
1
- import { Input, Session } from '@botonic/core'
1
+ import { Session } from '@botonic/core'
2
2
  import { useReducer, useRef } from 'react'
3
3
 
4
+ import { Reply } from '../../components'
4
5
  import { ThemeProps, Webview } from '../../components/index-types'
5
6
  import { COLORS, WEBCHAT } from '../../constants'
6
- import { ClientInput, WebchatMessage } from '../../index-types'
7
- import { WebchatAction } from '../actions'
8
- import { DevSettings, ErrorMessage, WebchatState } from '../index-types'
9
- import { webchatReducer } from '../webchat-reducer'
7
+ import { WebchatMessage } from '../../index-types'
8
+ import { WebchatAction } from './actions'
9
+ import { ClientInput, DevSettings, ErrorMessage, WebchatState } from './types'
10
+ import { webchatReducer } from './webchat-reducer'
10
11
 
11
12
  export const webchatInitialState: WebchatState = {
12
13
  width: WEBCHAT.DEFAULTS.WIDTH,
@@ -19,7 +20,7 @@ export const webchatInitialState: WebchatState = {
19
20
  webview: null,
20
21
  webviewParams: null,
21
22
  session: { user: undefined },
22
- lastRoutePath: null,
23
+ lastRoutePath: undefined,
23
24
  handoff: false,
24
25
  theme: {
25
26
  headerTitle: WEBCHAT.DEFAULTS.TITLE,
@@ -47,7 +48,44 @@ export const webchatInitialState: WebchatState = {
47
48
  isInputFocused: false,
48
49
  }
49
50
 
50
- export function useWebchat() {
51
+ export interface UseWebchat {
52
+ addMessage: (message: WebchatMessage) => void
53
+ addMessageComponent: (message: { props: WebchatMessage }) => void
54
+ clearMessages: () => void
55
+ doRenderCustomComponent: (toggle: boolean) => void
56
+ resetUnreadMessages: () => void
57
+ setCurrentAttachment: (attachment?: File) => void
58
+ setError: (error?: ErrorMessage) => void
59
+ setIsInputFocused: (isInputFocused: boolean) => void
60
+ setLastMessageVisible: (isLastMessageVisible: boolean) => void
61
+ setOnline: (online: boolean) => void
62
+ toggleCoverComponent: (toggle: boolean) => void
63
+ toggleEmojiPicker: (toggle: boolean) => void
64
+ togglePersistentMenu: (toggle: boolean) => void
65
+ toggleWebchat: (toggle: boolean) => void
66
+ updateDevSettings: (settings: DevSettings) => void
67
+ updateHandoff: (handoff: boolean) => void
68
+ updateLastMessageDate: (date: string) => void
69
+ updateLastRoutePath: (path: string) => void
70
+ updateLatestInput: (input: ClientInput) => void
71
+ updateMessage: (message: WebchatMessage) => void
72
+ updateReplies: (replies: (typeof Reply)[]) => void
73
+ updateSession: (session: Partial<Session>) => void
74
+ updateTheme: (theme: ThemeProps, themeUpdates?: ThemeProps) => void
75
+ updateTyping: (typing: boolean) => void
76
+ updateWebview: (webview: Webview, params: Record<string, string>) => void
77
+ removeReplies: () => void
78
+ removeWebview: () => void
79
+ webchatState: WebchatState
80
+ webchatRef: React.MutableRefObject<HTMLDivElement | null> // TODO: Change name, already exists WebchatRef for useImperativeHandle
81
+ headerRef: React.MutableRefObject<HTMLDivElement | null>
82
+ chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
83
+ scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
84
+ repliesRef: React.MutableRefObject<HTMLDivElement | null>
85
+ inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
86
+ }
87
+
88
+ export function useWebchat(): UseWebchat {
51
89
  const [webchatState, webchatDispatch] = useReducer(
52
90
  webchatReducer,
53
91
  webchatInitialState
@@ -72,9 +110,12 @@ export function useWebchat() {
72
110
  const updateMessage = (message: WebchatMessage) =>
73
111
  webchatDispatch({ type: WebchatAction.UPDATE_MESSAGE, payload: message })
74
112
 
75
- const updateReplies = replies =>
113
+ const updateReplies = (replies: (typeof Reply)[]) =>
76
114
  webchatDispatch({ type: WebchatAction.UPDATE_REPLIES, payload: replies })
77
115
 
116
+ const removeReplies = () =>
117
+ webchatDispatch({ type: WebchatAction.REMOVE_REPLIES, payload: [] })
118
+
78
119
  const updateLatestInput = (input: ClientInput) =>
79
120
  webchatDispatch({ type: WebchatAction.UPDATE_LATEST_INPUT, payload: input })
80
121
 
@@ -87,7 +128,12 @@ export function useWebchat() {
87
128
  payload: { webview, webviewParams: params },
88
129
  })
89
130
 
90
- const updateSession = (session: Session) => {
131
+ const removeWebview = () =>
132
+ webchatDispatch({
133
+ type: WebchatAction.REMOVE_WEBVIEW,
134
+ })
135
+
136
+ const updateSession = (session: Partial<Session>) => {
91
137
  webchatDispatch({
92
138
  type: WebchatAction.UPDATE_SESSION,
93
139
  payload: session,
@@ -152,7 +198,7 @@ export function useWebchat() {
152
198
  payload: toggle,
153
199
  })
154
200
 
155
- const setError = (error: ErrorMessage) =>
201
+ const setError = (error?: ErrorMessage) =>
156
202
  webchatDispatch({
157
203
  type: WebchatAction.SET_ERROR,
158
204
  payload: error,
@@ -177,7 +223,7 @@ export function useWebchat() {
177
223
  })
178
224
  }
179
225
 
180
- const setCurrentAttachment = (attachment: File) => {
226
+ const setCurrentAttachment = (attachment?: File) => {
181
227
  webchatDispatch({
182
228
  type: WebchatAction.SET_CURRENT_ATTACHMENT,
183
229
  payload: attachment,
@@ -230,7 +276,8 @@ export function useWebchat() {
230
276
  updateTheme,
231
277
  updateTyping,
232
278
  updateWebview,
233
- webchatDispatch,
279
+ removeReplies,
280
+ removeWebview,
234
281
  webchatState,
235
282
  webchatRef,
236
283
  headerRef,
@@ -1,6 +1,6 @@
1
1
  import { WebchatAction } from './actions'
2
- import { WebchatState } from './index-types'
3
2
  import { messagesReducer } from './messages-reducer'
3
+ import { WebchatState } from './types'
4
4
 
5
5
  // eslint-disable-next-line complexity
6
6
  export function webchatReducer(
@@ -10,6 +10,8 @@ export function webchatReducer(
10
10
  switch (action.type) {
11
11
  case WebchatAction.UPDATE_WEBVIEW:
12
12
  return { ...state, ...action.payload }
13
+ case WebchatAction.REMOVE_WEBVIEW:
14
+ return { ...state, webview: null, webviewParams: null }
13
15
  case WebchatAction.UPDATE_SESSION:
14
16
  return { ...state, session: { ...action.payload } }
15
17
  case WebchatAction.UPDATE_TYPING:
@@ -1,7 +1,7 @@
1
1
  import React, { useContext } from 'react'
2
2
 
3
3
  import { WEBCHAT } from '../../constants'
4
- import { WebchatContext } from '../../contexts'
4
+ import { WebchatContext } from '../context'
5
5
 
6
6
  interface Props {
7
7
  component: any
@@ -0,0 +1,3 @@
1
+ interface Window {
2
+ _botonicInsertStyles?: HTMLStyleElement[]
3
+ }
@@ -0,0 +1,75 @@
1
+ import React, { useContext } from 'react'
2
+
3
+ import { COLORS, ROLES, WEBCHAT } from '../../constants'
4
+ import { Scale } from '../../shared/styles'
5
+ import { resolveImage } from '../../util/environment'
6
+ import { ConditionalWrapper } from '../../util/react'
7
+ import { WebchatContext } from '../../webchat/context'
8
+ import {
9
+ CloseHeader,
10
+ HeaderContainer,
11
+ ImageContainer,
12
+ Subtitle,
13
+ TextContainer,
14
+ Title,
15
+ } from './styles'
16
+
17
+ export const DefaultHeader = () => {
18
+ const { getThemeProperty, toggleWebchat } = useContext(WebchatContext)
19
+
20
+ const animationsEnabled = getThemeProperty(
21
+ WEBCHAT.CUSTOM_PROPERTIES.enableAnimations,
22
+ true
23
+ )
24
+
25
+ const headerImage = getThemeProperty(
26
+ WEBCHAT.CUSTOM_PROPERTIES.headerImage,
27
+ getThemeProperty(
28
+ WEBCHAT.CUSTOM_PROPERTIES.brandImage,
29
+ WEBCHAT.DEFAULTS.LOGO
30
+ )
31
+ )
32
+
33
+ const headerTitle = getThemeProperty(
34
+ WEBCHAT.CUSTOM_PROPERTIES.headerTitle,
35
+ WEBCHAT.DEFAULTS.TITLE
36
+ )
37
+
38
+ const headerSubtitle = getThemeProperty(
39
+ WEBCHAT.CUSTOM_PROPERTIES.headerSubtitle,
40
+ ''
41
+ )
42
+
43
+ const handleCloseWebchat = () => {
44
+ toggleWebchat(false)
45
+ }
46
+
47
+ const color = getThemeProperty(
48
+ WEBCHAT.CUSTOM_PROPERTIES.brandColor,
49
+ COLORS.BOTONIC_BLUE
50
+ )
51
+
52
+ return (
53
+ <HeaderContainer
54
+ role={ROLES.HEADER}
55
+ color={color}
56
+ style={{ ...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.headerStyle) }}
57
+ >
58
+ {headerImage && (
59
+ <ImageContainer>
60
+ <img src={resolveImage(headerImage)} />
61
+ </ImageContainer>
62
+ )}
63
+ <TextContainer>
64
+ <Title>{headerTitle}</Title>
65
+ {headerSubtitle ? <Subtitle>{headerSubtitle}</Subtitle> : null}
66
+ </TextContainer>
67
+ <ConditionalWrapper
68
+ condition={animationsEnabled}
69
+ wrapper={children => <Scale>{children}</Scale>}
70
+ >
71
+ <CloseHeader onClick={handleCloseWebchat}>⨯</CloseHeader>
72
+ </ConditionalWrapper>
73
+ </HeaderContainer>
74
+ )
75
+ }
@@ -0,0 +1,37 @@
1
+ import React, { ForwardedRef, forwardRef, useContext } from 'react'
2
+
3
+ import { WEBCHAT } from '../../constants'
4
+ import { WebchatContext } from '../../webchat/context'
5
+ import { BotonicContainerId } from '../constants'
6
+ import { DefaultHeader } from './default-header'
7
+ import { StyledWebchatHeader } from './styles'
8
+
9
+ export const WebchatHeader = forwardRef(
10
+ (_, ref: ForwardedRef<HTMLDivElement>) => {
11
+ const { getThemeProperty, toggleWebchat } = useContext(WebchatContext)
12
+
13
+ const handleCloseWebchat = () => {
14
+ toggleWebchat(false)
15
+ }
16
+
17
+ const CustomHeader = getThemeProperty(
18
+ WEBCHAT.CUSTOM_PROPERTIES.customHeader
19
+ )
20
+
21
+ if (CustomHeader) {
22
+ return (
23
+ <div id={BotonicContainerId.Header} ref={ref}>
24
+ <CustomHeader onCloseClick={handleCloseWebchat} />
25
+ </div>
26
+ )
27
+ }
28
+
29
+ return (
30
+ <StyledWebchatHeader id={BotonicContainerId.Header} ref={ref}>
31
+ <DefaultHeader />
32
+ </StyledWebchatHeader>
33
+ )
34
+ }
35
+ )
36
+
37
+ WebchatHeader.displayName = 'WebchatHeader'
@@ -0,0 +1,62 @@
1
+ import styled from 'styled-components'
2
+
3
+ import { COLORS, WEBCHAT } from '../../constants'
4
+
5
+ export const HeaderContainer = styled.div`
6
+ display: flex;
7
+ background: linear-gradient(
8
+ 90deg,
9
+ ${COLORS.BLEACHED_CEDAR_PURPLE} 0%,
10
+ ${props => props.color} 100%
11
+ );
12
+ border-radius: ${WEBCHAT.DEFAULTS.BORDER_RADIUS_TOP_CORNERS};
13
+ z-index: 2;
14
+ height: inherit;
15
+ `
16
+
17
+ export const ImageContainer = styled.div`
18
+ padding: 10px;
19
+ align-items: center;
20
+
21
+ img {
22
+ width: 32px;
23
+ border-radius: 50%;
24
+ }
25
+ `
26
+
27
+ export const TextContainer = styled.div`
28
+ display: flex;
29
+ flex-direction: column;
30
+ justify-content: center;
31
+ flex: 1 1 auto;
32
+ `
33
+
34
+ export const Title = styled.div`
35
+ display: flex;
36
+ font-family: inherit;
37
+ font-size: 15px;
38
+ font-weight: bold;
39
+ color: ${COLORS.SOLID_WHITE};
40
+ `
41
+
42
+ export const Subtitle = styled.div`
43
+ display: flex;
44
+ font-family: inherit;
45
+ font-size: 11px;
46
+ color: ${COLORS.SOLID_WHITE};
47
+ `
48
+
49
+ export const CloseHeader = styled.div`
50
+ padding: 0px 16px;
51
+ cursor: pointer;
52
+ color: ${COLORS.SOLID_WHITE};
53
+ font-family: inherit;
54
+ font-size: 36px;
55
+ `
56
+
57
+ export const StyledWebchatHeader = styled.div`
58
+ border-radius: 8px 8px 0px 0px;
59
+ box-shadow: ${COLORS.PIGEON_POST_BLUE_ALPHA_0_5} 0px 2px 5px;
60
+ height: 55px;
61
+ flex: none;
62
+ `
@@ -6,6 +6,5 @@ export { useScrollToBottom } from './use-scroll-to-bottom'
6
6
  export { useScrollbarController } from './use-scrollbar-controller'
7
7
  export { useTyping } from './use-typing'
8
8
  export { useVirtualKeyboardDetection } from './use-virtual-keyboard-detection'
9
- export { useWebchat, webchatInitialState } from './use-webchat'
10
9
  export { useWebchatDimensions } from './use-webchat-dimensions'
11
10
  export { useWebchatResizer } from './use-webchat-resizer'
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useRef } from 'react'
2
2
 
3
- export function usePrevious(value) {
3
+ export function usePrevious(value: any): any {
4
4
  const ref = useRef()
5
5
  useEffect(() => {
6
6
  ref.current = value
@@ -1,6 +1,6 @@
1
1
  import { useContext, useEffect } from 'react'
2
2
 
3
- import { WebchatContext } from '../../contexts'
3
+ import { WebchatContext } from '../../webchat/context'
4
4
  import { DEVICES, isMobileDevice } from '../devices'
5
5
 
6
6
  // TODO: Investigate why when we have some messages, scroll actions are not disabled properly
@@ -30,7 +30,7 @@ export const useScrollbarController = (currentDevice, host) => {
30
30
 
31
31
  const hasScrollbar = () => {
32
32
  if (chatAreaRef.current && scrollableMessagesListRef.current) {
33
- if (!repliesRef) {
33
+ if (!repliesRef?.current) {
34
34
  return (
35
35
  scrollableMessagesListRef.current?.scrollHeight >
36
36
  chatAreaRef.current?.clientHeight
@@ -1,7 +1,7 @@
1
1
  import { useEffect } from 'react'
2
2
 
3
3
  import { WebchatMessage } from '../../index-types'
4
- import { WebchatState } from '../index-types'
4
+ import { WebchatState } from '../context'
5
5
 
6
6
  interface UseTyping {
7
7
  webchatState: WebchatState
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useContext } from 'react'
2
2
 
3
- import { WebchatContext } from '../../contexts'
3
+ import { WebchatContext } from '../../webchat/context'
4
4
 
5
5
  export const useWebchatDimensions = () => {
6
6
  const {
@@ -1,6 +1,6 @@
1
1
  import { useContext } from 'react'
2
2
 
3
- import { WebchatContext } from '../../contexts'
3
+ import { WebchatContext } from '../../webchat/context'
4
4
  import { useWebchatDimensions } from './use-webchat-dimensions'
5
5
 
6
6
  export const useWebchatResizer = () => {
@@ -1,7 +1,4 @@
1
- import type { Input as CoreInput, Session as CoreSession } from '@botonic/core'
2
- import { RefObject } from 'react'
3
-
4
- import { Webview } from '../components/index-types'
1
+ import { WebchatArgs } from '../index-types'
5
2
 
6
3
  export interface WebchatStateTheme {
7
4
  headerTitle: string
@@ -11,54 +8,11 @@ export interface WebchatStateTheme {
11
8
  textPlaceholder: string
12
9
  style: {
13
10
  fontFamily: string
11
+ borderRadius?: string
14
12
  }
15
13
  }
16
14
 
17
- export interface ErrorMessage {
18
- message?: string
19
- }
20
- export interface DevSettings {
21
- keepSessionOnReload?: boolean
22
- showSessionView?: boolean
23
- }
24
-
25
- export interface WebchatState {
26
- width: number
27
- height: number
28
- messagesJSON: any[]
29
- messagesComponents: any[]
30
- replies: any[]
31
- latestInput: Partial<CoreInput>
32
- typing: boolean
33
- webview: Webview | null
34
- webviewParams: null
35
- session: Partial<CoreSession>
36
- lastRoutePath: string | null
37
- handoff: boolean
38
- theme: WebchatStateTheme
39
- themeUpdates: Partial<WebchatStateTheme>
40
- error: ErrorMessage
41
- online: boolean
42
- devSettings: DevSettings
43
- isWebchatOpen: boolean
44
- isEmojiPickerOpen: boolean
45
- isPersistentMenuOpen: boolean
46
- isCoverComponentOpen: boolean
47
- isCustomComponentRendered: boolean
48
- lastMessageUpdate?: string
49
- currentAttachment?: File
50
- numUnreadMessages: number
51
- isLastMessageVisible: boolean
52
- isInputFocused: boolean
53
- }
54
-
55
- // export interface WebchatProps extends WebchatArgs {
56
- export interface WebchatProps {
57
- ref: RefObject<any>
58
- onConnectionRegained?: () => Promise<void>
59
- }
60
-
61
- export interface WebchatDevProps extends WebchatProps {
15
+ export interface WebchatDevProps extends WebchatArgs {
62
16
  initialDevSettings?: {
63
17
  keepSessionOnReload?: boolean
64
18
  showSessionView?: boolean
@@ -1,4 +1,5 @@
1
1
  // @ts-nocheck
2
+ export { WebchatContext } from './context'
2
3
  export { Webchat } from './webchat'
3
4
  export { WebchatDev } from './webchat-dev'
4
5
 
@@ -2,13 +2,13 @@ import React, { useContext, useRef } from 'react'
2
2
 
3
3
  import AttachmentIcon from '../../assets/attachment-icon.svg'
4
4
  import { ROLES, WEBCHAT } from '../../constants'
5
- import { WebchatContext } from '../../contexts'
5
+ import { WebchatContext } from '../../webchat/context'
6
6
  import { Icon } from '../components/common'
7
7
  import { ConditionalAnimation } from '../components/conditional-animation'
8
8
 
9
9
  interface AttachmentProps {
10
10
  accept: string
11
- enableAttachments: boolean
11
+ enableAttachments?: boolean
12
12
  onChange: (event: any) => void
13
13
  }
14
14
 
@@ -2,12 +2,12 @@ import React, { useContext } from 'react'
2
2
 
3
3
  import LogoEmoji from '../../assets/emojiButton.svg'
4
4
  import { ROLES, WEBCHAT } from '../../constants'
5
- import { WebchatContext } from '../../contexts'
5
+ import { WebchatContext } from '../../webchat/context'
6
6
  import { Icon } from '../components/common'
7
7
  import { ConditionalAnimation } from '../components/conditional-animation'
8
8
 
9
9
  interface EmojiPickerProps {
10
- enableEmojiPicker: boolean
10
+ enableEmojiPicker?: boolean
11
11
  onClick: () => void
12
12
  }
13
13
 
@@ -3,8 +3,8 @@ import React, { useContext } from 'react'
3
3
  import { v7 as uuidv7 } from 'uuid'
4
4
 
5
5
  import { WEBCHAT } from '../../constants'
6
- import { WebchatContext } from '../../contexts'
7
6
  import { getFullMimeWhitelist } from '../../message-utils'
7
+ import { WebchatContext } from '../../webchat/context'
8
8
  import { BotonicContainerId } from '../constants'
9
9
  import { Attachment } from './attachment'
10
10
  import { EmojiPicker } from './emoji-picker'
@@ -16,10 +16,10 @@ import { Textarea } from './textarea'
16
16
 
17
17
  interface InputPanelProps {
18
18
  persistentMenu: any
19
- enableEmojiPicker: boolean
20
- enableAttachments: boolean
19
+ enableEmojiPicker?: boolean
20
+ enableAttachments?: boolean
21
21
  handleAttachment: (event: any) => void
22
- textareaRef: React.MutableRefObject<HTMLTextAreaElement>
22
+ textareaRef: React.MutableRefObject<HTMLTextAreaElement | undefined>
23
23
  host: HTMLElement
24
24
  onUserInput?: (event: any) => Promise<void>
25
25
  }
@@ -43,6 +43,8 @@ export const InputPanel = ({
43
43
  } = useContext(WebchatContext)
44
44
 
45
45
  const handleSelectedEmoji = event => {
46
+ if (!textareaRef.current) return
47
+
46
48
  textareaRef.current.value += event.emoji
47
49
  textareaRef.current.focus()
48
50
  }
@@ -56,7 +58,9 @@ export const InputPanel = ({
56
58
  }
57
59
 
58
60
  const sendTextAreaText = async () => {
59
- await sendText(textareaRef.current.value)
61
+ if (!textareaRef.current) return
62
+
63
+ await sendText(textareaRef.current?.value)
60
64
  textareaRef.current.value = ''
61
65
  }
62
66
 
@@ -2,7 +2,7 @@ import React, { useContext } from 'react'
2
2
 
3
3
  import LogoMenu from '../../assets/menuButton.svg'
4
4
  import { ROLES, WEBCHAT } from '../../constants'
5
- import { WebchatContext } from '../../contexts'
5
+ import { WebchatContext } from '../../webchat/context'
6
6
  import { Icon } from '../components/common'
7
7
  import { ConditionalAnimation } from '../components/conditional-animation'
8
8
 
@@ -2,7 +2,7 @@ import React, { useContext } from 'react'
2
2
 
3
3
  import SendButtonIcon from '../../assets/send-button.svg'
4
4
  import { ROLES, WEBCHAT } from '../../constants'
5
- import { WebchatContext } from '../../contexts'
5
+ import { WebchatContext } from '../../webchat/context'
6
6
  import { Icon } from '../components/common'
7
7
  import { ConditionalAnimation } from '../components/conditional-animation'
8
8
 
@@ -3,15 +3,15 @@ import TextareaAutosize from 'react-textarea-autosize'
3
3
 
4
4
  import { PersistentMenuTheme } from '../../components/index-types'
5
5
  import { WEBCHAT } from '../../constants'
6
- import { WebchatContext } from '../../contexts'
7
6
  import { Typing } from '../../index-types'
7
+ import { WebchatContext } from '../../webchat/context'
8
8
  import { useDeviceAdapter } from '../hooks'
9
9
  import { TextAreaContainer } from './styles'
10
10
 
11
11
  interface TextareaProps {
12
12
  host: HTMLElement
13
13
  persistentMenu: PersistentMenuTheme
14
- textareaRef: React.MutableRefObject<HTMLTextAreaElement>
14
+ textareaRef: React.MutableRefObject<HTMLTextAreaElement | undefined>
15
15
  sendChatEvent: (event: string) => Promise<void>
16
16
  sendTextAreaText: () => Promise<void>
17
17
  }
@@ -45,6 +45,8 @@ export const Textarea = ({
45
45
  }
46
46
 
47
47
  const onKeyUp = () => {
48
+ if (!textareaRef.current) return
49
+
48
50
  if (textareaRef.current.value === '') {
49
51
  stopTyping()
50
52
  return
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useEffect, useRef, useState } from 'react'
2
2
 
3
3
  import { ROLES } from '../../constants'
4
- import { WebchatContext } from '../../contexts'
4
+ import { WebchatContext } from '../../webchat/context'
5
5
  import { BotonicContainerId } from '../constants'
6
6
  import TypingIndicator from '../typing-indicator'
7
7
  import { IntroMessage } from './intro-message'
@@ -12,11 +12,9 @@ import { useNotifications } from './use-notifications'
12
12
 
13
13
  const SCROLL_TIMEOUT = 200
14
14
  const scrollOptionsEnd: ScrollIntoViewOptions = {
15
- behavior: 'smooth',
16
15
  block: 'end',
17
16
  }
18
17
  const scrollOptionsCenter: ScrollIntoViewOptions = {
19
- behavior: 'smooth',
20
18
  block: 'center',
21
19
  }
22
20
 
@@ -136,8 +134,8 @@ export const WebchatMessageList = () => {
136
134
  <IntroMessage />
137
135
  {webchatState.messagesComponents.map((messageComponent, index) => {
138
136
  return (
139
- <>
140
- <ContainerMessage role={ROLES.MESSAGE} key={index}>
137
+ <React.Fragment key={messageComponent.props.id}>
138
+ <ContainerMessage role={ROLES.MESSAGE}>
141
139
  {showUnreadMessagesBanner(messageComponent.props.id) && (
142
140
  <UnreadMessagesBanner
143
141
  unreadMessagesBannerRef={unreadMessagesBannerRef}
@@ -153,7 +151,7 @@ export const WebchatMessageList = () => {
153
151
  }}
154
152
  ></div>
155
153
  )}
156
- </>
154
+ </React.Fragment>
157
155
  )
158
156
  })}
159
157
  {webchatState.typing && <TypingIndicator ref={typingRef} />}
@@ -1,10 +1,10 @@
1
1
  import React, { useContext } from 'react'
2
2
 
3
3
  import { WEBCHAT } from '../../constants'
4
- import { WebchatContext } from '../../contexts'
5
4
  import { Fade } from '../../shared/styles'
6
5
  import { resolveImage } from '../../util/environment'
7
6
  import { ConditionalWrapper } from '../../util/react'
7
+ import { WebchatContext } from '../../webchat/context'
8
8
  import { DefaultIntroImage } from './styles'
9
9
 
10
10
  export const IntroMessage = () => {
@@ -55,5 +55,6 @@ export const ScrollableMessageList = styled.div`
55
55
  overflow-y: auto;
56
56
  overflow-x: hidden;
57
57
  overscroll-behavior: contain; // https://css-tricks.com/almanac/properties/o/overscroll-behavior/
58
+ scroll-behavior: smooth;
58
59
  -webkit-overflow-scrolling: touch;
59
60
  `
@@ -1,8 +1,8 @@
1
1
  import React, { useContext } from 'react'
2
2
 
3
3
  import ArrowDown from '../../assets/arrow-down.svg'
4
- import { WebchatContext } from '../../contexts'
5
4
  import { resolveImage } from '../../util/environment'
5
+ import { WebchatContext } from '../../webchat/context'
6
6
  import { ContainerUnreadMessagesBanner } from './styles'
7
7
  import { useNotifications } from './use-notifications'
8
8