@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
@@ -1,12 +1,14 @@
1
- import { Input, Session } from '@botonic/core'
1
+ import { Session } from '@botonic/core'
2
2
  import { useReducer, useRef } from 'react'
3
3
 
4
- import { ThemeProps, Webview } from '../../components/index-types'
4
+ import { Reply } from '../../components'
5
+ import { 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 { ThemeProps } from '../theme/types'
9
+ import { WebchatAction } from './actions'
10
+ import { ClientInput, DevSettings, ErrorMessage, WebchatState } from './types'
11
+ import { webchatReducer } from './webchat-reducer'
10
12
 
11
13
  export const webchatInitialState: WebchatState = {
12
14
  width: WEBCHAT.DEFAULTS.WIDTH,
@@ -19,8 +21,9 @@ export const webchatInitialState: WebchatState = {
19
21
  webview: null,
20
22
  webviewParams: null,
21
23
  session: { user: undefined },
22
- lastRoutePath: null,
24
+ lastRoutePath: undefined,
23
25
  handoff: false,
26
+ // TODO: type create a defaultTheme using ThemeProps, and put this in initialState
24
27
  theme: {
25
28
  headerTitle: WEBCHAT.DEFAULTS.TITLE,
26
29
  brandColor: COLORS.BOTONIC_BLUE,
@@ -47,7 +50,44 @@ export const webchatInitialState: WebchatState = {
47
50
  isInputFocused: false,
48
51
  }
49
52
 
50
- export function useWebchat() {
53
+ export interface UseWebchat {
54
+ addMessage: (message: WebchatMessage) => void
55
+ addMessageComponent: (message: { props: WebchatMessage }) => void
56
+ clearMessages: () => void
57
+ doRenderCustomComponent: (toggle: boolean) => void
58
+ resetUnreadMessages: () => void
59
+ setCurrentAttachment: (attachment?: File) => void
60
+ setError: (error?: ErrorMessage) => void
61
+ setIsInputFocused: (isInputFocused: boolean) => void
62
+ setLastMessageVisible: (isLastMessageVisible: boolean) => void
63
+ setOnline: (online: boolean) => void
64
+ toggleCoverComponent: (toggle: boolean) => void
65
+ toggleEmojiPicker: (toggle: boolean) => void
66
+ togglePersistentMenu: (toggle: boolean) => void
67
+ toggleWebchat: (toggle: boolean) => void
68
+ updateDevSettings: (settings: DevSettings) => void
69
+ updateHandoff: (handoff: boolean) => void
70
+ updateLastMessageDate: (date: string) => void
71
+ updateLastRoutePath: (path: string) => void
72
+ updateLatestInput: (input: ClientInput) => void
73
+ updateMessage: (message: WebchatMessage) => void
74
+ updateReplies: (replies: (typeof Reply)[]) => void
75
+ updateSession: (session: Partial<Session>) => void
76
+ updateTheme: (theme: ThemeProps, themeUpdates?: ThemeProps) => void
77
+ updateTyping: (typing: boolean) => void
78
+ updateWebview: (webview: Webview, params: Record<string, string>) => void
79
+ removeReplies: () => void
80
+ removeWebview: () => void
81
+ webchatState: WebchatState
82
+ webchatRef: React.MutableRefObject<HTMLDivElement | null> // TODO: Change name, already exists WebchatRef for useImperativeHandle
83
+ headerRef: React.MutableRefObject<HTMLDivElement | null>
84
+ chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
85
+ scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
86
+ repliesRef: React.MutableRefObject<HTMLDivElement | null>
87
+ inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
88
+ }
89
+
90
+ export function useWebchat(): UseWebchat {
51
91
  const [webchatState, webchatDispatch] = useReducer(
52
92
  webchatReducer,
53
93
  webchatInitialState
@@ -72,9 +112,12 @@ export function useWebchat() {
72
112
  const updateMessage = (message: WebchatMessage) =>
73
113
  webchatDispatch({ type: WebchatAction.UPDATE_MESSAGE, payload: message })
74
114
 
75
- const updateReplies = replies =>
115
+ const updateReplies = (replies: (typeof Reply)[]) =>
76
116
  webchatDispatch({ type: WebchatAction.UPDATE_REPLIES, payload: replies })
77
117
 
118
+ const removeReplies = () =>
119
+ webchatDispatch({ type: WebchatAction.REMOVE_REPLIES, payload: [] })
120
+
78
121
  const updateLatestInput = (input: ClientInput) =>
79
122
  webchatDispatch({ type: WebchatAction.UPDATE_LATEST_INPUT, payload: input })
80
123
 
@@ -87,7 +130,12 @@ export function useWebchat() {
87
130
  payload: { webview, webviewParams: params },
88
131
  })
89
132
 
90
- const updateSession = (session: Session) => {
133
+ const removeWebview = () =>
134
+ webchatDispatch({
135
+ type: WebchatAction.REMOVE_WEBVIEW,
136
+ })
137
+
138
+ const updateSession = (session: Partial<Session>) => {
91
139
  webchatDispatch({
92
140
  type: WebchatAction.UPDATE_SESSION,
93
141
  payload: session,
@@ -152,7 +200,7 @@ export function useWebchat() {
152
200
  payload: toggle,
153
201
  })
154
202
 
155
- const setError = (error: ErrorMessage) =>
203
+ const setError = (error?: ErrorMessage) =>
156
204
  webchatDispatch({
157
205
  type: WebchatAction.SET_ERROR,
158
206
  payload: error,
@@ -177,7 +225,7 @@ export function useWebchat() {
177
225
  })
178
226
  }
179
227
 
180
- const setCurrentAttachment = (attachment: File) => {
228
+ const setCurrentAttachment = (attachment?: File) => {
181
229
  webchatDispatch({
182
230
  type: WebchatAction.SET_CURRENT_ATTACHMENT,
183
231
  payload: attachment,
@@ -230,7 +278,8 @@ export function useWebchat() {
230
278
  updateTheme,
231
279
  updateTyping,
232
280
  updateWebview,
233
- webchatDispatch,
281
+ removeReplies,
282
+ removeWebview,
234
283
  webchatState,
235
284
  webchatRef,
236
285
  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,60 +8,13 @@ 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
65
19
  }
66
20
  }
67
-
68
- export interface CoverComponentProps {
69
- closeComponent: () => void
70
- }
@@ -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
 
@@ -1,17 +1,17 @@
1
1
  import React, { useContext } from 'react'
2
2
  import TextareaAutosize from 'react-textarea-autosize'
3
3
 
4
- import { PersistentMenuTheme } from '../../components/index-types'
5
4
  import { WEBCHAT } from '../../constants'
6
- import { WebchatContext } from '../../contexts'
7
5
  import { Typing } from '../../index-types'
6
+ import { WebchatContext } from '../../webchat/context'
8
7
  import { useDeviceAdapter } from '../hooks'
8
+ import { PersistentMenuOptionsTheme } from '../theme/types'
9
9
  import { TextAreaContainer } from './styles'
10
10
 
11
11
  interface TextareaProps {
12
12
  host: HTMLElement
13
- persistentMenu: PersistentMenuTheme
14
- textareaRef: React.MutableRefObject<HTMLTextAreaElement>
13
+ persistentMenu: PersistentMenuOptionsTheme
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
  `