@botonic/react 0.31.5-alpha.1 → 0.32.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (606) 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/element.js +6 -6
  15. package/lib/cjs/components/element.js.map +1 -1
  16. package/lib/cjs/components/handoff.d.ts +1 -1
  17. package/lib/cjs/components/handoff.js +2 -2
  18. package/lib/cjs/components/handoff.js.map +1 -1
  19. package/lib/cjs/components/image.d.ts +8 -7
  20. package/lib/cjs/components/image.js +5 -5
  21. package/lib/cjs/components/image.js.map +1 -1
  22. package/lib/cjs/components/index-types.d.ts +30 -127
  23. package/lib/cjs/components/index.d.ts +7 -1
  24. package/lib/cjs/components/index.js +14 -1
  25. package/lib/cjs/components/index.js.map +1 -1
  26. package/lib/cjs/components/message/index.js +2 -1
  27. package/lib/cjs/components/message/index.js.map +1 -1
  28. package/lib/cjs/components/message/message-feedback.d.ts +1 -1
  29. package/lib/cjs/components/message/message-feedback.js +2 -2
  30. package/lib/cjs/components/message/message-feedback.js.map +1 -1
  31. package/lib/cjs/components/message/message-footer.d.ts +1 -1
  32. package/lib/cjs/components/message/message-footer.js +2 -2
  33. package/lib/cjs/components/message/message-footer.js.map +1 -1
  34. package/lib/cjs/components/message/message-image.js +2 -2
  35. package/lib/cjs/components/message/message-image.js.map +1 -1
  36. package/lib/cjs/components/message/timestamps.d.ts +1 -1
  37. package/lib/cjs/components/message/timestamps.js +2 -2
  38. package/lib/cjs/components/message/timestamps.js.map +1 -1
  39. package/lib/cjs/components/multichannel/multichannel-button.d.ts +1 -1
  40. package/lib/cjs/components/multichannel/multichannel-button.js +2 -2
  41. package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
  42. package/lib/cjs/components/multichannel/multichannel-carousel.js +4 -4
  43. package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
  44. package/lib/cjs/components/multichannel/multichannel-reply.d.ts +1 -1
  45. package/lib/cjs/components/multichannel/multichannel-text.d.ts +1 -1
  46. package/lib/cjs/components/multichannel/multichannel-text.js +12 -11
  47. package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
  48. package/lib/cjs/components/multichannel/multichannel-utils.d.ts +9 -15
  49. package/lib/cjs/components/multichannel/multichannel-utils.js +48 -27
  50. package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
  51. package/lib/cjs/components/multichannel/multichannel.js +7 -7
  52. package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
  53. package/lib/cjs/components/multichannel/whatsapp/constants.d.ts +11 -0
  54. package/lib/cjs/components/multichannel/whatsapp/constants.js +13 -0
  55. package/lib/cjs/components/multichannel/whatsapp/constants.js.map +1 -0
  56. package/lib/cjs/components/raw.d.ts +1 -1
  57. package/lib/cjs/components/reply.d.ts +7 -6
  58. package/lib/cjs/components/reply.js +10 -6
  59. package/lib/cjs/components/reply.js.map +1 -1
  60. package/lib/cjs/components/text.d.ts +1 -1
  61. package/lib/cjs/components/video.d.ts +8 -7
  62. package/lib/cjs/components/video.js +2 -3
  63. package/lib/cjs/components/video.js.map +1 -1
  64. package/lib/cjs/components/webchat-settings.d.ts +15 -2
  65. package/lib/cjs/components/webchat-settings.js +2 -2
  66. package/lib/cjs/components/webchat-settings.js.map +1 -1
  67. package/lib/cjs/components/whatsapp-button-list.js +2 -2
  68. package/lib/cjs/components/whatsapp-button-list.js.map +1 -1
  69. package/lib/cjs/components/whatsapp-catalog.d.ts +6 -0
  70. package/lib/cjs/components/whatsapp-catalog.js +25 -0
  71. package/lib/cjs/components/whatsapp-catalog.js.map +1 -0
  72. package/lib/cjs/components/whatsapp-cta-url-button.js +5 -5
  73. package/lib/cjs/components/whatsapp-cta-url-button.js.map +1 -1
  74. package/lib/cjs/components/whatsapp-media-carousel.d.ts +46 -0
  75. package/lib/cjs/components/whatsapp-media-carousel.js +40 -0
  76. package/lib/cjs/components/whatsapp-media-carousel.js.map +1 -0
  77. package/lib/cjs/components/whatsapp-product-carousel.d.ts +32 -0
  78. package/lib/cjs/components/whatsapp-product-carousel.js +34 -0
  79. package/lib/cjs/components/whatsapp-product-carousel.js.map +1 -0
  80. package/lib/cjs/components/whatsapp-product-list.d.ts +15 -0
  81. package/lib/cjs/components/whatsapp-product-list.js +26 -0
  82. package/lib/cjs/components/whatsapp-product-list.js.map +1 -0
  83. package/lib/cjs/components/whatsapp-product.d.ts +7 -0
  84. package/lib/cjs/components/whatsapp-product.js +25 -0
  85. package/lib/cjs/components/whatsapp-product.js.map +1 -0
  86. package/lib/cjs/constants.d.ts +0 -6
  87. package/lib/cjs/constants.js +1 -7
  88. package/lib/cjs/constants.js.map +1 -1
  89. package/lib/cjs/contexts.d.ts +3 -4
  90. package/lib/cjs/contexts.js +2 -76
  91. package/lib/cjs/contexts.js.map +1 -1
  92. package/lib/cjs/dev-app.d.ts +7 -0
  93. package/lib/cjs/dev-app.js +5 -2
  94. package/lib/cjs/dev-app.js.map +1 -1
  95. package/lib/cjs/index-types.d.ts +90 -61
  96. package/lib/cjs/index-types.js.map +1 -1
  97. package/lib/cjs/index.d.ts +1 -1
  98. package/lib/cjs/index.js +1 -2
  99. package/lib/cjs/index.js.map +1 -1
  100. package/lib/cjs/msg-to-botonic.d.ts +1 -1
  101. package/lib/cjs/msg-to-botonic.js +5 -8
  102. package/lib/cjs/msg-to-botonic.js.map +1 -1
  103. package/lib/cjs/react-bot.d.ts +1 -1
  104. package/lib/cjs/util/error-boundary.d.ts +1 -1
  105. package/lib/cjs/util/functional.d.ts +3 -0
  106. package/lib/cjs/util/functional.js +30 -0
  107. package/lib/cjs/util/functional.js.map +1 -0
  108. package/lib/cjs/util/react.d.ts +1 -1
  109. package/lib/cjs/util/webchat.d.ts +17 -6
  110. package/lib/cjs/util/webchat.js +9 -7
  111. package/lib/cjs/util/webchat.js.map +1 -1
  112. package/lib/cjs/webchat/chat-area/index.d.ts +1 -1
  113. package/lib/cjs/webchat/chat-area/index.js +3 -3
  114. package/lib/cjs/webchat/chat-area/index.js.map +1 -1
  115. package/lib/cjs/webchat/components/common.d.ts +1 -1
  116. package/lib/cjs/webchat/components/conditional-animation.d.ts +1 -1
  117. package/lib/cjs/webchat/components/conditional-animation.js +2 -2
  118. package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
  119. package/lib/cjs/webchat/components/opened-persistent-menu.d.ts +1 -1
  120. package/lib/cjs/webchat/components/opened-persistent-menu.js +2 -2
  121. package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -1
  122. package/lib/cjs/webchat/{actions.d.ts → context/actions.d.ts} +4 -1
  123. package/lib/cjs/webchat/{actions.js → context/actions.js} +4 -0
  124. package/lib/cjs/webchat/context/actions.js.map +1 -0
  125. package/lib/cjs/webchat/context/index.d.ts +5 -0
  126. package/lib/cjs/webchat/context/index.js +86 -0
  127. package/lib/cjs/webchat/context/index.js.map +1 -0
  128. package/lib/cjs/webchat/{messages-reducer.d.ts → context/messages-reducer.d.ts} +1 -1
  129. package/lib/cjs/webchat/{messages-reducer.js → context/messages-reducer.js} +3 -1
  130. package/lib/cjs/webchat/context/messages-reducer.js.map +1 -0
  131. package/lib/cjs/webchat/context/types.d.ts +76 -0
  132. package/lib/cjs/webchat/context/types.js +3 -0
  133. package/lib/cjs/webchat/context/types.js.map +1 -0
  134. package/lib/cjs/webchat/{hooks → context}/use-webchat.d.ts +21 -20
  135. package/lib/cjs/webchat/{hooks → context}/use-webchat.js +21 -7
  136. package/lib/cjs/webchat/context/use-webchat.js.map +1 -0
  137. package/lib/cjs/webchat/{webchat-reducer.d.ts → context/webchat-reducer.d.ts} +1 -1
  138. package/lib/cjs/webchat/{webchat-reducer.js → context/webchat-reducer.js} +4 -0
  139. package/lib/cjs/webchat/context/webchat-reducer.js.map +1 -0
  140. package/lib/cjs/webchat/cover-component/index.d.ts +1 -1
  141. package/lib/cjs/webchat/cover-component/index.js +2 -2
  142. package/lib/cjs/webchat/cover-component/index.js.map +1 -1
  143. package/lib/cjs/webchat/header/default-header.d.ts +1 -0
  144. package/lib/cjs/webchat/header/default-header.js +25 -0
  145. package/lib/cjs/webchat/header/default-header.js.map +1 -0
  146. package/lib/cjs/webchat/header/index.d.ts +2 -0
  147. package/lib/cjs/webchat/header/index.js +23 -0
  148. package/lib/cjs/webchat/header/index.js.map +1 -0
  149. package/lib/cjs/webchat/header/styles.d.ts +7 -0
  150. package/lib/cjs/webchat/header/styles.js +59 -0
  151. package/lib/cjs/webchat/header/styles.js.map +1 -0
  152. package/lib/cjs/webchat/hooks/index.d.ts +0 -1
  153. package/lib/cjs/webchat/hooks/index.js +1 -4
  154. package/lib/cjs/webchat/hooks/index.js.map +1 -1
  155. package/lib/cjs/webchat/hooks/use-previous.d.ts +1 -1
  156. package/lib/cjs/webchat/hooks/use-previous.js.map +1 -1
  157. package/lib/cjs/webchat/hooks/use-scroll-to-bottom.d.ts +6 -4
  158. package/lib/cjs/webchat/hooks/use-scroll-to-bottom.js.map +1 -1
  159. package/lib/cjs/webchat/hooks/use-scrollbar-controller.js +16 -16
  160. package/lib/cjs/webchat/hooks/use-scrollbar-controller.js.map +1 -1
  161. package/lib/cjs/webchat/hooks/use-typing.d.ts +1 -1
  162. package/lib/cjs/webchat/hooks/use-webchat-dimensions.js +4 -4
  163. package/lib/cjs/webchat/hooks/use-webchat-dimensions.js.map +1 -1
  164. package/lib/cjs/webchat/hooks/use-webchat-resizer.js +6 -6
  165. package/lib/cjs/webchat/hooks/use-webchat-resizer.js.map +1 -1
  166. package/lib/cjs/webchat/index-types.d.ts +3 -46
  167. package/lib/cjs/webchat/index.d.ts +1 -0
  168. package/lib/cjs/webchat/index.js +3 -1
  169. package/lib/cjs/webchat/index.js.map +1 -1
  170. package/lib/cjs/webchat/input-panel/attachment.d.ts +2 -2
  171. package/lib/cjs/webchat/input-panel/attachment.js +2 -2
  172. package/lib/cjs/webchat/input-panel/attachment.js.map +1 -1
  173. package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +2 -2
  174. package/lib/cjs/webchat/input-panel/emoji-picker.js +2 -2
  175. package/lib/cjs/webchat/input-panel/emoji-picker.js.map +1 -1
  176. package/lib/cjs/webchat/input-panel/index.d.ts +4 -4
  177. package/lib/cjs/webchat/input-panel/index.js +8 -3
  178. package/lib/cjs/webchat/input-panel/index.js.map +1 -1
  179. package/lib/cjs/webchat/input-panel/opened-emoji-picker.d.ts +1 -1
  180. package/lib/cjs/webchat/input-panel/persistent-menu.d.ts +1 -1
  181. package/lib/cjs/webchat/input-panel/persistent-menu.js +2 -2
  182. package/lib/cjs/webchat/input-panel/persistent-menu.js.map +1 -1
  183. package/lib/cjs/webchat/input-panel/send-button.d.ts +1 -1
  184. package/lib/cjs/webchat/input-panel/send-button.js +2 -2
  185. package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
  186. package/lib/cjs/webchat/input-panel/textarea.d.ts +4 -4
  187. package/lib/cjs/webchat/input-panel/textarea.js +11 -3
  188. package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
  189. package/lib/cjs/webchat/message-list/index.d.ts +1 -1
  190. package/lib/cjs/webchat/message-list/index.js +64 -38
  191. package/lib/cjs/webchat/message-list/index.js.map +1 -1
  192. package/lib/cjs/webchat/message-list/intro-message.d.ts +1 -1
  193. package/lib/cjs/webchat/message-list/intro-message.js +2 -2
  194. package/lib/cjs/webchat/message-list/intro-message.js.map +1 -1
  195. package/lib/cjs/webchat/message-list/scroll-button.d.ts +1 -0
  196. package/lib/cjs/webchat/message-list/styles.js +4 -3
  197. package/lib/cjs/webchat/message-list/styles.js.map +1 -1
  198. package/lib/cjs/webchat/message-list/unread-messages-banner.js +2 -2
  199. package/lib/cjs/webchat/message-list/unread-messages-banner.js.map +1 -1
  200. package/lib/cjs/webchat/message-list/use-notifications.js +2 -2
  201. package/lib/cjs/webchat/message-list/use-notifications.js.map +1 -1
  202. package/lib/cjs/webchat/replies/index.d.ts +1 -0
  203. package/lib/cjs/webchat/replies/index.js +32 -0
  204. package/lib/cjs/webchat/replies/index.js.map +1 -0
  205. package/lib/cjs/webchat/replies/styles.d.ts +8 -0
  206. package/lib/cjs/webchat/replies/styles.js +25 -0
  207. package/lib/cjs/webchat/replies/styles.js.map +1 -0
  208. package/lib/cjs/webchat/session-view.d.ts +1 -1
  209. package/lib/cjs/webchat/session-view.js +4 -4
  210. package/lib/cjs/webchat/session-view.js.map +1 -1
  211. package/lib/cjs/webchat/styles.d.ts +9 -0
  212. package/lib/cjs/webchat/styles.js +54 -0
  213. package/lib/cjs/webchat/styles.js.map +1 -0
  214. package/lib/cjs/webchat/theme/types.d.ts +167 -0
  215. package/lib/cjs/webchat/theme/types.js +3 -0
  216. package/lib/cjs/webchat/theme/types.js.map +1 -0
  217. package/lib/cjs/webchat/trigger-button/index.d.ts +1 -0
  218. package/lib/cjs/webchat/trigger-button/index.js +2 -2
  219. package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
  220. package/lib/cjs/webchat/typing-indicator/index.d.ts +3 -1
  221. package/lib/cjs/webchat/typing-indicator/index.js +4 -3
  222. package/lib/cjs/webchat/typing-indicator/index.js.map +1 -1
  223. package/lib/cjs/webchat/typing-indicator/styles.d.ts +3 -2
  224. package/lib/cjs/webchat/typing-indicator/styles.js +6 -3
  225. package/lib/cjs/webchat/typing-indicator/styles.js.map +1 -1
  226. package/lib/cjs/webchat/webchat-dev.d.ts +2 -2
  227. package/lib/cjs/webchat/webchat-dev.js +2 -2
  228. package/lib/cjs/webchat/webchat-dev.js.map +1 -1
  229. package/lib/cjs/webchat/webchat.d.ts +4 -2
  230. package/lib/cjs/webchat/webchat.js +91 -116
  231. package/lib/cjs/webchat/webchat.js.map +1 -1
  232. package/lib/cjs/webchat/webview/header.d.ts +1 -0
  233. package/lib/cjs/webchat/webview/header.js +16 -0
  234. package/lib/cjs/webchat/webview/header.js.map +1 -0
  235. package/lib/cjs/webchat/webview/index.d.ts +1 -0
  236. package/lib/cjs/webchat/webview/index.js +49 -0
  237. package/lib/cjs/webchat/webview/index.js.map +1 -0
  238. package/lib/cjs/webchat/webview/styles.d.ts +7 -0
  239. package/lib/cjs/webchat/webview/styles.js +46 -0
  240. package/lib/cjs/webchat/webview/styles.js.map +1 -0
  241. package/lib/cjs/webchat-app.d.ts +62 -86
  242. package/lib/cjs/webchat-app.js +126 -62
  243. package/lib/cjs/webchat-app.js.map +1 -1
  244. package/lib/cjs/webview-app.js +5 -2
  245. package/lib/cjs/webview-app.js.map +1 -1
  246. package/lib/esm/components/audio.d.ts +8 -7
  247. package/lib/esm/components/audio.js +7 -4
  248. package/lib/esm/components/audio.js.map +1 -1
  249. package/lib/esm/components/button.js +2 -3
  250. package/lib/esm/components/button.js.map +1 -1
  251. package/lib/esm/components/carousel.js +1 -1
  252. package/lib/esm/components/carousel.js.map +1 -1
  253. package/lib/esm/components/custom-message.d.ts +16 -12
  254. package/lib/esm/components/custom-message.js +3 -9
  255. package/lib/esm/components/custom-message.js.map +1 -1
  256. package/lib/esm/components/document.d.ts +8 -7
  257. package/lib/esm/components/document.js +4 -4
  258. package/lib/esm/components/document.js.map +1 -1
  259. package/lib/esm/components/element.js +6 -6
  260. package/lib/esm/components/element.js.map +1 -1
  261. package/lib/esm/components/handoff.d.ts +1 -1
  262. package/lib/esm/components/handoff.js +1 -1
  263. package/lib/esm/components/handoff.js.map +1 -1
  264. package/lib/esm/components/image.d.ts +8 -7
  265. package/lib/esm/components/image.js +4 -4
  266. package/lib/esm/components/image.js.map +1 -1
  267. package/lib/esm/components/index-types.d.ts +30 -127
  268. package/lib/esm/components/index.d.ts +7 -1
  269. package/lib/esm/components/index.js +7 -1
  270. package/lib/esm/components/index.js.map +1 -1
  271. package/lib/esm/components/message/index.js +2 -1
  272. package/lib/esm/components/message/index.js.map +1 -1
  273. package/lib/esm/components/message/message-feedback.d.ts +1 -1
  274. package/lib/esm/components/message/message-feedback.js +1 -1
  275. package/lib/esm/components/message/message-feedback.js.map +1 -1
  276. package/lib/esm/components/message/message-footer.d.ts +1 -1
  277. package/lib/esm/components/message/message-footer.js +1 -1
  278. package/lib/esm/components/message/message-footer.js.map +1 -1
  279. package/lib/esm/components/message/message-image.js +1 -1
  280. package/lib/esm/components/message/message-image.js.map +1 -1
  281. package/lib/esm/components/message/timestamps.d.ts +1 -1
  282. package/lib/esm/components/message/timestamps.js +1 -1
  283. package/lib/esm/components/message/timestamps.js.map +1 -1
  284. package/lib/esm/components/multichannel/multichannel-button.d.ts +1 -1
  285. package/lib/esm/components/multichannel/multichannel-button.js +1 -1
  286. package/lib/esm/components/multichannel/multichannel-carousel.js +5 -5
  287. package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
  288. package/lib/esm/components/multichannel/multichannel-reply.d.ts +1 -1
  289. package/lib/esm/components/multichannel/multichannel-text.d.ts +1 -1
  290. package/lib/esm/components/multichannel/multichannel-text.js +2 -1
  291. package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
  292. package/lib/esm/components/multichannel/multichannel-utils.d.ts +9 -15
  293. package/lib/esm/components/multichannel/multichannel-utils.js +40 -24
  294. package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
  295. package/lib/esm/components/multichannel/multichannel.js +7 -7
  296. package/lib/esm/components/multichannel/multichannel.js.map +1 -1
  297. package/lib/esm/components/multichannel/whatsapp/constants.d.ts +11 -0
  298. package/lib/esm/components/multichannel/whatsapp/constants.js +10 -0
  299. package/lib/esm/components/multichannel/whatsapp/constants.js.map +1 -0
  300. package/lib/esm/components/raw.d.ts +1 -1
  301. package/lib/esm/components/reply.d.ts +7 -6
  302. package/lib/esm/components/reply.js +9 -5
  303. package/lib/esm/components/reply.js.map +1 -1
  304. package/lib/esm/components/text.d.ts +1 -1
  305. package/lib/esm/components/video.d.ts +8 -7
  306. package/lib/esm/components/video.js +2 -3
  307. package/lib/esm/components/video.js.map +1 -1
  308. package/lib/esm/components/webchat-settings.d.ts +15 -2
  309. package/lib/esm/components/webchat-settings.js +1 -1
  310. package/lib/esm/components/webchat-settings.js.map +1 -1
  311. package/lib/esm/components/whatsapp-button-list.js +1 -1
  312. package/lib/esm/components/whatsapp-catalog.d.ts +6 -0
  313. package/lib/esm/components/whatsapp-catalog.js +21 -0
  314. package/lib/esm/components/whatsapp-catalog.js.map +1 -0
  315. package/lib/esm/components/whatsapp-cta-url-button.js +1 -1
  316. package/lib/esm/components/whatsapp-media-carousel.d.ts +46 -0
  317. package/lib/esm/components/whatsapp-media-carousel.js +36 -0
  318. package/lib/esm/components/whatsapp-media-carousel.js.map +1 -0
  319. package/lib/esm/components/whatsapp-product-carousel.d.ts +32 -0
  320. package/lib/esm/components/whatsapp-product-carousel.js +30 -0
  321. package/lib/esm/components/whatsapp-product-carousel.js.map +1 -0
  322. package/lib/esm/components/whatsapp-product-list.d.ts +15 -0
  323. package/lib/esm/components/whatsapp-product-list.js +22 -0
  324. package/lib/esm/components/whatsapp-product-list.js.map +1 -0
  325. package/lib/esm/components/whatsapp-product.d.ts +7 -0
  326. package/lib/esm/components/whatsapp-product.js +21 -0
  327. package/lib/esm/components/whatsapp-product.js.map +1 -0
  328. package/lib/esm/constants.d.ts +0 -6
  329. package/lib/esm/constants.js +0 -6
  330. package/lib/esm/constants.js.map +1 -1
  331. package/lib/esm/contexts.d.ts +3 -4
  332. package/lib/esm/contexts.js +1 -75
  333. package/lib/esm/contexts.js.map +1 -1
  334. package/lib/esm/dev-app.d.ts +7 -0
  335. package/lib/esm/dev-app.js +5 -2
  336. package/lib/esm/dev-app.js.map +1 -1
  337. package/lib/esm/index-types.d.ts +90 -61
  338. package/lib/esm/index-types.js.map +1 -1
  339. package/lib/esm/index.d.ts +1 -1
  340. package/lib/esm/index.js +1 -1
  341. package/lib/esm/index.js.map +1 -1
  342. package/lib/esm/msg-to-botonic.d.ts +1 -1
  343. package/lib/esm/msg-to-botonic.js +5 -8
  344. package/lib/esm/msg-to-botonic.js.map +1 -1
  345. package/lib/esm/react-bot.d.ts +1 -1
  346. package/lib/esm/util/error-boundary.d.ts +1 -1
  347. package/lib/esm/util/functional.d.ts +3 -0
  348. package/lib/esm/util/functional.js +26 -0
  349. package/lib/esm/util/functional.js.map +1 -0
  350. package/lib/esm/util/react.d.ts +1 -1
  351. package/lib/esm/util/webchat.d.ts +17 -6
  352. package/lib/esm/util/webchat.js +9 -7
  353. package/lib/esm/util/webchat.js.map +1 -1
  354. package/lib/esm/webchat/chat-area/index.d.ts +1 -1
  355. package/lib/esm/webchat/chat-area/index.js +2 -2
  356. package/lib/esm/webchat/chat-area/index.js.map +1 -1
  357. package/lib/esm/webchat/components/common.d.ts +1 -1
  358. package/lib/esm/webchat/components/conditional-animation.d.ts +1 -1
  359. package/lib/esm/webchat/components/conditional-animation.js +1 -1
  360. package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
  361. package/lib/esm/webchat/components/opened-persistent-menu.d.ts +1 -1
  362. package/lib/esm/webchat/components/opened-persistent-menu.js +1 -1
  363. package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -1
  364. package/lib/esm/webchat/{actions.d.ts → context/actions.d.ts} +4 -1
  365. package/lib/esm/webchat/{actions.js → context/actions.js} +4 -0
  366. package/lib/esm/webchat/context/actions.js.map +1 -0
  367. package/lib/esm/webchat/context/index.d.ts +5 -0
  368. package/lib/esm/webchat/context/index.js +81 -0
  369. package/lib/esm/webchat/context/index.js.map +1 -0
  370. package/lib/esm/webchat/{messages-reducer.d.ts → context/messages-reducer.d.ts} +1 -1
  371. package/lib/esm/webchat/{messages-reducer.js → context/messages-reducer.js} +3 -1
  372. package/lib/esm/webchat/context/messages-reducer.js.map +1 -0
  373. package/lib/esm/webchat/context/types.d.ts +76 -0
  374. package/lib/esm/webchat/context/types.js +2 -0
  375. package/lib/esm/webchat/context/types.js.map +1 -0
  376. package/lib/esm/webchat/{hooks → context}/use-webchat.d.ts +21 -20
  377. package/lib/esm/webchat/{hooks → context}/use-webchat.js +21 -7
  378. package/lib/esm/webchat/context/use-webchat.js.map +1 -0
  379. package/lib/esm/webchat/{webchat-reducer.d.ts → context/webchat-reducer.d.ts} +1 -1
  380. package/lib/esm/webchat/{webchat-reducer.js → context/webchat-reducer.js} +4 -0
  381. package/lib/esm/webchat/context/webchat-reducer.js.map +1 -0
  382. package/lib/esm/webchat/cover-component/index.d.ts +1 -1
  383. package/lib/esm/webchat/cover-component/index.js +1 -1
  384. package/lib/esm/webchat/cover-component/index.js.map +1 -1
  385. package/lib/esm/webchat/header/default-header.d.ts +1 -0
  386. package/lib/esm/webchat/header/default-header.js +21 -0
  387. package/lib/esm/webchat/header/default-header.js.map +1 -0
  388. package/lib/esm/webchat/header/index.d.ts +2 -0
  389. package/lib/esm/webchat/header/index.js +20 -0
  390. package/lib/esm/webchat/header/index.js.map +1 -0
  391. package/lib/esm/webchat/header/styles.d.ts +7 -0
  392. package/lib/esm/webchat/header/styles.js +55 -0
  393. package/lib/esm/webchat/header/styles.js.map +1 -0
  394. package/lib/esm/webchat/hooks/index.d.ts +0 -1
  395. package/lib/esm/webchat/hooks/index.js +0 -1
  396. package/lib/esm/webchat/hooks/index.js.map +1 -1
  397. package/lib/esm/webchat/hooks/use-previous.d.ts +1 -1
  398. package/lib/esm/webchat/hooks/use-previous.js.map +1 -1
  399. package/lib/esm/webchat/hooks/use-scroll-to-bottom.d.ts +6 -4
  400. package/lib/esm/webchat/hooks/use-scroll-to-bottom.js.map +1 -1
  401. package/lib/esm/webchat/hooks/use-scrollbar-controller.js +16 -16
  402. package/lib/esm/webchat/hooks/use-scrollbar-controller.js.map +1 -1
  403. package/lib/esm/webchat/hooks/use-typing.d.ts +1 -1
  404. package/lib/esm/webchat/hooks/use-webchat-dimensions.js +4 -4
  405. package/lib/esm/webchat/hooks/use-webchat-dimensions.js.map +1 -1
  406. package/lib/esm/webchat/hooks/use-webchat-resizer.js +6 -6
  407. package/lib/esm/webchat/hooks/use-webchat-resizer.js.map +1 -1
  408. package/lib/esm/webchat/index-types.d.ts +3 -46
  409. package/lib/esm/webchat/index.d.ts +1 -0
  410. package/lib/esm/webchat/index.js +1 -0
  411. package/lib/esm/webchat/index.js.map +1 -1
  412. package/lib/esm/webchat/input-panel/attachment.d.ts +2 -2
  413. package/lib/esm/webchat/input-panel/attachment.js +1 -1
  414. package/lib/esm/webchat/input-panel/attachment.js.map +1 -1
  415. package/lib/esm/webchat/input-panel/emoji-picker.d.ts +2 -2
  416. package/lib/esm/webchat/input-panel/emoji-picker.js +1 -1
  417. package/lib/esm/webchat/input-panel/emoji-picker.js.map +1 -1
  418. package/lib/esm/webchat/input-panel/index.d.ts +4 -4
  419. package/lib/esm/webchat/input-panel/index.js +7 -2
  420. package/lib/esm/webchat/input-panel/index.js.map +1 -1
  421. package/lib/esm/webchat/input-panel/opened-emoji-picker.d.ts +1 -1
  422. package/lib/esm/webchat/input-panel/persistent-menu.d.ts +1 -1
  423. package/lib/esm/webchat/input-panel/persistent-menu.js +1 -1
  424. package/lib/esm/webchat/input-panel/persistent-menu.js.map +1 -1
  425. package/lib/esm/webchat/input-panel/send-button.d.ts +1 -1
  426. package/lib/esm/webchat/input-panel/send-button.js +1 -1
  427. package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
  428. package/lib/esm/webchat/input-panel/textarea.d.ts +4 -4
  429. package/lib/esm/webchat/input-panel/textarea.js +11 -3
  430. package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
  431. package/lib/esm/webchat/message-list/index.d.ts +1 -1
  432. package/lib/esm/webchat/message-list/index.js +62 -37
  433. package/lib/esm/webchat/message-list/index.js.map +1 -1
  434. package/lib/esm/webchat/message-list/intro-message.d.ts +1 -1
  435. package/lib/esm/webchat/message-list/intro-message.js +1 -1
  436. package/lib/esm/webchat/message-list/intro-message.js.map +1 -1
  437. package/lib/esm/webchat/message-list/scroll-button.d.ts +1 -0
  438. package/lib/esm/webchat/message-list/styles.js +4 -3
  439. package/lib/esm/webchat/message-list/styles.js.map +1 -1
  440. package/lib/esm/webchat/message-list/unread-messages-banner.js +1 -1
  441. package/lib/esm/webchat/message-list/unread-messages-banner.js.map +1 -1
  442. package/lib/esm/webchat/message-list/use-notifications.js +1 -1
  443. package/lib/esm/webchat/message-list/use-notifications.js.map +1 -1
  444. package/lib/esm/webchat/replies/index.d.ts +1 -0
  445. package/lib/esm/webchat/replies/index.js +28 -0
  446. package/lib/esm/webchat/replies/index.js.map +1 -0
  447. package/lib/esm/webchat/replies/styles.d.ts +8 -0
  448. package/lib/esm/webchat/replies/styles.js +21 -0
  449. package/lib/esm/webchat/replies/styles.js.map +1 -0
  450. package/lib/esm/webchat/session-view.d.ts +1 -1
  451. package/lib/esm/webchat/session-view.js +2 -2
  452. package/lib/esm/webchat/session-view.js.map +1 -1
  453. package/lib/esm/webchat/styles.d.ts +9 -0
  454. package/lib/esm/webchat/styles.js +50 -0
  455. package/lib/esm/webchat/styles.js.map +1 -0
  456. package/lib/esm/webchat/theme/types.d.ts +167 -0
  457. package/lib/esm/webchat/theme/types.js +2 -0
  458. package/lib/esm/webchat/theme/types.js.map +1 -0
  459. package/lib/esm/webchat/trigger-button/index.d.ts +1 -0
  460. package/lib/esm/webchat/trigger-button/index.js +1 -1
  461. package/lib/esm/webchat/trigger-button/index.js.map +1 -1
  462. package/lib/esm/webchat/typing-indicator/index.d.ts +3 -1
  463. package/lib/esm/webchat/typing-indicator/index.js +5 -2
  464. package/lib/esm/webchat/typing-indicator/index.js.map +1 -1
  465. package/lib/esm/webchat/typing-indicator/styles.d.ts +3 -2
  466. package/lib/esm/webchat/typing-indicator/styles.js +5 -2
  467. package/lib/esm/webchat/typing-indicator/styles.js.map +1 -1
  468. package/lib/esm/webchat/webchat-dev.d.ts +2 -2
  469. package/lib/esm/webchat/webchat-dev.js +1 -1
  470. package/lib/esm/webchat/webchat-dev.js.map +1 -1
  471. package/lib/esm/webchat/webchat.d.ts +4 -2
  472. package/lib/esm/webchat/webchat.js +87 -112
  473. package/lib/esm/webchat/webchat.js.map +1 -1
  474. package/lib/esm/webchat/webview/header.d.ts +1 -0
  475. package/lib/esm/webchat/webview/header.js +12 -0
  476. package/lib/esm/webchat/webview/header.js.map +1 -0
  477. package/lib/esm/webchat/webview/index.d.ts +1 -0
  478. package/lib/esm/webchat/webview/index.js +45 -0
  479. package/lib/esm/webchat/webview/index.js.map +1 -0
  480. package/lib/esm/webchat/webview/styles.d.ts +7 -0
  481. package/lib/esm/webchat/webview/styles.js +42 -0
  482. package/lib/esm/webchat/webview/styles.js.map +1 -0
  483. package/lib/esm/webchat-app.d.ts +62 -86
  484. package/lib/esm/webchat-app.js +127 -63
  485. package/lib/esm/webchat-app.js.map +1 -1
  486. package/lib/esm/webview-app.js +5 -2
  487. package/lib/esm/webview-app.js.map +1 -1
  488. package/package.json +21 -18
  489. package/src/components/{audio.jsx → audio.tsx} +10 -4
  490. package/src/components/button.tsx +1 -3
  491. package/src/components/carousel.jsx +1 -1
  492. package/src/components/{custom-message.jsx → custom-message.tsx} +19 -7
  493. package/src/components/{document.jsx → document.tsx} +5 -3
  494. package/src/components/element.jsx +4 -11
  495. package/src/components/handoff.jsx +1 -1
  496. package/src/components/{image.jsx → image.tsx} +10 -4
  497. package/src/components/index-types.ts +25 -114
  498. package/src/components/index.ts +22 -1
  499. package/src/components/message/index.jsx +2 -1
  500. package/src/components/message/message-feedback.tsx +1 -1
  501. package/src/components/message/message-footer.tsx +1 -1
  502. package/src/components/message/message-image.tsx +1 -1
  503. package/src/components/message/timestamps.tsx +1 -1
  504. package/src/components/multichannel/multichannel-button.jsx +1 -1
  505. package/src/components/multichannel/multichannel-carousel.jsx +7 -5
  506. package/src/components/multichannel/multichannel-text.jsx +4 -2
  507. package/src/components/multichannel/multichannel-utils.js +45 -27
  508. package/src/components/multichannel/multichannel.jsx +12 -7
  509. package/src/components/multichannel/whatsapp/constants.ts +10 -0
  510. package/src/components/{reply.jsx → reply.tsx} +10 -4
  511. package/src/components/{video.jsx → video.tsx} +3 -2
  512. package/src/components/webchat-settings.tsx +14 -2
  513. package/src/components/whatsapp-button-list.tsx +1 -1
  514. package/src/components/whatsapp-catalog.tsx +42 -0
  515. package/src/components/whatsapp-cta-url-button.tsx +1 -1
  516. package/src/components/whatsapp-media-carousel.tsx +104 -0
  517. package/src/components/whatsapp-product-carousel.tsx +83 -0
  518. package/src/components/whatsapp-product-list.tsx +56 -0
  519. package/src/components/whatsapp-product.tsx +44 -0
  520. package/src/constants.js +0 -7
  521. package/src/contexts.tsx +5 -80
  522. package/src/dev-app.jsx +5 -5
  523. package/src/index-types.ts +101 -70
  524. package/src/index.ts +1 -5
  525. package/src/msg-to-botonic.jsx +5 -9
  526. package/src/util/functional.ts +31 -0
  527. package/src/util/{webchat.js → webchat.ts} +15 -9
  528. package/src/webchat/chat-area/index.tsx +2 -4
  529. package/src/webchat/components/conditional-animation.jsx +1 -1
  530. package/src/webchat/components/opened-persistent-menu.jsx +1 -1
  531. package/src/webchat/{actions.ts → context/actions.ts} +4 -0
  532. package/src/webchat/context/index.tsx +84 -0
  533. package/src/webchat/{messages-reducer.ts → context/messages-reducer.ts} +4 -2
  534. package/src/webchat/context/types.ts +86 -0
  535. package/src/webchat/{hooks → context}/use-webchat.ts +73 -15
  536. package/src/webchat/{webchat-reducer.ts → context/webchat-reducer.ts} +5 -1
  537. package/src/webchat/cover-component/index.tsx +1 -1
  538. package/src/webchat/global.d.ts +3 -0
  539. package/src/webchat/header/default-header.tsx +75 -0
  540. package/src/webchat/header/index.tsx +37 -0
  541. package/src/webchat/header/styles.ts +62 -0
  542. package/src/webchat/hooks/index.ts +0 -1
  543. package/src/webchat/hooks/use-previous.ts +1 -1
  544. package/src/webchat/hooks/use-scroll-to-bottom.ts +8 -2
  545. package/src/webchat/hooks/use-scrollbar-controller.ts +22 -17
  546. package/src/webchat/hooks/use-typing.ts +1 -1
  547. package/src/webchat/hooks/use-webchat-dimensions.ts +4 -4
  548. package/src/webchat/hooks/use-webchat-resizer.ts +6 -6
  549. package/src/webchat/index-types.ts +3 -52
  550. package/src/webchat/index.ts +1 -0
  551. package/src/webchat/input-panel/attachment.tsx +2 -2
  552. package/src/webchat/input-panel/emoji-picker.tsx +2 -2
  553. package/src/webchat/input-panel/index.tsx +9 -5
  554. package/src/webchat/input-panel/persistent-menu.tsx +1 -1
  555. package/src/webchat/input-panel/send-button.tsx +1 -1
  556. package/src/webchat/input-panel/textarea.tsx +18 -5
  557. package/src/webchat/message-list/index.tsx +78 -49
  558. package/src/webchat/message-list/intro-message.tsx +1 -1
  559. package/src/webchat/message-list/styles.ts +4 -3
  560. package/src/webchat/message-list/unread-messages-banner.tsx +1 -1
  561. package/src/webchat/message-list/use-notifications.ts +1 -1
  562. package/src/webchat/replies/index.tsx +47 -0
  563. package/src/webchat/replies/styles.ts +28 -0
  564. package/src/webchat/session-view.jsx +2 -2
  565. package/src/webchat/styles.ts +59 -0
  566. package/src/webchat/theme/types.ts +119 -0
  567. package/src/webchat/trigger-button/index.tsx +1 -1
  568. package/src/webchat/typing-indicator/index.tsx +20 -12
  569. package/src/webchat/typing-indicator/styles.ts +7 -3
  570. package/src/webchat/webchat-dev.jsx +1 -1
  571. package/src/webchat/{webchat.jsx → webchat.tsx} +118 -144
  572. package/src/webchat/webview/header.tsx +22 -0
  573. package/src/webchat/webview/index.tsx +80 -0
  574. package/src/webchat/webview/styles.ts +48 -0
  575. package/src/webchat-app.tsx +522 -0
  576. package/src/webview-app.tsx +6 -4
  577. package/lib/cjs/webchat/actions.js.map +0 -1
  578. package/lib/cjs/webchat/header.d.ts +0 -3
  579. package/lib/cjs/webchat/header.js +0 -86
  580. package/lib/cjs/webchat/header.js.map +0 -1
  581. package/lib/cjs/webchat/hooks/use-webchat.js.map +0 -1
  582. package/lib/cjs/webchat/messages-reducer.js.map +0 -1
  583. package/lib/cjs/webchat/replies.d.ts +0 -1
  584. package/lib/cjs/webchat/replies.js +0 -47
  585. package/lib/cjs/webchat/replies.js.map +0 -1
  586. package/lib/cjs/webchat/webchat-reducer.js.map +0 -1
  587. package/lib/cjs/webchat/webview.d.ts +0 -2
  588. package/lib/cjs/webchat/webview.js +0 -75
  589. package/lib/cjs/webchat/webview.js.map +0 -1
  590. package/lib/esm/webchat/actions.js.map +0 -1
  591. package/lib/esm/webchat/header.d.ts +0 -3
  592. package/lib/esm/webchat/header.js +0 -81
  593. package/lib/esm/webchat/header.js.map +0 -1
  594. package/lib/esm/webchat/hooks/use-webchat.js.map +0 -1
  595. package/lib/esm/webchat/messages-reducer.js.map +0 -1
  596. package/lib/esm/webchat/replies.d.ts +0 -1
  597. package/lib/esm/webchat/replies.js +0 -42
  598. package/lib/esm/webchat/replies.js.map +0 -1
  599. package/lib/esm/webchat/webchat-reducer.js.map +0 -1
  600. package/lib/esm/webchat/webview.d.ts +0 -2
  601. package/lib/esm/webchat/webview.js +0 -70
  602. package/lib/esm/webchat/webview.js.map +0 -1
  603. package/src/webchat/header.jsx +0 -149
  604. package/src/webchat/replies.jsx +0 -64
  605. package/src/webchat/webview.jsx +0 -105
  606. package/src/webchat-app.jsx +0 -389
