@botonic/react 0.31.0-alpha.1 → 0.31.5-alpha.1
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/audio.d.ts +1 -1
- package/lib/cjs/components/custom-message.d.ts +2 -2
- package/lib/cjs/components/document.d.ts +1 -1
- package/lib/cjs/components/handoff.d.ts +1 -1
- package/lib/cjs/components/image.d.ts +1 -1
- package/lib/cjs/components/index-types.d.ts +1 -0
- package/lib/cjs/components/message/message-feedback.d.ts +1 -1
- package/lib/cjs/components/message/message-footer.d.ts +1 -1
- package/lib/cjs/components/message/timestamps.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-button.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-reply.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.d.ts +1 -1
- package/lib/cjs/components/raw.d.ts +1 -1
- package/lib/cjs/components/text.d.ts +1 -1
- package/lib/cjs/components/video.d.ts +1 -1
- package/lib/cjs/contexts.js +3 -0
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/index-types.d.ts +1 -0
- package/lib/cjs/react-bot.d.ts +1 -1
- package/lib/cjs/util/error-boundary.d.ts +1 -1
- package/lib/cjs/util/react.d.ts +1 -1
- package/lib/cjs/webchat/chat-area/index.d.ts +1 -1
- package/lib/cjs/webchat/components/common.d.ts +1 -1
- package/lib/cjs/webchat/components/conditional-animation.d.ts +1 -1
- package/lib/cjs/webchat/components/opened-persistent-menu.d.ts +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/header.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/attachment.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/index.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/opened-emoji-picker.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/persistent-menu.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/send-button.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/textarea.d.ts +1 -1
- package/lib/cjs/webchat/message-list/index.d.ts +1 -1
- package/lib/cjs/webchat/message-list/intro-message.d.ts +1 -1
- package/lib/cjs/webchat/message-list/scroll-button.d.ts +0 -1
- package/lib/cjs/webchat/replies.d.ts +1 -1
- package/lib/cjs/webchat/session-view.d.ts +1 -1
- package/lib/cjs/webchat/session-view.js +2 -2
- package/lib/cjs/webchat/session-view.js.map +1 -1
- package/lib/cjs/webchat/trigger-button/index.d.ts +0 -1
- package/lib/cjs/webchat/typing-indicator/index.d.ts +1 -1
- package/lib/cjs/webchat/webchat-dev.d.ts +2 -2
- package/lib/cjs/webchat/webchat.js +10 -15
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview.d.ts +2 -2
- package/lib/cjs/webchat-app.d.ts +1 -1
- package/lib/esm/components/audio.d.ts +1 -1
- package/lib/esm/components/custom-message.d.ts +2 -2
- package/lib/esm/components/document.d.ts +1 -1
- package/lib/esm/components/handoff.d.ts +1 -1
- package/lib/esm/components/image.d.ts +1 -1
- package/lib/esm/components/index-types.d.ts +1 -0
- package/lib/esm/components/message/message-feedback.d.ts +1 -1
- package/lib/esm/components/message/message-footer.d.ts +1 -1
- package/lib/esm/components/message/timestamps.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-button.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-reply.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-text.d.ts +1 -1
- package/lib/esm/components/raw.d.ts +1 -1
- package/lib/esm/components/text.d.ts +1 -1
- package/lib/esm/components/video.d.ts +1 -1
- package/lib/esm/contexts.js +3 -0
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/index-types.d.ts +1 -0
- package/lib/esm/react-bot.d.ts +1 -1
- package/lib/esm/util/error-boundary.d.ts +1 -1
- package/lib/esm/util/react.d.ts +1 -1
- package/lib/esm/webchat/chat-area/index.d.ts +1 -1
- package/lib/esm/webchat/components/common.d.ts +1 -1
- package/lib/esm/webchat/components/conditional-animation.d.ts +1 -1
- package/lib/esm/webchat/components/opened-persistent-menu.d.ts +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/header.d.ts +1 -1
- package/lib/esm/webchat/input-panel/attachment.d.ts +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -1
- package/lib/esm/webchat/input-panel/index.d.ts +1 -1
- package/lib/esm/webchat/input-panel/opened-emoji-picker.d.ts +1 -1
- package/lib/esm/webchat/input-panel/persistent-menu.d.ts +1 -1
- package/lib/esm/webchat/input-panel/send-button.d.ts +1 -1
- package/lib/esm/webchat/input-panel/textarea.d.ts +1 -1
- package/lib/esm/webchat/message-list/index.d.ts +1 -1
- package/lib/esm/webchat/message-list/intro-message.d.ts +1 -1
- package/lib/esm/webchat/message-list/scroll-button.d.ts +0 -1
- package/lib/esm/webchat/replies.d.ts +1 -1
- package/lib/esm/webchat/session-view.d.ts +1 -1
- package/lib/esm/webchat/session-view.js +1 -1
- package/lib/esm/webchat/session-view.js.map +1 -1
- package/lib/esm/webchat/trigger-button/index.d.ts +0 -1
- package/lib/esm/webchat/typing-indicator/index.d.ts +1 -1
- package/lib/esm/webchat/webchat-dev.d.ts +2 -2
- package/lib/esm/webchat/webchat.js +10 -15
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview.d.ts +2 -2
- package/lib/esm/webchat-app.d.ts +1 -1
- package/package.json +15 -15
- package/src/components/index-types.ts +1 -0
- package/src/contexts.tsx +3 -0
- package/src/index-types.ts +1 -0
- package/src/webchat/cover-component/index.tsx +31 -0
- package/src/webchat/session-view.jsx +1 -1
- package/src/webchat/webchat.jsx +43 -46
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,
|
|
@@ -407,37 +408,18 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
407
408
|
(props.coverComponent.component || props.coverComponent)
|
|
408
409
|
)
|
|
409
410
|
}
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
const closeCoverComponent = () => {
|
|
413
|
-
toggleCoverComponent(false)
|
|
414
|
-
}
|
|
411
|
+
const coverComponent = getCoverComponent()
|
|
412
|
+
const coverComponentProps = props.coverComponent?.props
|
|
415
413
|
|
|
416
414
|
useEffect(() => {
|
|
417
|
-
if (!
|
|
415
|
+
if (!coverComponent) return
|
|
418
416
|
if (
|
|
419
417
|
!botonicState ||
|
|
420
|
-
(botonicState.messages && botonicState.messages.length
|
|
418
|
+
(botonicState.messages && botonicState.messages.length === 0)
|
|
421
419
|
)
|
|
422
420
|
toggleCoverComponent(true)
|
|
423
421
|
}, [])
|
|
424
422
|
|
|
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
423
|
const messageComponentFromInput = input => {
|
|
442
424
|
let messageComponent = null
|
|
443
425
|
if (isText(input)) {
|
|
@@ -708,6 +690,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
708
690
|
toggleWebchat,
|
|
709
691
|
toggleEmojiPicker,
|
|
710
692
|
togglePersistentMenu,
|
|
693
|
+
toggleCoverComponent,
|
|
711
694
|
updateLatestInput,
|
|
712
695
|
updateMessage,
|
|
713
696
|
updateReplies,
|
|
@@ -744,36 +727,50 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
744
727
|
toggleWebchat(false)
|
|
745
728
|
}}
|
|
746
729
|
/>
|
|
747
|
-
{webchatState.error.message && (
|
|
748
|
-
<ErrorMessageContainer>
|
|
749
|
-
<ErrorMessage>{webchatState.error.message}</ErrorMessage>
|
|
750
|
-
</ErrorMessageContainer>
|
|
751
|
-
)}
|
|
752
|
-
<ChatArea />
|
|
753
730
|
|
|
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}
|
|
731
|
+
{webchatState.isCoverComponentOpen ? (
|
|
732
|
+
<CoverComponent
|
|
733
|
+
component={coverComponent}
|
|
734
|
+
componentProps={coverComponentProps}
|
|
766
735
|
/>
|
|
736
|
+
) : (
|
|
737
|
+
<>
|
|
738
|
+
{webchatState.error.message && (
|
|
739
|
+
<ErrorMessageContainer>
|
|
740
|
+
<ErrorMessage>{webchatState.error.message}</ErrorMessage>
|
|
741
|
+
</ErrorMessageContainer>
|
|
742
|
+
)}
|
|
743
|
+
|
|
744
|
+
<ChatArea />
|
|
745
|
+
|
|
746
|
+
{webchatState.isPersistentMenuOpen && (
|
|
747
|
+
<DarkenBackground component={persistentMenu()} />
|
|
748
|
+
)}
|
|
749
|
+
|
|
750
|
+
{!webchatState.handoff && userInputEnabled && (
|
|
751
|
+
<InputPanel
|
|
752
|
+
persistentMenu={props.persistentMenu}
|
|
753
|
+
enableEmojiPicker={props.enableEmojiPicker}
|
|
754
|
+
enableAttachments={props.enableAttachments}
|
|
755
|
+
handleAttachment={handleAttachment}
|
|
756
|
+
textareaRef={textareaRef}
|
|
757
|
+
host={host}
|
|
758
|
+
onUserInput={props.onUserInput}
|
|
759
|
+
/>
|
|
760
|
+
)}
|
|
761
|
+
|
|
762
|
+
{webchatState.webview && webchatWebview()}
|
|
763
|
+
|
|
764
|
+
{webchatState.isCustomComponentRendered &&
|
|
765
|
+
customComponent &&
|
|
766
|
+
_renderCustomComponent()}
|
|
767
|
+
</>
|
|
767
768
|
)}
|
|
768
|
-
{webchatState.webview && webchatWebview()}
|
|
769
|
-
{webchatState.isCoverComponentOpen && coverComponent()}
|
|
770
|
-
{webchatState.isCustomComponentRendered &&
|
|
771
|
-
customComponent &&
|
|
772
|
-
_renderCustomComponent()}
|
|
773
769
|
</StyledWebchat>
|
|
774
770
|
)}
|
|
775
771
|
</WebchatContext.Provider>
|
|
776
772
|
)
|
|
773
|
+
|
|
777
774
|
return props.shadowDOM ? (
|
|
778
775
|
<StyleSheetManager target={host}>{WebchatComponent}</StyleSheetManager>
|
|
779
776
|
) : (
|