@botonic/react 0.22.0-alpha.2 → 0.22.0-beta.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/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 +22 -20
- package/lib/cjs/components/index.js +4 -1
- package/lib/cjs/components/index.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 +8 -3
- package/lib/cjs/components/multichannel/index.js +2 -0
- package/lib/cjs/components/multichannel/index.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/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 +8 -10
- package/lib/cjs/index.js +5 -7
- package/lib/cjs/index.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/esm/components/carousel.d.ts +2 -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 +22 -19
- package/lib/esm/components/index.js +2 -0
- package/lib/esm/components/index.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 +8 -3
- package/lib/esm/components/multichannel/index.js +1 -0
- package/lib/esm/components/multichannel/index.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/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 +8 -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/node-app.d.ts +3 -3
- package/lib/esm/react-bot.d.ts +2 -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-app.d.ts +4 -3
- package/package.json +1 -1
- package/src/components/{index.d.ts → index-types.ts} +22 -43
- package/src/components/{index.js → index.ts} +2 -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/contexts.jsx +3 -3
- package/src/index-types.ts +186 -0
- package/src/{index.js → index.ts} +4 -3
- package/src/webchat/{index.d.ts → index-types.ts} +5 -10
- package/src/webchat/{index.js → index.ts} +3 -3
- package/src/index.d.ts +0 -238
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as core from '@botonic/core';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
import { Webview } from '../components/index-types';
|
|
4
|
+
export interface WebchatStateTheme {
|
|
5
|
+
headerTitle: string;
|
|
6
|
+
brandColor: string;
|
|
7
|
+
brandImage: string;
|
|
8
|
+
triggerButtonImage: undefined;
|
|
9
|
+
textPlaceholder: string;
|
|
10
|
+
style: {
|
|
11
|
+
fontFamily: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface WebchatState {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
messagesJSON: any[];
|
|
18
|
+
messagesComponents: any[];
|
|
19
|
+
replies: any[];
|
|
20
|
+
latestInput: Partial<core.Input>;
|
|
21
|
+
typing: boolean;
|
|
22
|
+
webview: Webview | null;
|
|
23
|
+
webviewParams: null;
|
|
24
|
+
session: Partial<core.Session>;
|
|
25
|
+
lastRoutePath: string | null;
|
|
26
|
+
handoff: boolean;
|
|
27
|
+
theme: WebchatStateTheme;
|
|
28
|
+
themeUpdates: Partial<WebchatStateTheme>;
|
|
29
|
+
error: {
|
|
30
|
+
message?: string;
|
|
31
|
+
};
|
|
32
|
+
devSettings: {
|
|
33
|
+
keepSessionOnReload?: boolean;
|
|
34
|
+
showSessionView?: boolean;
|
|
35
|
+
};
|
|
36
|
+
isWebchatOpen: boolean;
|
|
37
|
+
isEmojiPickerOpen: boolean;
|
|
38
|
+
isPersistentMenuOpen: boolean;
|
|
39
|
+
isCoverComponentOpen: boolean;
|
|
40
|
+
lastMessageUpdate: string;
|
|
41
|
+
currentAttachment: File | undefined;
|
|
42
|
+
}
|
|
43
|
+
export interface WebchatProps {
|
|
44
|
+
ref: RefObject<any>;
|
|
45
|
+
onConnectionRegained?: () => Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export interface WebchatDevProps extends WebchatProps {
|
|
48
|
+
initialDevSettings?: {
|
|
49
|
+
keepSessionOnReload?: boolean;
|
|
50
|
+
showSessionView?: boolean;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface CoverComponentProps {
|
|
54
|
+
closeComponent: () => void;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-types.js","sourceRoot":"src/","sources":["webchat/index-types.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export { Webchat } from "./webchat";
|
|
6
|
-
export { WebchatDev } from "./webchat-dev";
|
|
1
|
+
export { Webchat } from './webchat';
|
|
2
|
+
export { WebchatDev } from './webchat-dev';
|
|
3
|
+
export declare function getBotonicApp(): any;
|
|
4
|
+
export * from './index-types';
|
package/lib/esm/webchat/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
export { Webchat } from './webchat';
|
|
2
3
|
export { WebchatDev } from './webchat-dev';
|
|
3
|
-
/**
|
|
4
|
-
* @returns {WebChatApp}
|
|
5
|
-
*/
|
|
6
4
|
export function getBotonicApp() {
|
|
7
5
|
// Botonic is exported from your bot
|
|
8
6
|
// eslint-disable-next-line no-undef
|
|
9
7
|
return Botonic;
|
|
10
8
|
}
|
|
9
|
+
export * from './index-types';
|
|
11
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["webchat/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["webchat/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,MAAM,UAAU,aAAa;IAC3B,oCAAoC;IACpC,oCAAoC;IACpC,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,cAAc,eAAe,CAAA"}
|
package/lib/esm/webchat-app.d.ts
CHANGED
|
@@ -55,15 +55,15 @@ export class WebchatApp {
|
|
|
55
55
|
onUserInput({ user, input }: {
|
|
56
56
|
user: any;
|
|
57
57
|
input: any;
|
|
58
|
-
}): Promise<
|
|
59
|
-
onConnectionRegained(): Promise<
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
onConnectionRegained(): Promise<void>;
|
|
60
60
|
onStateChange({ session: { user }, messagesJSON }: {
|
|
61
61
|
session: {
|
|
62
62
|
user: any;
|
|
63
63
|
};
|
|
64
64
|
messagesJSON: any;
|
|
65
65
|
}): void;
|
|
66
|
-
hubtypeService:
|
|
66
|
+
hubtypeService: HubtypeService | undefined;
|
|
67
67
|
onServiceEvent(event: any): void;
|
|
68
68
|
updateUser(user: any): void;
|
|
69
69
|
addBotMessage(message: any): void;
|
|
@@ -96,3 +96,4 @@ export class WebchatApp {
|
|
|
96
96
|
render(dest: any, optionsAtRuntime?: {}): Promise<void>;
|
|
97
97
|
}
|
|
98
98
|
import React from 'react';
|
|
99
|
+
import { HubtypeService } from '@botonic/core';
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ErrorInfo } from 'react'
|
|
1
|
+
import React, { ErrorInfo } from 'react'
|
|
3
2
|
|
|
4
|
-
import { CoverComponentProps } from '../webchat'
|
|
3
|
+
import { CoverComponentProps } from '../webchat/index-types'
|
|
5
4
|
|
|
6
5
|
export type MessageType =
|
|
7
6
|
| 'audio'
|
|
@@ -26,18 +25,10 @@ export interface MessageProps {
|
|
|
26
25
|
typing?: number
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
export const Audio: React.FunctionComponent<MessageProps>
|
|
30
|
-
export const Document: React.FunctionComponent<MessageProps>
|
|
31
|
-
|
|
32
|
-
export const Message: React.FunctionComponent<MessageProps>
|
|
33
|
-
export type Message = React.FunctionComponent<MessageProps>
|
|
34
|
-
export const Video: React.FunctionComponent<MessageProps>
|
|
35
|
-
|
|
36
28
|
export interface TextProps extends MessageProps {
|
|
37
29
|
// converts markdown syntax to HTML
|
|
38
30
|
markdown?: boolean
|
|
39
31
|
}
|
|
40
|
-
export const Text: React.FunctionComponent<TextProps>
|
|
41
32
|
|
|
42
33
|
export interface Webview {
|
|
43
34
|
name: string
|
|
@@ -56,23 +47,16 @@ export interface ButtonProps {
|
|
|
56
47
|
disabledstyle?: boolean
|
|
57
48
|
}
|
|
58
49
|
|
|
59
|
-
export const Button: React.FunctionComponent<ButtonProps>
|
|
60
|
-
|
|
61
50
|
export interface ReplyProps {
|
|
62
51
|
path?: string
|
|
63
52
|
payload?: string
|
|
64
53
|
children: string
|
|
65
54
|
}
|
|
66
|
-
export const Reply: React.FunctionComponent<ReplyProps>
|
|
67
|
-
export type Reply = React.FunctionComponent<ReplyProps>
|
|
68
55
|
|
|
69
56
|
export interface PicProps {
|
|
70
57
|
src: string
|
|
71
58
|
}
|
|
72
59
|
|
|
73
|
-
export const Carousel: React.FunctionComponent<MessageProps>
|
|
74
|
-
export const Image: React.FunctionComponent<ImageProps>
|
|
75
|
-
export const Pic: React.FunctionComponent<PicProps>
|
|
76
60
|
export type ImageProps = PicProps
|
|
77
61
|
|
|
78
62
|
export interface TitleProps {
|
|
@@ -80,17 +64,14 @@ export interface TitleProps {
|
|
|
80
64
|
style: string
|
|
81
65
|
}
|
|
82
66
|
|
|
83
|
-
export const Element: React.FunctionComponent<MessageProps>
|
|
84
|
-
export const Subtitle: React.FunctionComponent<SubtitleProps>
|
|
85
|
-
export const Title: React.FunctionComponent<TitleProps>
|
|
86
67
|
export type SubtitleProps = TitleProps
|
|
87
68
|
|
|
88
|
-
type CustomProp = { custom?: React.ComponentType }
|
|
89
|
-
type EnableProp = { enable?: boolean }
|
|
90
|
-
type ImageProp = { image?: string } // https URL or imported Image asset
|
|
91
|
-
type PersistentMenuCloseOption = { closeLabel: string }
|
|
92
|
-
type PersistentMenuOption = { label: string } & ButtonProps
|
|
93
|
-
type StyleProp = { style?: any }
|
|
69
|
+
export type CustomProp = { custom?: React.ComponentType }
|
|
70
|
+
export type EnableProp = { enable?: boolean }
|
|
71
|
+
export type ImageProp = { image?: string } // https URL or imported Image asset
|
|
72
|
+
export type PersistentMenuCloseOption = { closeLabel: string }
|
|
73
|
+
export type PersistentMenuOption = { label: string } & ButtonProps
|
|
74
|
+
export type StyleProp = { style?: any }
|
|
94
75
|
|
|
95
76
|
export type PersistentMenuTheme = (
|
|
96
77
|
| PersistentMenuCloseOption
|
|
@@ -202,27 +183,25 @@ export interface WebchatSettingsProps {
|
|
|
202
183
|
persistentMenu?: PersistentMenuTheme
|
|
203
184
|
theme?: ThemeProps
|
|
204
185
|
}
|
|
205
|
-
export const WebchatSettings: React.FunctionComponent<WebchatSettingsProps>
|
|
206
186
|
|
|
207
187
|
export type WrappedComponent<Props> = React.FunctionComponent<Props> & {
|
|
208
188
|
customTypeName: string
|
|
209
189
|
}
|
|
210
190
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
export function createErrorBoundary<Props>(_?: {
|
|
216
|
-
errorComponent: React.ComponentType
|
|
217
|
-
}): ErrorBoundary<Props>
|
|
191
|
+
// TODO: Reuse types to be typed in respective functions
|
|
192
|
+
// export class ErrorBoundary<Props> extends React.Component<Props> {
|
|
193
|
+
// componentDidCatch(error: Error, errorInfo: ErrorInfo): void
|
|
194
|
+
// }
|
|
218
195
|
|
|
219
|
-
export function
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
defaultProps?: Record<string, unknown>
|
|
223
|
-
errorBoundary?: ErrorBoundary<Props>
|
|
224
|
-
}): WrappedComponent<Props>
|
|
196
|
+
// export function createErrorBoundary<Props>(_?: {
|
|
197
|
+
// errorComponent: React.ComponentType
|
|
198
|
+
// }): ErrorBoundary<Props>
|
|
225
199
|
|
|
226
|
-
export function
|
|
200
|
+
// export function customMessage<Props>(_: {
|
|
201
|
+
// name: string
|
|
202
|
+
// component: React.ComponentType<Props>
|
|
203
|
+
// defaultProps?: Record<string, unknown>
|
|
204
|
+
// errorBoundary?: ErrorBoundary<Props>
|
|
205
|
+
// }): WrappedComponent<Props>
|
|
227
206
|
|
|
228
|
-
export
|
|
207
|
+
// export function getDisplayName(component: React.ComponentType): string
|
|
@@ -5,7 +5,9 @@ export { customMessage } from './custom-message'
|
|
|
5
5
|
export { Document } from './document'
|
|
6
6
|
export { Element } from './element'
|
|
7
7
|
export { Image } from './image'
|
|
8
|
+
export * from './index-types'
|
|
8
9
|
export { Location } from './location'
|
|
10
|
+
export { Message } from './message'
|
|
9
11
|
export { MessageTemplate } from './message-template'
|
|
10
12
|
export * from './multichannel'
|
|
11
13
|
export { Pic } from './pic'
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type IndexMode = 'number' | 'letter' | undefined //undefined means no index
|
|
1
|
+
export type IndexMode = 'number' | 'letter' | undefined //undefined means no index
|
|
4
2
|
|
|
5
3
|
export interface MultichannelViewOptions {
|
|
6
4
|
boldIndex?: boolean
|
|
@@ -23,8 +21,6 @@ export interface MultichannelTextProps extends MultichannelViewOptions {
|
|
|
23
21
|
buttonsTextSeparator?: string
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
export const MultichannelText: React.FunctionComponent<MultichannelTextProps>
|
|
27
|
-
|
|
28
24
|
// Carousel
|
|
29
25
|
export interface MultichannelCarouselProps extends MultichannelViewOptions {
|
|
30
26
|
enableURL?: boolean
|
|
@@ -33,7 +29,6 @@ export interface MultichannelCarouselProps extends MultichannelViewOptions {
|
|
|
33
29
|
showSubtitle?: boolean
|
|
34
30
|
buttonsAsText?: boolean
|
|
35
31
|
}
|
|
36
|
-
export const MultichannelCarousel: React.FunctionComponent<MultichannelCarouselProps>
|
|
37
32
|
|
|
38
33
|
// Button
|
|
39
34
|
export interface MultichannelButtonProps {
|
|
@@ -44,10 +39,8 @@ export interface MultichannelButtonProps {
|
|
|
44
39
|
webview?: string
|
|
45
40
|
asText?: boolean
|
|
46
41
|
}
|
|
47
|
-
export const MultichannelButton: React.FunctionComponent<MultichannelButtonProps>
|
|
48
42
|
|
|
49
43
|
// Reply
|
|
50
|
-
export const MultichannelReply: React.FunctionComponent<MultichannelButtonProps>
|
|
51
44
|
|
|
52
45
|
export interface MultichannelProps extends MultichannelViewOptions {
|
|
53
46
|
firstIndex?: number | string
|
|
@@ -61,5 +54,3 @@ export interface MultichannelProps extends MultichannelViewOptions {
|
|
|
61
54
|
**/
|
|
62
55
|
messageSeparator?: string
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
export const Multichannel: React.FunctionComponent<MultichannelProps>
|
package/src/contexts.jsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import { webchatInitialState } from './webchat/hooks'
|
|
4
4
|
|
|
5
|
-
export const RequestContext =
|
|
5
|
+
export const RequestContext = createContext({
|
|
6
6
|
getString: () => '',
|
|
7
7
|
setLocale: () => '',
|
|
8
8
|
session: {},
|
|
@@ -12,7 +12,7 @@ export const RequestContext = React.createContext({
|
|
|
12
12
|
defaultTyping: 0,
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
export const WebchatContext =
|
|
15
|
+
export const WebchatContext = createContext({
|
|
16
16
|
sendText: text => {},
|
|
17
17
|
sendAttachment: attachment => {},
|
|
18
18
|
sendPayload: payload => {},
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import * as core from '@botonic/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ButtonProps,
|
|
6
|
+
ReplyProps,
|
|
7
|
+
ThemeProps,
|
|
8
|
+
WebchatSettingsProps,
|
|
9
|
+
Webview,
|
|
10
|
+
} from './components/index-types'
|
|
11
|
+
import { WebchatState } from './webchat'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* See @botonic/core's Response for the description of the Response's semantics*/
|
|
15
|
+
export interface BotResponse extends core.BotRequest {
|
|
16
|
+
response: [React.ReactNode]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Route extends core.Route {
|
|
20
|
+
action?: React.ComponentType<any>
|
|
21
|
+
retryAction?: React.ComponentType<any>
|
|
22
|
+
}
|
|
23
|
+
export type Routes = core.Routes<Route>
|
|
24
|
+
|
|
25
|
+
// Parameters of the actions' botonicInit method
|
|
26
|
+
export interface ActionRequest {
|
|
27
|
+
defaultDelay: number
|
|
28
|
+
defaultTyping: number
|
|
29
|
+
input: core.Input
|
|
30
|
+
lastRoutePath: string
|
|
31
|
+
params: { [key: string]: string }
|
|
32
|
+
plugins: { [id: string]: core.Plugin }
|
|
33
|
+
session: core.Session
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RequestContextInterface extends ActionRequest {
|
|
37
|
+
getString: (stringId: string) => string
|
|
38
|
+
setLocale: (locale: string) => string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface CustomMessageType {
|
|
42
|
+
customTypeName: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// TODO: Reuse types to be reused in respective components
|
|
46
|
+
// export class WebchatApp {
|
|
47
|
+
// constructor(options: WebchatAppArgs)
|
|
48
|
+
// addBotMessage(message: WebchatMessage): void
|
|
49
|
+
// addBotText(text: string): void
|
|
50
|
+
// addUserMessage(message: WebchatMessage): void
|
|
51
|
+
// addUserPayload(payload: string): void
|
|
52
|
+
// addUserText(text: string): void
|
|
53
|
+
// clearMessages(): void
|
|
54
|
+
// close(): void
|
|
55
|
+
// closeCoverComponent(): void
|
|
56
|
+
// destroy(): void
|
|
57
|
+
// getComponent(
|
|
58
|
+
// host: HTMLElement,
|
|
59
|
+
// optionsAtRuntime?: WebchatAppArgs
|
|
60
|
+
// ): React.ForwardRefExoticComponent<any>
|
|
61
|
+
// getLastMessageUpdate(): string
|
|
62
|
+
// getMessages(): WebchatMessage[]
|
|
63
|
+
// getVisibility(): Promise<boolean>
|
|
64
|
+
// isWebchatVisible({ appId: string }): Promise<boolean>
|
|
65
|
+
// onCloseWebchat(args: any): void
|
|
66
|
+
// onInitWebchat(args: any): void
|
|
67
|
+
// onOpenWebchat(args: any): void
|
|
68
|
+
// onServiceEvent(event: Event): void
|
|
69
|
+
// onStateChange(args: OnStateChangeArgs): void
|
|
70
|
+
// onUserInput(args: OnUserInputArgs): Promise<void>
|
|
71
|
+
// open(): void
|
|
72
|
+
// openCoverComponent(): void
|
|
73
|
+
// render(dest?: HTMLElement, optionsAtRuntime?: WebchatAppArgs): void
|
|
74
|
+
// resendUnsentInputs(): Promise<void>
|
|
75
|
+
// resolveWebchatVisibility(optionsAtRuntime: {
|
|
76
|
+
// appId: string
|
|
77
|
+
// visibility: () => boolean
|
|
78
|
+
// }): Promise<boolean>
|
|
79
|
+
// setTyping(enable: boolean): void
|
|
80
|
+
// toggle(): void
|
|
81
|
+
// toggleCoverComponent(): void
|
|
82
|
+
// updateMessageInfo(msgId: string, messageInfo: MessageInfo): void
|
|
83
|
+
// updateLastMessageDate(date: string): void
|
|
84
|
+
// updateUser(user: Partial<core.SessionUser>): void
|
|
85
|
+
// updateWebchatSettings(settings: WebchatSettingsProps): void
|
|
86
|
+
// renderCustomComponent(customComponent: React.ReactNode): void
|
|
87
|
+
// unmountCustomComponent(): void
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
// export interface WebchatArgs {
|
|
91
|
+
// blockInputs?: BlockInputOption[]
|
|
92
|
+
// coverComponent?: CoverComponentOptions
|
|
93
|
+
// defaultDelay?: number
|
|
94
|
+
// defaultTyping?: number
|
|
95
|
+
// enableAnimations?: boolean
|
|
96
|
+
// enableAttachments?: boolean
|
|
97
|
+
// enableEmojiPicker?: boolean
|
|
98
|
+
// enableUserInput?: boolean
|
|
99
|
+
// shadowDOM?: boolean | (() => boolean)
|
|
100
|
+
// hostId?: string
|
|
101
|
+
// getString?: (stringId: string, session: core.Session) => string
|
|
102
|
+
// onClose?: (app: WebchatApp, args: any) => void
|
|
103
|
+
// onInit?: (app: WebchatApp, args: any) => void
|
|
104
|
+
// onMessage?: (app: WebchatApp, message: WebchatMessage) => void
|
|
105
|
+
// onOpen?: (app: WebchatApp, args: any) => void
|
|
106
|
+
// onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void
|
|
107
|
+
// persistentMenu?: PersistentMenuTheme
|
|
108
|
+
// storage?: Storage | null
|
|
109
|
+
// storageKey?: any
|
|
110
|
+
// theme?: ThemeProps
|
|
111
|
+
// }
|
|
112
|
+
|
|
113
|
+
// export interface WebchatAppArgs extends WebchatArgs {
|
|
114
|
+
export interface WebchatAppArgs {
|
|
115
|
+
appId?: string
|
|
116
|
+
visibility?: () => boolean
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface WebchatMessage {
|
|
120
|
+
ack: 0 | 1
|
|
121
|
+
buttons: ButtonProps[]
|
|
122
|
+
data: any
|
|
123
|
+
delay: number
|
|
124
|
+
display: boolean
|
|
125
|
+
from: 'user' | 'bot'
|
|
126
|
+
id: string
|
|
127
|
+
markdown: boolean
|
|
128
|
+
replies: ReplyProps[]
|
|
129
|
+
timestamp: string
|
|
130
|
+
type: core.InputType
|
|
131
|
+
typing: number
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface OnUserInputArgs {
|
|
135
|
+
input: core.Input
|
|
136
|
+
lastRoutePath?: string
|
|
137
|
+
session?: core.Session
|
|
138
|
+
user: core.SessionUser
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface OnStateChangeArgs {
|
|
142
|
+
messagesJSON: WebchatMessage[]
|
|
143
|
+
user: core.SessionUser
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface MessageInfo {
|
|
147
|
+
data: any | 'typing_on'
|
|
148
|
+
id: string
|
|
149
|
+
type: 'update_webchat_settings' | 'sender_action'
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface Event {
|
|
153
|
+
action?: 'update_message_info'
|
|
154
|
+
isError?: boolean
|
|
155
|
+
message?: MessageInfo
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface WebchatContextProps {
|
|
159
|
+
sendText: (text: string, payload?: string) => void
|
|
160
|
+
sendAttachment: (attachment: File) => void
|
|
161
|
+
sendPayload: (payload: string) => void
|
|
162
|
+
sendInput: (input: core.Input) => void
|
|
163
|
+
openWebview: (webviewComponent: Webview) => void
|
|
164
|
+
addMessage: (message: WebchatMessage) => void
|
|
165
|
+
updateMessage: (message: WebchatMessage) => void
|
|
166
|
+
updateReplies: (replies: boolean) => void
|
|
167
|
+
updateLatestInput: (input: core.Input) => void
|
|
168
|
+
closeWebview: () => void
|
|
169
|
+
toggleWebchat: () => void
|
|
170
|
+
getThemeProperty: (property: string, defaultValue?: string) => any
|
|
171
|
+
resolveCase: () => void
|
|
172
|
+
theme: ThemeProps
|
|
173
|
+
webchatState: WebchatState
|
|
174
|
+
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
175
|
+
updateUser: (user: Partial<core.SessionUser>) => void
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// export class DevApp extends WebchatApp {
|
|
179
|
+
// constructor(args: WebchatAppArgs)
|
|
180
|
+
// onUserInput(args: OnUserInputArgs): Promise<void>
|
|
181
|
+
// render(dest: HTMLElement, optionsAtRuntime: WebchatAppArgs): void
|
|
182
|
+
// }
|
|
183
|
+
|
|
184
|
+
export * from './components'
|
|
185
|
+
export * from './util'
|
|
186
|
+
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 { staticAsset } from './util/environment'
|
|
8
|
-
export { getBotonicApp, Webchat } from './webchat/index
|
|
8
|
+
// export { staticAsset } from './util/environment'
|
|
9
|
+
// export { getBotonicApp, Webchat } from './webchat/index'
|
|
9
10
|
export { WebchatApp } from './webchat-app'
|
|
10
11
|
export { WebviewApp } from './webview-app'
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import * as core from '@botonic/core'
|
|
2
|
-
import * as React from 'react'
|
|
3
2
|
import { RefObject } from 'react'
|
|
4
3
|
|
|
5
|
-
import {
|
|
6
|
-
import { Message, WebchatApp, WebchatArgs } from '../index'
|
|
4
|
+
import { Webview } from '../components/index-types'
|
|
7
5
|
|
|
8
6
|
export interface WebchatStateTheme {
|
|
9
7
|
headerTitle: string
|
|
@@ -20,8 +18,8 @@ export interface WebchatState {
|
|
|
20
18
|
width: number
|
|
21
19
|
height: number
|
|
22
20
|
messagesJSON: any[]
|
|
23
|
-
messagesComponents:
|
|
24
|
-
replies:
|
|
21
|
+
messagesComponents: any[]
|
|
22
|
+
replies: any[]
|
|
25
23
|
latestInput: Partial<core.Input>
|
|
26
24
|
typing: boolean
|
|
27
25
|
webview: Webview | null
|
|
@@ -41,11 +39,11 @@ export interface WebchatState {
|
|
|
41
39
|
currentAttachment: File | undefined
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
export interface WebchatProps extends WebchatArgs {
|
|
42
|
+
// export interface WebchatProps extends WebchatArgs {
|
|
43
|
+
export interface WebchatProps {
|
|
45
44
|
ref: RefObject<any>
|
|
46
45
|
onConnectionRegained?: () => Promise<void>
|
|
47
46
|
}
|
|
48
|
-
export const WebChat: React.ForwardRefExoticComponent<WebchatProps>
|
|
49
47
|
|
|
50
48
|
export interface WebchatDevProps extends WebchatProps {
|
|
51
49
|
initialDevSettings?: {
|
|
@@ -53,9 +51,6 @@ export interface WebchatDevProps extends WebchatProps {
|
|
|
53
51
|
showSessionView?: boolean
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
|
-
export const WebChatDev: React.ForwardRefExoticComponent<WebchatDevProps>
|
|
57
|
-
|
|
58
|
-
export function getBotonicApp(): WebchatApp
|
|
59
54
|
|
|
60
55
|
export interface CoverComponentProps {
|
|
61
56
|
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'
|