@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botonic/react",
3
- "version": "0.31.5-alpha.1",
3
+ "version": "0.32.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "description": "Build Chatbots using React",
6
6
  "main": "./lib/cjs",
@@ -20,39 +20,42 @@
20
20
  "lint_core": "../../node_modules/.bin/eslint_d --cache --quiet '.*.js' '*.js' 'src/**/*.js*' --fix"
21
21
  },
22
22
  "dependencies": {
23
- "@botonic/core": "^0.30.0",
24
- "axios": "^1.7.2",
25
- "emoji-picker-react": "^4.4.9",
23
+ "@botonic/core": "0.32.0-alpha.0",
24
+ "axios": "^1.7.9",
25
+ "emoji-picker-react": "^4.12.0",
26
26
  "lodash.merge": "^4.6.2",
27
- "markdown-it": "^12.0.6",
28
- "react": "^16.14.0",
29
- "react-dom": "^16.14.0",
30
- "react-json-tree": "^0.15.0",
27
+ "markdown-it": "^12.3.2",
28
+ "react": "^18.3.1",
29
+ "react-dom": "^18.3.1",
30
+ "react-json-tree": "^0.18.0",
31
31
  "react-router-dom": "^5.3.4",
32
- "react-textarea-autosize": "^8.5.3",
33
- "styled-components": "^5.3.0",
32
+ "react-textarea-autosize": "^8.5.5",
33
+ "styled-components": "^5.3.11",
34
34
  "ua-parser-js": "^1.0.39",
35
35
  "uuid": "^10.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@babel/plugin-transform-runtime": "^7.23.9",
39
- "@babel/preset-react": "^7.18.6",
40
- "@testing-library/react": "^12.0.0",
41
- "@testing-library/react-hooks": "^8.0.1",
42
- "@types/jest": "^29.5.1",
38
+ "@babel/plugin-transform-runtime": "^7.25.9",
39
+ "@babel/preset-react": "^7.26.3",
40
+ "@testing-library/react": "^16.0.1",
41
+ "@types/jest": "^29.5.14",
42
+ "@types/lodash.merge": "^4.6.9",
43
43
  "@types/parse5": "^7.0.0",
44
- "@types/react": "^16.14.56",
44
+ "@types/react": "^18.3.18",
45
+ "@types/react-dom": "^18.3.5",
45
46
  "@types/styled-components": "^5.1.34",
47
+ "@types/ua-parser-js": "^0.7.39",
46
48
  "@types/uuid": "^10.0.0",
47
49
  "babel-plugin-add-module-exports": "^1.0.4",
48
50
  "copyfiles": "^2.4.1",
49
51
  "identity-obj-proxy": "^3.0.0",
50
52
  "intersection-observer": "^0.12.2",
51
- "react-test-renderer": "^16.14.0",
53
+ "react-test-renderer": "^18.3.1",
52
54
  "typescript": "5.0.4"
53
55
  },
54
56
  "engines": {
55
- "node": ">=20.0.0"
57
+ "node": ">=20.0.0",
58
+ "npm": ">=10.0.0"
56
59
  },
