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

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 (161) hide show
  1. package/lib/cjs/components/element.js +6 -6
  2. package/lib/cjs/components/element.js.map +1 -1
  3. package/lib/cjs/components/index-types.d.ts +2 -0
  4. package/lib/cjs/components/multichannel/multichannel-button.js +2 -2
  5. package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
  6. package/lib/cjs/components/multichannel/multichannel-carousel.js +4 -4
  7. package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
  8. package/lib/cjs/components/multichannel/multichannel-text.js +12 -11
  9. package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
  10. package/lib/cjs/components/multichannel/multichannel-utils.d.ts +9 -15
  11. package/lib/cjs/components/multichannel/multichannel-utils.js +48 -27
  12. package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
  13. package/lib/cjs/components/multichannel/multichannel.js +7 -7
  14. package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
  15. package/lib/cjs/components/multichannel/whatsapp/constants.d.ts +11 -0
  16. package/lib/cjs/components/multichannel/whatsapp/constants.js +13 -0
  17. package/lib/cjs/components/multichannel/whatsapp/constants.js.map +1 -0
  18. package/lib/cjs/components/whatsapp-button-list.js +2 -2
  19. package/lib/cjs/components/whatsapp-button-list.js.map +1 -1
  20. package/lib/cjs/components/whatsapp-cta-url-button.js +5 -5
  21. package/lib/cjs/components/whatsapp-cta-url-button.js.map +1 -1
  22. package/lib/cjs/constants.d.ts +0 -6
  23. package/lib/cjs/constants.js +1 -7
  24. package/lib/cjs/constants.js.map +1 -1
  25. package/lib/cjs/contexts.js +6 -0
  26. package/lib/cjs/contexts.js.map +1 -1
  27. package/lib/cjs/dev-app.d.ts +7 -0
  28. package/lib/cjs/index-types.d.ts +4 -7
  29. package/lib/cjs/index-types.js.map +1 -1
  30. package/lib/cjs/index.d.ts +1 -1
  31. package/lib/cjs/index.js.map +1 -1
  32. package/lib/cjs/webchat/actions.d.ts +2 -1
  33. package/lib/cjs/webchat/actions.js +1 -0
  34. package/lib/cjs/webchat/actions.js.map +1 -1
  35. package/lib/cjs/webchat/cover-component/index.d.ts +6 -0
  36. package/lib/cjs/webchat/cover-component/index.js +21 -0
  37. package/lib/cjs/webchat/cover-component/index.js.map +1 -0
  38. package/lib/cjs/webchat/hooks/use-scroll-to-bottom.d.ts +6 -4
  39. package/lib/cjs/webchat/hooks/use-scroll-to-bottom.js.map +1 -1
  40. package/lib/cjs/webchat/hooks/use-webchat.d.ts +1 -0
  41. package/lib/cjs/webchat/hooks/use-webchat.js +8 -0
  42. package/lib/cjs/webchat/hooks/use-webchat.js.map +1 -1
  43. package/lib/cjs/webchat/index-types.d.ts +1 -0
  44. package/lib/cjs/webchat/input-panel/textarea.js +8 -2
  45. package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
  46. package/lib/cjs/webchat/message-list/index.js +63 -35
  47. package/lib/cjs/webchat/message-list/index.js.map +1 -1
  48. package/lib/cjs/webchat/message-list/styles.js +3 -3
  49. package/lib/cjs/webchat/typing-indicator/index.d.ts +3 -1
  50. package/lib/cjs/webchat/typing-indicator/index.js +4 -3
  51. package/lib/cjs/webchat/typing-indicator/index.js.map +1 -1
  52. package/lib/cjs/webchat/typing-indicator/styles.d.ts +3 -2
  53. package/lib/cjs/webchat/typing-indicator/styles.js +6 -3
  54. package/lib/cjs/webchat/typing-indicator/styles.js.map +1 -1
  55. package/lib/cjs/webchat/webchat-reducer.js +2 -0
  56. package/lib/cjs/webchat/webchat-reducer.js.map +1 -1
  57. package/lib/cjs/webchat/webchat-typed/styles.d.ts +7 -0
  58. package/lib/cjs/webchat/webchat-typed/styles.js +54 -0
  59. package/lib/cjs/webchat/webchat-typed/styles.js.map +1 -0
  60. package/lib/cjs/webchat/webchat-typed/webchat-typed.d.ts +0 -0
  61. package/lib/cjs/webchat/webchat-typed/webchat-typed.js +663 -0
  62. package/lib/cjs/webchat/webchat-typed/webchat-typed.js.map +1 -0
  63. package/lib/cjs/webchat/webchat.js +16 -18
  64. package/lib/cjs/webchat/webchat.js.map +1 -1
  65. package/lib/cjs/webchat-app.d.ts +117 -76
  66. package/lib/cjs/webchat-app.js +98 -55
  67. package/lib/cjs/webchat-app.js.map +1 -1
  68. package/lib/esm/components/element.js +6 -6
  69. package/lib/esm/components/element.js.map +1 -1
  70. package/lib/esm/components/index-types.d.ts +2 -0
  71. package/lib/esm/components/multichannel/multichannel-button.js +1 -1
  72. package/lib/esm/components/multichannel/multichannel-carousel.js +5 -5
  73. package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
  74. package/lib/esm/components/multichannel/multichannel-text.js +2 -1
  75. package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
  76. package/lib/esm/components/multichannel/multichannel-utils.d.ts +9 -15
  77. package/lib/esm/components/multichannel/multichannel-utils.js +40 -24
  78. package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
  79. package/lib/esm/components/multichannel/multichannel.js +7 -7
  80. package/lib/esm/components/multichannel/multichannel.js.map +1 -1
  81. package/lib/esm/components/multichannel/whatsapp/constants.d.ts +11 -0
  82. package/lib/esm/components/multichannel/whatsapp/constants.js +10 -0
  83. package/lib/esm/components/multichannel/whatsapp/constants.js.map +1 -0
  84. package/lib/esm/components/whatsapp-button-list.js +1 -1
  85. package/lib/esm/components/whatsapp-cta-url-button.js +1 -1
  86. package/lib/esm/constants.d.ts +0 -6
  87. package/lib/esm/constants.js +0 -6
  88. package/lib/esm/constants.js.map +1 -1
  89. package/lib/esm/contexts.js +6 -0
  90. package/lib/esm/contexts.js.map +1 -1
  91. package/lib/esm/dev-app.d.ts +7 -0
  92. package/lib/esm/index-types.d.ts +4 -7
  93. package/lib/esm/index-types.js.map +1 -1
  94. package/lib/esm/index.d.ts +1 -1
  95. package/lib/esm/index.js.map +1 -1
  96. package/lib/esm/webchat/actions.d.ts +2 -1
  97. package/lib/esm/webchat/actions.js +1 -0
  98. package/lib/esm/webchat/actions.js.map +1 -1
  99. package/lib/esm/webchat/cover-component/index.d.ts +6 -0
  100. package/lib/esm/webchat/cover-component/index.js +17 -0
  101. package/lib/esm/webchat/cover-component/index.js.map +1 -0
  102. package/lib/esm/webchat/hooks/use-scroll-to-bottom.d.ts +6 -4
  103. package/lib/esm/webchat/hooks/use-scroll-to-bottom.js.map +1 -1
  104. package/lib/esm/webchat/hooks/use-webchat.d.ts +1 -0
  105. package/lib/esm/webchat/hooks/use-webchat.js +8 -0
  106. package/lib/esm/webchat/hooks/use-webchat.js.map +1 -1
  107. package/lib/esm/webchat/index-types.d.ts +1 -0
  108. package/lib/esm/webchat/input-panel/textarea.js +8 -2
  109. package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
  110. package/lib/esm/webchat/message-list/index.js +62 -35
  111. package/lib/esm/webchat/message-list/index.js.map +1 -1
  112. package/lib/esm/webchat/message-list/styles.js +3 -3
  113. package/lib/esm/webchat/typing-indicator/index.d.ts +3 -1
  114. package/lib/esm/webchat/typing-indicator/index.js +5 -2
  115. package/lib/esm/webchat/typing-indicator/index.js.map +1 -1
  116. package/lib/esm/webchat/typing-indicator/styles.d.ts +3 -2
  117. package/lib/esm/webchat/typing-indicator/styles.js +5 -2
  118. package/lib/esm/webchat/typing-indicator/styles.js.map +1 -1
  119. package/lib/esm/webchat/webchat-reducer.js +2 -0
  120. package/lib/esm/webchat/webchat-reducer.js.map +1 -1
  121. package/lib/esm/webchat/webchat-typed/styles.d.ts +7 -0
  122. package/lib/esm/webchat/webchat-typed/styles.js +50 -0
  123. package/lib/esm/webchat/webchat-typed/styles.js.map +1 -0
  124. package/lib/esm/webchat/webchat-typed/webchat-typed.d.ts +0 -0
  125. package/lib/esm/webchat/webchat-typed/webchat-typed.js +663 -0
  126. package/lib/esm/webchat/webchat-typed/webchat-typed.js.map +1 -0
  127. package/lib/esm/webchat/webchat.js +16 -18
  128. package/lib/esm/webchat/webchat.js.map +1 -1
  129. package/lib/esm/webchat-app.d.ts +117 -76
  130. package/lib/esm/webchat-app.js +99 -56
  131. package/lib/esm/webchat-app.js.map +1 -1
  132. package/package.json +5 -4
  133. package/src/components/element.jsx +4 -11
  134. package/src/components/index-types.ts +4 -0
  135. package/src/components/multichannel/multichannel-button.jsx +1 -1
  136. package/src/components/multichannel/multichannel-carousel.jsx +7 -5
  137. package/src/components/multichannel/multichannel-text.jsx +4 -2
  138. package/src/components/multichannel/multichannel-utils.js +45 -27
  139. package/src/components/multichannel/multichannel.jsx +12 -7
  140. package/src/components/multichannel/whatsapp/constants.ts +10 -0
  141. package/src/components/whatsapp-button-list.tsx +1 -1
  142. package/src/components/whatsapp-cta-url-button.tsx +1 -1
  143. package/src/constants.js +0 -7
  144. package/src/contexts.tsx +6 -0
  145. package/src/index-types.ts +4 -7
  146. package/src/index.ts +1 -1
  147. package/src/webchat/actions.ts +1 -0
  148. package/src/webchat/cover-component/index.tsx +31 -0
  149. package/src/webchat/hooks/use-scroll-to-bottom.ts +8 -2
  150. package/src/webchat/hooks/use-webchat.ts +9 -0
  151. package/src/webchat/index-types.ts +1 -0
  152. package/src/webchat/input-panel/textarea.tsx +12 -1
  153. package/src/webchat/message-list/index.tsx +79 -48
  154. package/src/webchat/message-list/styles.ts +3 -3
  155. package/src/webchat/typing-indicator/index.tsx +20 -12
  156. package/src/webchat/typing-indicator/styles.ts +7 -3
  157. package/src/webchat/webchat-reducer.ts +2 -0
  158. package/src/webchat/webchat-typed/styles.ts +54 -0
  159. package/src/webchat/webchat-typed/webchat-typed.tsx +728 -0
  160. package/src/webchat/webchat.jsx +48 -48
  161. package/src/{webchat-app.jsx → webchat-app.tsx} +246 -77
