@botonic/react 0.22.0-alpha.1 → 0.22.0-alpha.3
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/botonic-tester.js +8 -10
- package/lib/cjs/botonic-tester.js.map +1 -1
- package/lib/cjs/components/audio.js +3 -7
- package/lib/cjs/components/audio.js.map +1 -1
- package/lib/cjs/components/button.js +7 -18
- package/lib/cjs/components/button.js.map +1 -1
- package/lib/cjs/components/carousel.d.ts +1 -1
- package/lib/cjs/components/carousel.js +6 -19
- package/lib/cjs/components/carousel.js.map +1 -1
- package/lib/cjs/components/custom-message.d.ts +3 -34
- package/lib/cjs/components/custom-message.js +4 -10
- package/lib/cjs/components/custom-message.js.map +1 -1
- package/lib/cjs/components/document.js +3 -6
- package/lib/cjs/components/document.js.map +1 -1
- package/lib/cjs/components/element.js +3 -2
- package/lib/cjs/components/element.js.map +1 -1
- package/lib/cjs/components/handoff.js +3 -7
- package/lib/cjs/components/handoff.js.map +1 -1
- package/lib/cjs/components/image.js +3 -7
- package/lib/cjs/components/image.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +174 -0
- package/lib/cjs/components/index-types.js +17 -0
- package/lib/cjs/components/index-types.js.map +1 -0
- package/lib/cjs/components/index.d.ts +23 -20
- package/lib/cjs/components/index.js +6 -1
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/location.js +3 -9
- package/lib/cjs/components/location.js.map +1 -1
- package/lib/cjs/components/message-template.js +2 -3
- package/lib/cjs/components/message-template.js.map +1 -1
- package/lib/cjs/components/message.js +7 -25
- package/lib/cjs/components/message.js.map +1 -1
- package/lib/cjs/components/multichannel/index-types.d.ts +45 -0
- package/lib/cjs/components/multichannel/index-types.js +3 -0
- package/lib/cjs/components/multichannel/index-types.js.map +1 -0
- package/lib/cjs/components/multichannel/index.d.ts +11 -6
- package/lib/cjs/components/multichannel/index.js +2 -0
- package/lib/cjs/components/multichannel/index.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-button.js +4 -5
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js +3 -20
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-context.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-reply.js +2 -1
- package/lib/cjs/components/multichannel/multichannel-reply.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.js +9 -24
- package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel.js +16 -28
- package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
- package/lib/cjs/components/pic.js +3 -2
- package/lib/cjs/components/pic.js.map +1 -1
- package/lib/cjs/components/raw.js +3 -12
- package/lib/cjs/components/raw.js.map +1 -1
- package/lib/cjs/components/reply.js +5 -8
- package/lib/cjs/components/reply.js.map +1 -1
- package/lib/cjs/components/share-button.js +2 -3
- package/lib/cjs/components/share-button.js.map +1 -1
- package/lib/cjs/components/subtitle.js +3 -4
- package/lib/cjs/components/subtitle.js.map +1 -1
- package/lib/cjs/components/text.js +3 -6
- package/lib/cjs/components/text.js.map +1 -1
- package/lib/cjs/components/timestamps.js +2 -5
- package/lib/cjs/components/timestamps.js.map +1 -1
- package/lib/cjs/components/title.js +3 -2
- package/lib/cjs/components/title.js.map +1 -1
- package/lib/cjs/components/video.js +3 -6
- package/lib/cjs/components/video.js.map +1 -1
- package/lib/cjs/components/webchat-settings.js +2 -1
- package/lib/cjs/components/webchat-settings.js.map +1 -1
- package/lib/cjs/components/whatsapp-button-list.d.ts +24 -0
- package/lib/cjs/components/whatsapp-button-list.js +26 -0
- package/lib/cjs/components/whatsapp-button-list.js.map +1 -0
- package/lib/cjs/components/whatsapp-template.js +3 -4
- package/lib/cjs/components/whatsapp-template.js.map +1 -1
- package/lib/cjs/contexts.d.ts +2 -3
- package/lib/cjs/contexts.js +3 -4
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/dev-app.d.ts +2 -2
- package/lib/cjs/dev-app.js +2 -1
- package/lib/cjs/dev-app.js.map +1 -1
- package/lib/cjs/index-types.d.ts +94 -0
- package/lib/cjs/index-types.js +12 -0
- package/lib/cjs/index-types.js.map +1 -0
- package/lib/cjs/index.d.ts +9 -10
- package/lib/cjs/index.js +5 -7
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/message-utils.d.ts +1 -1
- package/lib/cjs/message-utils.js +16 -16
- package/lib/cjs/message-utils.js.map +1 -1
- package/lib/cjs/msg-to-botonic.d.ts +1 -1
- package/lib/cjs/msg-to-botonic.js +24 -46
- package/lib/cjs/msg-to-botonic.js.map +1 -1
- package/lib/cjs/node-app.d.ts +2 -2
- package/lib/cjs/react-bot.d.ts +1 -1
- package/lib/cjs/react-bot.js +5 -6
- package/lib/cjs/react-bot.js.map +1 -1
- package/lib/cjs/util/error-boundary.d.ts +6 -39
- package/lib/cjs/util/error-boundary.js +17 -30
- package/lib/cjs/util/error-boundary.js.map +1 -1
- package/lib/cjs/util/index.d.ts +8 -0
- package/lib/cjs/util/index.js +10 -0
- package/lib/cjs/util/index.js.map +1 -1
- package/lib/cjs/util/webchat.d.ts +1 -1
- package/lib/cjs/webchat/components/attachment.js +7 -10
- package/lib/cjs/webchat/components/attachment.js.map +1 -1
- package/lib/cjs/webchat/components/common.js +2 -1
- package/lib/cjs/webchat/components/common.js.map +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js +2 -3
- package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
- package/lib/cjs/webchat/components/emoji-picker.js +3 -12
- package/lib/cjs/webchat/components/emoji-picker.js.map +1 -1
- package/lib/cjs/webchat/components/persistent-menu.js +5 -19
- package/lib/cjs/webchat/components/persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/components/send-button.js +2 -7
- package/lib/cjs/webchat/components/send-button.js.map +1 -1
- package/lib/cjs/webchat/components/typing-indicator.js +2 -5
- package/lib/cjs/webchat/components/typing-indicator.js.map +1 -1
- package/lib/cjs/webchat/devices/device-adapter.d.ts +2 -2
- package/lib/cjs/webchat/header.js +4 -14
- package/lib/cjs/webchat/header.js.map +1 -1
- package/lib/cjs/webchat/hooks.js +2 -1
- package/lib/cjs/webchat/hooks.js.map +1 -1
- package/lib/cjs/webchat/index-types.d.ts +55 -0
- package/lib/cjs/webchat/index-types.js +3 -0
- package/lib/cjs/webchat/index-types.js.map +1 -0
- package/lib/cjs/webchat/index.d.ts +4 -6
- package/lib/cjs/webchat/index.js +3 -3
- package/lib/cjs/webchat/index.js.map +1 -1
- package/lib/cjs/webchat/message-list.js +5 -12
- package/lib/cjs/webchat/message-list.js.map +1 -1
- package/lib/cjs/webchat/replies.js +2 -5
- package/lib/cjs/webchat/replies.js.map +1 -1
- package/lib/cjs/webchat/session-view.js +7 -30
- package/lib/cjs/webchat/session-view.js.map +1 -1
- package/lib/cjs/webchat/use-storage-state-hook.js +12 -2
- package/lib/cjs/webchat/use-storage-state-hook.js.map +1 -1
- package/lib/cjs/webchat/webchat-dev.d.ts +1 -1
- package/lib/cjs/webchat/webchat-dev.js +6 -10
- package/lib/cjs/webchat/webchat-dev.js.map +1 -1
- package/lib/cjs/webchat/webchat.d.ts +1 -1
- package/lib/cjs/webchat/webchat.js +43 -86
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview.js +5 -13
- package/lib/cjs/webchat/webview.js.map +1 -1
- package/lib/cjs/webchat-app.d.ts +2 -2
- package/lib/cjs/webchat-app.js +6 -4
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/cjs/webview-app.js +12 -13
- package/lib/cjs/webview-app.js.map +1 -1
- package/lib/esm/botonic-tester.js +5 -7
- package/lib/esm/botonic-tester.js.map +1 -1
- package/lib/esm/components/audio.js +3 -7
- package/lib/esm/components/audio.js.map +1 -1
- package/lib/esm/components/button.js +7 -18
- package/lib/esm/components/button.js.map +1 -1
- package/lib/esm/components/carousel.d.ts +2 -1
- package/lib/esm/components/carousel.js +6 -19
- package/lib/esm/components/carousel.js.map +1 -1
- package/lib/esm/components/custom-message.d.ts +3 -34
- package/lib/esm/components/custom-message.js +4 -10
- package/lib/esm/components/custom-message.js.map +1 -1
- package/lib/esm/components/document.js +3 -6
- package/lib/esm/components/document.js.map +1 -1
- package/lib/esm/components/element.js +3 -2
- package/lib/esm/components/element.js.map +1 -1
- package/lib/esm/components/handoff.js +3 -7
- package/lib/esm/components/handoff.js.map +1 -1
- package/lib/esm/components/image.js +3 -7
- package/lib/esm/components/image.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +174 -0
- package/lib/esm/components/index-types.js +16 -0
- package/lib/esm/components/index-types.js.map +1 -0
- package/lib/esm/components/index.d.ts +23 -19
- package/lib/esm/components/index.js +3 -0
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/location.js +3 -9
- package/lib/esm/components/location.js.map +1 -1
- package/lib/esm/components/message-template.js +2 -3
- package/lib/esm/components/message-template.js.map +1 -1
- package/lib/esm/components/message.js +7 -25
- package/lib/esm/components/message.js.map +1 -1
- package/lib/esm/components/multichannel/index-types.d.ts +45 -0
- package/lib/esm/components/multichannel/index-types.js +2 -0
- package/lib/esm/components/multichannel/index-types.js.map +1 -0
- package/lib/esm/components/multichannel/index.d.ts +11 -6
- package/lib/esm/components/multichannel/index.js +1 -0
- package/lib/esm/components/multichannel/index.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-button.js +4 -5
- package/lib/esm/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js +3 -20
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-context.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-reply.js +2 -1
- package/lib/esm/components/multichannel/multichannel-reply.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-text.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-text.js +9 -24
- package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel.js +11 -23
- package/lib/esm/components/multichannel/multichannel.js.map +1 -1
- package/lib/esm/components/pic.js +3 -2
- package/lib/esm/components/pic.js.map +1 -1
- package/lib/esm/components/raw.js +3 -12
- package/lib/esm/components/raw.js.map +1 -1
- package/lib/esm/components/reply.js +5 -8
- package/lib/esm/components/reply.js.map +1 -1
- package/lib/esm/components/share-button.js +2 -3
- package/lib/esm/components/share-button.js.map +1 -1
- package/lib/esm/components/subtitle.js +3 -4
- package/lib/esm/components/subtitle.js.map +1 -1
- package/lib/esm/components/text.js +3 -6
- package/lib/esm/components/text.js.map +1 -1
- package/lib/esm/components/timestamps.js +2 -5
- package/lib/esm/components/timestamps.js.map +1 -1
- package/lib/esm/components/title.js +3 -2
- package/lib/esm/components/title.js.map +1 -1
- package/lib/esm/components/video.js +3 -6
- package/lib/esm/components/video.js.map +1 -1
- package/lib/esm/components/webchat-settings.js +2 -1
- package/lib/esm/components/webchat-settings.js.map +1 -1
- package/lib/esm/components/whatsapp-button-list.d.ts +24 -0
- package/lib/esm/components/whatsapp-button-list.js +22 -0
- package/lib/esm/components/whatsapp-button-list.js.map +1 -0
- package/lib/esm/components/whatsapp-template.js +3 -4
- package/lib/esm/components/whatsapp-template.js.map +1 -1
- package/lib/esm/contexts.d.ts +2 -3
- package/lib/esm/contexts.js +3 -3
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/dev-app.d.ts +2 -2
- package/lib/esm/dev-app.js +2 -1
- package/lib/esm/dev-app.js.map +1 -1
- package/lib/esm/index-types.d.ts +94 -0
- package/lib/esm/index-types.js +9 -0
- package/lib/esm/index-types.js.map +1 -0
- package/lib/esm/index.d.ts +9 -9
- package/lib/esm/index.js +4 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/message-utils.d.ts +2 -1
- package/lib/esm/message-utils.js +1 -1
- package/lib/esm/message-utils.js.map +1 -1
- package/lib/esm/msg-to-botonic.d.ts +1 -1
- package/lib/esm/msg-to-botonic.js +23 -45
- package/lib/esm/msg-to-botonic.js.map +1 -1
- package/lib/esm/node-app.d.ts +4 -4
- package/lib/esm/react-bot.d.ts +2 -1
- package/lib/esm/react-bot.js +4 -5
- package/lib/esm/react-bot.js.map +1 -1
- package/lib/esm/util/error-boundary.d.ts +6 -39
- package/lib/esm/util/error-boundary.js +17 -30
- package/lib/esm/util/error-boundary.js.map +1 -1
- package/lib/esm/util/index.d.ts +8 -0
- package/lib/esm/util/index.js +8 -1
- package/lib/esm/util/index.js.map +1 -1
- package/lib/esm/util/webchat.d.ts +1 -1
- package/lib/esm/webchat/components/attachment.js +8 -11
- package/lib/esm/webchat/components/attachment.js.map +1 -1
- package/lib/esm/webchat/components/common.js +2 -1
- package/lib/esm/webchat/components/common.js.map +1 -1
- package/lib/esm/webchat/components/conditional-animation.js +2 -3
- package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
- package/lib/esm/webchat/components/emoji-picker.js +3 -12
- package/lib/esm/webchat/components/emoji-picker.js.map +1 -1
- package/lib/esm/webchat/components/persistent-menu.js +5 -19
- package/lib/esm/webchat/components/persistent-menu.js.map +1 -1
- package/lib/esm/webchat/components/send-button.js +2 -7
- package/lib/esm/webchat/components/send-button.js.map +1 -1
- package/lib/esm/webchat/components/typing-indicator.js +2 -5
- package/lib/esm/webchat/components/typing-indicator.js.map +1 -1
- package/lib/esm/webchat/devices/device-adapter.d.ts +2 -2
- package/lib/esm/webchat/header.js +4 -14
- package/lib/esm/webchat/header.js.map +1 -1
- package/lib/esm/webchat/hooks.js +2 -1
- package/lib/esm/webchat/hooks.js.map +1 -1
- package/lib/esm/webchat/index-types.d.ts +55 -0
- package/lib/esm/webchat/index-types.js +2 -0
- package/lib/esm/webchat/index-types.js.map +1 -0
- package/lib/esm/webchat/index.d.ts +4 -6
- package/lib/esm/webchat/index.js +2 -3
- package/lib/esm/webchat/index.js.map +1 -1
- package/lib/esm/webchat/message-list.js +5 -12
- package/lib/esm/webchat/message-list.js.map +1 -1
- package/lib/esm/webchat/replies.js +2 -5
- package/lib/esm/webchat/replies.js.map +1 -1
- package/lib/esm/webchat/session-view.js +7 -30
- package/lib/esm/webchat/session-view.js.map +1 -1
- package/lib/esm/webchat/use-storage-state-hook.js +12 -2
- package/lib/esm/webchat/use-storage-state-hook.js.map +1 -1
- package/lib/esm/webchat/webchat-dev.d.ts +1 -1
- package/lib/esm/webchat/webchat-dev.js +6 -10
- package/lib/esm/webchat/webchat-dev.js.map +1 -1
- package/lib/esm/webchat/webchat.d.ts +1 -1
- package/lib/esm/webchat/webchat.js +43 -86
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview.js +5 -13
- package/lib/esm/webchat/webview.js.map +1 -1
- package/lib/esm/webchat-app.d.ts +5 -4
- package/lib/esm/webchat-app.js +4 -2
- package/lib/esm/webchat-app.js.map +1 -1
- package/lib/esm/webview-app.js +5 -6
- package/lib/esm/webview-app.js.map +1 -1
- package/package.json +22 -16
- package/src/botonic-tester.jsx +1 -1
- package/src/components/{index.d.ts → index-types.ts} +22 -43
- package/src/components/{index.js → index.ts} +6 -0
- package/src/components/multichannel/{index.d.ts → index-types.ts} +1 -10
- package/src/components/multichannel/{index.js → index.ts} +2 -0
- package/src/components/whatsapp-button-list.tsx +64 -0
- package/src/contexts.jsx +3 -3
- package/src/index-types.ts +195 -0
- package/src/{index.js → index.ts} +4 -3
- package/src/message-utils.js +1 -1
- package/src/msg-to-botonic.jsx +11 -11
- package/src/react-bot.jsx +1 -1
- package/src/util/error-boundary.jsx +15 -30
- package/src/util/index.ts +8 -0
- package/src/webchat/components/attachment.jsx +10 -2
- package/src/webchat/components/emoji-picker.jsx +7 -1
- package/src/webchat/hooks.js +2 -1
- package/src/webchat/{index.d.ts → index-types.ts} +11 -13
- package/src/webchat/{index.js → index.ts} +3 -3
- package/src/webchat/use-storage-state-hook.js +13 -2
- package/src/webchat/webchat.jsx +5 -7
- package/src/webchat-app.jsx +2 -1
- package/src/webview-app.tsx +1 -1
- package/src/index.d.ts +0 -238
- package/src/util/index.d.ts +0 -9
- package/src/util/index.js +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BotRequest as CoreBotRequest,
|
|
3
|
+
Input as CoreInput,
|
|
4
|
+
InputType as CoreInputType,
|
|
5
|
+
Plugin as CorePlugin,
|
|
6
|
+
Route as CoreRoute,
|
|
7
|
+
Routes as CoreRoutes,
|
|
8
|
+
Session as CoreSession,
|
|
9
|
+
SessionUser as CoreSessionUser,
|
|
10
|
+
} from '@botonic/core/lib/esm/models/legacy-types'
|
|
11
|
+
import React from 'react'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
ButtonProps,
|
|
15
|
+
ReplyProps,
|
|
16
|
+
ThemeProps,
|
|
17
|
+
WebchatSettingsProps,
|
|
18
|
+
Webview,
|
|
19
|
+
} from './components/index-types'
|
|
20
|
+
import { WebchatState } from './webchat'
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* See @botonic/core's Response for the description of the Response's semantics*/
|
|
24
|
+
export interface BotResponse extends CoreBotRequest {
|
|
25
|
+
response: [React.ReactNode]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Route extends CoreRoute {
|
|
29
|
+
action?: React.ComponentType<any>
|
|
30
|
+
retryAction?: React.ComponentType<any>
|
|
31
|
+
}
|
|
32
|
+
export type Routes = CoreRoutes<Route>
|
|
33
|
+
|
|
34
|
+
// Parameters of the actions' botonicInit method
|
|
35
|
+
export interface ActionRequest {
|
|
36
|
+
defaultDelay: number
|
|
37
|
+
defaultTyping: number
|
|
38
|
+
input: CoreInput
|
|
39
|
+
lastRoutePath: string
|
|
40
|
+
params: { [key: string]: string }
|
|
41
|
+
plugins: { [id: string]: CorePlugin }
|
|
42
|
+
session: CoreSession
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface RequestContextInterface extends ActionRequest {
|
|
46
|
+
getString: (stringId: string) => string
|
|
47
|
+
setLocale: (locale: string) => string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface CustomMessageType {
|
|
51
|
+
customTypeName: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// TODO: Reuse types to be reused in respective components
|
|
55
|
+
// export class WebchatApp {
|
|
56
|
+
// constructor(options: WebchatAppArgs)
|
|
57
|
+
// addBotMessage(message: WebchatMessage): void
|
|
58
|
+
// addBotText(text: string): void
|
|
59
|
+
// addUserMessage(message: WebchatMessage): void
|
|
60
|
+
// addUserPayload(payload: string): void
|
|
61
|
+
// addUserText(text: string): void
|
|
62
|
+
// clearMessages(): void
|
|
63
|
+
// close(): void
|
|
64
|
+
// closeCoverComponent(): void
|
|
65
|
+
// destroy(): void
|
|
66
|
+
// getComponent(
|
|
67
|
+
// host: HTMLElement,
|
|
68
|
+
// optionsAtRuntime?: WebchatAppArgs
|
|
69
|
+
// ): React.ForwardRefExoticComponent<any>
|
|
70
|
+
// getLastMessageUpdate(): string
|
|
71
|
+
// getMessages(): WebchatMessage[]
|
|
72
|
+
// getVisibility(): Promise<boolean>
|
|
73
|
+
// isWebchatVisible({ appId: string }): Promise<boolean>
|
|
74
|
+
// onCloseWebchat(args: any): void
|
|
75
|
+
// onInitWebchat(args: any): void
|
|
76
|
+
// onOpenWebchat(args: any): void
|
|
77
|
+
// onServiceEvent(event: Event): void
|
|
78
|
+
// onStateChange(args: OnStateChangeArgs): void
|
|
79
|
+
// onUserInput(args: OnUserInputArgs): Promise<void>
|
|
80
|
+
// open(): void
|
|
81
|
+
// openCoverComponent(): void
|
|
82
|
+
// render(dest?: HTMLElement, optionsAtRuntime?: WebchatAppArgs): void
|
|
83
|
+
// resendUnsentInputs(): Promise<void>
|
|
84
|
+
// resolveWebchatVisibility(optionsAtRuntime: {
|
|
85
|
+
// appId: string
|
|
86
|
+
// visibility: () => boolean
|
|
87
|
+
// }): Promise<boolean>
|
|
88
|
+
// setTyping(enable: boolean): void
|
|
89
|
+
// toggle(): void
|
|
90
|
+
// toggleCoverComponent(): void
|
|
91
|
+
// updateMessageInfo(msgId: string, messageInfo: MessageInfo): void
|
|
92
|
+
// updateLastMessageDate(date: string): void
|
|
93
|
+
// updateUser(user: Partial<CoreSessionUser>): void
|
|
94
|
+
// updateWebchatSettings(settings: WebchatSettingsProps): void
|
|
95
|
+
// renderCustomComponent(customComponent: React.ReactNode): void
|
|
96
|
+
// unmountCustomComponent(): void
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
// export interface WebchatArgs {
|
|
100
|
+
// blockInputs?: BlockInputOption[]
|
|
101
|
+
// coverComponent?: CoverComponentOptions
|
|
102
|
+
// defaultDelay?: number
|
|
103
|
+
// defaultTyping?: number
|
|
104
|
+
// enableAnimations?: boolean
|
|
105
|
+
// enableAttachments?: boolean
|
|
106
|
+
// enableEmojiPicker?: boolean
|
|
107
|
+
// enableUserInput?: boolean
|
|
108
|
+
// shadowDOM?: boolean | (() => boolean)
|
|
109
|
+
// hostId?: string
|
|
110
|
+
// getString?: (stringId: string, session: CoreSession) => string
|
|
111
|
+
// onClose?: (app: WebchatApp, args: any) => void
|
|
112
|
+
// onInit?: (app: WebchatApp, args: any) => void
|
|
113
|
+
// onMessage?: (app: WebchatApp, message: WebchatMessage) => void
|
|
114
|
+
// onOpen?: (app: WebchatApp, args: any) => void
|
|
115
|
+
// onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void
|
|
116
|
+
// persistentMenu?: PersistentMenuTheme
|
|
117
|
+
// storage?: Storage | null
|
|
118
|
+
// storageKey?: any
|
|
119
|
+
// theme?: ThemeProps
|
|
120
|
+
// }
|
|
121
|
+
|
|
122
|
+
// export interface WebchatAppArgs extends WebchatArgs {
|
|
123
|
+
export interface WebchatAppArgs {
|
|
124
|
+
appId?: string
|
|
125
|
+
visibility?: () => boolean
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface WebchatMessage {
|
|
129
|
+
ack: 0 | 1
|
|
130
|
+
buttons: ButtonProps[]
|
|
131
|
+
data: any
|
|
132
|
+
delay: number
|
|
133
|
+
display: boolean
|
|
134
|
+
from: 'user' | 'bot'
|
|
135
|
+
id: string
|
|
136
|
+
markdown: boolean
|
|
137
|
+
replies: ReplyProps[]
|
|
138
|
+
timestamp: string
|
|
139
|
+
type: CoreInputType
|
|
140
|
+
typing: number
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface OnUserInputArgs {
|
|
144
|
+
input: CoreInput
|
|
145
|
+
lastRoutePath?: string
|
|
146
|
+
session?: CoreSession
|
|
147
|
+
user: CoreSessionUser
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface OnStateChangeArgs {
|
|
151
|
+
messagesJSON: WebchatMessage[]
|
|
152
|
+
user: CoreSessionUser
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface MessageInfo {
|
|
156
|
+
data: any | 'typing_on'
|
|
157
|
+
id: string
|
|
158
|
+
type: 'update_webchat_settings' | 'sender_action'
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface Event {
|
|
162
|
+
action?: 'update_message_info'
|
|
163
|
+
isError?: boolean
|
|
164
|
+
message?: MessageInfo
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface WebchatContextProps {
|
|
168
|
+
sendText: (text: string, payload?: string) => void
|
|
169
|
+
sendAttachment: (attachment: File) => void
|
|
170
|
+
sendPayload: (payload: string) => void
|
|
171
|
+
sendInput: (input: CoreInput) => void
|
|
172
|
+
openWebview: (webviewComponent: Webview) => void
|
|
173
|
+
addMessage: (message: WebchatMessage) => void
|
|
174
|
+
updateMessage: (message: WebchatMessage) => void
|
|
175
|
+
updateReplies: (replies: boolean) => void
|
|
176
|
+
updateLatestInput: (input: CoreInput) => void
|
|
177
|
+
closeWebview: () => void
|
|
178
|
+
toggleWebchat: () => void
|
|
179
|
+
getThemeProperty: (property: string, defaultValue?: string) => any
|
|
180
|
+
resolveCase: () => void
|
|
181
|
+
theme: ThemeProps
|
|
182
|
+
webchatState: WebchatState
|
|
183
|
+
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
184
|
+
updateUser: (user: Partial<CoreSessionUser>) => void
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// export class DevApp extends WebchatApp {
|
|
188
|
+
// constructor(args: WebchatAppArgs)
|
|
189
|
+
// onUserInput(args: OnUserInputArgs): Promise<void>
|
|
190
|
+
// render(dest: HTMLElement, optionsAtRuntime: WebchatAppArgs): void
|
|
191
|
+
// }
|
|
192
|
+
|
|
193
|
+
export * from './components'
|
|
194
|
+
export * from './util'
|
|
195
|
+
export * from './webchat'
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { BotonicInputTester, BotonicOutputTester } from './botonic-tester'
|
|
2
|
-
export * from './components'
|
|
2
|
+
// export * from './components'
|
|
3
3
|
export { RequestContext, WebchatContext } from './contexts'
|
|
4
4
|
export { DevApp } from './dev-app'
|
|
5
|
+
export * from './index-types'
|
|
5
6
|
export { msgsToBotonic, msgToBotonic } from './msg-to-botonic'
|
|
6
7
|
export { NodeApp } from './node-app'
|
|
7
|
-
export
|
|
8
|
-
export { getBotonicApp, Webchat } from './webchat/index
|
|
8
|
+
export * from './util'
|
|
9
|
+
// export { getBotonicApp, Webchat } from './webchat/index'
|
|
9
10
|
export { WebchatApp } from './webchat-app'
|
|
10
11
|
export { WebviewApp } from './webview-app'
|
package/src/message-utils.js
CHANGED
package/src/msg-to-botonic.jsx
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
isAudio,
|
|
5
|
-
isButtonMessage,
|
|
6
|
-
isCarousel,
|
|
7
|
-
isCustom,
|
|
8
|
-
isDocument,
|
|
9
|
-
isImage,
|
|
10
|
-
isLocation,
|
|
11
|
-
isText,
|
|
12
|
-
isVideo,
|
|
13
|
-
} from './message-utils'
|
|
14
3
|
import { Audio } from './components/audio'
|
|
15
4
|
import { Button } from './components/button'
|
|
16
5
|
import { ButtonsDisabler } from './components/buttons-disabler'
|
|
@@ -25,6 +14,17 @@ import { Subtitle } from './components/subtitle'
|
|
|
25
14
|
import { Text } from './components/text'
|
|
26
15
|
import { Title } from './components/title'
|
|
27
16
|
import { Video } from './components/video'
|
|
17
|
+
import {
|
|
18
|
+
isAudio,
|
|
19
|
+
isButtonMessage,
|
|
20
|
+
isCarousel,
|
|
21
|
+
isCustom,
|
|
22
|
+
isDocument,
|
|
23
|
+
isImage,
|
|
24
|
+
isLocation,
|
|
25
|
+
isText,
|
|
26
|
+
isVideo,
|
|
27
|
+
} from './message-utils'
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
*
|
package/src/react-bot.jsx
CHANGED
|
@@ -1,48 +1,33 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import { isNode } from '@botonic/core'
|
|
2
|
-
import React from 'react'
|
|
3
|
+
import React, { useState } from 'react'
|
|
3
4
|
|
|
4
5
|
import { Text } from '../components/text'
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
* Replaces crashed children with the provided fallback component.
|
|
8
|
-
* https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html
|
|
9
|
-
* See alternative at https://stackoverflow.com/a/60255291/145289
|
|
10
|
-
*/
|
|
11
7
|
export const createErrorBoundary = ({
|
|
12
|
-
errorComponent =
|
|
8
|
+
errorComponent = ({ errorMessage }) => (
|
|
9
|
+
<Text>The message cannot be displayed</Text>
|
|
10
|
+
),
|
|
13
11
|
} = {}) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
super(props)
|
|
17
|
-
this.state = { error: null }
|
|
18
|
-
}
|
|
12
|
+
const ErrorBoundary = ({ children }) => {
|
|
13
|
+
const [error, setError] = useState(null)
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
* @param error the exception which was trown
|
|
22
|
-
* @param errorInfo the stack of component names at the error
|
|
23
|
-
*/
|
|
24
|
-
componentDidCatch(error, errorInfo) {
|
|
25
|
-
// No need to log the error because at least chrome & firefox already show
|
|
26
|
-
// both component and call stacks
|
|
15
|
+
const componentDidCatch = (error, errorInfo) => {
|
|
27
16
|
if (isNode()) {
|
|
28
|
-
// In node, only the component stack is displayed
|
|
29
17
|
console.error(`Failure at:`, error)
|
|
30
18
|
}
|
|
31
19
|
}
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
const getDerivedStateFromError = error => {
|
|
34
22
|
return { error }
|
|
35
23
|
}
|
|
36
24
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} else {
|
|
44
|
-
return this.props.children
|
|
45
|
-
}
|
|
25
|
+
if (error) {
|
|
26
|
+
return errorComponent({
|
|
27
|
+
errorMessage: error.message,
|
|
28
|
+
})
|
|
29
|
+
} else {
|
|
30
|
+
return children
|
|
46
31
|
}
|
|
47
32
|
}
|
|
48
33
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext } from 'react'
|
|
1
|
+
import React, { useContext, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
import AttachmentIcon from '../../assets/attachment-icon.svg'
|
|
4
4
|
import { ROLES, WEBCHAT } from '../../constants'
|
|
@@ -9,6 +9,8 @@ import { Icon } from './common'
|
|
|
9
9
|
export const Attachment = ({ onChange, accept, enableAttachments }) => {
|
|
10
10
|
const { getThemeProperty } = useContext(WebchatContext)
|
|
11
11
|
|
|
12
|
+
const fileInputRef = useRef(null)
|
|
13
|
+
|
|
12
14
|
const CustomAttachments = getThemeProperty(
|
|
13
15
|
WEBCHAT.CUSTOM_PROPERTIES.customAttachments,
|
|
14
16
|
undefined
|
|
@@ -25,6 +27,11 @@ export const Attachment = ({ onChange, accept, enableAttachments }) => {
|
|
|
25
27
|
}
|
|
26
28
|
const attachmentsEnabled = isAttachmentsEnabled()
|
|
27
29
|
|
|
30
|
+
const handleOnChange = event => {
|
|
31
|
+
onChange(event)
|
|
32
|
+
fileInputRef.current.value = null
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
return (
|
|
29
36
|
<>
|
|
30
37
|
{attachmentsEnabled ? (
|
|
@@ -38,11 +45,12 @@ export const Attachment = ({ onChange, accept, enableAttachments }) => {
|
|
|
38
45
|
)}
|
|
39
46
|
</label>
|
|
40
47
|
<input
|
|
48
|
+
ref={fileInputRef}
|
|
41
49
|
type='file'
|
|
42
50
|
name='file'
|
|
43
51
|
id='attachment'
|
|
44
52
|
style={{ display: 'none' }}
|
|
45
|
-
onChange={
|
|
53
|
+
onChange={handleOnChange}
|
|
46
54
|
accept={accept}
|
|
47
55
|
/>
|
|
48
56
|
</div>
|
|
@@ -64,7 +64,13 @@ export const OpenedEmojiPicker = props => {
|
|
|
64
64
|
<div ref={ref}>
|
|
65
65
|
{isComponentVisible && (
|
|
66
66
|
<Container role={ROLES.EMOJI_PICKER}>
|
|
67
|
-
<Picker
|
|
67
|
+
<Picker
|
|
68
|
+
width='100%'
|
|
69
|
+
height='19rem'
|
|
70
|
+
previewConfig={{ showPreview: false }}
|
|
71
|
+
onEmojiClick={props.onEmojiClick}
|
|
72
|
+
disableAutoFocus={true}
|
|
73
|
+
/>
|
|
68
74
|
</Container>
|
|
69
75
|
)}
|
|
70
76
|
</div>
|
package/src/webchat/hooks.js
CHANGED
|
@@ -247,7 +247,8 @@ export function useComponentVisible(initialIsVisible, onClickOutside) {
|
|
|
247
247
|
const [isComponentVisible, setIsComponentVisible] = useState(initialIsVisible)
|
|
248
248
|
const ref = useRef(null)
|
|
249
249
|
const handleClickOutside = event => {
|
|
250
|
-
|
|
250
|
+
const target = event.path ? event.path[0] : event.target
|
|
251
|
+
if (ref.current && !ref.current.contains(target)) {
|
|
251
252
|
setIsComponentVisible(false)
|
|
252
253
|
onClickOutside()
|
|
253
254
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
Input as CoreInput,
|
|
3
|
+
Session as CoreSession,
|
|
4
|
+
} from '@botonic/core/lib/esm/models/legacy-types'
|
|
3
5
|
import { RefObject } from 'react'
|
|
4
6
|
|
|
5
|
-
import {
|
|
6
|
-
import { Message, WebchatApp, WebchatArgs } from '../index'
|
|
7
|
+
import { Webview } from '../components/index-types'
|
|
7
8
|
|
|
8
9
|
export interface WebchatStateTheme {
|
|
9
10
|
headerTitle: string
|
|
@@ -20,13 +21,13 @@ export interface WebchatState {
|
|
|
20
21
|
width: number
|
|
21
22
|
height: number
|
|
22
23
|
messagesJSON: any[]
|
|
23
|
-
messagesComponents:
|
|
24
|
-
replies:
|
|
25
|
-
latestInput: Partial<
|
|
24
|
+
messagesComponents: any[]
|
|
25
|
+
replies: any[]
|
|
26
|
+
latestInput: Partial<CoreInput>
|
|
26
27
|
typing: boolean
|
|
27
28
|
webview: Webview | null
|
|
28
29
|
webviewParams: null
|
|
29
|
-
session: Partial<
|
|
30
|
+
session: Partial<CoreSession>
|
|
30
31
|
lastRoutePath: string | null
|
|
31
32
|
handoff: boolean
|
|
32
33
|
theme: WebchatStateTheme
|
|
@@ -41,11 +42,11 @@ export interface WebchatState {
|
|
|
41
42
|
currentAttachment: File | undefined
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
export interface WebchatProps extends WebchatArgs {
|
|
45
|
+
// export interface WebchatProps extends WebchatArgs {
|
|
46
|
+
export interface WebchatProps {
|
|
45
47
|
ref: RefObject<any>
|
|
46
48
|
onConnectionRegained?: () => Promise<void>
|
|
47
49
|
}
|
|
48
|
-
export const WebChat: React.ForwardRefExoticComponent<WebchatProps>
|
|
49
50
|
|
|
50
51
|
export interface WebchatDevProps extends WebchatProps {
|
|
51
52
|
initialDevSettings?: {
|
|
@@ -53,9 +54,6 @@ export interface WebchatDevProps extends WebchatProps {
|
|
|
53
54
|
showSessionView?: boolean
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
export const WebChatDev: React.ForwardRefExoticComponent<WebchatDevProps>
|
|
57
|
-
|
|
58
|
-
export function getBotonicApp(): WebchatApp
|
|
59
57
|
|
|
60
58
|
export interface CoverComponentProps {
|
|
61
59
|
closeComponent: () => void
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
export { Webchat } from './webchat'
|
|
2
3
|
export { WebchatDev } from './webchat-dev'
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
* @returns {WebChatApp}
|
|
6
|
-
*/
|
|
7
5
|
export function getBotonicApp() {
|
|
8
6
|
// Botonic is exported from your bot
|
|
9
7
|
// eslint-disable-next-line no-undef
|
|
10
8
|
return Botonic
|
|
11
9
|
}
|
|
10
|
+
|
|
11
|
+
export * from './index-types'
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
//Code taken from https://github.com/leny/react-use-storage
|
|
4
|
-
const
|
|
3
|
+
// Code taken from https://github.com/leny/react-use-storage/blob/master/src/index.js
|
|
4
|
+
const IS_BROWSER =
|
|
5
|
+
typeof window !== 'undefined' &&
|
|
6
|
+
typeof navigator !== 'undefined' &&
|
|
7
|
+
typeof document !== 'undefined'
|
|
5
8
|
|
|
6
9
|
export function useStorageState(storage, key, defaultValue) {
|
|
10
|
+
let evtTarget
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
evtTarget = new EventTarget()
|
|
14
|
+
} catch {
|
|
15
|
+
evtTarget = (IS_BROWSER ? document : {})?.createElement?.('phony')
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
const raw = storage?.getItem(key)
|
|
8
19
|
|
|
9
20
|
const [value, setValue] = useState(raw ? JSON.parse(raw) : defaultValue)
|
package/src/webchat/webchat.jsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { INPUT, isMobile, params2queryString } from '@botonic/core'
|
|
2
|
-
import { motion } from 'framer-motion'
|
|
3
2
|
import merge from 'lodash.merge'
|
|
4
3
|
import React, {
|
|
5
4
|
forwardRef,
|
|
@@ -161,7 +160,7 @@ const DarkBackgroundMenu = styled.div`
|
|
|
161
160
|
height: 100%;
|
|
162
161
|
`
|
|
163
162
|
|
|
164
|
-
// eslint-disable-next-line complexity
|
|
163
|
+
// eslint-disable-next-line complexity, react/display-name
|
|
165
164
|
export const Webchat = forwardRef((props, ref) => {
|
|
166
165
|
const {
|
|
167
166
|
webchatState,
|
|
@@ -372,8 +371,8 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
372
371
|
const openWebview = (webviewComponent, params) =>
|
|
373
372
|
updateWebview(webviewComponent, params)
|
|
374
373
|
|
|
375
|
-
const handleSelectedEmoji =
|
|
376
|
-
textArea.current.value +=
|
|
374
|
+
const handleSelectedEmoji = event => {
|
|
375
|
+
textArea.current.value += event.emoji
|
|
377
376
|
textArea.current.focus()
|
|
378
377
|
}
|
|
379
378
|
|
|
@@ -712,8 +711,6 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
712
711
|
}
|
|
713
712
|
}, [webchatState.isWebchatOpen])
|
|
714
713
|
|
|
715
|
-
const textArea = useRef()
|
|
716
|
-
|
|
717
714
|
const getTriggerImage = () => {
|
|
718
715
|
const triggerImage = getThemeProperty(
|
|
719
716
|
WEBCHAT.CUSTOM_PROPERTIES.triggerButtonImage,
|
|
@@ -768,6 +765,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
768
765
|
|
|
769
766
|
const userInputEnabled = isUserInputEnabled()
|
|
770
767
|
|
|
768
|
+
const textArea = useRef(null)
|
|
771
769
|
const userInputArea = () => {
|
|
772
770
|
return (
|
|
773
771
|
userInputEnabled && (
|
|
@@ -792,6 +790,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
792
790
|
|
|
793
791
|
<TextAreaContainer>
|
|
794
792
|
<Textarea
|
|
793
|
+
inputRef={textArea}
|
|
795
794
|
name='text'
|
|
796
795
|
onFocus={() => deviceAdapter.onFocus(host)}
|
|
797
796
|
onBlur={() => deviceAdapter.onBlur()}
|
|
@@ -803,7 +802,6 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
803
802
|
WEBCHAT.DEFAULTS.PLACEHOLDER
|
|
804
803
|
)}
|
|
805
804
|
autoFocus={true}
|
|
806
|
-
inputRef={textArea}
|
|
807
805
|
onKeyDown={e => onKeyDown(e)}
|
|
808
806
|
onKeyUp={onKeyUp}
|
|
809
807
|
style={{
|
package/src/webchat-app.jsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { HubtypeService
|
|
1
|
+
import { HubtypeService } from '@botonic/core'
|
|
2
|
+
import { INPUT } from '@botonic/core/lib/esm/models/legacy-types'
|
|
2
3
|
import merge from 'lodash.merge'
|
|
3
4
|
import React, { createRef } from 'react'
|
|
4
5
|
import { render, unmountComponentAtNode } from 'react-dom'
|
package/src/webview-app.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import type { PROVIDER } from '@botonic/core'
|
|
3
2
|
import { getString } from '@botonic/core/lib/esm/i18n'
|
|
3
|
+
import { PROVIDER } from '@botonic/core/lib/esm/models/legacy-types'
|
|
4
4
|
import { params2queryString } from '@botonic/core/lib/esm/utils'
|
|
5
5
|
import axios from 'axios'
|
|
6
6
|
import React from 'react'
|