@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.
- package/lib/cjs/components/element.js +6 -6
- package/lib/cjs/components/element.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +2 -0
- package/lib/cjs/components/multichannel/multichannel-button.js +2 -2
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js +4 -4
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.js +12 -11
- package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-utils.d.ts +9 -15
- package/lib/cjs/components/multichannel/multichannel-utils.js +48 -27
- package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel.js +7 -7
- package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
- package/lib/cjs/components/multichannel/whatsapp/constants.d.ts +11 -0
- package/lib/cjs/components/multichannel/whatsapp/constants.js +13 -0
- package/lib/cjs/components/multichannel/whatsapp/constants.js.map +1 -0
- package/lib/cjs/components/whatsapp-button-list.js +2 -2
- package/lib/cjs/components/whatsapp-button-list.js.map +1 -1
- package/lib/cjs/components/whatsapp-cta-url-button.js +5 -5
- package/lib/cjs/components/whatsapp-cta-url-button.js.map +1 -1
- package/lib/cjs/constants.d.ts +0 -6
- package/lib/cjs/constants.js +1 -7
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/contexts.js +6 -0
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/dev-app.d.ts +7 -0
- package/lib/cjs/index-types.d.ts +4 -7
- package/lib/cjs/index-types.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/webchat/actions.d.ts +2 -1
- package/lib/cjs/webchat/actions.js +1 -0
- package/lib/cjs/webchat/actions.js.map +1 -1
- package/lib/cjs/webchat/cover-component/index.d.ts +6 -0
- package/lib/cjs/webchat/cover-component/index.js +21 -0
- package/lib/cjs/webchat/cover-component/index.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-scroll-to-bottom.d.ts +6 -4
- package/lib/cjs/webchat/hooks/use-scroll-to-bottom.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-webchat.d.ts +1 -0
- package/lib/cjs/webchat/hooks/use-webchat.js +8 -0
- package/lib/cjs/webchat/hooks/use-webchat.js.map +1 -1
- package/lib/cjs/webchat/index-types.d.ts +1 -0
- package/lib/cjs/webchat/input-panel/textarea.js +8 -2
- package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
- package/lib/cjs/webchat/message-list/index.js +63 -35
- package/lib/cjs/webchat/message-list/index.js.map +1 -1
- package/lib/cjs/webchat/message-list/styles.js +3 -3
- package/lib/cjs/webchat/typing-indicator/index.d.ts +3 -1
- package/lib/cjs/webchat/typing-indicator/index.js +4 -3
- package/lib/cjs/webchat/typing-indicator/index.js.map +1 -1
- package/lib/cjs/webchat/typing-indicator/styles.d.ts +3 -2
- package/lib/cjs/webchat/typing-indicator/styles.js +6 -3
- package/lib/cjs/webchat/typing-indicator/styles.js.map +1 -1
- package/lib/cjs/webchat/webchat-reducer.js +2 -0
- package/lib/cjs/webchat/webchat-reducer.js.map +1 -1
- package/lib/cjs/webchat/webchat-typed/styles.d.ts +7 -0
- package/lib/cjs/webchat/webchat-typed/styles.js +54 -0
- package/lib/cjs/webchat/webchat-typed/styles.js.map +1 -0
- package/lib/cjs/webchat/webchat-typed/webchat-typed.d.ts +0 -0
- package/lib/cjs/webchat/webchat-typed/webchat-typed.js +663 -0
- package/lib/cjs/webchat/webchat-typed/webchat-typed.js.map +1 -0
- package/lib/cjs/webchat/webchat.js +16 -18
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat-app.d.ts +117 -76
- package/lib/cjs/webchat-app.js +98 -55
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/esm/components/element.js +6 -6
- package/lib/esm/components/element.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +2 -0
- package/lib/esm/components/multichannel/multichannel-button.js +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js +5 -5
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-text.js +2 -1
- package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-utils.d.ts +9 -15
- package/lib/esm/components/multichannel/multichannel-utils.js +40 -24
- package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel.js +7 -7
- package/lib/esm/components/multichannel/multichannel.js.map +1 -1
- package/lib/esm/components/multichannel/whatsapp/constants.d.ts +11 -0
- package/lib/esm/components/multichannel/whatsapp/constants.js +10 -0
- package/lib/esm/components/multichannel/whatsapp/constants.js.map +1 -0
- package/lib/esm/components/whatsapp-button-list.js +1 -1
- package/lib/esm/components/whatsapp-cta-url-button.js +1 -1
- package/lib/esm/constants.d.ts +0 -6
- package/lib/esm/constants.js +0 -6
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/contexts.js +6 -0
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/dev-app.d.ts +7 -0
- package/lib/esm/index-types.d.ts +4 -7
- package/lib/esm/index-types.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/webchat/actions.d.ts +2 -1
- package/lib/esm/webchat/actions.js +1 -0
- package/lib/esm/webchat/actions.js.map +1 -1
- package/lib/esm/webchat/cover-component/index.d.ts +6 -0
- package/lib/esm/webchat/cover-component/index.js +17 -0
- package/lib/esm/webchat/cover-component/index.js.map +1 -0
- package/lib/esm/webchat/hooks/use-scroll-to-bottom.d.ts +6 -4
- package/lib/esm/webchat/hooks/use-scroll-to-bottom.js.map +1 -1
- package/lib/esm/webchat/hooks/use-webchat.d.ts +1 -0
- package/lib/esm/webchat/hooks/use-webchat.js +8 -0
- package/lib/esm/webchat/hooks/use-webchat.js.map +1 -1
- package/lib/esm/webchat/index-types.d.ts +1 -0
- package/lib/esm/webchat/input-panel/textarea.js +8 -2
- package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
- package/lib/esm/webchat/message-list/index.js +62 -35
- package/lib/esm/webchat/message-list/index.js.map +1 -1
- package/lib/esm/webchat/message-list/styles.js +3 -3
- package/lib/esm/webchat/typing-indicator/index.d.ts +3 -1
- package/lib/esm/webchat/typing-indicator/index.js +5 -2
- package/lib/esm/webchat/typing-indicator/index.js.map +1 -1
- package/lib/esm/webchat/typing-indicator/styles.d.ts +3 -2
- package/lib/esm/webchat/typing-indicator/styles.js +5 -2
- package/lib/esm/webchat/typing-indicator/styles.js.map +1 -1
- package/lib/esm/webchat/webchat-reducer.js +2 -0
- package/lib/esm/webchat/webchat-reducer.js.map +1 -1
- package/lib/esm/webchat/webchat-typed/styles.d.ts +7 -0
- package/lib/esm/webchat/webchat-typed/styles.js +50 -0
- package/lib/esm/webchat/webchat-typed/styles.js.map +1 -0
- package/lib/esm/webchat/webchat-typed/webchat-typed.d.ts +0 -0
- package/lib/esm/webchat/webchat-typed/webchat-typed.js +663 -0
- package/lib/esm/webchat/webchat-typed/webchat-typed.js.map +1 -0
- package/lib/esm/webchat/webchat.js +16 -18
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat-app.d.ts +117 -76
- package/lib/esm/webchat-app.js +99 -56
- package/lib/esm/webchat-app.js.map +1 -1
- package/package.json +5 -4
- package/src/components/element.jsx +4 -11
- package/src/components/index-types.ts +4 -0
- package/src/components/multichannel/multichannel-button.jsx +1 -1
- package/src/components/multichannel/multichannel-carousel.jsx +7 -5
- package/src/components/multichannel/multichannel-text.jsx +4 -2
- package/src/components/multichannel/multichannel-utils.js +45 -27
- package/src/components/multichannel/multichannel.jsx +12 -7
- package/src/components/multichannel/whatsapp/constants.ts +10 -0
- package/src/components/whatsapp-button-list.tsx +1 -1
- package/src/components/whatsapp-cta-url-button.tsx +1 -1
- package/src/constants.js +0 -7
- package/src/contexts.tsx +6 -0
- package/src/index-types.ts +4 -7
- package/src/index.ts +1 -1
- package/src/webchat/actions.ts +1 -0
- package/src/webchat/cover-component/index.tsx +31 -0
- package/src/webchat/hooks/use-scroll-to-bottom.ts +8 -2
- package/src/webchat/hooks/use-webchat.ts +9 -0
- package/src/webchat/index-types.ts +1 -0
- package/src/webchat/input-panel/textarea.tsx +12 -1
- package/src/webchat/message-list/index.tsx +79 -48
- package/src/webchat/message-list/styles.ts +3 -3
- package/src/webchat/typing-indicator/index.tsx +20 -12
- package/src/webchat/typing-indicator/styles.ts +7 -3
- package/src/webchat/webchat-reducer.ts +2 -0
- package/src/webchat/webchat-typed/styles.ts +54 -0
- package/src/webchat/webchat-typed/webchat-typed.tsx +728 -0
- package/src/webchat/webchat.jsx +48 -48
- package/src/{webchat-app.jsx → webchat-app.tsx} +246 -77
package/src/webchat/webchat.jsx
CHANGED
|
@@ -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(
|
|
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
|
|
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 (!
|
|
416
|
+
if (!coverComponent) return
|
|
418
417
|
if (
|
|
419
418
|
!botonicState ||
|
|
420
|
-
(botonicState.messages && botonicState.messages.length
|
|
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.
|
|
755
|
-
<
|
|
756
|
-
|
|
757
|
-
|
|
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
|
) : (
|