package/src/contexts.tsx CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Input as CoreInput, Session as CoreSession } from '@botonic/core'
2
2
  import { createContext } from 'react'
3
3
 
4
- import { ActionRequest, WebchatContextProps } from './index-types'
5
- import { webchatInitialState } from './webchat/hooks'
4
+ import { ActionRequest } from './index-types'
6
5
 
7
6
  export const RequestContext = createContext<
8
7
  Partial<ActionRequest> & {
@@ -27,86 +26,12 @@ export interface CloseWebviewOptions {
27
26
 
28
27
  export const WebviewRequestContext = createContext<{
29
28
  closeWebview: (options?: CloseWebviewOptions) => Promise<void>
30
- getString: (stringId: string) => string
29
+ getString?: (stringId: string) => string
31
30
  params: Record<string, any>
32
- session: CoreSession
31
+ session: Partial<CoreSession>
33
32
  }>({
34
33
  closeWebview: async () => undefined,
35
- getString: () => '',
34
+ getString: undefined,
36
35
  params: {} as Record<string, any>,
37
- session: {} as CoreSession,
38
- })
39
-
40
- export const WebchatContext = createContext<WebchatContextProps>({
41
- addMessage: () => {
42
- return
43
- },
44
- closeWebview: async () => {
45
- return
46
- },
47
- getThemeProperty: () => {
48
- return
49
- }, // used to retrieve a specific property of the theme defined by the developer in his 'webchat/index.js'
50
- openWebview: () => {
51
- return
52
- },
53
- resolveCase: () => {
54
- return
55
- },
56
- resetUnreadMessages: () => {
57
- return
58
- },
59
- setLastMessageVisible: () => {
60
- return
61
- },
62
- sendAttachment: async () => {
63
- return
64
- },
65
- sendInput: async () => {
66
- return
67
- },
68
- sendPayload: async () => {
69
- return
70
- },
71
- sendText: async () => {
72
- return
73
- },
74
- theme: {},
75
- toggleCoverComponent: () => {
76
- return
77
- },
78
- toggleWebchat: () => {
79
- return
80
- },
81
- toggleEmojiPicker: () => {
82
- return
83
- },
84
- togglePersistentMenu: () => {
85
- return
86
- },
87
- updateLatestInput: () => {
88
- return
89
- },
90
- updateMessage: () => {
91
- return
92
- },
93
- updateReplies: () => {
94
- return
95
- },
96
- updateUser: () => {
97
- return
98
- },
99
- updateWebchatDevSettings: () => {
100
- return
101
- },
102
- webchatState: webchatInitialState,
103
- trackEvent: async () => {
104
- return
105
- },
106
- webchatRef: { current: null },
107
- chatAreaRef: { current: null },
108
- inputPanelRef: { current: null },
109
- headerRef: { current: null },
110
- scrollableMessagesListRef: { current: null },
111
- repliesRef: { current: null },
36
+ session: {} as Partial<CoreSession>,
112
37
  })
package/src/dev-app.jsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import merge from 'lodash.merge'
2
2
  import React from 'react'
3
- import { render } from 'react-dom'
3
+ import { createRoot } from 'react-dom/client'
4
4
 
5
5
  import { SENDERS } from './index-types'
6
6
  import { ReactBot } from './react-bot'
@@ -119,10 +119,10 @@ export class DevApp extends WebchatApp {
119
119
 
120
120
  render(dest, optionsAtRuntime = {}) {
121
121
  onDOMLoaded(() => {
122
- render(
123
- this.getComponent(dest, optionsAtRuntime),
124
- this.getReactMountNode(dest)
125
- )
122
+ const devAppComponent = this.getComponent(dest, optionsAtRuntime)
123
+ const container = this.getReactMountNode(dest)
124
+ const reactRoot = createRoot(container)
125
+ reactRoot.render(devAppComponent)
126
126
  })
127
127
  }
128
128
 
@@ -5,6 +5,7 @@ import {
5
5
  Plugin as CorePlugin,
6
6
  Route as CoreRoute,
7
7
  Routes as CoreRoutes,
8
+ ServerConfig,
8
9
  Session as CoreSession,
9
10
  SessionUser as CoreSessionUser,
10
11
  } from '@botonic/core'
@@ -13,14 +14,16 @@ import React from 'react'
13
14
  import {
14
15
  BlockInputOption,
15
16
  ButtonProps,
16
- CoverComponentOptions,
17
- PersistentMenuTheme,
18
17
  ReplyProps,
19
- ThemeProps,
20
18
  WebchatSettingsProps,
21
- Webview,
22
- } from './components/index-types'
23
- import { WebchatState } from './webchat/index-types'
19
+ } from './components'
20
+ import { CloseWebviewOptions } from './contexts'
21
+ import { UseWebchat } from './webchat/context/use-webchat'
22
+ import {
23
+ CoverComponentOptions,
24
+ PersistentMenuOptionsTheme,
25
+ ThemeProps,
26
+ } from './webchat/theme/types'
24
27
  import { WebchatApp } from './webchat-app'
25
28
 
26
29
  /**
@@ -51,46 +54,100 @@ export interface RequestContextInterface extends ActionRequest {
51
54
  setLocale: (locale: string) => string
52
55
  }
53
56
 
54
- export interface CustomMessageType {
55
- customTypeName: string
57
+ export interface WebchatRef {
58
+ addBotResponse: ({
59
+ response,
60
+ session,
61
+ lastRoutePath,
62
+ }: AddBotResponseArgs) => void
63
+ setTyping: (typing: boolean) => void
64
+ addUserMessage: (message: any) => Promise<void>
65
+ updateUser: (userToUpdate: any) => void
66
+ openWebchat: () => void
67
+ closeWebchat: () => void
68
+ toggleWebchat: () => void
69
+ openCoverComponent: () => void
70
+ closeCoverComponent: () => void
71
+ toggleCoverComponent: () => void
72
+ renderCustomComponent: (customComponent: any) => void
73
+ unmountCustomComponent: () => void
74
+ isOnline: () => boolean
75
+ setOnline: (online: boolean) => void
76
+ getMessages: () => { id: string; ack: number; unsentInput: CoreInput }[] // TODO: define MessagesJSON
77
+ clearMessages: () => void
78
+ getLastMessageUpdate: () => string | undefined
79
+ updateMessageInfo: (msgId: string, messageInfo: any) => void
80
+ updateWebchatSettings: (settings: WebchatSettingsProps) => void
81
+ closeWebview: (options?: CloseWebviewOptions) => Promise<void>
82
+ }
83
+
84
+ interface AddBotResponseArgs {
85
+ response: any
86
+ session?: any
87
+ lastRoutePath?: any
56
88
  }
57
89
 
58
90
  export interface WebchatArgs {
59
- blockInputs?: BlockInputOption[]
91
+ theme?: ThemeProps
92
+ persistentMenu?: PersistentMenuOptionsTheme
60
93
  coverComponent?: CoverComponentOptions
61
- defaultDelay?: number
62
- defaultTyping?: number
63
- enableAnimations?: boolean
64
- enableAttachments?: boolean
94
+ blockInputs?: BlockInputOption[]
65
95
  enableEmojiPicker?: boolean
96
+ enableAttachments?: boolean
66
97
  enableUserInput?: boolean
67
- shadowDOM?: boolean | (() => boolean)
98
+ enableAnimations?: boolean
68
99
  hostId?: string
69
- getString?: (stringId: string, session: CoreSession) => string
70
- onClose?: (app: WebchatApp, args: any) => void
100
+ shadowDOM?: boolean | (() => boolean)
101
+ defaultDelay?: number
102
+ defaultTyping?: number
103
+ storage?: Storage | null
104
+ storageKey?: string
71
105
  onInit?: (app: WebchatApp, args: any) => void
72
- onMessage?: (app: WebchatApp, message: WebchatMessage) => void
73
106
  onOpen?: (app: WebchatApp, args: any) => void
74
- onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void
107
+ onClose?: (app: WebchatApp, args: any) => void
108
+ onMessage?: (app: WebchatApp, message: WebchatMessage) => void
75
109
  onTrackEvent?: TrackEventFunction
76
- persistentMenu?: PersistentMenuTheme
77
- storage?: Storage | null
78
- storageKey?: any
110
+ onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void
111
+ appId?: string
112
+ visibility?: boolean | (() => boolean) | 'dynamic'
113
+ server?: ServerConfig
114
+ }
115
+
116
+ export interface WebchatProps {
117
+ webchatHooks?: UseWebchat
118
+ initialSession?: any
119
+ initialDevSettings?: any
120
+ onStateChange: (args: OnStateChangeArgs) => void
121
+
122
+ shadowDOM?: any
79
123
  theme?: ThemeProps
124
+ persistentMenu?: PersistentMenuOptionsTheme
125
+ coverComponent?: CoverComponentOptions
126
+ blockInputs?: BlockInputOption[]
127
+ enableEmojiPicker?: boolean
128
+ enableAttachments?: boolean
129
+ enableUserInput?: boolean
130
+ enableAnimations?: boolean
131
+ storage?: Storage | null
132
+ storageKey?: string | (() => string)
133
+ defaultDelay?: number
134
+ defaultTyping?: number
135
+ onInit?: (args?: any) => void
136
+ onOpen?: (args?: any) => void
137
+ onClose?: (args?: any) => void
138
+ onUserInput(args: OnUserInputArgs): Promise<void>
139
+ onTrackEvent?: TrackEventFunction
140
+ host?: any
141
+ server?: ServerConfig
80
142
  }
81
143
 
82
- type EventArgs = { [key: string]: any }
83
- type TrackEventFunction = (
144
+ export type EventArgs = { [key: string]: any }
145
+ export type TrackEventFunction = (
84
146
  request: ActionRequest,
85
147
  eventName: string,
86
148
  args?: EventArgs
87
149
  ) => Promise<void>
88
150
 
89
- export interface WebchatAppArgs {
90
- appId?: string
91
- visibility?: () => boolean
92
- }
93
-
94
151
  export enum SENDERS {
95
152
  bot = 'bot',
96
153
  user = 'user',
@@ -106,19 +163,19 @@ export interface WebchatMessage {
106
163
  ack: 0 | 1
107
164
  blob: boolean
108
165
  buttons: ButtonProps[]
109
- children: any
110
- data: any
166
+ children: any // messageJSON don't have children prop
167
+ data: any // if message.type === 'text' => message.data = {text: string}
111
168
  delay: number
112
169
  display: boolean
113
- enabletimestamps: boolean
170
+ enabletimestamps?: boolean
114
171
  id: string
115
- imagestyle: any
172
+ imagestyle?: any
116
173
  isUnread: boolean
117
174
  json: any
118
- markdown: boolean
175
+ markdown: boolean // 0 | 1
119
176
  replies: ReplyProps[]
120
177
  sentBy: SENDERS
121
- style: any
178
+ style?: any
122
179
  timestamp: string
123
180
  type: CoreInputType
124
181
  typing: number
@@ -128,7 +185,7 @@ export interface OnUserInputArgs {
128
185
  input: CoreInput
129
186
  lastRoutePath?: string
130
187
  session?: CoreSession
131
- user: CoreSessionUser
188
+ user?: CoreSessionUser
132
189
  }
133
190
 
134
191
  export interface OnStateChangeArgs {
@@ -142,43 +199,17 @@ export interface MessageInfo {
142
199
  type: 'update_webchat_settings' | 'sender_action'
143
200
  }
144
201
 
145
- export interface Event {
146
- action?: 'update_message_info'
202
+ export type Event = ConnectionChangeEvent | UpdateMessageInfoEvent
203
+
204
+ interface ConnectionChangeEvent {
205
+ action: 'connectionChange'
206
+ online: boolean
147
207
  isError?: boolean
148
208
  message?: MessageInfo
149
209
  }
150
210
 
151
- // ClientInput: type for sendInput and updateLatestInput function without message_id and bot_interaction_id because backend set this values
152
- export type ClientInput = Omit<CoreInput, 'message_id' | 'bot_interaction_id'>
153
-
154
- export interface WebchatContextProps {
155
- addMessage: (message: WebchatMessage) => void
156
- closeWebview: () => Promise<void>
157
- getThemeProperty: (property: string, defaultValue?: any) => any
158
- openWebview: (webviewComponent: Webview, params?: any) => void
159
- resetUnreadMessages: () => void
160
- resolveCase: () => void
161
- sendAttachment: (attachment: File) => Promise<void>
162
- sendInput: (input: ClientInput) => Promise<void>
163
- sendPayload: (payload: string) => Promise<void>
164
- sendText: (text: string, payload?: string) => Promise<void>
165
- setLastMessageVisible: (isLastMessageVisible: boolean) => void
166
- theme: ThemeProps
167
- toggleWebchat: (toggle: boolean) => void
168
- toggleEmojiPicker: (toggle: boolean) => void
169
- togglePersistentMenu: (toggle: boolean) => void
170
- toggleCoverComponent: (toggle: boolean) => void
171
- updateLatestInput: (input: ClientInput) => void
172
- updateMessage: (message: WebchatMessage) => void
173
- updateReplies: (replies: boolean) => void
174
- updateUser: (user: Partial<CoreSessionUser>) => void
175
- updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
176
- webchatState: WebchatState
177
- trackEvent: TrackEventFunction
178
- webchatRef: React.MutableRefObject<HTMLDivElement | null>
179
- chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
180
- inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
181
- headerRef: React.MutableRefObject<HTMLDivElement | null>
182
- scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
183
- repliesRef: React.MutableRefObject<HTMLDivElement | null>
211
+ interface UpdateMessageInfoEvent {
212
+ action: 'update_message_info'
213
+ message: MessageInfo
214
+ isError?: boolean
184
215
  }
package/src/index.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  export { BotonicInputTester, BotonicOutputTester } from './botonic-tester'
2
2
  export * from './components'
3
- export {
4
- RequestContext,
5
- WebchatContext,
6
- WebviewRequestContext,
7
- } from './contexts'
3
+ export { RequestContext, WebviewRequestContext } from './contexts'
8
4
  export { DevApp } from './dev-app'
9
5
  export * from './index-types'
10
6
  export { msgsToBotonic, msgToBotonic } from './msg-to-botonic'
@@ -32,7 +32,7 @@ import {
32
32
  * @param customMessageTypes {{customTypeName}[]?}
33
33
  * @return {React.ReactNode}
34
34
  */
35
- export function msgToBotonic(msg, customMessageTypes) {
35
+ export function msgToBotonic(msg, customMessageTypes = []) {
36
36
  delete msg.display
37
37
  if (isCustom(msg)) {
38
38
  try {
@@ -56,28 +56,28 @@ export function msgToBotonic(msg, customMessageTypes) {
56
56
  <Image
57
57
  key={msg.key}
58
58
  {...msg}
59
- src={msg.data.image != undefined ? msg.data.image : msg.data}
59
+ src={msg.data.image !== undefined ? msg.data.image : msg.data}
60
60
  />
61
61
  )
62
62
  } else if (isVideo(msg)) {
63
63
  return (
64
64
  <Video
65
65
  {...msg}
66
- src={msg.data.video != undefined ? msg.data.video : msg.data}
66
+ src={msg.data.video !== undefined ? msg.data.video : msg.data}
67
67
  />
68
68
  )
69
69
  } else if (isAudio(msg)) {
70
70
  return (
71
71
  <Audio
72
72
  {...msg}
73
- src={msg.data.audio != undefined ? msg.data.audio : msg.data}
73
+ src={msg.data.audio !== undefined ? msg.data.audio : msg.data}
74
74
  />
75
75
  )
76
76
  } else if (isDocument(msg)) {
77
77
  return (
78
78
  <Document
79
79
  {...msg}
80
- src={msg.data.document != undefined ? msg.data.document : msg.data}
80
+ src={msg.data.document !== undefined ? msg.data.document : msg.data}
81
81
  />
82
82
  )
83
83
  } else if (isLocation(msg)) {
@@ -99,10 +99,6 @@ export function msgToBotonic(msg, customMessageTypes) {
99
99
  return null
100
100
  }
101
101
 
102
- function rndStr() {
103
- return Math.random().toString()
104
- }
105
-
106
102
  /**
107
103
  * @param msgs {object|object[]}
108
104
  * @param customMessageTypes {{customTypeName}[]?}
@@ -0,0 +1,31 @@
1
+ function camelCaseToSnake(str: string): string {
2
+ return str
3
+ .replace(/([a-z])([A-Z])/g, '$1_$2')
4
+ .replace(/([A-Za-z])(\d)/g, '$1_$2')
5
+ .replace(/(\d)([A-Za-z])/g, '$1_$2')
6
+ .toLowerCase()
7
+ }
8
+ type Input = Record<string, any> | Record<string, any>[] | undefined
9
+
10
+ export function toSnakeCaseKeys(input: Input): Input {
11
+ if (Array.isArray(input)) {
12
+ return input.map(item => toSnakeCaseKeys(item))
13
+ }
14
+
15
+ if (typeof input === 'object' && input !== null) {
16
+ const result = Object.keys(input).reduce((acc, key) => {
17
+ const snakeKey = camelCaseToSnake(key)
18
+ const value = input[key]
19
+ acc[snakeKey] =
20
+ typeof value === 'object' && value !== null
21
+ ? toSnakeCaseKeys(value)
22
+ : value
23
+
24
+ return acc
25
+ }, {})
26
+
27
+ return result
28
+ }
29
+
30
+ return input
31
+ }
@@ -3,6 +3,7 @@ import UAParser from 'ua-parser-js'
3
3
  import { v7 as uuidv7 } from 'uuid'
4
4
 
5
5
  import { WEBCHAT } from '../constants'
6
+ import { ThemeProps } from '../webchat/theme/types'
6
7
  import { getProperty } from './objects'
7
8
 
8
9
  /**
@@ -11,13 +12,12 @@ import { getProperty } from './objects'
11
12
  * If property doesn't exist, returns the defaultValue.
12
13
  */
13
14
  export const _getThemeProperty =
14
- theme =>
15
- (property, defaultValue = undefined) => {
16
- for (const [k, v] of Object.entries(WEBCHAT.CUSTOM_PROPERTIES)) {
17
- if (v == property) {
18
- const nestedProperty = getProperty(theme, v)
15
+ (theme: ThemeProps) => (property: string, defaultValue?: any) => {
16
+ for (const [key, value] of Object.entries(WEBCHAT.CUSTOM_PROPERTIES)) {
17
+ if (value === property) {
18
+ const nestedProperty = getProperty(theme, value)
19
19
  if (nestedProperty !== undefined) return nestedProperty
20
- const plainProperty = getProperty(theme, k)
20
+ const plainProperty = getProperty(theme, key)
21
21
  if (plainProperty !== undefined) return plainProperty
22
22
  return defaultValue
23
23
  }
@@ -25,7 +25,10 @@ export const _getThemeProperty =
25
25
  return undefined
26
26
  }
27
27
 
28
- export const createUser = () => {
28
+ export const createUser = (): {
29
+ id: string
30
+ name: string
31
+ } => {
29
32
  const parser = new UAParser()
30
33
  const ua = parser.getResult()
31
34
  let name = `${ua.os.name} ${ua.browser.name}`
@@ -35,9 +38,11 @@ export const createUser = () => {
35
38
  name,
36
39
  }
37
40
  }
38
- export const initSession = session => {
41
+ export const initSession = (
42
+ session: any
43
+ ): { user: { id: string; name: string } } => {
39
44
  if (!session) session = {}
40
- const hasUserId = session.user && session.user.id !== undefined
45
+ const hasUserId = session?.user?.id !== undefined
41
46
  if (!session.user || Object.keys(session.user).length === 0 || !hasUserId)
42
47
  session.user = !hasUserId ? merge(session.user, createUser()) : createUser()
43
48
  return session
@@ -48,6 +53,7 @@ export const shouldKeepSessionOnReload = ({
48
53
  devSettings,
49
54
  }) => !initialDevSettings || (devSettings && devSettings.keepSessionOnReload)
50
55
 
56
+ //TODO: Review param serverConfig if is of type ServerConfig this never have errorMessage
51
57
  export const getServerErrorMessage = serverConfig => {
52
58
  if (!serverConfig || !serverConfig.errorMessage) return 'Connection issues'
53
59
  if (typeof serverConfig.errorMessage === 'function') {
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useEffect, useState } from 'react'
2
2
 
3
- import { WebchatContext } from '../../contexts'
4
3
  import { BotonicContainerId } from '../constants'
4
+ import { WebchatContext } from '../context'
5
5
  import { useWebchatDimensions } from '../hooks'
6
6
  import { WebchatMessageList } from '../message-list'
7
7
  import { WebchatReplies } from '../replies'
@@ -27,9 +27,7 @@ export const ChatArea = () => {
27
27
  height={chatAreaHeight}
28
28
  >
29
29
  <WebchatMessageList />
30
- {replies && Object.keys(replies).length > 0 && (
31
- <WebchatReplies replies={replies} />
32
- )}
30
+ {replies && replies.length > 0 && <WebchatReplies />}
33
31
  </StyledChatArea>
34
32
  )
35
33
  }
@@ -1,9 +1,9 @@
1
1
  import React, { useContext } from 'react'
2
2
 
3
3
  import { WEBCHAT } from '../../constants'
4
- import { WebchatContext } from '../../contexts'
5
4
  import { Scale } from '../../shared/styles'
6
5
  import { ConditionalWrapper } from '../../util/react'
6
+ import { WebchatContext } from '../context'
7
7
 
8
8
  export const ConditionalAnimation = props => {
9
9
  const { getThemeProperty } = useContext(WebchatContext)
@@ -3,7 +3,7 @@ import styled from 'styled-components'
3
3
 
4
4
  import { Button } from '../../components/button'
5
5
  import { ROLES, WEBCHAT } from '../../constants'
6
- import { WebchatContext } from '../../contexts'
6
+ import { WebchatContext } from '../context'
7
7
  import { useComponentVisible } from '../hooks'
8
8
 
9
9
  const ButtonsContainer = styled.div`
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
1
2
  export enum WebchatAction {
2
3
  ADD_MESSAGE = 'addMessage',
3
4
  ADD_MESSAGE_COMPONENT = 'addMessageComponent',
@@ -23,4 +24,7 @@ export enum WebchatAction {
23
24
  UPDATE_THEME = 'updateTheme',
24
25
  UPDATE_TYPING = 'updateTyping',
25
26
  UPDATE_WEBVIEW = 'updateWebview',
27
+ REMOVE_REPLIES = 'removeReplies',
28
+ REMOVE_WEBVIEW = 'removeWebview',
29
+ SET_IS_INPUT_FOCUSED = 'setIsInputFocused',
26
30
  }
@@ -0,0 +1,84 @@
1
+ import { createContext } from 'react'
2
+
3
+ import { WebchatContextProps } from './types'
4
+ import { webchatInitialState } from './use-webchat'
5
+
6
+ export { WebchatState } from './types'
7
+ export { useWebchat, webchatInitialState } from './use-webchat'
8
+
9
+ export const WebchatContext = createContext<WebchatContextProps>({
10
+ addMessage: () => {
11
+ return
12
+ },
13
+ getThemeProperty: () => {
14
+ return
15
+ }, // used to retrieve a specific property of the theme defined by the developer in his 'webchat/index.js'
16
+ closeWebview: async () => {
17
+ return
18
+ },
19
+ openWebview: () => {
20
+ return
21
+ },
22
+ resolveCase: () => {
23
+ return
24
+ },
25
+ resetUnreadMessages: () => {
26
+ return
27
+ },
28
+ setIsInputFocused: () => {
29
+ return
30
+ },
31
+ setLastMessageVisible: () => {
32
+ return
33
+ },
34
+ sendAttachment: async () => {
35
+ return
36
+ },
37
+ sendInput: async () => {
38
+ return
39
+ },
40
+ sendPayload: async () => {
41
+ return
42
+ },
43
+ sendText: async () => {
44
+ return
45
+ },
46
+ theme: {}, // TODO: Remove this attribute and use allways webchatState.theme
47
+ toggleCoverComponent: () => {
48
+ return
49
+ },
50
+ toggleWebchat: () => {
51
+ return
52
+ },
53
+ toggleEmojiPicker: () => {
54
+ return
55
+ },
56
+ togglePersistentMenu: () => {
57
+ return
58
+ },
59
+ updateLatestInput: () => {
60
+ return
61
+ },
62
+ updateMessage: () => {
63
+ return
64
+ },
65
+ updateReplies: () => {
66
+ return
67
+ },
68
+ updateUser: () => {
69
+ return
70
+ },
71
+ updateWebchatDevSettings: () => {
72
+ return
73
+ },
74
+ webchatState: webchatInitialState,
75
+ trackEvent: async () => {
76
+ return
77
+ },
78
+ webchatContainerRef: { current: null },
79
+ chatAreaRef: { current: null },
80
+ inputPanelRef: { current: null },
81
+ headerRef: { current: null },
82
+ scrollableMessagesListRef: { current: null },
83
+ repliesRef: { current: null },
84
+ })
@@ -1,6 +1,6 @@
1
- import { SENDERS } from '../index-types'
1
+ import { SENDERS } from '../../index-types'
2
2
  import { WebchatAction } from './actions'
3
- import { WebchatState } from './index-types'
3
+ import { WebchatState } from './types'
4
4
 
5
5
  export const messagesReducer = (
6
6
  state: WebchatState,
@@ -15,6 +15,8 @@ export const messagesReducer = (
15
15
  return updateMessageReducer(state, action)
16
16
  case WebchatAction.UPDATE_REPLIES:
17
17
  return { ...state, replies: action.payload }
18
+ case WebchatAction.REMOVE_REPLIES:
19
+ return { ...state, replies: undefined }
18
20
  case WebchatAction.CLEAR_MESSAGES:
19
21
  return {
20
22
  ...state,