@botpress/webchat 0.5.1 → 1.0.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/dist/App.d.ts +10 -0
- package/dist/Utils/colors.d.ts +18 -0
- package/dist/Utils/eventEmitter.d.ts +12 -0
- package/dist/Utils/index.d.ts +2 -0
- package/dist/client/MessagingClient.d.ts +27 -0
- package/dist/client/adapters/Audio.d.ts +19 -0
- package/dist/client/adapters/Card.d.ts +188 -0
- package/dist/client/adapters/Carousel.d.ts +147 -0
- package/dist/client/adapters/Choice.d.ts +45 -0
- package/dist/client/adapters/Dropdown.d.ts +46 -0
- package/dist/client/adapters/File.d.ts +19 -0
- package/dist/client/adapters/Image.d.ts +19 -0
- package/dist/client/adapters/Location.d.ts +27 -0
- package/dist/client/adapters/Message.d.ts +433 -0
- package/dist/client/adapters/Text.d.ts +20 -0
- package/dist/client/adapters/Utils.d.ts +5 -0
- package/dist/client/adapters/Video.d.ts +19 -0
- package/dist/client/adapters/Voice.d.ts +15 -0
- package/dist/client/adapters/index.d.ts +12 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/components/Avatar.d.ts +6 -0
- package/dist/components/Block.d.ts +4 -0
- package/dist/components/Composer.d.ts +12 -14
- package/dist/components/Container.d.ts +2 -12
- package/dist/components/Header.d.ts +36 -26
- package/dist/components/LoadingIndicator.d.ts +2 -0
- package/dist/components/Message.d.ts +7 -0
- package/dist/components/MessageList.d.ts +2 -0
- package/dist/components/Modal.d.ts +17 -0
- package/dist/components/RestartConversation.d.ts +5 -0
- package/dist/components/Webchat.d.ts +6 -0
- package/dist/components/dev-tools/DevTools.d.ts +1 -0
- package/dist/components/dev-tools/configuration.d.ts +2 -0
- package/dist/components/dev-tools/helpers.d.ts +5 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/renderers/Audio.d.ts +3 -0
- package/dist/components/renderers/Bubble.d.ts +5 -0
- package/dist/components/renderers/Button.d.ts +4 -0
- package/dist/components/renderers/Carousel.d.ts +3 -0
- package/dist/components/renderers/Column.d.ts +5 -0
- package/dist/components/renderers/Dropdown.d.ts +5 -0
- package/dist/components/renderers/File.d.ts +3 -0
- package/dist/components/renderers/Image.d.ts +3 -0
- package/dist/components/renderers/Location.d.ts +3 -0
- package/dist/components/renderers/Row.d.ts +5 -0
- package/dist/components/renderers/Text.d.ts +4 -0
- package/dist/components/renderers/Video.d.ts +3 -0
- package/dist/components/renderers/index.d.ts +2 -0
- package/dist/contexts/ComposerContext.d.ts +8 -0
- package/dist/contexts/MessageContext.d.ts +8 -0
- package/dist/contexts/ModalContext.d.ts +14 -0
- package/dist/contexts/WebchatContext.d.ts +56 -0
- package/dist/contexts/index.d.ts +4 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useImageSize.d.ts +2 -0
- package/dist/hooks/useRefresh.d.ts +10 -0
- package/dist/hooks/useWebchatStore.d.ts +30 -0
- package/dist/index.d.ts +3 -17
- package/dist/index.js +43569 -48
- package/dist/index.umd.cjs +702 -0
- package/dist/main.d.ts +11 -13
- package/dist/providers/ModalProvider.d.ts +8 -0
- package/dist/providers/WebchatProvider.d.ts +13 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/theme.d.ts +3371 -0
- package/dist/services/clipboard.d.ts +1 -0
- package/dist/services/images.d.ts +2 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/toast.d.ts +17 -0
- package/dist/themes/dawn.d.ts +2 -0
- package/dist/themes/duskTheme.d.ts +2 -0
- package/dist/themes/eggplant.d.ts +2 -0
- package/dist/themes/galaxy.d.ts +2 -0
- package/dist/themes/index.d.ts +6 -0
- package/dist/themes/midnight.d.ts +2 -0
- package/dist/themes/prism.d.ts +2 -0
- package/dist/twind.config.d.ts +9 -0
- package/dist/types/block-type.d.ts +93 -0
- package/dist/types/image.d.ts +11 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +61 -49
- package/README.md +0 -41
- package/assets/fonts/roboto/roboto.woff2 +0 -0
- package/assets/fonts/roboto/roboto500.woff2 +0 -0
- package/assets/fonts/roboto.css +0 -128
- package/assets/notification.mp3 +0 -0
- package/dist/components/Composer.js +0 -118
- package/dist/components/Container.js +0 -62
- package/dist/components/ConversationList.d.ts +0 -10
- package/dist/components/ConversationList.js +0 -41
- package/dist/components/Footer.d.ts +0 -3
- package/dist/components/Footer.js +0 -21
- package/dist/components/Header.js +0 -181
- package/dist/components/VoiceRecorder.d.ts +0 -10
- package/dist/components/VoiceRecorder.js +0 -137
- package/dist/components/common/Avatar/index.d.ts +0 -9
- package/dist/components/common/Avatar/index.js +0 -13
- package/dist/components/common/BotInfo/index.d.ts +0 -10
- package/dist/components/common/BotInfo/index.js +0 -107
- package/dist/components/common/BotInfo/style.scss +0 -88
- package/dist/components/common/ConfirmDialog/index.d.ts +0 -11
- package/dist/components/common/ConfirmDialog/index.js +0 -78
- package/dist/components/common/ConfirmDialog/style.module.scss +0 -48
- package/dist/components/common/Dialog/index.d.ts +0 -17
- package/dist/components/common/Dialog/index.js +0 -57
- package/dist/components/common/Dialog/style.module.scss +0 -29
- package/dist/components/common/ToolTip/index.d.ts +0 -10
- package/dist/components/common/ToolTip/index.js +0 -163
- package/dist/components/common/ToolTip/style.module.scss +0 -108
- package/dist/components/common/ToolTip/utils.d.ts +0 -15
- package/dist/components/common/ToolTip/utils.js +0 -78
- package/dist/components/common/variables.scss +0 -38
- package/dist/components/messages/InlineFeedback.d.ts +0 -11
- package/dist/components/messages/InlineFeedback.js +0 -56
- package/dist/components/messages/Message.d.ts +0 -11
- package/dist/components/messages/Message.js +0 -106
- package/dist/components/messages/MessageGroup.d.ts +0 -23
- package/dist/components/messages/MessageGroup.js +0 -63
- package/dist/components/messages/MessageList.d.ts +0 -10
- package/dist/components/messages/MessageList.js +0 -148
- package/dist/core/api.d.ts +0 -23
- package/dist/core/api.js +0 -117
- package/dist/core/constants.d.ts +0 -14
- package/dist/core/constants.js +0 -29
- package/dist/core/socket.d.ts +0 -14
- package/dist/core/socket.js +0 -57
- package/dist/declaration.d.ts +0 -2
- package/dist/declaration.js +0 -1
- package/dist/fonts/roboto.d.ts +0 -4
- package/dist/fonts/roboto.js +0 -9
- package/dist/globals.d.ts +0 -7
- package/dist/globals.js +0 -2
- package/dist/icons/Add.d.ts +0 -6
- package/dist/icons/Add.js +0 -10
- package/dist/icons/Cancel.d.ts +0 -5
- package/dist/icons/Cancel.js +0 -10
- package/dist/icons/Chat.d.ts +0 -6
- package/dist/icons/Chat.js +0 -9
- package/dist/icons/Close.d.ts +0 -3
- package/dist/icons/Close.js +0 -10
- package/dist/icons/Delete.d.ts +0 -3
- package/dist/icons/Delete.js +0 -11
- package/dist/icons/Download.d.ts +0 -3
- package/dist/icons/Download.js +0 -10
- package/dist/icons/Email.d.ts +0 -3
- package/dist/icons/Email.js +0 -8
- package/dist/icons/Information.d.ts +0 -3
- package/dist/icons/Information.js +0 -12
- package/dist/icons/List.d.ts +0 -3
- package/dist/icons/List.js +0 -15
- package/dist/icons/Microphone.d.ts +0 -5
- package/dist/icons/Microphone.js +0 -12
- package/dist/icons/Phone.d.ts +0 -3
- package/dist/icons/Phone.js +0 -8
- package/dist/icons/Reload.d.ts +0 -3
- package/dist/icons/Reload.js +0 -10
- package/dist/icons/ThumbsDown.d.ts +0 -3
- package/dist/icons/ThumbsDown.js +0 -11
- package/dist/icons/ThumbsUp.d.ts +0 -3
- package/dist/icons/ThumbsUp.js +0 -11
- package/dist/icons/Website.d.ts +0 -3
- package/dist/icons/Website.js +0 -8
- package/dist/main.js +0 -336
- package/dist/store/composer.d.ts +0 -17
- package/dist/store/composer.js +0 -98
- package/dist/store/index.d.ts +0 -89
- package/dist/store/index.js +0 -604
- package/dist/store/view.d.ts +0 -61
- package/dist/store/view.js +0 -365
- package/dist/translations/ar.json +0 -30
- package/dist/translations/de.json +0 -32
- package/dist/translations/en.json +0 -40
- package/dist/translations/es.json +0 -19
- package/dist/translations/fr.json +0 -40
- package/dist/translations/index.d.ts +0 -9
- package/dist/translations/index.js +0 -95
- package/dist/translations/it.json +0 -38
- package/dist/translations/pt.json +0 -19
- package/dist/translations/ru.json +0 -24
- package/dist/translations/uk.json +0 -24
- package/dist/typings.d.ts +0 -410
- package/dist/typings.js +0 -2
- package/dist/utils/analytics.d.ts +0 -5
- package/dist/utils/analytics.js +0 -37
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +0 -27
- package/dist/utils/storage.d.ts +0 -16
- package/dist/utils/storage.js +0 -129
- package/dist/utils/webchatEvents.d.ts +0 -2
- package/dist/utils/webchatEvents.js +0 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copyToClipboard(value: string, description?: string): Promise<string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
type ToastType = ToastProps['type'] | CustomToastProps['type'];
|
|
3
|
+
type CustomToastProps = {
|
|
4
|
+
type: 'custom';
|
|
5
|
+
content?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
type ToastProps = {
|
|
8
|
+
type?: 'success' | 'error' | 'neutral';
|
|
9
|
+
title: string;
|
|
10
|
+
icon?: FC<{
|
|
11
|
+
className?: string;
|
|
12
|
+
type?: ToastType;
|
|
13
|
+
}>;
|
|
14
|
+
description?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function showToast(props: ToastProps | CustomToastProps): string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const config: import("@twind/core").TwindConfig<import("@twind/core").BaseTheme & import("@twind/preset-tailwind").TailwindTheme & import("@twind/preset-container-queries").ContainerQueriesTheme & {
|
|
2
|
+
fontFamily: {
|
|
3
|
+
sans: string[];
|
|
4
|
+
rubik: string[];
|
|
5
|
+
plex: string[];
|
|
6
|
+
mono: string[];
|
|
7
|
+
};
|
|
8
|
+
extend: never;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Theme } from '../schemas';
|
|
2
|
+
export declare const blockTypes: readonly ["button", "text", "image", "audio", "video", "file", "location", "column", "row", "bubble", "carousel", "dropdown"];
|
|
3
|
+
export declare const markdownTypes: readonly ["heading1", "heading2", "heading3", "text", "horizontalRule", "link", "italic", "bold", "orderedList", "unorderedList", "listItem", "lineBreak", "pre"];
|
|
4
|
+
export type MarkdownTypes = (typeof markdownTypes)[number];
|
|
5
|
+
export type BlockTypes = (typeof blockTypes)[number];
|
|
6
|
+
export type BlockStyles = NonNullable<Theme['message']>['blocks'];
|
|
7
|
+
export type BlockObject = DropdownBlock | ButtonBlock | TextBlock | ImageBlock | AudioBlock | VideoBlock | FileBlock | LocationBlock | ColumnBlock | RowBlock | BubbleBlock | CarouselBlock;
|
|
8
|
+
export type Sender = {
|
|
9
|
+
name: string;
|
|
10
|
+
avatar?: string;
|
|
11
|
+
};
|
|
12
|
+
export type MessageObject = {
|
|
13
|
+
direction: 'incoming' | 'outgoing' | 'system';
|
|
14
|
+
disableInput?: boolean;
|
|
15
|
+
sender: Sender;
|
|
16
|
+
timestamp: Date;
|
|
17
|
+
block: BlockObject;
|
|
18
|
+
};
|
|
19
|
+
export type ButtonBlock = {
|
|
20
|
+
type: 'button';
|
|
21
|
+
variant: 'action' | 'link';
|
|
22
|
+
reusable?: boolean;
|
|
23
|
+
groupId?: string;
|
|
24
|
+
text: string;
|
|
25
|
+
buttonValue: string;
|
|
26
|
+
};
|
|
27
|
+
export type TextBlock = {
|
|
28
|
+
type: 'text';
|
|
29
|
+
text: string;
|
|
30
|
+
};
|
|
31
|
+
export type ImageBlock = {
|
|
32
|
+
type: 'image';
|
|
33
|
+
orientation?: 'portrait' | 'landscape' | 'square' | 'auto';
|
|
34
|
+
url: string;
|
|
35
|
+
};
|
|
36
|
+
export type AudioBlock = {
|
|
37
|
+
type: 'audio';
|
|
38
|
+
url: string;
|
|
39
|
+
};
|
|
40
|
+
export type VideoBlock = {
|
|
41
|
+
type: 'video';
|
|
42
|
+
url: string;
|
|
43
|
+
};
|
|
44
|
+
export type FileBlock = {
|
|
45
|
+
type: 'file';
|
|
46
|
+
url: string;
|
|
47
|
+
title?: string;
|
|
48
|
+
};
|
|
49
|
+
type DropdownChoice = {
|
|
50
|
+
label: string;
|
|
51
|
+
value: string;
|
|
52
|
+
};
|
|
53
|
+
export type DropdownBlock = {
|
|
54
|
+
label?: string;
|
|
55
|
+
type: 'dropdown';
|
|
56
|
+
reusable?: boolean;
|
|
57
|
+
options: DropdownChoice[];
|
|
58
|
+
};
|
|
59
|
+
export type LocationBlock = {
|
|
60
|
+
type: 'location';
|
|
61
|
+
latitude: number;
|
|
62
|
+
longitude: number;
|
|
63
|
+
title?: string;
|
|
64
|
+
};
|
|
65
|
+
export type ColumnBlock = {
|
|
66
|
+
type: 'column';
|
|
67
|
+
blocks: BlockObject[];
|
|
68
|
+
horizontalAlignment?: 'left' | 'center' | 'right';
|
|
69
|
+
verticalAlignment?: 'top' | 'center' | 'bottom' | 'stretch';
|
|
70
|
+
};
|
|
71
|
+
export type RowBlock = {
|
|
72
|
+
type: 'row';
|
|
73
|
+
blocks: BlockObject[];
|
|
74
|
+
horizontalAlignment?: 'left' | 'center' | 'right' | 'stretch';
|
|
75
|
+
verticalAlignment?: 'top' | 'center' | 'bottom';
|
|
76
|
+
};
|
|
77
|
+
export type CarouselBlock = {
|
|
78
|
+
type: 'carousel';
|
|
79
|
+
blocks: BlockObject[];
|
|
80
|
+
};
|
|
81
|
+
export type BubbleBlock = {
|
|
82
|
+
type: 'bubble';
|
|
83
|
+
block: BlockObject;
|
|
84
|
+
};
|
|
85
|
+
export type CommonBlockProps = {
|
|
86
|
+
styles?: BlockStyles;
|
|
87
|
+
};
|
|
88
|
+
export type BlockMap<P extends BlockObject = BlockObject> = {
|
|
89
|
+
[T in P['type']]: Extract<P, {
|
|
90
|
+
type: T;
|
|
91
|
+
}>;
|
|
92
|
+
};
|
|
93
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,55 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/webchat",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"prepublish": "yarn run -T rimraf dist && yarn --immutable && yarn run -T tsc --build && yarn run -T rimraf dist/.tsbuildinfo && yarn copy:scss"
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.umd.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.umd.cjs"
|
|
12
|
+
}
|
|
14
13
|
},
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"@types/js-cookie": "^3.0.1",
|
|
22
|
-
"@types/lodash": "^4.14.178",
|
|
23
|
-
"@types/mime": "^2.0.3",
|
|
24
|
-
"@types/node": "^16.11.13",
|
|
25
|
-
"@types/react": "^17.0.38",
|
|
26
|
-
"@types/react-dom": "^17.0.11",
|
|
27
|
-
"@types/uuid": "^8.3.4",
|
|
28
|
-
"prop-types": "^15.8.1"
|
|
14
|
+
"scripts": {
|
|
15
|
+
"type:check": "tsc --noEmit",
|
|
16
|
+
"dev": "vite",
|
|
17
|
+
"build": "pnpm type:check && vite build",
|
|
18
|
+
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
19
|
+
"preview": "vite preview"
|
|
29
20
|
},
|
|
30
21
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
22
|
+
"@botpress/messaging-socket": "^1.2.0",
|
|
23
|
+
"@floating-ui/react": "^0.25.4",
|
|
24
|
+
"@headlessui/react": "1.7.11",
|
|
25
|
+
"@heroicons/react": "^2.0.18",
|
|
26
|
+
"@material/material-color-utilities": "^0.2.7",
|
|
27
|
+
"@radix-ui/react-avatar": "^1.0.3",
|
|
28
|
+
"@radix-ui/react-collapsible": "^1.0.3",
|
|
29
|
+
"@radix-ui/react-dialog": "^1.0.4",
|
|
30
|
+
"@radix-ui/react-icons": "^1.3.0",
|
|
31
|
+
"@tailwindcss/container-queries": "^0.1.1",
|
|
32
|
+
"@twind/core": "^1.1.3",
|
|
33
|
+
"@twind/intellisense": "^1.1.3",
|
|
34
|
+
"@twind/preset-autoprefix": "^1.0.7",
|
|
35
|
+
"@twind/preset-container-queries": "^1.0.7",
|
|
36
|
+
"@twind/preset-tailwind": "^1.1.4",
|
|
37
|
+
"@twind/with-react": "^1.1.3",
|
|
38
|
+
"@types/color-convert": "^2.0.1",
|
|
39
|
+
"@types/uuid": "^9.0.3",
|
|
40
|
+
"classnames": "^2.3.2",
|
|
41
|
+
"clsx": "^2.0.0",
|
|
42
|
+
"color-convert": "^2.0.1",
|
|
43
|
+
"embla-carousel-react": "8.0.0-rc11",
|
|
44
|
+
"google-map-react": "^2.2.1",
|
|
45
|
+
"react": "^18.2.0",
|
|
46
|
+
"react-colorful": "^5.6.1",
|
|
47
|
+
"react-dom": "^18.2.0",
|
|
48
|
+
"react-hot-toast": "^2.4.1",
|
|
49
|
+
"react-markdown": "^8.0.7",
|
|
50
|
+
"react-use": "^17.4.0",
|
|
51
|
+
"tailwind-scrollbar": "^3.0.4",
|
|
52
|
+
"uuid": "^9.0.0",
|
|
53
|
+
"vite-plugin-svgr": "^3.2.0",
|
|
54
|
+
"zod": "^3.21.4",
|
|
55
|
+
"zustand": "^4.4.1"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/react": "^18.0.37",
|
|
59
|
+
"@types/react-dom": "^18.0.11",
|
|
60
|
+
"@vitejs/plugin-react-swc": "^3.0.0",
|
|
61
|
+
"autoprefixer": "^10.4.14",
|
|
62
|
+
"tailwindcss": "^3.3.2",
|
|
63
|
+
"typescript": "^5.0.2",
|
|
64
|
+
"vite": "^4.3.9",
|
|
65
|
+
"vite-plugin-dts": "^3.5.4"
|
|
54
66
|
}
|
|
55
|
-
}
|
|
67
|
+
}
|
package/README.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Webchat
|
|
2
|
-
|
|
3
|
-
### Sending
|
|
4
|
-
|
|
5
|
-
| Channels | Webchat | Details |
|
|
6
|
-
| -------- | :-----: | :------ |
|
|
7
|
-
| Text | ✅ | |
|
|
8
|
-
| Image | ✅ | |
|
|
9
|
-
| Choice | ✅ | |
|
|
10
|
-
| Dropdown | ✅ | |
|
|
11
|
-
| Card | ✅ | |
|
|
12
|
-
| Carousel | ✅ | |
|
|
13
|
-
| File | ✅ | |
|
|
14
|
-
| Audio | ✅ | |
|
|
15
|
-
| Video | ✅ | |
|
|
16
|
-
| Location | ✅ | |
|
|
17
|
-
|
|
18
|
-
### Receiving
|
|
19
|
-
|
|
20
|
-
| Channels | Webchat | Details |
|
|
21
|
-
| ------------- | :-----: | :------ |
|
|
22
|
-
| Text | ✅ | |
|
|
23
|
-
| Quick Reply | ✅ | |
|
|
24
|
-
| Postback | ✅ | |
|
|
25
|
-
| Say Something | ✅ | |
|
|
26
|
-
| Voice | ✅ | |
|
|
27
|
-
| Image | ❌ | |
|
|
28
|
-
| File | ❌ | |
|
|
29
|
-
| Audio | ❌ | |
|
|
30
|
-
| Video | ❌ | |
|
|
31
|
-
| Location | ❌ | |
|
|
32
|
-
|
|
33
|
-
## Development
|
|
34
|
-
|
|
35
|
-
When working on the webchat, to see changes made to the codebase, you will need to follow the steps detailed [here](../inject/README.md). The inject script is the part that links any web page to a webchat. This is the easiest way to manually test the webchat.
|
|
36
|
-
|
|
37
|
-
## Tests
|
|
38
|
-
|
|
39
|
-
To run automated E2E tests, simply run the command `yarn test:chat [--browser <chromium | firefox | edge | electron>]` (for the list of supported browsers see: https://docs.cypress.io/guides/guides/launching-browsers#Browsers).
|
|
40
|
-
|
|
41
|
-
Tests can be found in `tests/e2e` and uses Cypress as the test framework. Configurations for Cypress can be found in the `cypress.json` file at the root of the repository.
|
|
Binary file
|
|
Binary file
|
package/assets/fonts/roboto.css
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/* cyrillic-ext */
|
|
2
|
-
@font-face {
|
|
3
|
-
font-family: 'Roboto';
|
|
4
|
-
font-style: normal;
|
|
5
|
-
font-weight: 400;
|
|
6
|
-
font-display: swap;
|
|
7
|
-
src: local('Roboto'), local('Roboto-Regular'), url(roboto/roboto.woff2) format('woff2');
|
|
8
|
-
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
|
9
|
-
}
|
|
10
|
-
/* cyrillic */
|
|
11
|
-
@font-face {
|
|
12
|
-
font-family: 'Roboto';
|
|
13
|
-
font-style: normal;
|
|
14
|
-
font-weight: 400;
|
|
15
|
-
font-display: swap;
|
|
16
|
-
src: local('Roboto'), local('Roboto-Regular'), url(roboto/roboto.woff2) format('woff2');
|
|
17
|
-
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
|
18
|
-
}
|
|
19
|
-
/* greek-ext */
|
|
20
|
-
@font-face {
|
|
21
|
-
font-family: 'Roboto';
|
|
22
|
-
font-style: normal;
|
|
23
|
-
font-weight: 400;
|
|
24
|
-
font-display: swap;
|
|
25
|
-
src: local('Roboto'), local('Roboto-Regular'), url(roboto/roboto.woff2) format('woff2');
|
|
26
|
-
unicode-range: U+1F00-1FFF;
|
|
27
|
-
}
|
|
28
|
-
/* greek */
|
|
29
|
-
@font-face {
|
|
30
|
-
font-family: 'Roboto';
|
|
31
|
-
font-style: normal;
|
|
32
|
-
font-weight: 400;
|
|
33
|
-
font-display: swap;
|
|
34
|
-
src: local('Roboto'), local('Roboto-Regular'), url(roboto/roboto.woff2) format('woff2');
|
|
35
|
-
unicode-range: U+0370-03FF;
|
|
36
|
-
}
|
|
37
|
-
/* vietnamese */
|
|
38
|
-
@font-face {
|
|
39
|
-
font-family: 'Roboto';
|
|
40
|
-
font-style: normal;
|
|
41
|
-
font-weight: 400;
|
|
42
|
-
font-display: swap;
|
|
43
|
-
src: local('Roboto'), local('Roboto-Regular'), url(roboto/roboto.woff2) format('woff2');
|
|
44
|
-
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
|
|
45
|
-
}
|
|
46
|
-
/* latin-ext */
|
|
47
|
-
@font-face {
|
|
48
|
-
font-family: 'Roboto';
|
|
49
|
-
font-style: normal;
|
|
50
|
-
font-weight: 400;
|
|
51
|
-
font-display: swap;
|
|
52
|
-
src: local('Roboto'), local('Roboto-Regular'), url(roboto/roboto.woff2) format('woff2');
|
|
53
|
-
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
|
54
|
-
}
|
|
55
|
-
/* latin */
|
|
56
|
-
@font-face {
|
|
57
|
-
font-family: 'Roboto';
|
|
58
|
-
font-style: normal;
|
|
59
|
-
font-weight: 400;
|
|
60
|
-
font-display: swap;
|
|
61
|
-
src: local('Roboto'), local('Roboto-Regular'), url(roboto/roboto.woff2) format('woff2');
|
|
62
|
-
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC,
|
|
63
|
-
U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
64
|
-
}
|
|
65
|
-
/* cyrillic-ext */
|
|
66
|
-
@font-face {
|
|
67
|
-
font-family: 'Roboto';
|
|
68
|
-
font-style: normal;
|
|
69
|
-
font-weight: 500;
|
|
70
|
-
font-display: swap;
|
|
71
|
-
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/roboto500.woff2) format('woff2');
|
|
72
|
-
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
|
73
|
-
}
|
|
74
|
-
/* cyrillic */
|
|
75
|
-
@font-face {
|
|
76
|
-
font-family: 'Roboto';
|
|
77
|
-
font-style: normal;
|
|
78
|
-
font-weight: 500;
|
|
79
|
-
font-display: swap;
|
|
80
|
-
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/roboto500.woff2) format('woff2');
|
|
81
|
-
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
|
82
|
-
}
|
|
83
|
-
/* greek-ext */
|
|
84
|
-
@font-face {
|
|
85
|
-
font-family: 'Roboto';
|
|
86
|
-
font-style: normal;
|
|
87
|
-
font-weight: 500;
|
|
88
|
-
font-display: swap;
|
|
89
|
-
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/roboto500.woff2) format('woff2');
|
|
90
|
-
unicode-range: U+1F00-1FFF;
|
|
91
|
-
}
|
|
92
|
-
/* greek */
|
|
93
|
-
@font-face {
|
|
94
|
-
font-family: 'Roboto';
|
|
95
|
-
font-style: normal;
|
|
96
|
-
font-weight: 500;
|
|
97
|
-
font-display: swap;
|
|
98
|
-
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/roboto500.woff2) format('woff2');
|
|
99
|
-
unicode-range: U+0370-03FF;
|
|
100
|
-
}
|
|
101
|
-
/* vietnamese */
|
|
102
|
-
@font-face {
|
|
103
|
-
font-family: 'Roboto';
|
|
104
|
-
font-style: normal;
|
|
105
|
-
font-weight: 500;
|
|
106
|
-
font-display: swap;
|
|
107
|
-
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/roboto500.woff2) format('woff2');
|
|
108
|
-
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB;
|
|
109
|
-
}
|
|
110
|
-
/* latin-ext */
|
|
111
|
-
@font-face {
|
|
112
|
-
font-family: 'Roboto';
|
|
113
|
-
font-style: normal;
|
|
114
|
-
font-weight: 500;
|
|
115
|
-
font-display: swap;
|
|
116
|
-
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/roboto500.woff2) format('woff2');
|
|
117
|
-
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
|
118
|
-
}
|
|
119
|
-
/* latin */
|
|
120
|
-
@font-face {
|
|
121
|
-
font-family: 'Roboto';
|
|
122
|
-
font-style: normal;
|
|
123
|
-
font-weight: 500;
|
|
124
|
-
font-display: swap;
|
|
125
|
-
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/roboto500.woff2) format('woff2');
|
|
126
|
-
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC,
|
|
127
|
-
U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
|
128
|
-
}
|
package/assets/notification.mp3
DELETED
|
Binary file
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const mobx_1 = require("mobx");
|
|
16
|
-
const mobx_react_1 = require("mobx-react");
|
|
17
|
-
const react_1 = __importDefault(require("react"));
|
|
18
|
-
const react_intl_1 = require("react-intl");
|
|
19
|
-
const ToolTip_1 = __importDefault(require("./common/ToolTip"));
|
|
20
|
-
const VoiceRecorder_1 = __importDefault(require("./VoiceRecorder"));
|
|
21
|
-
class Composer extends react_1.default.Component {
|
|
22
|
-
constructor(props) {
|
|
23
|
-
super(props);
|
|
24
|
-
this.focus = () => {
|
|
25
|
-
setTimeout(() => {
|
|
26
|
-
var _a;
|
|
27
|
-
(_a = this.textInput.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
28
|
-
}, 50);
|
|
29
|
-
};
|
|
30
|
-
this.handleKeyPress = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
if (e.key === 'Enter') {
|
|
32
|
-
e.preventDefault();
|
|
33
|
-
yield this.props.sendMessage();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
this.handleKeyDown = (e) => {
|
|
37
|
-
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
|
38
|
-
this.props.recallHistory(e.key);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
this.handleMessageChanged = (e) => this.props.updateMessage(e.target.value);
|
|
42
|
-
this.isLastMessageFromBot = () => {
|
|
43
|
-
var _a, _b, _c, _d;
|
|
44
|
-
return ((_d = (_c = (_b = (_a = this.props.currentConversation) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b.slice(-1)) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.authorId) === undefined;
|
|
45
|
-
};
|
|
46
|
-
this.onVoiceStart = () => {
|
|
47
|
-
this.setState({ isRecording: true });
|
|
48
|
-
};
|
|
49
|
-
this.onVoiceEnd = (voice, ext) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
this.setState({ isRecording: false });
|
|
51
|
-
yield this.props.sendVoiceMessage(voice, ext);
|
|
52
|
-
});
|
|
53
|
-
this.onVoiceNotAvailable = () => {
|
|
54
|
-
console.warn('Voice input is not available on this browser. Please check https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder for compatibility');
|
|
55
|
-
};
|
|
56
|
-
this.textInput = react_1.default.createRef();
|
|
57
|
-
this.state = { isRecording: false };
|
|
58
|
-
}
|
|
59
|
-
componentDidMount() {
|
|
60
|
-
this.focus();
|
|
61
|
-
(0, mobx_1.observe)(this.props.focusedArea, (focus) => {
|
|
62
|
-
var _a;
|
|
63
|
-
focus.newValue === 'input' && ((_a = this.textInput.current) === null || _a === void 0 ? void 0 : _a.focus());
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
componentWillReceiveProps(newProps) {
|
|
67
|
-
// Focus on the composer when it's unlocked
|
|
68
|
-
if (this.props.composerLocked === true && newProps.composerLocked === false) {
|
|
69
|
-
this.focus();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
render() {
|
|
73
|
-
if (this.props.composerHidden) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
const placeholder = this.props.composerPlaceholder ||
|
|
77
|
-
this.props.intl.formatMessage({
|
|
78
|
-
id: this.isLastMessageFromBot() ? 'composer.placeholder' : 'composer.placeholderInit'
|
|
79
|
-
}, { name: this.props.botName });
|
|
80
|
-
return (react_1.default.createElement("div", { role: "region", className: 'bpw-composer' },
|
|
81
|
-
react_1.default.createElement("div", { className: 'bpw-composer-inner' },
|
|
82
|
-
react_1.default.createElement("textarea", { ref: this.textInput, id: "input-message", onFocus: this.props.setFocus.bind(this, 'input'), placeholder: placeholder, onChange: this.handleMessageChanged, value: this.props.message, onKeyPress: this.handleKeyPress, onKeyDown: this.handleKeyDown, "aria-label": this.props.intl.formatMessage({
|
|
83
|
-
id: 'composer.message',
|
|
84
|
-
defaultMessage: 'Message to send'
|
|
85
|
-
}), disabled: this.props.composerLocked }),
|
|
86
|
-
react_1.default.createElement("label", { htmlFor: "input-message", style: { display: 'none' } }, placeholder),
|
|
87
|
-
react_1.default.createElement("div", { className: 'bpw-send-buttons' },
|
|
88
|
-
this.props.enableVoiceComposer && (react_1.default.createElement(VoiceRecorder_1.default, { onStart: this.onVoiceStart, onDone: this.onVoiceEnd, onNotAvailable: this.onVoiceNotAvailable })),
|
|
89
|
-
react_1.default.createElement(ToolTip_1.default, { childId: "btn-send", content: this.props.intl.formatMessage({
|
|
90
|
-
id: 'composer.sendMessage',
|
|
91
|
-
defaultMessage: 'Send Message'
|
|
92
|
-
}) },
|
|
93
|
-
react_1.default.createElement("button", { className: 'bpw-send-button', disabled: !this.props.message.length || this.props.composerLocked || this.state.isRecording, onClick: this.props.sendMessage.bind(this, undefined), "aria-label": this.props.intl.formatMessage({
|
|
94
|
-
id: 'composer.send',
|
|
95
|
-
defaultMessage: 'Send'
|
|
96
|
-
}), id: "btn-send" },
|
|
97
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: 'composer.send' })))))));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
101
|
-
enableVoiceComposer: store.config.enableVoiceComposer,
|
|
102
|
-
message: store.composer.message,
|
|
103
|
-
composerLocked: store.composer.locked,
|
|
104
|
-
composerHidden: store.composer.hidden,
|
|
105
|
-
composerPlaceholder: store.composer.composerPlaceholder,
|
|
106
|
-
updateMessage: store.composer.updateMessage,
|
|
107
|
-
recallHistory: store.composer.recallHistory,
|
|
108
|
-
intl: store.intl,
|
|
109
|
-
sendMessage: store.sendMessage,
|
|
110
|
-
sendVoiceMessage: store.sendVoiceMessage,
|
|
111
|
-
botName: store.botName,
|
|
112
|
-
setFocus: store.view.setFocus,
|
|
113
|
-
focusedArea: store.view.focusedArea,
|
|
114
|
-
focusPrevious: store.view.focusPrevious,
|
|
115
|
-
focusNext: store.view.focusNext,
|
|
116
|
-
currentConversation: store.currentConversation,
|
|
117
|
-
preferredLanguage: store.preferredLanguage
|
|
118
|
-
}))((0, react_intl_1.injectIntl)((0, mobx_react_1.observer)(Composer)));
|