57
60
  "sideEffects": [
58
61
  "*.scss",
@@ -1,23 +1,29 @@
1
1
  import { INPUT, isBrowser } from '@botonic/core'
2
2
  import React from 'react'
3
+ import styled from 'styled-components'
3
4
 
4
5
  import { ROLES } from '../constants'
5
6
  import { staticAsset } from '../util/environment'
7
+ import { AudioProps } from './index-types'
6
8
  import { Message } from './message'
7
9
 
8
- const serialize = audioProps => {
10
+ const StyledAudio = styled.audio`
11
+ max-width: 100%;
12
+ `
13
+
14
+ const serialize = (audioProps: { src: string }) => {
9
15
  return { audio: audioProps.src }
10
16
  }
11
17
 
12
- export const Audio = props => {
18
+ export const Audio = (props: AudioProps) => {
13
19
  props = { ...props, src: staticAsset(props.src) }
14
20
  let content = props.children
15
21
  if (isBrowser())
16
22
  content = (
17
- <audio style={{ maxWidth: '100%' }} id='myAudio' controls>
23
+ <StyledAudio id='myAudio' controls>
18
24
  <source src={props.src} type='audio/mpeg' />
19
25
  Your browser does not support this audio format.
20
- </audio>
26
+ </StyledAudio>
21
27
  )
22
28
  return (
23
29
  <Message
@@ -3,10 +3,10 @@ import React, { useContext, useState } from 'react'
3
3
  import styled from 'styled-components'
4
4
 
5
5
  import { COLORS, WEBCHAT } from '../constants'
6
- import { WebchatContext } from '../contexts'
7
6
  import { resolveImage } from '../util/environment'
8
7
  import { renderComponent } from '../util/react'
9
8
  import { generateWebviewUrlWithParams } from '../util/webviews'
9
+ import { WebchatContext } from '../webchat/context'
10
10
  import { ButtonsDisabler } from './buttons-disabler'
11
11
  import { ButtonProps } from './index-types'
12
12
 
@@ -46,7 +46,6 @@ export const Button = (props: ButtonProps) => {
46
46
  updateMessage,
47
47
  } = useContext(WebchatContext)
48
48
  const [hover, setHover] = useState(false)
49
- const { theme } = webchatState
50
49
  const { autoDisable, disabledStyle } = ButtonsDisabler.resolveDisabling(
51
50
  webchatState.theme,
52
51
  props
@@ -170,7 +169,6 @@ export const Button = (props: ButtonProps) => {
170
169
  return (
171
170
  <StyledButton
172
171
  className={getClassName()}
173
- theme={theme}
174
172
  onMouseEnter={() => setHover(true)}
175
173
  onMouseLeave={() => setHover(false)}
176
174
  onClick={e => handleClick(e)}
@@ -5,8 +5,8 @@ import styled from 'styled-components'
5
5
  import LeftArrow from '../assets/leftArrow.svg'
6
6
  import RightArrow from '../assets/rightArrow.svg'
7
7
  import { COLORS, WEBCHAT } from '../constants'
8
- import { WebchatContext } from '../contexts'
9
8
  import { resolveImage } from '../util/environment'
9
+ import { WebchatContext } from '../webchat/context'
10
10
  import { ButtonsDisabler } from './buttons-disabler'
11
11
  import { Message } from './message'
12
12
 
@@ -6,22 +6,31 @@ import { SENDERS } from '../index-types'
6
6
  import { createErrorBoundary } from '../util/error-boundary'
7
7
  import { warnDeprecatedProps } from '../util/logs'
8
8
  import { mapObjectNonBooleanValues } from '../util/react'
9
+ import { CustomMessageType } from './index-types'
9
10
  import { Message } from './message'
10
11
  import { Reply } from './reply'
11
12
 
12
13
  /**
13
14
  *
14
- * @param name as it appears at ThemeProps' message.customTypes key
15
- * @param CustomMessageComponent
16
- * @param defaultProps Props for the wrapper Message
17
- * @param ErrorBoundary to recover in case it fails
15
+ * name: as it appears at ThemeProps' message.customTypes key
16
+ * CustomMessageComponent
17
+ * defaultProps: Props for the wrapper Message
18
+ * ErrorBoundary: to recover in case it fails
18
19
  */
20
+
21
+ export interface CustomMessageArgs {
22
+ name: string
23
+ component: React.ComponentType
24
+ defaultProps?: Record<string, any>
25
+ errorBoundary?: any
26
+ }
27
+
19
28
  export const customMessage = ({
20
29
  name,
21
30
  component: CustomMessageComponent,
22
31
  defaultProps = {},
23
- errorBoundary: ErrorBoundary = createErrorBoundary(),
24
- }) => {
32
+ errorBoundary = createErrorBoundary(),
33
+ }: CustomMessageArgs): CustomMessageType => {
25
34
  const CustomMessage = props => {
26
35
  warnDeprecatedProps(defaultProps, 'customMessage:')
27
36
  if (defaultProps.sentBy === SENDERS.user) {
@@ -57,6 +66,9 @@ export const customMessage = ({
57
66
  const WrappedComponent = props => {
58
67
  const { id, children, ...customMessageProps } = props
59
68
  const { replies, childrenWithoutReplies } = splitChildren(props)
69
+
70
+ const ErrorBoundary = errorBoundary
71
+
60
72
  return (
61
73
  <CustomMessage
62
74
  id={id}
@@ -80,7 +92,7 @@ export const customMessage = ({
80
92
  }
81
93
  WrappedComponent.customTypeName = name
82
94
  // eslint-disable-next-line react/display-name
83
- WrappedComponent.deserialize = msg => (
95
+ WrappedComponent.deserialize = (msg: any) => (
84
96
  <WrappedComponent
85
97
  id={msg.id}
86
98
  key={msg.key}
@@ -3,8 +3,9 @@ import React, { useContext } from 'react'
3
3
  import styled from 'styled-components'
4
4
 
5
5
  import { ROLES, WEBCHAT } from '../constants'
6
- import { WebchatContext } from '../contexts'
7
6
  import { staticAsset } from '../util/environment'
7
+ import { WebchatContext } from '../webchat/context'
8
+ import { DocumentProps } from './index-types'
8
9
  import { Message } from './message'
9
10
 
10
11
  const StyledButton = styled.a`
@@ -25,12 +26,13 @@ const StyledButton = styled.a`
25
26
  }
26
27
  `
27
28
 
28
- const serialize = documentProps => {
29
+ const serialize = (documentProps: { src: string }) => {
29
30
  return { document: documentProps.src }
30
31
  }
31
32
 
32
- export const Document = props => {
33
+ export const Document = (props: DocumentProps) => {
33
34
  props = { ...props, src: staticAsset(props.src) }
35
+
34
36
  let content = props.children
35
37
 
36
38
  const { getThemeProperty } = useContext(WebchatContext)
@@ -3,6 +3,7 @@ import styled from 'styled-components'
3
3
 
4
4
  import { COLORS, WEBCHAT } from '../constants'
5
5
  import { renderComponent } from '../util/react'
6
+ import { Button } from './button'
6
7
 
7
8
  const ElementContainer = styled.div`
8
9
  display: flex;
@@ -38,21 +39,13 @@ Element.serialize = elementProps => {
38
39
  ...elementProps.children
39
40
  .filter(c => {
40
41
  if (c instanceof Array) return true
41
- return c && c.type && c.type.name == 'Button'
42
+ return c?.type?.name === Button.name
42
43
  })
43
44
  .map(b => {
44
45
  if (b instanceof Array) {
45
- return b.map(
46
- bb =>
47
- bb &&
48
- bb.type &&
49
- bb.type.serialize &&
50
- bb.type.serialize(bb.props).button
51
- )
46
+ b.map(bb => bb?.type?.serialize?.(bb.props)?.button)
52
47
  }
53
- return (
54
- b && b.type && b.type.serialize && b.type.serialize(b.props).button
55
- )
48
+ return b?.type?.serialize(b.props).button
56
49
  }),
57
50
  ]
58
51
  // When we have the buttons from backend, we have all buttons inside an array on the first position
@@ -2,7 +2,7 @@ import React, { useContext, useState } from 'react'
2
2
  import styled from 'styled-components'
3
3
 
4
4
  import { COLORS } from '../constants'
5
- import { WebchatContext } from '../contexts'
5
+ import { WebchatContext } from '../webchat/context'
6
6
 
7
7
  const Container = styled.div`
8
8
  display: flex;
@@ -3,11 +3,16 @@ import React, { useContext, useState } from 'react'
3
3
  import styled from 'styled-components'
4
4
 
5
5
  import { ROLES, WEBCHAT } from '../constants'
6
- import { WebchatContext } from '../contexts'
7
6
  import { staticAsset } from '../util/environment'
7
+ import { WebchatContext } from '../webchat/context'
8
+ import { ImageProps } from './index-types'
8
9
  import { Message } from './message'
9
10
 
10
- const StyledImage = styled.img`
11
+ interface StyledImageProps {
12
+ hasPreviewer: boolean
13
+ }
14
+
15
+ const StyledImage = styled.img<StyledImageProps>`
11
16
  border-radius: 8px;
12
17
  max-width: 150px;
13
18
  max-height: 150px;
@@ -15,14 +20,15 @@ const StyledImage = styled.img`
15
20
  cursor: ${({ hasPreviewer }) => (hasPreviewer ? 'pointer' : 'auto')};
16
21
  `
17
22
 
18
- const serialize = imageProps => {
23
+ const serialize = (imageProps: { src: string }) => {
19
24
  return { image: imageProps.src }
20
25
  }
21
26
 
22
- export const Image = props => {
27
+ export const Image = (props: ImageProps) => {
23
28
  props = props.input?.data
24
29
  ? { ...props, src: props.input.data }
25
30
  : { ...props, src: staticAsset(props.src) }
31
+
26
32
  let content = props.children
27
33
 
28
34
  const [isPreviewerOpened, setIsPreviewerOpened] = useState(false)
@@ -1,7 +1,6 @@
1
1
  import React from 'react'
2
2
 
3
3
  import { SENDERS } from '../index-types'
4
- import { CoverComponentProps } from '../webchat/index-types'
5
4
 
6
5
  export type MessageType =
7
6
  | 'audio'
@@ -16,7 +15,7 @@ export type MessageType =
16
15
 
17
16
  export interface MessageProps {
18
17
  blob?: boolean
19
- children: React.ReactNode
18
+ children?: React.ReactNode
20
19
  delay?: number
21
20
  enabletimestamps?: boolean
22
21
  sentBy?: SENDERS
@@ -64,7 +63,26 @@ export interface PicProps {
64
63
  src: string
65
64
  }
66
65
 
67
- export type ImageProps = PicProps
66
+ export interface ImageProps extends MessageProps {
67
+ src: string
68
+ input?: { data: string }
69
+ }
70
+
71
+ export interface VideoProps extends MessageProps {
72
+ src: string
73
+ input?: { data: string }
74
+ }
75
+
76
+ export interface AudioProps extends MessageProps {
77
+ src: string
78
+ input?: { data: string }
79
+ }
80
+
81
+ export interface DocumentProps extends MessageProps {
82
+ src: string
83
+ input?: { data: string }
84
+ from?: any
85
+ }
68
86
 
69
87
  export interface TitleProps {
70
88
  children: React.ReactNode
@@ -73,21 +91,10 @@ export interface TitleProps {
73
91
 
74
92
  export type SubtitleProps = TitleProps
75
93
 
76
- export type CustomProp = { custom?: React.ComponentType }
77
- export type EnableProp = { enable?: boolean }
78
- export type ImageProp = { image?: string } // https URL or imported Image asset
79
- export type PersistentMenuCloseOption = { closeLabel: string }
80
- export type PersistentMenuOption = { label: string } & ButtonProps
81
- export type StyleProp = { style?: any }
82
-
83
- export type PersistentMenuTheme = (
84
- | PersistentMenuCloseOption
85
- | PersistentMenuOption
86
- )[]
87
-
88
- export interface PersistentMenuProps {
89
- onClick: () => void
90
- options: any
94
+ export interface CustomMessageType {
95
+ (props: any): JSX.Element
96
+ customTypeName: string
97
+ deserialize(msg: any): JSX.Element
91
98
  }
92
99
 
93
100
  export type BlockInputOption = {
@@ -96,102 +103,6 @@ export type BlockInputOption = {
96
103
  message: string
97
104
  }
98
105
 
99
- export interface BlobProps {
100
- blobTick?: boolean
101
- blobTickStyle?: any
102
- blobWidth?: string
103
- imageStyle?: any
104
- }
105
-
106
- export interface ThemeProps extends StyleProp {
107
- coverComponent?: CoverComponentOptions
108
- mobileBreakpoint?: number
109
- mobileStyle?: any
110
- webview?: StyleProp & { header?: StyleProp }
111
- animations?: EnableProp
112
- intro?: StyleProp & ImageProp & CustomProp
113
- brand?: { color?: string } & ImageProp
114
- header?: { title?: string; subtitle?: string } & ImageProp &
115
- StyleProp &
116
- CustomProp
117
- message?: {
118
- bot?: BlobProps & ImageProp & StyleProp
119
- agent?: ImageProp
120
- user?: BlobProps & StyleProp
121
- customTypes?: React.ComponentType[]
122
- } & StyleProp & {
123
- timestamps?: {
124
- withImage?: boolean
125
- format: () => string
126
- } & StyleProp &
127
- EnableProp
128
- }
129
- button?: {
130
- autodisable?: boolean
131
- disabledstyle?: any
132
- hoverBackground?: string
133
- hoverTextColor?: string
134
- messageType?: 'text' | 'payload'
135
- urlIcon?: ImageProp & EnableProp
136
- } & StyleProp &
137
- CustomProp
138
- replies?: {
139
- align?: 'left' | 'center' | 'right'
140
- wrap?: 'wrap' | 'nowrap'
141
- }
142
- carousel?: {
143
- arrow?: {
144
- left: CustomProp
145
- right: CustomProp
146
- }
147
- enableArrows?: boolean
148
- }
149
- reply?: StyleProp & CustomProp
150
- triggerButton?: ImageProp & StyleProp & CustomProp
151
- notifications?: EnableProp & {
152
- banner?: CustomProp & EnableProp & { text?: string }
153
- triggerButton?: EnableProp
154
- }
155
- scrollButton?: EnableProp & CustomProp
156
- markdownStyle?: string // string template with css styles
157
- userInput?: {
158
- attachments?: EnableProp & CustomProp
159
- blockInputs?: BlockInputOption[]
160
- box?: { placeholder: string } & StyleProp
161
- emojiPicker?: EnableProp & CustomProp
162
- menu?: { darkBackground?: boolean } & {
163
- custom?: React.ComponentType<PersistentMenuProps>
164
- }
165
- menuButton?: CustomProp
166
- persistentMenu?: PersistentMenuTheme
167
- sendButton?: EnableProp & CustomProp
168
- } & EnableProp &
169
- StyleProp
170
- imagePreviewer?: React.ComponentType<ImagePreviewerProps>
171
- }
172
-
173
- interface ImagePreviewerProps {
174
- src: string
175
- isPreviewerOpened: boolean
176
- closePreviewer: () => void
177
- }
178
-
179
- export interface CoverComponentOptions {
180
- component: React.ComponentType<CoverComponentProps>
181
- props?: any
182
- }
183
-
184
- export interface WebchatSettingsProps {
185
- blockInputs?: BlockInputOption[]
186
- enableAnimations?: boolean
187
- enableAttachments?: boolean
188
- enableEmojiPicker?: boolean
189
- enableUserInput?: boolean
190
- persistentMenu?: PersistentMenuTheme
191
- theme?: ThemeProps
192
- user?: { extra_data?: any }
193
- }
194
-
195
106
  export type WrappedComponent<Props> = React.FunctionComponent<Props> & {
196
107
  customTypeName: string
197
108
  }
@@ -4,6 +4,7 @@ export { Carousel } from './carousel'
4
4
  export { customMessage } from './custom-message'
5
5
  export { Document } from './document'
6
6
  export { Element } from './element'
7
+ export { Handoff } from './handoff'
7
8
  export { Image } from './image'
8
9
  export * from './index-types'
9
10
  export { Location } from './location'
@@ -18,15 +19,35 @@ export { Subtitle } from './subtitle'
18
19
  export { Text } from './text'
19
20
  export { Title } from './title'
20
21
  export { Video } from './video'
21
- export { WebchatSettings } from './webchat-settings'
22
+ export {
23
+ normalizeWebchatSettings,
24
+ WebchatSettings,
25
+ WebchatSettingsProps,
26
+ } from './webchat-settings'
22
27
  export {
23
28
  WhatsappButtonList,
24
29
  WhatsappButtonListProps,
25
30
  WhatsappButtonListRowProps,
26
31
  WhatsappButtonListSectionProps,
27
32
  } from './whatsapp-button-list'
33
+ export { WhatsappCatalog, WhatsappCatalogProps } from './whatsapp-catalog'
28
34
  export {
29
35
  WhatsappCTAUrlButton,
30
36
  WhatsappCTAUrlButtonProps,
31
37
  } from './whatsapp-cta-url-button'
38
+ export {
39
+ WhatsappMediaCarousel,
40
+ WhatsappMediaCarouselProps,
41
+ } from './whatsapp-media-carousel'
42
+ export { WhatsappProduct } from './whatsapp-product'
43
+ export {
44
+ WhatsappProductCarousel,
45
+ WhatsappProductCarouselProps,
46
+ } from './whatsapp-product-carousel'
47
+ export {
48
+ ProductItem,
49
+ WhatsappProductList,
50
+ WhatsappProductListProps,
51
+ WhatsappProductListSection,
52
+ } from './whatsapp-product-list'
32
53
  export { WhatsappTemplate } from './whatsapp-template'
@@ -3,11 +3,12 @@ import React, { useContext, useEffect, useState } from 'react'
3
3
  import { v7 as uuidv7 } from 'uuid'
4
4
 
5
5
  import { COLORS, WEBCHAT } from '../../constants'
6
- import { RequestContext, WebchatContext } from '../../contexts'
6
+ import { RequestContext } from '../../contexts'
7
7
  import { SENDERS } from '../../index-types'
8
8
  import { Fade } from '../../shared/styles'
9
9
  import { isDev } from '../../util/environment'
10
10
  import { ConditionalWrapper, renderComponent } from '../../util/react'
11
+ import { WebchatContext } from '../../webchat/context'
11
12
  import { Button } from '../button'
12
13
  import { ButtonsDisabler } from '../buttons-disabler'
13
14
  import { getMarkdownStyle, renderLinks, renderMarkdown } from '../markdown'
@@ -3,9 +3,9 @@ import { v7 as uuidv7 } from 'uuid'
3
3
 
4
4
  import ThumbsDown from '../../assets/thumbs-down.svg'
5
5
  import ThumbsUp from '../../assets/thumbs-up.svg'
6
- import { WebchatContext } from '../../contexts'
7
6
  import { ActionRequest } from '../../index-types'
8
7
  import { resolveImage } from '../../util'
8
+ import { WebchatContext } from '../../webchat/context'
9
9
  import { EventAction, FeedbackOption } from '../../webchat/tracking'
10
10
  import { FeedbackButton, FeedbackMessageContainer } from './styles'
11
11
 
@@ -1,7 +1,7 @@
1
1
  import React, { useContext } from 'react'
2
2
 
3
- import { WebchatContext } from '../../contexts'
4
3
  import { SENDERS } from '../../index-types'
4
+ import { WebchatContext } from '../../webchat/context'
5
5
  import { MessageFeedback } from './message-feedback'
6
6
  import { MessageFooterContainer } from './styles'
7
7
  import { MessageTimestamp, resolveMessageTimestamps } from './timestamps'
@@ -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 { SENDERS } from '../../index-types'
6
5
  import { resolveImage } from '../../util/environment'
6
+ import { WebchatContext } from '../../webchat/context'
7
7
  import { BotMessageImageContainer } from './styles'
8
8
 
9
9
  interface MessageImageProps {
@@ -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 { SENDERS } from '../../index-types'
6
5
  import { resolveImage } from '../../util'
6
+ import { WebchatContext } from '../../webchat/context'
7
7
  import { TimestampContainer, TimestampText } from './styles'
8
8
 
9
9
  export const resolveMessageTimestamps = (
@@ -5,7 +5,7 @@ import { RequestContext } from '../../contexts'
5
5
  import { truncateText } from '../../util'
6
6
  import { Button } from '../button'
7
7
  import { MultichannelContext } from './multichannel-context'
8
- import { WHATSAPP_MAX_BUTTON_CHARS } from './multichannel-utils'
8
+ import { WHATSAPP_MAX_BUTTON_CHARS } from './whatsapp/constants'
9
9
 
10
10
  export const MultichannelButton = props => {
11
11
  const requestContext = useContext(RequestContext)
@@ -7,7 +7,9 @@ import { MultichannelText } from './multichannel-text'
7
7
  import {
8
8
  getFilteredElements,
9
9
  isMultichannelButton,
10
- isNodeKind,
10
+ isNodePic,
11
+ isNodeSubtitle,
12
+ isNodeTitle,
11
13
  } from './multichannel-utils'
12
14
 
13
15
  export const MultichannelCarousel = props => {
@@ -26,17 +28,17 @@ export const MultichannelCarousel = props => {
26
28
  const buttons = []
27
29
 
28
30
  for (const node of element) {
29
- if (isNodeKind(node, 'Pic')) {
31
+ if (isNodePic(node)) {
30
32
  imageProps = node.props
31
33
  }
32
- if (isNodeKind(node, 'Title')) {
34
+ if (isNodeTitle(node)) {
33
35
  title = node.props.children
34
36
  }
35
- if (isNodeKind(node, 'Subtitle')) {
37
+ if (isNodeSubtitle(node)) {
36
38
  subtitle = node.props.children
37
39
  }
38
40
 
39
- if (isNodeKind(node, 'MultichannelButton')) {
41
+ if (isMultichannelButton(node)) {
40
42
  buttons.push(node)
41
43
  }
42
44
  //TODO support fragment containing an array
@@ -9,18 +9,20 @@ import { MultichannelButton } from './multichannel-button'
9
9
  import { MultichannelContext } from './multichannel-context'
10
10
  import {
11
11
  buttonTypes,
12
- DEFAULT_WHATSAPP_MAX_BUTTON_SEPARATOR,
13
12
  elementHasPostback,
14
13
  elementHasUrl,
15
14
  elementHasWebview,
16
15
  getButtonType,
17
16
  getMultichannelButtons,
18
17
  getMultichannelReplies,
18
+ } from './multichannel-utils'
19
+ import {
20
+ DEFAULT_WHATSAPP_MAX_BUTTON_SEPARATOR,
19
21
  MENU_BUTTON_WHATSAPP_BUTTON_LIST,
20
22
  MULTICHANNEL_WHATSAPP_PROPS,
21
23
  WHATSAPP_LIST_MAX_BUTTONS,
22
24
  WHATSAPP_MAX_BUTTONS,
23
- } from './multichannel-utils'
25
+ } from './whatsapp/constants'
24
26
  import { convertToMarkdownMeta } from './whatsapp/markdown-meta'
25
27
 
26
28
  export const MultichannelText = props => {