@@ -44,6 +44,7 @@ import {
44
44
  import { ChatArea } from './chat-area'
45
45
  import { OpenedPersistentMenu } from './components/opened-persistent-menu'
46
46
  import { BotonicContainerId } from './constants'
47
+ import { CoverComponent } from './cover-component'
47
48
  import { WebchatHeader } from './header'
48
49
  import {
49
50
  useComponentWillMount,
@@ -120,6 +121,7 @@ export const Webchat = forwardRef((props, ref) => {
120
121
  resetUnreadMessages,
121
122
  setCurrentAttachment,
122
123
  setError,
124
+ setIsInputFocused,
123
125
  setLastMessageVisible,
124
126
  setOnline,
125
127
  toggleCoverComponent,
@@ -203,7 +205,7 @@ export const Webchat = forwardRef((props, ref) => {
203
205
  const sendUserInput = async input => {
204
206
  if (props.onUserInput) {
205
207
  resetUnreadMessages()
206
- scrollToBottom({ host })
208
+ scrollToBottom()
207
209
  props.onUserInput({
208
210
  user: webchatState.session.user,
209
211
  input: input,
@@ -367,7 +369,7 @@ export const Webchat = forwardRef((props, ref) => {
367
369
  if (getBlockInputs(rule, input.data)) {
368
370
  addMessageComponent(
369
371
  <Text
370
- id={input.id}
372
+ id={input.id} //TODO: Remove id from Text component
371
373
  sentBy={SENDERS.user}
372
374
  blob={false}
373
375
  style={{
@@ -407,41 +409,23 @@ export const Webchat = forwardRef((props, ref) => {
407
409
  (props.coverComponent.component || props.coverComponent)
408
410
  )
409
411
  }
410
- const CoverComponent = getCoverComponent()
411
-
412
- const closeCoverComponent = () => {
413
- toggleCoverComponent(false)
414
- }
412
+ const coverComponent = getCoverComponent()
413
+ const coverComponentProps = props.coverComponent?.props
415
414
 
416
415
  useEffect(() => {
417
- if (!CoverComponent) return
416
+ if (!coverComponent) return
418
417
  if (
419
418
  !botonicState ||
420
- (botonicState.messages && botonicState.messages.length == 0)
419
+ (botonicState.messages && botonicState.messages.length === 0)
421
420
  )
422
421
  toggleCoverComponent(true)
423
422
  }, [])
424
423
 
425
- const coverComponent = () => {
426
- const coverComponentProps = getThemeProperty(
427
- WEBCHAT.CUSTOM_PROPERTIES.coverComponentProps,
428
- props.coverComponent && props.coverComponent.props
429
- )
430
-
431
- if (CoverComponent && webchatState.isCoverComponentOpen)
432
- return (
433
- <CoverComponent
434
- closeComponent={closeCoverComponent}
435
- {...coverComponentProps}
436
- />
437
- )
438
- return null
439
- }
440
-
441
424
  const messageComponentFromInput = input => {
442
425
  let messageComponent = null
443
426
  if (isText(input)) {
444
427
  messageComponent = (
428
+ //TODO: Remove id and payload from Text component
445
429
  <Text id={input.id} payload={input.payload} sentBy={SENDERS.user}>
446
430
  {input.data}
447
431
  </Text>
@@ -700,6 +684,7 @@ export const Webchat = forwardRef((props, ref) => {
700
684
  openWebview,
701
685
  resolveCase,
702
686
  resetUnreadMessages,
687
+ setIsInputFocused,
703
688
  setLastMessageVisible,
704
689
  sendAttachment,
705
690
  sendInput,
@@ -708,6 +693,7 @@ export const Webchat = forwardRef((props, ref) => {
708
693
  toggleWebchat,
709
694
  toggleEmojiPicker,
710
695
  togglePersistentMenu,
696
+ toggleCoverComponent,
711
697
  updateLatestInput,
712
698
  updateMessage,
713
699
  updateReplies,
@@ -744,36 +730,50 @@ export const Webchat = forwardRef((props, ref) => {
744
730
  toggleWebchat(false)
745
731
  }}
746
732
  />
747
- {webchatState.error.message && (
748
- <ErrorMessageContainer>
749
- <ErrorMessage>{webchatState.error.message}</ErrorMessage>
750
- </ErrorMessageContainer>
751
- )}
752
- <ChatArea />
753
733
 
754
- {webchatState.isPersistentMenuOpen && (
755
- <DarkenBackground component={persistentMenu()} />
756
- )}
757
- {!webchatState.handoff && userInputEnabled && (
758
- <InputPanel
759
- persistentMenu={props.persistentMenu}
760
- enableEmojiPicker={props.enableEmojiPicker}
761
- enableAttachments={props.enableAttachments}
762
- handleAttachment={handleAttachment}
763
- textareaRef={textareaRef}
764
- host={host}
765
- onUserInput={props.onUserInput}
734
+ {webchatState.isCoverComponentOpen ? (
735
+ <CoverComponent
736
+ component={coverComponent}
737
+ componentProps={coverComponentProps}
766
738
  />
739
+ ) : (
740
+ <>
741
+ {webchatState.error.message && (
742
+ <ErrorMessageContainer>
743
+ <ErrorMessage>{webchatState.error.message}</ErrorMessage>
744
+ </ErrorMessageContainer>
745
+ )}
746
+
747
+ <ChatArea />
748
+
749
+ {webchatState.isPersistentMenuOpen && (
750
+ <DarkenBackground component={persistentMenu()} />
751
+ )}
752
+
753
+ {!webchatState.handoff && userInputEnabled && (
754
+ <InputPanel
755
+ persistentMenu={props.persistentMenu}
756
+ enableEmojiPicker={props.enableEmojiPicker}
757
+ enableAttachments={props.enableAttachments}
758
+ handleAttachment={handleAttachment}
759
+ textareaRef={textareaRef}
760
+ host={host}
761
+ onUserInput={props.onUserInput}
762
+ />
763
+ )}
764
+
765
+ {webchatState.webview && webchatWebview()}
766
+
767
+ {webchatState.isCustomComponentRendered &&
768
+ customComponent &&
769
+ _renderCustomComponent()}
770
+ </>
767
771
  )}
768
- {webchatState.webview && webchatWebview()}
769
- {webchatState.isCoverComponentOpen && coverComponent()}
770
- {webchatState.isCustomComponentRendered &&
771
- customComponent &&
772
- _renderCustomComponent()}
773
772
  </StyledWebchat>
774
773
  )}
775
774
  </WebchatContext.Provider>
776
775
  )
776
+
777
777
  return props.shadowDOM ? (
778
778
  <StyleSheetManager target={host}>{WebchatComponent}</StyleSheetManager>
779
779
  ) : (