@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.
- package/lib/cjs/components/{button.d.ts → button/index.d.ts} +4 -5
- package/lib/cjs/components/{button.js → button/index.js} +26 -56
- package/lib/cjs/components/button/index.js.map +1 -0
- package/lib/cjs/components/button/styles.d.ts +2 -0
- package/lib/cjs/components/button/styles.js +40 -0
- package/lib/cjs/components/button/styles.js.map +1 -0
- package/lib/cjs/components/buttons-disabler.d.ts +20 -23
- package/lib/cjs/components/buttons-disabler.js +11 -26
- package/lib/cjs/components/buttons-disabler.js.map +1 -1
- package/lib/cjs/components/carousel.js +1 -1
- package/lib/cjs/components/carousel.js.map +1 -1
- package/lib/cjs/components/element.js +3 -3
- package/lib/cjs/components/element.js.map +1 -1
- package/lib/cjs/components/image.js +1 -1
- package/lib/cjs/components/image.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +1 -1
- package/lib/cjs/components/index.d.ts +1 -1
- package/lib/cjs/components/index.js +2 -2
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/message/index.js +7 -7
- package/lib/cjs/components/message/index.js.map +1 -1
- package/lib/cjs/components/message/message-image.js +1 -1
- package/lib/cjs/components/message/message-image.js.map +1 -1
- package/lib/cjs/components/message/styles.d.ts +11 -11
- package/lib/cjs/components/message/timestamps.js +1 -1
- package/lib/cjs/components/message/timestamps.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-button.js +4 -4
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js +2 -2
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-utils.js +2 -2
- package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/cjs/components/reply.js +3 -1
- package/lib/cjs/components/reply.js.map +1 -1
- package/lib/cjs/components/webchat-settings.d.ts +6 -3
- package/lib/cjs/components/webchat-settings.js.map +1 -1
- package/lib/cjs/constants.d.ts +0 -12
- package/lib/cjs/constants.js +0 -12
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/contexts.d.ts +1 -5
- package/lib/cjs/contexts.js +10 -5
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/dev-app.js +3 -11
- package/lib/cjs/dev-app.js.map +1 -1
- package/lib/cjs/index-types.d.ts +6 -28
- package/lib/cjs/index-types.js.map +1 -1
- package/lib/cjs/msg-to-botonic.js +2 -2
- package/lib/cjs/msg-to-botonic.js.map +1 -1
- package/lib/cjs/react-bot.d.ts +16 -6
- package/lib/cjs/react-bot.js +5 -6
- package/lib/cjs/react-bot.js.map +1 -1
- package/lib/cjs/shared/styles.d.ts +2 -2
- package/lib/cjs/time-zone-to-country-code.d.ts +1 -0
- package/lib/cjs/time-zone-to-country-code.js +108 -0
- package/lib/cjs/time-zone-to-country-code.js.map +1 -0
- package/lib/cjs/util/webchat.d.ts +11 -2
- package/lib/cjs/util/webchat.js +29 -1
- package/lib/cjs/util/webchat.js.map +1 -1
- package/lib/cjs/webchat/chat-area/styles.d.ts +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
- package/lib/cjs/webchat/components/opened-persistent-menu.js +4 -4
- package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/context/index.d.ts +1 -1
- package/lib/cjs/webchat/context/index.js +4 -7
- package/lib/cjs/webchat/context/index.js.map +1 -1
- package/lib/cjs/webchat/context/types.d.ts +16 -9
- package/lib/cjs/webchat/context/use-webchat.d.ts +3 -4
- package/lib/cjs/webchat/context/use-webchat.js +35 -43
- package/lib/cjs/webchat/context/use-webchat.js.map +1 -1
- package/lib/cjs/webchat/header/default-header.js +5 -5
- package/lib/cjs/webchat/header/default-header.js.map +1 -1
- package/lib/cjs/webchat/header/styles.d.ts +7 -7
- package/lib/cjs/webchat/header/styles.js +5 -1
- package/lib/cjs/webchat/header/styles.js.map +1 -1
- package/lib/cjs/webchat/index-types.d.ts +0 -11
- package/lib/cjs/webchat/input-panel/attachment.d.ts +1 -2
- package/lib/cjs/webchat/input-panel/attachment.js +6 -5
- package/lib/cjs/webchat/input-panel/attachment.js.map +1 -1
- package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -2
- package/lib/cjs/webchat/input-panel/emoji-picker.js +6 -5
- package/lib/cjs/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/cjs/webchat/input-panel/index.d.ts +1 -4
- package/lib/cjs/webchat/input-panel/index.js +2 -2
- package/lib/cjs/webchat/input-panel/index.js.map +1 -1
- package/lib/cjs/webchat/input-panel/persistent-menu.d.ts +1 -2
- package/lib/cjs/webchat/input-panel/persistent-menu.js +5 -4
- package/lib/cjs/webchat/input-panel/persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/input-panel/send-button.js +4 -3
- package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
- package/lib/cjs/webchat/input-panel/styles.d.ts +3 -3
- package/lib/cjs/webchat/input-panel/textarea.d.ts +1 -3
- package/lib/cjs/webchat/input-panel/textarea.js +7 -5
- package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
- package/lib/cjs/webchat/message-list/intro-message.js +1 -1
- package/lib/cjs/webchat/message-list/intro-message.js.map +1 -1
- package/lib/cjs/webchat/message-list/styles.d.ts +5 -5
- package/lib/cjs/webchat/message-list/use-notifications.js +4 -4
- package/lib/cjs/webchat/message-list/use-notifications.js.map +1 -1
- package/lib/cjs/webchat/replies/styles.d.ts +3 -3
- package/lib/cjs/webchat/styles.d.ts +4 -9
- package/lib/cjs/webchat/styles.js +18 -7
- package/lib/cjs/webchat/styles.js.map +1 -1
- package/lib/cjs/webchat/theme/default-theme.d.ts +2 -0
- package/lib/cjs/webchat/theme/default-theme.js +104 -0
- package/lib/cjs/webchat/theme/default-theme.js.map +1 -0
- package/lib/cjs/webchat/theme/types.d.ts +59 -12
- package/lib/cjs/webchat/trigger-button/index.js +3 -3
- package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
- package/lib/cjs/webchat/trigger-button/styles.d.ts +3 -3
- package/lib/cjs/webchat/typing-indicator/styles.d.ts +3 -3
- package/lib/cjs/webchat/webchat-dev.d.ts +1 -1
- package/lib/cjs/webchat/webchat.js +26 -34
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview/index.js +1 -14
- package/lib/cjs/webchat/webview/index.js.map +1 -1
- package/lib/cjs/webchat/webview/styles.d.ts +6 -6
- package/lib/cjs/webchat/webview/styles.js +16 -2
- package/lib/cjs/webchat/webview/styles.js.map +1 -1
- package/lib/cjs/webchat-app.d.ts +35 -2
- package/lib/cjs/webchat-app.js +45 -17
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/cjs/webview-app.js +0 -1
- package/lib/cjs/webview-app.js.map +1 -1
- package/lib/esm/components/{button.d.ts → button/index.d.ts} +4 -5
- package/lib/esm/components/{button.js → button/index.js} +26 -55
- package/lib/esm/components/button/index.js.map +1 -0
- package/lib/esm/components/button/styles.d.ts +2 -0
- package/lib/esm/components/button/styles.js +36 -0
- package/lib/esm/components/button/styles.js.map +1 -0
- package/lib/esm/components/buttons-disabler.d.ts +20 -23
- package/lib/esm/components/buttons-disabler.js +11 -26
- package/lib/esm/components/buttons-disabler.js.map +1 -1
- package/lib/esm/components/carousel.js +1 -1
- package/lib/esm/components/carousel.js.map +1 -1
- package/lib/esm/components/element.js +1 -1
- package/lib/esm/components/element.js.map +1 -1
- package/lib/esm/components/image.js +1 -1
- package/lib/esm/components/image.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +1 -1
- package/lib/esm/components/index.d.ts +1 -1
- package/lib/esm/components/index.js +1 -1
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/message/index.js +5 -5
- package/lib/esm/components/message/index.js.map +1 -1
- package/lib/esm/components/message/message-image.js +1 -1
- package/lib/esm/components/message/message-image.js.map +1 -1
- package/lib/esm/components/message/styles.d.ts +11 -11
- package/lib/esm/components/message/timestamps.js +1 -1
- package/lib/esm/components/message/timestamps.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-button.js +1 -1
- package/lib/esm/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-utils.js +1 -1
- package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/esm/components/reply.js +4 -2
- package/lib/esm/components/reply.js.map +1 -1
- package/lib/esm/components/webchat-settings.d.ts +6 -3
- package/lib/esm/components/webchat-settings.js.map +1 -1
- package/lib/esm/constants.d.ts +0 -12
- package/lib/esm/constants.js +0 -12
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/contexts.d.ts +1 -5
- package/lib/esm/contexts.js +10 -5
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/dev-app.js +3 -11
- package/lib/esm/dev-app.js.map +1 -1
- package/lib/esm/index-types.d.ts +6 -28
- package/lib/esm/index-types.js.map +1 -1
- package/lib/esm/msg-to-botonic.js +1 -1
- package/lib/esm/msg-to-botonic.js.map +1 -1
- package/lib/esm/react-bot.d.ts +16 -6
- package/lib/esm/react-bot.js +5 -6
- package/lib/esm/react-bot.js.map +1 -1
- package/lib/esm/shared/styles.d.ts +2 -2
- package/lib/esm/time-zone-to-country-code.d.ts +1 -0
- package/lib/esm/time-zone-to-country-code.js +105 -0
- package/lib/esm/time-zone-to-country-code.js.map +1 -0
- package/lib/esm/util/webchat.d.ts +11 -2
- package/lib/esm/util/webchat.js +27 -0
- package/lib/esm/util/webchat.js.map +1 -1
- package/lib/esm/webchat/chat-area/styles.d.ts +1 -1
- package/lib/esm/webchat/components/conditional-animation.js +1 -1
- package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
- package/lib/esm/webchat/components/opened-persistent-menu.js +2 -2
- package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/esm/webchat/context/index.d.ts +1 -1
- package/lib/esm/webchat/context/index.js +2 -4
- package/lib/esm/webchat/context/index.js.map +1 -1
- package/lib/esm/webchat/context/types.d.ts +16 -9
- package/lib/esm/webchat/context/use-webchat.d.ts +3 -4
- package/lib/esm/webchat/context/use-webchat.js +33 -41
- package/lib/esm/webchat/context/use-webchat.js.map +1 -1
- package/lib/esm/webchat/header/default-header.js +6 -6
- package/lib/esm/webchat/header/default-header.js.map +1 -1
- package/lib/esm/webchat/header/styles.d.ts +7 -7
- package/lib/esm/webchat/header/styles.js +6 -2
- package/lib/esm/webchat/header/styles.js.map +1 -1
- package/lib/esm/webchat/index-types.d.ts +0 -11
- package/lib/esm/webchat/input-panel/attachment.d.ts +1 -2
- package/lib/esm/webchat/input-panel/attachment.js +7 -6
- package/lib/esm/webchat/input-panel/attachment.js.map +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -2
- package/lib/esm/webchat/input-panel/emoji-picker.js +7 -6
- package/lib/esm/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/esm/webchat/input-panel/index.d.ts +1 -4
- package/lib/esm/webchat/input-panel/index.js +2 -2
- package/lib/esm/webchat/input-panel/index.js.map +1 -1
- package/lib/esm/webchat/input-panel/persistent-menu.d.ts +1 -2
- package/lib/esm/webchat/input-panel/persistent-menu.js +6 -5
- package/lib/esm/webchat/input-panel/persistent-menu.js.map +1 -1
- package/lib/esm/webchat/input-panel/send-button.js +5 -4
- package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
- package/lib/esm/webchat/input-panel/styles.d.ts +3 -3
- package/lib/esm/webchat/input-panel/textarea.d.ts +1 -3
- package/lib/esm/webchat/input-panel/textarea.js +7 -5
- package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
- package/lib/esm/webchat/message-list/intro-message.js +1 -1
- package/lib/esm/webchat/message-list/intro-message.js.map +1 -1
- package/lib/esm/webchat/message-list/styles.d.ts +5 -5
- package/lib/esm/webchat/message-list/use-notifications.js +4 -4
- package/lib/esm/webchat/message-list/use-notifications.js.map +1 -1
- package/lib/esm/webchat/replies/styles.d.ts +3 -3
- package/lib/esm/webchat/styles.d.ts +4 -9
- package/lib/esm/webchat/styles.js +19 -8
- package/lib/esm/webchat/styles.js.map +1 -1
- package/lib/esm/webchat/theme/default-theme.d.ts +2 -0
- package/lib/esm/webchat/theme/default-theme.js +101 -0
- package/lib/esm/webchat/theme/default-theme.js.map +1 -0
- package/lib/esm/webchat/theme/types.d.ts +59 -12
- package/lib/esm/webchat/trigger-button/index.js +3 -3
- package/lib/esm/webchat/trigger-button/index.js.map +1 -1
- package/lib/esm/webchat/trigger-button/styles.d.ts +3 -3
- package/lib/esm/webchat/typing-indicator/styles.d.ts +3 -3
- package/lib/esm/webchat/webchat-dev.d.ts +1 -1
- package/lib/esm/webchat/webchat.js +29 -37
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview/index.js +1 -14
- package/lib/esm/webchat/webview/index.js.map +1 -1
- package/lib/esm/webchat/webview/styles.d.ts +6 -6
- package/lib/esm/webchat/webview/styles.js +17 -3
- package/lib/esm/webchat/webview/styles.js.map +1 -1
- package/lib/esm/webchat-app.d.ts +35 -2
- package/lib/esm/webchat-app.js +45 -17
- package/lib/esm/webchat-app.js.map +1 -1
- package/lib/esm/webview-app.js +1 -2
- package/lib/esm/webview-app.js.map +1 -1
- package/package.json +4 -2
- package/src/components/{button.tsx → button/index.tsx} +26 -102
- package/src/components/button/styles.ts +38 -0
- package/src/components/{buttons-disabler.js → buttons-disabler.ts} +35 -39
- package/src/components/carousel.tsx +1 -2
- package/src/components/element.tsx +1 -1
- package/src/components/image.tsx +3 -2
- package/src/components/index-types.ts +1 -1
- package/src/components/index.ts +1 -1
- package/src/components/message/index.jsx +5 -9
- package/src/components/message/message-image.tsx +1 -4
- package/src/components/message/timestamps.tsx +1 -2
- package/src/components/multichannel/multichannel-button.jsx +1 -1
- package/src/components/multichannel/multichannel-carousel.jsx +1 -1
- package/src/components/multichannel/multichannel-utils.js +1 -1
- package/src/components/reply.tsx +2 -8
- package/src/components/webchat-settings.tsx +11 -3
- package/src/constants.js +0 -12
- package/src/contexts.tsx +11 -12
- package/src/dev-app.jsx +1 -25
- package/src/index-types.ts +8 -26
- package/src/msg-to-botonic.jsx +1 -1
- package/src/react-bot.tsx +51 -0
- package/src/time-zone-to-country-code.ts +104 -0
- package/src/util/webchat.ts +38 -2
- package/src/webchat/components/conditional-animation.jsx +2 -2
- package/src/webchat/components/opened-persistent-menu.jsx +2 -3
- package/src/webchat/context/index.tsx +3 -5
- package/src/webchat/context/types.ts +18 -13
- package/src/webchat/context/use-webchat.ts +36 -43
- package/src/webchat/header/default-header.tsx +6 -17
- package/src/webchat/header/styles.ts +6 -2
- package/src/webchat/index-types.ts +0 -12
- package/src/webchat/input-panel/attachment.tsx +5 -16
- package/src/webchat/input-panel/emoji-picker.tsx +5 -15
- package/src/webchat/input-panel/index.tsx +2 -13
- package/src/webchat/input-panel/persistent-menu.tsx +5 -15
- package/src/webchat/input-panel/send-button.tsx +3 -9
- package/src/webchat/input-panel/textarea.tsx +8 -14
- package/src/webchat/message-list/intro-message.tsx +1 -2
- package/src/webchat/message-list/use-notifications.ts +4 -8
- package/src/webchat/styles.ts +20 -14
- package/src/webchat/theme/default-theme.ts +102 -0
- package/src/webchat/theme/theme.d.ts +8 -0
- package/src/webchat/theme/types.ts +111 -24
- package/src/webchat/trigger-button/index.tsx +3 -5
- package/src/webchat/webchat.tsx +79 -102
- package/src/webchat/webview/index.tsx +0 -14
- package/src/webchat/webview/styles.ts +16 -2
- package/src/webchat-app.tsx +88 -35
- package/src/webview-app.tsx +1 -3
- package/lib/cjs/components/button.js.map +0 -1
- package/lib/esm/components/button.js.map +0 -1
- 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 {
|
|
14
|
+
const { webchatState } = useContext(WebchatContext)
|
|
15
15
|
|
|
16
|
-
const sendButtonEnabled =
|
|
17
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableSendButton,
|
|
18
|
-
true
|
|
19
|
-
)
|
|
16
|
+
const sendButtonEnabled = webchatState.theme.userInput?.sendButton?.enable
|
|
20
17
|
|
|
21
|
-
const CustomSendButton =
|
|
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 {
|
|
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 =
|
|
35
|
-
|
|
36
|
-
|
|
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={
|
|
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
|
-
...
|
|
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(
|
package/src/webchat/styles.ts
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import styled from 'styled-components'
|
|
2
2
|
|
|
3
|
-
import { COLORS
|
|
3
|
+
import { COLORS } from '../constants'
|
|
4
4
|
|
|
5
|
-
|
|
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:
|
|
13
|
-
bottom:
|
|
14
|
-
width: ${props => props.width}
|
|
15
|
-
height: ${props => props.height}
|
|
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: ${
|
|
12
|
+
background-color: ${props => props.theme.style.backgroundColor};
|
|
18
13
|
border-radius: 10px;
|
|
19
|
-
box-shadow: ${
|
|
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: ${
|
|
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
|
|
42
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
87
|
+
webview?: {
|
|
88
|
+
style?: any
|
|
89
|
+
header?: {
|
|
90
|
+
style?: any
|
|
91
|
+
}
|
|
92
|
+
}
|
|
47
93
|
animations?: { enable?: boolean }
|
|
48
|
-
intro?: {
|
|
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?:
|
|
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
|
|
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?:
|
|
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' | '
|
|
79
|
-
urlIcon?: {
|
|
80
|
-
|
|
81
|
-
|
|
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?: {
|
|
95
|
-
|
|
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?: {
|
|
166
|
+
banner?: {
|
|
167
|
+
custom?: React.ComponentType
|
|
168
|
+
enable?: boolean
|
|
169
|
+
text?: string
|
|
170
|
+
}
|
|
99
171
|
triggerButton?: { enable?: boolean }
|
|
100
172
|
}
|
|
101
|
-
scrollButton?: {
|
|
173
|
+
scrollButton?: {
|
|
174
|
+
enable?: boolean
|
|
175
|
+
custom?: React.ComponentType
|
|
176
|
+
}
|
|
102
177
|
markdownStyle?: string // string template with css styles
|
|
103
178
|
userInput?: {
|
|
104
|
-
attachments?: {
|
|
179
|
+
attachments?: {
|
|
180
|
+
enable?: boolean
|
|
181
|
+
custom?: React.ComponentType
|
|
182
|
+
}
|
|
105
183
|
blockInputs?: BlockInputOption[]
|
|
106
|
-
box?: {
|
|
107
|
-
|
|
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?: {
|
|
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.
|
|
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) => {
|