@botonic/react 0.34.1 → 0.35.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 (302) hide show
  1. package/lib/cjs/components/{button.d.ts → button/index.d.ts} +4 -5
  2. package/lib/cjs/components/{button.js → button/index.js} +26 -56
  3. package/lib/cjs/components/button/index.js.map +1 -0
  4. package/lib/cjs/components/button/styles.d.ts +2 -0
  5. package/lib/cjs/components/button/styles.js +40 -0
  6. package/lib/cjs/components/button/styles.js.map +1 -0
  7. package/lib/cjs/components/buttons-disabler.d.ts +20 -23
  8. package/lib/cjs/components/buttons-disabler.js +11 -26
  9. package/lib/cjs/components/buttons-disabler.js.map +1 -1
  10. package/lib/cjs/components/carousel.js +1 -1
  11. package/lib/cjs/components/carousel.js.map +1 -1
  12. package/lib/cjs/components/element.js +3 -3
  13. package/lib/cjs/components/element.js.map +1 -1
  14. package/lib/cjs/components/image.js +1 -1
  15. package/lib/cjs/components/image.js.map +1 -1
  16. package/lib/cjs/components/index-types.d.ts +1 -1
  17. package/lib/cjs/components/index.d.ts +1 -1
  18. package/lib/cjs/components/index.js +2 -2
  19. package/lib/cjs/components/index.js.map +1 -1
  20. package/lib/cjs/components/message/index.js +7 -7
  21. package/lib/cjs/components/message/index.js.map +1 -1
  22. package/lib/cjs/components/message/message-image.js +1 -1
  23. package/lib/cjs/components/message/message-image.js.map +1 -1
  24. package/lib/cjs/components/message/styles.d.ts +11 -11
  25. package/lib/cjs/components/message/timestamps.js +1 -1
  26. package/lib/cjs/components/message/timestamps.js.map +1 -1
  27. package/lib/cjs/components/multichannel/multichannel-button.js +4 -4
  28. package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
  29. package/lib/cjs/components/multichannel/multichannel-carousel.js +2 -2
  30. package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
  31. package/lib/cjs/components/multichannel/multichannel-utils.js +2 -2
  32. package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
  33. package/lib/cjs/components/reply.js +3 -1
  34. package/lib/cjs/components/reply.js.map +1 -1
  35. package/lib/cjs/components/webchat-settings.d.ts +6 -3
  36. package/lib/cjs/components/webchat-settings.js.map +1 -1
  37. package/lib/cjs/constants.d.ts +0 -12
  38. package/lib/cjs/constants.js +0 -12
  39. package/lib/cjs/constants.js.map +1 -1
  40. package/lib/cjs/contexts.d.ts +1 -5
  41. package/lib/cjs/contexts.js +10 -5
  42. package/lib/cjs/contexts.js.map +1 -1
  43. package/lib/cjs/dev-app.js +3 -11
  44. package/lib/cjs/dev-app.js.map +1 -1
  45. package/lib/cjs/index-types.d.ts +6 -28
  46. package/lib/cjs/index-types.js.map +1 -1
  47. package/lib/cjs/msg-to-botonic.js +2 -2
  48. package/lib/cjs/msg-to-botonic.js.map +1 -1
  49. package/lib/cjs/react-bot.d.ts +16 -6
  50. package/lib/cjs/react-bot.js +5 -6
  51. package/lib/cjs/react-bot.js.map +1 -1
  52. package/lib/cjs/shared/styles.d.ts +2 -2
  53. package/lib/cjs/time-zone-to-country-code.d.ts +1 -0
  54. package/lib/cjs/time-zone-to-country-code.js +108 -0
  55. package/lib/cjs/time-zone-to-country-code.js.map +1 -0
  56. package/lib/cjs/util/webchat.d.ts +11 -2
  57. package/lib/cjs/util/webchat.js +29 -1
  58. package/lib/cjs/util/webchat.js.map +1 -1
  59. package/lib/cjs/webchat/chat-area/styles.d.ts +1 -1
  60. package/lib/cjs/webchat/components/conditional-animation.js +1 -1
  61. package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
  62. package/lib/cjs/webchat/components/opened-persistent-menu.js +4 -4
  63. package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -1
  64. package/lib/cjs/webchat/context/index.d.ts +1 -1
  65. package/lib/cjs/webchat/context/index.js +4 -7
  66. package/lib/cjs/webchat/context/index.js.map +1 -1
  67. package/lib/cjs/webchat/context/types.d.ts +16 -9
  68. package/lib/cjs/webchat/context/use-webchat.d.ts +3 -4
  69. package/lib/cjs/webchat/context/use-webchat.js +35 -43
  70. package/lib/cjs/webchat/context/use-webchat.js.map +1 -1
  71. package/lib/cjs/webchat/header/default-header.js +5 -5
  72. package/lib/cjs/webchat/header/default-header.js.map +1 -1
  73. package/lib/cjs/webchat/header/styles.d.ts +7 -7
  74. package/lib/cjs/webchat/header/styles.js +5 -1
  75. package/lib/cjs/webchat/header/styles.js.map +1 -1
  76. package/lib/cjs/webchat/index-types.d.ts +0 -11
  77. package/lib/cjs/webchat/input-panel/attachment.d.ts +1 -2
  78. package/lib/cjs/webchat/input-panel/attachment.js +6 -5
  79. package/lib/cjs/webchat/input-panel/attachment.js.map +1 -1
  80. package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -2
  81. package/lib/cjs/webchat/input-panel/emoji-picker.js +6 -5
  82. package/lib/cjs/webchat/input-panel/emoji-picker.js.map +1 -1
  83. package/lib/cjs/webchat/input-panel/index.d.ts +1 -4
  84. package/lib/cjs/webchat/input-panel/index.js +2 -2
  85. package/lib/cjs/webchat/input-panel/index.js.map +1 -1
  86. package/lib/cjs/webchat/input-panel/persistent-menu.d.ts +1 -2
  87. package/lib/cjs/webchat/input-panel/persistent-menu.js +5 -4
  88. package/lib/cjs/webchat/input-panel/persistent-menu.js.map +1 -1
  89. package/lib/cjs/webchat/input-panel/send-button.js +4 -3
  90. package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
  91. package/lib/cjs/webchat/input-panel/styles.d.ts +3 -3
  92. package/lib/cjs/webchat/input-panel/textarea.d.ts +1 -3
  93. package/lib/cjs/webchat/input-panel/textarea.js +7 -5
  94. package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
  95. package/lib/cjs/webchat/message-list/intro-message.js +1 -1
  96. package/lib/cjs/webchat/message-list/intro-message.js.map +1 -1
  97. package/lib/cjs/webchat/message-list/styles.d.ts +5 -5
  98. package/lib/cjs/webchat/message-list/use-notifications.js +4 -4
  99. package/lib/cjs/webchat/message-list/use-notifications.js.map +1 -1
  100. package/lib/cjs/webchat/replies/styles.d.ts +3 -3
  101. package/lib/cjs/webchat/styles.d.ts +4 -9
  102. package/lib/cjs/webchat/styles.js +18 -7
  103. package/lib/cjs/webchat/styles.js.map +1 -1
  104. package/lib/cjs/webchat/theme/default-theme.d.ts +2 -0
  105. package/lib/cjs/webchat/theme/default-theme.js +104 -0
  106. package/lib/cjs/webchat/theme/default-theme.js.map +1 -0
  107. package/lib/cjs/webchat/theme/types.d.ts +59 -12
  108. package/lib/cjs/webchat/trigger-button/index.js +3 -3
  109. package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
  110. package/lib/cjs/webchat/trigger-button/styles.d.ts +3 -3
  111. package/lib/cjs/webchat/typing-indicator/styles.d.ts +3 -3
  112. package/lib/cjs/webchat/webchat-dev.d.ts +1 -1
  113. package/lib/cjs/webchat/webchat.js +26 -34
  114. package/lib/cjs/webchat/webchat.js.map +1 -1
  115. package/lib/cjs/webchat/webview/index.js +1 -14
  116. package/lib/cjs/webchat/webview/index.js.map +1 -1
  117. package/lib/cjs/webchat/webview/styles.d.ts +6 -6
  118. package/lib/cjs/webchat/webview/styles.js +16 -2
  119. package/lib/cjs/webchat/webview/styles.js.map +1 -1
  120. package/lib/cjs/webchat-app.d.ts +35 -2
  121. package/lib/cjs/webchat-app.js +45 -17
  122. package/lib/cjs/webchat-app.js.map +1 -1
  123. package/lib/cjs/webview-app.js +0 -1
  124. package/lib/cjs/webview-app.js.map +1 -1
  125. package/lib/esm/components/{button.d.ts → button/index.d.ts} +4 -5
  126. package/lib/esm/components/{button.js → button/index.js} +26 -55
  127. package/lib/esm/components/button/index.js.map +1 -0
  128. package/lib/esm/components/button/styles.d.ts +2 -0
  129. package/lib/esm/components/button/styles.js +36 -0
  130. package/lib/esm/components/button/styles.js.map +1 -0
  131. package/lib/esm/components/buttons-disabler.d.ts +20 -23
  132. package/lib/esm/components/buttons-disabler.js +11 -26
  133. package/lib/esm/components/buttons-disabler.js.map +1 -1
  134. package/lib/esm/components/carousel.js +1 -1
  135. package/lib/esm/components/carousel.js.map +1 -1
  136. package/lib/esm/components/element.js +1 -1
  137. package/lib/esm/components/element.js.map +1 -1
  138. package/lib/esm/components/image.js +1 -1
  139. package/lib/esm/components/image.js.map +1 -1
  140. package/lib/esm/components/index-types.d.ts +1 -1
  141. package/lib/esm/components/index.d.ts +1 -1
  142. package/lib/esm/components/index.js +1 -1
  143. package/lib/esm/components/index.js.map +1 -1
  144. package/lib/esm/components/message/index.js +5 -5
  145. package/lib/esm/components/message/index.js.map +1 -1
  146. package/lib/esm/components/message/message-image.js +1 -1
  147. package/lib/esm/components/message/message-image.js.map +1 -1
  148. package/lib/esm/components/message/styles.d.ts +11 -11
  149. package/lib/esm/components/message/timestamps.js +1 -1
  150. package/lib/esm/components/message/timestamps.js.map +1 -1
  151. package/lib/esm/components/multichannel/multichannel-button.js +1 -1
  152. package/lib/esm/components/multichannel/multichannel-button.js.map +1 -1
  153. package/lib/esm/components/multichannel/multichannel-carousel.js +1 -1
  154. package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
  155. package/lib/esm/components/multichannel/multichannel-utils.js +1 -1
  156. package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
  157. package/lib/esm/components/reply.js +4 -2
  158. package/lib/esm/components/reply.js.map +1 -1
  159. package/lib/esm/components/webchat-settings.d.ts +6 -3
  160. package/lib/esm/components/webchat-settings.js.map +1 -1
  161. package/lib/esm/constants.d.ts +0 -12
  162. package/lib/esm/constants.js +0 -12
  163. package/lib/esm/constants.js.map +1 -1
  164. package/lib/esm/contexts.d.ts +1 -5
  165. package/lib/esm/contexts.js +10 -5
  166. package/lib/esm/contexts.js.map +1 -1
  167. package/lib/esm/dev-app.js +3 -11
  168. package/lib/esm/dev-app.js.map +1 -1
  169. package/lib/esm/index-types.d.ts +6 -28
  170. package/lib/esm/index-types.js.map +1 -1
  171. package/lib/esm/msg-to-botonic.js +1 -1
  172. package/lib/esm/msg-to-botonic.js.map +1 -1
  173. package/lib/esm/react-bot.d.ts +16 -6
  174. package/lib/esm/react-bot.js +5 -6
  175. package/lib/esm/react-bot.js.map +1 -1
  176. package/lib/esm/shared/styles.d.ts +2 -2
  177. package/lib/esm/time-zone-to-country-code.d.ts +1 -0
  178. package/lib/esm/time-zone-to-country-code.js +105 -0
  179. package/lib/esm/time-zone-to-country-code.js.map +1 -0
  180. package/lib/esm/util/webchat.d.ts +11 -2
  181. package/lib/esm/util/webchat.js +27 -0
  182. package/lib/esm/util/webchat.js.map +1 -1
  183. package/lib/esm/webchat/chat-area/styles.d.ts +1 -1
  184. package/lib/esm/webchat/components/conditional-animation.js +1 -1
  185. package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
  186. package/lib/esm/webchat/components/opened-persistent-menu.js +2 -2
  187. package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -1
  188. package/lib/esm/webchat/context/index.d.ts +1 -1
  189. package/lib/esm/webchat/context/index.js +2 -4
  190. package/lib/esm/webchat/context/index.js.map +1 -1
  191. package/lib/esm/webchat/context/types.d.ts +16 -9
  192. package/lib/esm/webchat/context/use-webchat.d.ts +3 -4
  193. package/lib/esm/webchat/context/use-webchat.js +33 -41
  194. package/lib/esm/webchat/context/use-webchat.js.map +1 -1
  195. package/lib/esm/webchat/header/default-header.js +6 -6
  196. package/lib/esm/webchat/header/default-header.js.map +1 -1
  197. package/lib/esm/webchat/header/styles.d.ts +7 -7
  198. package/lib/esm/webchat/header/styles.js +6 -2
  199. package/lib/esm/webchat/header/styles.js.map +1 -1
  200. package/lib/esm/webchat/index-types.d.ts +0 -11
  201. package/lib/esm/webchat/input-panel/attachment.d.ts +1 -2
  202. package/lib/esm/webchat/input-panel/attachment.js +7 -6
  203. package/lib/esm/webchat/input-panel/attachment.js.map +1 -1
  204. package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -2
  205. package/lib/esm/webchat/input-panel/emoji-picker.js +7 -6
  206. package/lib/esm/webchat/input-panel/emoji-picker.js.map +1 -1
  207. package/lib/esm/webchat/input-panel/index.d.ts +1 -4
  208. package/lib/esm/webchat/input-panel/index.js +2 -2
  209. package/lib/esm/webchat/input-panel/index.js.map +1 -1
  210. package/lib/esm/webchat/input-panel/persistent-menu.d.ts +1 -2
  211. package/lib/esm/webchat/input-panel/persistent-menu.js +6 -5
  212. package/lib/esm/webchat/input-panel/persistent-menu.js.map +1 -1
  213. package/lib/esm/webchat/input-panel/send-button.js +5 -4
  214. package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
  215. package/lib/esm/webchat/input-panel/styles.d.ts +3 -3
  216. package/lib/esm/webchat/input-panel/textarea.d.ts +1 -3
  217. package/lib/esm/webchat/input-panel/textarea.js +7 -5
  218. package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
  219. package/lib/esm/webchat/message-list/intro-message.js +1 -1
  220. package/lib/esm/webchat/message-list/intro-message.js.map +1 -1
  221. package/lib/esm/webchat/message-list/styles.d.ts +5 -5
  222. package/lib/esm/webchat/message-list/use-notifications.js +4 -4
  223. package/lib/esm/webchat/message-list/use-notifications.js.map +1 -1
  224. package/lib/esm/webchat/replies/styles.d.ts +3 -3
  225. package/lib/esm/webchat/styles.d.ts +4 -9
  226. package/lib/esm/webchat/styles.js +19 -8
  227. package/lib/esm/webchat/styles.js.map +1 -1
  228. package/lib/esm/webchat/theme/default-theme.d.ts +2 -0
  229. package/lib/esm/webchat/theme/default-theme.js +101 -0
  230. package/lib/esm/webchat/theme/default-theme.js.map +1 -0
  231. package/lib/esm/webchat/theme/types.d.ts +59 -12
  232. package/lib/esm/webchat/trigger-button/index.js +3 -3
  233. package/lib/esm/webchat/trigger-button/index.js.map +1 -1
  234. package/lib/esm/webchat/trigger-button/styles.d.ts +3 -3
  235. package/lib/esm/webchat/typing-indicator/styles.d.ts +3 -3
  236. package/lib/esm/webchat/webchat-dev.d.ts +1 -1
  237. package/lib/esm/webchat/webchat.js +29 -37
  238. package/lib/esm/webchat/webchat.js.map +1 -1
  239. package/lib/esm/webchat/webview/index.js +1 -14
  240. package/lib/esm/webchat/webview/index.js.map +1 -1
  241. package/lib/esm/webchat/webview/styles.d.ts +6 -6
  242. package/lib/esm/webchat/webview/styles.js +17 -3
  243. package/lib/esm/webchat/webview/styles.js.map +1 -1
  244. package/lib/esm/webchat-app.d.ts +35 -2
  245. package/lib/esm/webchat-app.js +45 -17
  246. package/lib/esm/webchat-app.js.map +1 -1
  247. package/lib/esm/webview-app.js +1 -2
  248. package/lib/esm/webview-app.js.map +1 -1
  249. package/package.json +4 -2
  250. package/src/components/{button.tsx → button/index.tsx} +26 -102
  251. package/src/components/button/styles.ts +38 -0
  252. package/src/components/{buttons-disabler.js → buttons-disabler.ts} +35 -39
  253. package/src/components/carousel.tsx +1 -2
  254. package/src/components/element.tsx +1 -1
  255. package/src/components/image.tsx +3 -2
  256. package/src/components/index-types.ts +1 -1
  257. package/src/components/index.ts +1 -1
  258. package/src/components/message/index.jsx +5 -9
  259. package/src/components/message/message-image.tsx +1 -4
  260. package/src/components/message/timestamps.tsx +1 -2
  261. package/src/components/multichannel/multichannel-button.jsx +1 -1
  262. package/src/components/multichannel/multichannel-carousel.jsx +1 -1
  263. package/src/components/multichannel/multichannel-utils.js +1 -1
  264. package/src/components/reply.tsx +2 -8
  265. package/src/components/webchat-settings.tsx +11 -3
  266. package/src/constants.js +0 -12
  267. package/src/contexts.tsx +11 -12
  268. package/src/dev-app.jsx +1 -25
  269. package/src/index-types.ts +8 -26
  270. package/src/msg-to-botonic.jsx +1 -1
  271. package/src/react-bot.tsx +51 -0
  272. package/src/time-zone-to-country-code.ts +104 -0
  273. package/src/util/webchat.ts +38 -2
  274. package/src/webchat/components/conditional-animation.jsx +2 -2
  275. package/src/webchat/components/opened-persistent-menu.jsx +2 -3
  276. package/src/webchat/context/index.tsx +3 -5
  277. package/src/webchat/context/types.ts +18 -13
  278. package/src/webchat/context/use-webchat.ts +36 -43
  279. package/src/webchat/header/default-header.tsx +6 -17
  280. package/src/webchat/header/styles.ts +6 -2
  281. package/src/webchat/index-types.ts +0 -12
  282. package/src/webchat/input-panel/attachment.tsx +5 -16
  283. package/src/webchat/input-panel/emoji-picker.tsx +5 -15
  284. package/src/webchat/input-panel/index.tsx +2 -13
  285. package/src/webchat/input-panel/persistent-menu.tsx +5 -15
  286. package/src/webchat/input-panel/send-button.tsx +3 -9
  287. package/src/webchat/input-panel/textarea.tsx +8 -14
  288. package/src/webchat/message-list/intro-message.tsx +1 -2
  289. package/src/webchat/message-list/use-notifications.ts +4 -8
  290. package/src/webchat/styles.ts +20 -14
  291. package/src/webchat/theme/default-theme.ts +102 -0
  292. package/src/webchat/theme/theme.d.ts +8 -0
  293. package/src/webchat/theme/types.ts +111 -24
  294. package/src/webchat/trigger-button/index.tsx +3 -5
  295. package/src/webchat/webchat.tsx +79 -102
  296. package/src/webchat/webview/index.tsx +0 -14
  297. package/src/webchat/webview/styles.ts +16 -2
  298. package/src/webchat-app.tsx +88 -35
  299. package/src/webview-app.tsx +1 -3
  300. package/lib/cjs/components/button.js.map +0 -1
  301. package/lib/esm/components/button.js.map +0 -1
  302. package/src/react-bot.jsx +0 -38
@@ -11,17 +11,11 @@ interface SendButtonProps {
11
11
  }
12
12
 
13
13
  export const SendButton = ({ onClick }: SendButtonProps) => {
14
- const { getThemeProperty } = useContext(WebchatContext)
14
+ const { webchatState } = useContext(WebchatContext)
15
15
 
16
- const sendButtonEnabled = getThemeProperty(
17
- WEBCHAT.CUSTOM_PROPERTIES.enableSendButton,
18
- true
19
- )
16
+ const sendButtonEnabled = webchatState.theme.userInput?.sendButton?.enable
20
17
 
21
- const CustomSendButton = getThemeProperty(
22
- WEBCHAT.CUSTOM_PROPERTIES.customSendButton,
23
- undefined
24
- )
18
+ const CustomSendButton = webchatState.theme.userInput?.sendButton?.custom
25
19
 
26
20
  return (
27
21
  <>
@@ -5,12 +5,10 @@ import { WEBCHAT } from '../../constants'
5
5
  import { Typing } from '../../index-types'
6
6
  import { WebchatContext } from '../../webchat/context'
7
7
  import { useDeviceAdapter } from '../hooks'
8
- import { PersistentMenuOptionsTheme } from '../theme/types'
9
8
  import { TextAreaContainer } from './styles'
10
9
 
11
10
  interface TextareaProps {
12
11
  host: HTMLElement
13
- persistentMenu: PersistentMenuOptionsTheme
14
12
  textareaRef: React.MutableRefObject<HTMLTextAreaElement | undefined>
15
13
  sendChatEvent: (event: string) => Promise<void>
16
14
  sendTextAreaText: () => Promise<void>
@@ -18,23 +16,22 @@ interface TextareaProps {
18
16
 
19
17
  export const Textarea = ({
20
18
  host,
21
- persistentMenu,
22
19
  textareaRef,
23
20
  sendChatEvent,
24
21
  sendTextAreaText,
25
22
  }: TextareaProps) => {
26
- const { getThemeProperty, webchatState, setIsInputFocused } =
27
- useContext(WebchatContext)
23
+ const { webchatState, setIsInputFocused } = useContext(WebchatContext)
28
24
 
29
25
  useDeviceAdapter(host, webchatState.isWebchatOpen)
30
26
 
31
27
  let isTyping = false
32
28
  let typingTimeout
33
29
 
34
- const persistentMenuOptions = getThemeProperty(
35
- WEBCHAT.CUSTOM_PROPERTIES.persistentMenu,
36
- persistentMenu
37
- )
30
+ const persistentMenuOptions = webchatState.theme.userInput?.persistentMenu
31
+
32
+ const placeholder = webchatState.theme.userInput?.box?.placeholder
33
+
34
+ const userInputBoxStyle = webchatState.theme.userInput?.box?.style
38
35
 
39
36
  const onKeyDown = event => {
40
37
  if (event.keyCode === 13 && event.shiftKey === false) {
@@ -92,10 +89,7 @@ export const Textarea = ({
92
89
  maxRows={4}
93
90
  wrap='soft'
94
91
  maxLength={1000}
95
- placeholder={getThemeProperty(
96
- WEBCHAT.CUSTOM_PROPERTIES.textPlaceholder,
97
- WEBCHAT.DEFAULTS.PLACEHOLDER
98
- )}
92
+ placeholder={placeholder}
99
93
  autoFocus={false}
100
94
  onKeyDown={e => onKeyDown(e)}
101
95
  onKeyUp={onKeyUp}
@@ -111,7 +105,7 @@ export const Textarea = ({
111
105
  padding: 10,
112
106
  paddingLeft: persistentMenuOptions ? 0 : 10,
113
107
  fontFamily: 'inherit',
114
- ...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.userInputBoxStyle),
108
+ ...userInputBoxStyle,
115
109
  }}
116
110
  />
117
111
  </TextAreaContainer>
@@ -11,8 +11,7 @@ export const IntroMessage = () => {
11
11
  const { getThemeProperty } = useContext(WebchatContext)
12
12
 
13
13
  const animationsEnabled = getThemeProperty(
14
- WEBCHAT.CUSTOM_PROPERTIES.enableAnimations,
15
- true
14
+ WEBCHAT.CUSTOM_PROPERTIES.enableAnimations
16
15
  )
17
16
  const CustomIntro = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.customIntro)
18
17
  const introImage = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.introImage)
@@ -7,13 +7,11 @@ export function useNotifications() {
7
7
  const { getThemeProperty } = useContext(WebchatContext)
8
8
 
9
9
  const CustomUnreadMessagesBanner = getThemeProperty(
10
- WEBCHAT.CUSTOM_PROPERTIES.notificationsBannerCustom,
11
- undefined
10
+ WEBCHAT.CUSTOM_PROPERTIES.notificationsBannerCustom
12
11
  )
13
12
 
14
13
  const notificationsBannerEnabled = getThemeProperty(
15
- WEBCHAT.CUSTOM_PROPERTIES.notificationsBannerEnabled,
16
- undefined
14
+ WEBCHAT.CUSTOM_PROPERTIES.notificationsBannerEnabled
17
15
  )
18
16
 
19
17
  const notificationsEnabled = getThemeProperty(
@@ -22,13 +20,11 @@ export function useNotifications() {
22
20
  )
23
21
 
24
22
  const bannerText = getThemeProperty(
25
- WEBCHAT.CUSTOM_PROPERTIES.notificationsBannerText,
26
- 'unread messages'
23
+ WEBCHAT.CUSTOM_PROPERTIES.notificationsBannerText
27
24
  )
28
25
 
29
26
  const CustomScrollButton = getThemeProperty(
30
- WEBCHAT.CUSTOM_PROPERTIES.scrollButtonCustom,
31
- undefined
27
+ WEBCHAT.CUSTOM_PROPERTIES.scrollButtonCustom
32
28
  )
33
29
 
34
30
  const scrollButtonEnabled = getThemeProperty(
@@ -1,26 +1,32 @@
1
1
  import styled from 'styled-components'
2
2
 
3
- import { COLORS, WEBCHAT } from '../constants'
3
+ import { COLORS } from '../constants'
4
4
 
5
- interface StyledWebchatProps {
6
- width: number
7
- height: number
8
- }
9
-
10
- export const StyledWebchat = styled.div<StyledWebchatProps>`
5
+ export const StyledWebchat = styled.div`
11
6
  position: fixed;
12
- right: 20px;
13
- bottom: 20px;
14
- width: ${props => props.width}px;
15
- height: ${props => props.height}px;
7
+ right: ${props => props.theme.style.right};
8
+ bottom: ${props => props.theme.style.bottom};
9
+ width: ${props => props.theme.style.width};
10
+ height: ${props => props.theme.style.height};
16
11
  margin: auto;
17
- background-color: ${COLORS.SOLID_WHITE};
12
+ background-color: ${props => props.theme.style.backgroundColor};
18
13
  border-radius: 10px;
19
- box-shadow: ${COLORS.SOLID_BLACK_ALPHA_0_2} 0px 0px 12px;
14
+ box-shadow: ${props => props.theme.style.boxShadow};
15
+ font-family: ${props => props.theme.style.fontFamily};
20
16
  display: flex;
21
17
  flex-direction: column;
22
18
  justify-content: space-between;
23
19
  overflow: hidden;
20
+
21
+ @media (max-width: ${props => props.theme.mobileBreakpoint}px) {
22
+ position: ${props => props.theme.mobileStyle.position};
23
+ right: ${props => props.theme.mobileStyle.right};
24
+ bottom: ${props => props.theme.mobileStyle.bottom};
25
+ width: ${props => props.theme.mobileStyle.width};
26
+ height: ${props => props.theme.mobileStyle.height};
27
+ border-radius: ${props => props.theme.mobileStyle.borderRadius};
28
+ font-size: ${props => props.theme.mobileStyle.fontSize};
29
+ }
24
30
  `
25
31
 
26
32
  export const ErrorMessageContainer = styled.div`
@@ -43,7 +49,7 @@ export const ErrorMessage = styled.div`
43
49
  border-radius: 5px;
44
50
  align-items: center;
45
51
  justify-content: center;
46
- font-family: ${WEBCHAT.DEFAULTS.FONT_FAMILY};
52
+ font-family: ${props => props.theme.style.fontFamily};
47
53
  `
48
54
 
49
55
  export const DarkBackgroundMenu = styled.div`
@@ -0,0 +1,102 @@
1
+ import { COLORS, WEBCHAT } from '../../constants'
2
+ import { WebchatTheme } from './types'
3
+
4
+ export const defaultTheme: WebchatTheme = {
5
+ style: {
6
+ width: '300px',
7
+ height: '450px',
8
+ borderRadius: '10px',
9
+ fontFamily: "'Noto Sans JP', sans-serif",
10
+ fontSize: '16px',
11
+ position: 'fixed',
12
+ right: '20px',
13
+ bottom: '20px',
14
+ backgroundColor: COLORS.SOLID_WHITE,
15
+ boxShadow: `${COLORS.SOLID_BLACK_ALPHA_0_2} 0px 0px 12px`,
16
+ },
17
+ mobileBreakpoint: 768,
18
+ mobileStyle: {
19
+ width: '100%',
20
+ height: '100%',
21
+ borderRadius: '0px',
22
+ fontSize: '16px',
23
+ position: 'absolute',
24
+ right: '0px',
25
+ bottom: '0px',
26
+ },
27
+ header: {
28
+ title: 'Botonic',
29
+ subtitle: '',
30
+ image: WEBCHAT.DEFAULTS.LOGO,
31
+ style: {
32
+ borderRadius: '10px 10px 0px 0px',
33
+ },
34
+ mobileStyle: {
35
+ borderRadius: '0px',
36
+ },
37
+ },
38
+ brand: {
39
+ color: COLORS.BOTONIC_BLUE,
40
+ image: WEBCHAT.DEFAULTS.LOGO,
41
+ },
42
+ button: {
43
+ autodisable: false,
44
+ disabledstyle: {
45
+ opacity: 0.5,
46
+ cursor: 'auto',
47
+ pointerEvents: 'none',
48
+ },
49
+ messageType: 'text',
50
+ hoverBackground: COLORS.CONCRETE_WHITE,
51
+ hoverTextColor: COLORS.SOLID_BLACK,
52
+ style: {
53
+ width: '100%',
54
+ maxHeight: '80px',
55
+ height: 'auto',
56
+ fontFamily: 'inherit',
57
+ fontSize: '14px',
58
+ fontWeight: 'normal',
59
+ background: COLORS.SOLID_WHITE,
60
+ color: COLORS.SOLID_BLACK,
61
+ outline: '0',
62
+ border: ` 1px solid ${COLORS.SEASHELL_WHITE}`,
63
+ borderRadius: '0px',
64
+ padding: '12px 32px',
65
+ overflow: 'hidden',
66
+ },
67
+ urlIcon: {
68
+ enable: false,
69
+ image: WEBCHAT.DEFAULTS.URL_ICON,
70
+ },
71
+ },
72
+ message: {
73
+ user: {
74
+ blobTick: true,
75
+ },
76
+ bot: {
77
+ blobTick: true,
78
+ },
79
+ },
80
+ triggerButton: { image: WEBCHAT.DEFAULTS.LOGO },
81
+ userInput: {
82
+ attachments: { enable: false },
83
+ box: {
84
+ placeholder: 'Ask me something...',
85
+ },
86
+ emojiPicker: { enable: false },
87
+ sendButton: { enable: true },
88
+ enable: true,
89
+ },
90
+ carousel: {
91
+ enableArrows: true,
92
+ },
93
+ animations: { enable: true },
94
+ notifications: {
95
+ enable: false,
96
+ banner: {
97
+ enable: false,
98
+ text: 'unread messages',
99
+ },
100
+ triggerButton: { enable: false },
101
+ },
102
+ }
@@ -0,0 +1,8 @@
1
+ import 'styled-components'
2
+
3
+ import { WebchatTheme } from './types'
4
+
5
+ // With this declaration, we can use the theme prop in styled components with TypeScript defined in WebchatTheme
6
+ declare module 'styled-components' {
7
+ export interface DefaultTheme extends WebchatTheme {}
8
+ }
@@ -4,7 +4,7 @@ import {
4
4
  CustomMessageType,
5
5
  } from '../../components/index-types'
6
6
 
7
- interface ImagePreviewerProps {
7
+ export interface ImagePreviewerProps {
8
8
  src: string
9
9
  isPreviewerOpened: boolean
10
10
  closePreviewer: () => void
@@ -38,29 +38,82 @@ export interface BlobProps {
38
38
  imageStyle?: any
39
39
  }
40
40
 
41
- export interface ThemeProps {
42
- style?: any
41
+ export interface CustomButtonProps {
42
+ children: React.ReactNode
43
+ onClick?: () => void
44
+ }
45
+
46
+ interface ButtonStyle {
47
+ width?: string
48
+ maxHeight?: string
49
+ height?: string
50
+ fontFamily?: string
51
+ fontSize?: string
52
+ fontWeight?: string
53
+ background?: string
54
+ color?: string
55
+ outline?: string
56
+ border?: string
57
+ borderRadius?: string
58
+ padding?: string
59
+ overflow?: string
60
+ }
61
+
62
+ export interface WebchatTheme {
63
+ style: {
64
+ width?: string
65
+ height?: string
66
+ borderRadius?: string
67
+ fontFamily?: string
68
+ fontSize?: string
69
+ position?: 'fixed' | 'absolute'
70
+ right?: string
71
+ bottom?: string
72
+ backgroundColor?: string
73
+ boxShadow?: string
74
+ }
75
+ mobileBreakpoint: number
76
+ mobileStyle: {
77
+ width?: string
78
+ height?: string
79
+ borderRadius?: string
80
+ fontSize?: string
81
+ position?: 'fixed' | 'absolute'
82
+ right?: string
83
+ bottom?: string
84
+ }
85
+
43
86
  coverComponent?: CoverComponentOptions
44
- mobileBreakpoint?: number
45
- mobileStyle?: any
46
- webview?: { style?: any; header?: { style?: any } }
87
+ webview?: {
88
+ style?: any
89
+ header?: {
90
+ style?: any
91
+ }
92
+ }
47
93
  animations?: { enable?: boolean }
48
- intro?: { style?: any; image?: string; custom?: React.ComponentType }
94
+ intro?: {
95
+ style?: any
96
+ image?: string
97
+ custom?: React.ComponentType
98
+ }
49
99
  brand?: { color?: string; image?: string }
50
100
  header?: {
51
101
  title?: string
52
102
  subtitle?: string
53
103
  image?: string
54
- style?: any
104
+ style?: {
105
+ borderRadius?: string
106
+ }
107
+ mobileStyle?: {
108
+ borderRadius?: string
109
+ }
55
110
  custom?: React.ComponentType
56
111
  }
57
- // TODO: Review if this is needed hear, or only in message.customTypes? use the same type in both places
58
- customMessageTypes?: CustomMessageType[]
59
112
  message?: {
60
113
  bot?: BlobProps & { image?: string; style?: any }
61
114
  agent?: { image?: string }
62
115
  user?: BlobProps & { style?: any }
63
- // TODO: Review type used in cutomTypes should be a component exported by default with customMessage function
116
+ // TODO: Review type used in customTypes should be a component exported by default with customMessage function
64
117
  customTypes?: CustomMessageType[]
65
118
  style?: any
66
119
  timestamps?: {
@@ -72,13 +125,21 @@ export interface ThemeProps {
72
125
  }
73
126
  button?: {
74
127
  autodisable?: boolean
75
- disabledstyle?: any
128
+ disabledstyle?: {
129
+ opacity?: number
130
+ cursor?: string
131
+ pointerEvents?: string
132
+ backgroundColor?: string
133
+ }
76
134
  hoverBackground?: string
77
135
  hoverTextColor?: string
78
- messageType?: 'text' | 'payload'
79
- urlIcon?: { image?: string; enable?: boolean }
80
- style?: any
81
- custom?: React.ComponentType
136
+ messageType?: 'text' | 'postback'
137
+ urlIcon?: {
138
+ image?: string
139
+ enable?: boolean
140
+ }
141
+ style?: ButtonStyle
142
+ custom?: React.ComponentType<CustomButtonProps>
82
143
  }
83
144
  replies?: {
84
145
  align?: 'left' | 'center' | 'right'
@@ -91,27 +152,53 @@ export interface ThemeProps {
91
152
  }
92
153
  enableArrows?: boolean
93
154
  }
94
- reply?: { style?: any; custom?: React.ComponentType }
95
- triggerButton?: { image?: string; style?: any; custom?: React.ComponentType }
155
+ reply?: {
156
+ style?: any
157
+ custom?: React.ComponentType
158
+ }
159
+ triggerButton: {
160
+ image?: string
161
+ style?: any
162
+ custom?: React.ComponentType
163
+ }
96
164
  notifications?: {
97
165
  enable?: boolean
98
- banner?: { custom?: React.ComponentType; enable?: boolean; text?: string }
166
+ banner?: {
167
+ custom?: React.ComponentType
168
+ enable?: boolean
169
+ text?: string
170
+ }
99
171
  triggerButton?: { enable?: boolean }
100
172
  }
101
- scrollButton?: { enable?: boolean; custom?: React.ComponentType }
173
+ scrollButton?: {
174
+ enable?: boolean
175
+ custom?: React.ComponentType
176
+ }
102
177
  markdownStyle?: string // string template with css styles
103
178
  userInput?: {
104
- attachments?: { enable?: boolean; custom?: React.ComponentType }
179
+ attachments?: {
180
+ enable?: boolean
181
+ custom?: React.ComponentType
182
+ }
105
183
  blockInputs?: BlockInputOption[]
106
- box?: { placeholder: string; style?: any }
107
- emojiPicker?: { enable?: boolean; custom?: React.ComponentType }
184
+ box?: {
185
+ placeholder: string
186
+ style?: any
187
+ }
188
+ emojiPicker?: {
189
+ enable?: boolean
190
+ custom?: React.ComponentType
191
+ }
108
192
  menu?: {
109
193
  darkBackground?: boolean
110
194
  custom?: React.ComponentType<PersistentMenuOptionsProps>
111
195
  }
112
196
  menuButton?: { custom?: React.ComponentType }
113
197
  persistentMenu?: PersistentMenuOptionsTheme
114
- sendButton?: { enable?: boolean; custom?: React.ComponentType }
198
+ sendButton?: {
199
+ enable?: boolean
200
+ custom?: React.ComponentType
201
+ }
115
202
  enable?: boolean
116
203
  style?: any
117
204
  }
@@ -20,7 +20,7 @@ export const TriggerButton = (): JSX.Element => {
20
20
  )
21
21
 
22
22
  if (!image) {
23
- webchatState.theme.triggerButtonImage = WEBCHAT.DEFAULTS.LOGO
23
+ webchatState.theme.triggerButton.image = WEBCHAT.DEFAULTS.LOGO
24
24
  return null
25
25
  }
26
26
  return image
@@ -33,8 +33,7 @@ export const TriggerButton = (): JSX.Element => {
33
33
  )
34
34
 
35
35
  const notificationsTriggerButtonEnabled = getThemeProperty(
36
- WEBCHAT.CUSTOM_PROPERTIES.notificationsTriggerButtonEnabled,
37
- false
36
+ WEBCHAT.CUSTOM_PROPERTIES.notificationsTriggerButtonEnabled
38
37
  )
39
38
 
40
39
  const notificationsEnabled = getThemeProperty(
@@ -43,8 +42,7 @@ export const TriggerButton = (): JSX.Element => {
43
42
  )
44
43
 
45
44
  const CustomTriggerButton = getThemeProperty(
46
- WEBCHAT.CUSTOM_PROPERTIES.customTrigger,
47
- undefined
45
+ WEBCHAT.CUSTOM_PROPERTIES.customTrigger
48
46
  )
49
47
 
50
48
  const handleClick = (event: any) => {