@botpress/webchat 0.0.1 → 0.2.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/dist/components/Composer.d.ts +9 -11
- package/dist/components/Composer.js +3 -3
- package/dist/components/Container.d.ts +8 -7
- package/dist/components/Container.js +6 -25
- package/dist/components/ConversationList.d.ts +6 -3
- package/dist/components/ConversationList.js +6 -4
- package/dist/components/Header.js +3 -3
- package/dist/components/OverridableComponent.js +1 -1
- package/dist/components/VoiceRecorder.js +9 -9
- package/dist/components/common/BotInfo.d.ts +6 -3
- package/dist/components/common/BotInfo.js +4 -4
- package/dist/components/messages/InlineFeedback.js +2 -2
- package/dist/components/messages/Message.d.ts +6 -3
- package/dist/components/messages/Message.js +23 -98
- package/dist/components/messages/MessageGroup.js +4 -12
- package/dist/components/messages/MessageList.d.ts +6 -3
- package/dist/components/messages/MessageList.js +8 -8
- package/dist/core/api.d.ts +1 -0
- package/dist/core/api.js +26 -6
- package/dist/core/socket.d.ts +2 -0
- package/dist/core/socket.js +29 -6
- package/dist/fonts/roboto.d.ts +4 -0
- package/dist/fonts/roboto.js +9 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +15 -11
- package/dist/main.d.ts +9 -7
- package/dist/main.js +46 -27
- package/dist/store/composer.js +2 -2
- package/dist/store/index.d.ts +4 -4
- package/dist/store/index.js +36 -40
- package/dist/store/view.js +2 -2
- package/dist/translations/index.d.ts +1 -2
- package/dist/translations/index.js +11 -25
- package/dist/typings.d.ts +3 -1
- package/dist/utils.js +1 -1
- package/package.json +34 -13
- package/dist/components/Keyboard.d.ts +0 -22
- package/dist/components/Keyboard.js +0 -86
- package/dist/components/messages/renderer/Button.d.ts +0 -16
- package/dist/components/messages/renderer/Button.js +0 -66
- package/dist/components/messages/renderer/Carousel.d.ts +0 -21
- package/dist/components/messages/renderer/Carousel.js +0 -72
- package/dist/components/messages/renderer/Dropdown.d.ts +0 -3
- package/dist/components/messages/renderer/Dropdown.js +0 -76
- package/dist/components/messages/renderer/FileInput.d.ts +0 -9
- package/dist/components/messages/renderer/FileInput.js +0 -32
- package/dist/components/messages/renderer/FileMessage.d.ts +0 -3
- package/dist/components/messages/renderer/FileMessage.js +0 -53
- package/dist/components/messages/renderer/LoginPrompt.d.ts +0 -6
- package/dist/components/messages/renderer/LoginPrompt.js +0 -98
- package/dist/components/messages/renderer/QuickReplies.d.ts +0 -18
- package/dist/components/messages/renderer/QuickReplies.js +0 -73
- package/dist/components/messages/renderer/Text.d.ts +0 -11
- package/dist/components/messages/renderer/Text.js +0 -71
- package/dist/components/messages/renderer/VoiceMessage.d.ts +0 -5
- package/dist/components/messages/renderer/VoiceMessage.js +0 -50
- package/dist/components/messages/renderer/index.d.ts +0 -8
- package/dist/components/messages/renderer/index.js +0 -19
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WrappedComponentProps } from 'react-intl';
|
|
3
3
|
import { StoreDef } from '../store';
|
|
4
|
-
declare const _default: React.
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<ComposerProps, "intl"> & {
|
|
5
|
+
forwardedRef?: React.Ref<any> | undefined;
|
|
6
|
+
} & React.RefAttributes<any>> & {
|
|
7
|
+
WrappedComponent: React.ComponentType<ComposerProps>;
|
|
8
|
+
} & import("mobx-react").IWrappedComponent<unknown>;
|
|
9
|
+
export default _default;
|
|
10
|
+
declare type ComposerProps = {
|
|
5
11
|
focused: boolean;
|
|
6
12
|
composerPlaceholder: string;
|
|
7
13
|
composerLocked: boolean;
|
|
8
14
|
composerHidden: boolean;
|
|
9
|
-
} & Pick<StoreDef,
|
|
10
|
-
WrappedComponent: React.ComponentType<{
|
|
11
|
-
focused: boolean;
|
|
12
|
-
composerPlaceholder: string;
|
|
13
|
-
composerLocked: boolean;
|
|
14
|
-
composerHidden: boolean;
|
|
15
|
-
} & Pick<StoreDef, "intl" | "message" | "composerPlaceholder" | "updateMessage" | "recallHistory" | "focusedArea" | "setFocus" | "focusPrevious" | "focusNext" | "currentConversation" | "preferredLanguage" | "botName" | "isEmulator" | "sendMessage" | "resetSession" | "sendVoiceMessage" | "enableArrowNavigation" | "enableResetSessionShortcut" | "enableVoiceComposer"> & InjectedIntlProps>;
|
|
16
|
-
} & import("mobx-react").IWrappedComponent<unknown>;
|
|
17
|
-
export default _default;
|
|
15
|
+
} & WrappedComponentProps & Pick<StoreDef, 'botName' | 'composerPlaceholder' | 'intl' | 'focusedArea' | 'sendMessage' | 'sendVoiceMessage' | 'focusPrevious' | 'focusNext' | 'recallHistory' | 'setFocus' | 'updateMessage' | 'message' | 'enableArrowNavigation' | 'resetSession' | 'isEmulator' | 'enableResetSessionShortcut' | 'enableVoiceComposer' | 'currentConversation' | 'preferredLanguage'>;
|
|
@@ -70,7 +70,7 @@ class Composer extends react_1.default.Component {
|
|
|
70
70
|
setTimeout(() => {
|
|
71
71
|
this.textInput.current.focus();
|
|
72
72
|
}, 50);
|
|
73
|
-
mobx_1.observe(this.props.focusedArea, (focus) => {
|
|
73
|
+
(0, mobx_1.observe)(this.props.focusedArea, (focus) => {
|
|
74
74
|
focus.newValue === 'input' && this.textInput.current.focus();
|
|
75
75
|
});
|
|
76
76
|
}
|
|
@@ -92,7 +92,7 @@ class Composer extends react_1.default.Component {
|
|
|
92
92
|
react_1.default.createElement("div", { className: 'bpw-send-buttons' }, this.props.enableVoiceComposer && (react_1.default.createElement(VoiceRecorder_1.default, { onStart: this.onVoiceStart, onDone: this.onVoiceEnd, onNotAvailable: this.onVoiceNotAvailable }))))));
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
exports.default = mobx_react_1.inject(({ store }) => ({
|
|
95
|
+
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
96
96
|
enableVoiceComposer: store.config.enableVoiceComposer,
|
|
97
97
|
message: store.composer.message,
|
|
98
98
|
composerLocked: store.composer.locked,
|
|
@@ -114,4 +114,4 @@ exports.default = mobx_react_1.inject(({ store }) => ({
|
|
|
114
114
|
currentConversation: store.currentConversation,
|
|
115
115
|
isEmulator: store.isEmulator,
|
|
116
116
|
preferredLanguage: store.preferredLanguage
|
|
117
|
-
}))(react_intl_1.injectIntl(mobx_react_1.observer(Composer)));
|
|
117
|
+
}))((0, react_intl_1.injectIntl)((0, mobx_react_1.observer)(Composer)));
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WrappedComponentProps } from 'react-intl';
|
|
3
3
|
import { RootStore, StoreDef } from '../store';
|
|
4
|
-
declare const _default: React.
|
|
5
|
-
|
|
6
|
-
} &
|
|
7
|
-
WrappedComponent: React.ComponentType<
|
|
8
|
-
store?: RootStore | undefined;
|
|
9
|
-
} & Pick<StoreDef, "rtl" | "isFullscreen" | "dimensions" | "isConversationsDisplayed" | "isPoweredByDisplayed" | "isBotInfoDisplayed" | "sideTransition" | "config" | "isInitialized" | "botName" | "isEmulator"> & InjectedIntlProps>;
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<ContainerProps, "intl"> & {
|
|
5
|
+
forwardedRef?: React.Ref<any> | undefined;
|
|
6
|
+
} & React.RefAttributes<any>> & {
|
|
7
|
+
WrappedComponent: React.ComponentType<ContainerProps>;
|
|
10
8
|
} & import("mobx-react").IWrappedComponent<unknown>;
|
|
11
9
|
export default _default;
|
|
10
|
+
declare type ContainerProps = {
|
|
11
|
+
store?: RootStore;
|
|
12
|
+
} & WrappedComponentProps & Pick<StoreDef, 'config' | 'botName' | 'isFullscreen' | 'isConversationsDisplayed' | 'isBotInfoDisplayed' | 'sideTransition' | 'isInitialized' | 'dimensions' | 'isEmulator' | 'isPoweredByDisplayed' | 'rtl'>;
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
4
|
};
|
|
24
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const messaging_components_1 = require("@botpress/messaging-components");
|
|
25
7
|
const classnames_1 = __importDefault(require("classnames"));
|
|
26
8
|
const mobx_react_1 = require("mobx-react");
|
|
27
9
|
const react_1 = __importDefault(require("react"));
|
|
@@ -31,7 +13,6 @@ const Composer_1 = __importDefault(require("./Composer"));
|
|
|
31
13
|
const ConversationList_1 = __importDefault(require("./ConversationList"));
|
|
32
14
|
const Footer_1 = __importDefault(require("./Footer"));
|
|
33
15
|
const Header_1 = __importDefault(require("./Header"));
|
|
34
|
-
const Keyboard = __importStar(require("./Keyboard"));
|
|
35
16
|
const MessageList_1 = __importDefault(require("./messages/MessageList"));
|
|
36
17
|
const OverridableComponent_1 = __importDefault(require("./OverridableComponent"));
|
|
37
18
|
class Container extends react_1.default.Component {
|
|
@@ -47,17 +28,17 @@ class Container extends react_1.default.Component {
|
|
|
47
28
|
return react_1.default.createElement(BotInfo_1.default, null);
|
|
48
29
|
}
|
|
49
30
|
else {
|
|
50
|
-
return (react_1.default.createElement("div", { className: classnames_1.default('bpw-msg-list-container', {
|
|
31
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('bpw-msg-list-container', {
|
|
51
32
|
'bpw-emulator': this.props.isEmulator,
|
|
52
33
|
'bpw-rtl': this.props.rtl
|
|
53
34
|
}) },
|
|
54
35
|
react_1.default.createElement(MessageList_1.default, null),
|
|
55
|
-
react_1.default.createElement(Keyboard
|
|
36
|
+
react_1.default.createElement(messaging_components_1.Keyboard, null,
|
|
56
37
|
react_1.default.createElement(OverridableComponent_1.default, { name: 'composer', original: Composer_1.default }))));
|
|
57
38
|
}
|
|
58
39
|
}
|
|
59
40
|
render() {
|
|
60
|
-
const classNames = classnames_1.default('bpw-layout', 'bpw-chat-container', {
|
|
41
|
+
const classNames = (0, classnames_1.default)('bpw-layout', 'bpw-chat-container', {
|
|
61
42
|
'bpw-layout-fullscreen': this.props.isFullscreen && 'fullscreen',
|
|
62
43
|
[`bpw-anim-${this.props.sideTransition}`]: true
|
|
63
44
|
});
|
|
@@ -70,7 +51,7 @@ class Container extends react_1.default.Component {
|
|
|
70
51
|
this.props.isPoweredByDisplayed && react_1.default.createElement(Footer_1.default, null))));
|
|
71
52
|
}
|
|
72
53
|
}
|
|
73
|
-
exports.default = mobx_react_1.inject(({ store }) => ({
|
|
54
|
+
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
74
55
|
store,
|
|
75
56
|
isConversationsDisplayed: store.view.isConversationsDisplayed,
|
|
76
57
|
isBotInfoDisplayed: store.view.isBotInfoDisplayed,
|
|
@@ -83,4 +64,4 @@ exports.default = mobx_react_1.inject(({ store }) => ({
|
|
|
83
64
|
config: store.config,
|
|
84
65
|
botName: store.botName,
|
|
85
66
|
rtl: store.rtl
|
|
86
|
-
}))(react_intl_1.injectIntl(mobx_react_1.observer(Container)));
|
|
67
|
+
}))((0, react_intl_1.injectIntl)((0, mobx_react_1.observer)(Container)));
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WrappedComponentProps } from 'react-intl';
|
|
3
3
|
import { StoreDef } from '../store';
|
|
4
|
-
declare const _default: React.
|
|
5
|
-
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<ConversationListProps, "intl"> & {
|
|
5
|
+
forwardedRef?: React.Ref<any> | undefined;
|
|
6
|
+
} & React.RefAttributes<any>> & {
|
|
7
|
+
WrappedComponent: React.ComponentType<ConversationListProps>;
|
|
6
8
|
} & import("mobx-react").IWrappedComponent<unknown>;
|
|
7
9
|
export default _default;
|
|
10
|
+
declare type ConversationListProps = WrappedComponentProps & Pick<StoreDef, 'conversations' | 'fetchConversation' | 'createConversation' | 'enableArrowNavigation'>;
|
|
@@ -3,14 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const intl_utils_1 = require("@formatjs/intl-utils");
|
|
6
7
|
const mobx_react_1 = require("mobx-react");
|
|
7
8
|
const react_1 = __importDefault(require("react"));
|
|
8
9
|
const react_intl_1 = require("react-intl");
|
|
9
10
|
const Add_1 = __importDefault(require("../icons/Add"));
|
|
10
|
-
const ConversationListItem = react_intl_1.injectIntl(({ conversation, onClick, hasFocus, intl }) => {
|
|
11
|
+
const ConversationListItem = (0, react_intl_1.injectIntl)(({ conversation, onClick, hasFocus, intl }) => {
|
|
11
12
|
var _a, _b, _c;
|
|
12
13
|
const title = intl.formatMessage({ id: 'conversationList.title' }, { id: conversation.id });
|
|
13
|
-
const
|
|
14
|
+
const { value, unit } = (0, intl_utils_1.selectUnit)(new Date(((_a = conversation.lastMessage) === null || _a === void 0 ? void 0 : _a.sentOn) || conversation.createdOn));
|
|
15
|
+
const date = intl.formatRelativeTime(value, unit);
|
|
14
16
|
const message = ((_c = (_b = conversation.lastMessage) === null || _b === void 0 ? void 0 : _b.payload) === null || _c === void 0 ? void 0 : _c.text) || '...';
|
|
15
17
|
return (react_1.default.createElement("div", { className: 'bpw-convo-item', onClick: onClick },
|
|
16
18
|
react_1.default.createElement("div", { className: 'bpw-align-right' },
|
|
@@ -72,9 +74,9 @@ class ConversationList extends react_1.default.Component {
|
|
|
72
74
|
react_1.default.createElement(Add_1.default, { width: 15, height: 15 }))));
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
exports.default = mobx_react_1.inject(({ store }) => ({
|
|
77
|
+
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
76
78
|
conversations: store.conversations,
|
|
77
79
|
createConversation: store.createConversation,
|
|
78
80
|
fetchConversation: store.fetchConversation,
|
|
79
81
|
enableArrowNavigation: store.config.enableArrowNavigation
|
|
80
|
-
}))(react_intl_1.injectIntl(mobx_react_1.observer(ConversationList)));
|
|
82
|
+
}))((0, react_intl_1.injectIntl)((0, mobx_react_1.observer)(ConversationList)));
|
|
@@ -115,7 +115,7 @@ class Header extends react_1.default.Component {
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
componentDidMount() {
|
|
118
|
-
mobx_1.observe(this.props.focusedArea, (focus) => {
|
|
118
|
+
(0, mobx_1.observe)(this.props.focusedArea, (focus) => {
|
|
119
119
|
focus.newValue === 'header' && this.changeButtonFocus(1);
|
|
120
120
|
});
|
|
121
121
|
}
|
|
@@ -198,7 +198,7 @@ class Header extends react_1.default.Component {
|
|
|
198
198
|
this.props.showCloseButton && this.renderCloseButton()));
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
exports.default = mobx_react_1.inject(({ store }) => ({
|
|
201
|
+
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
202
202
|
intl: store.intl,
|
|
203
203
|
isConversationsDisplayed: store.view.isConversationsDisplayed,
|
|
204
204
|
showDeleteConversationButton: store.view.showDeleteConversationButton,
|
|
@@ -225,4 +225,4 @@ exports.default = mobx_react_1.inject(({ store }) => ({
|
|
|
225
225
|
isEmulator: store.isEmulator,
|
|
226
226
|
botConvoDescription: store.config.botConvoDescription,
|
|
227
227
|
enableArrowNavigation: store.config.enableArrowNavigation
|
|
228
|
-
}))(mobx_react_1.observer(Header));
|
|
228
|
+
}))((0, mobx_react_1.observer)(Header));
|
|
@@ -44,7 +44,7 @@ class OverridableComponent extends react_1.default.Component {
|
|
|
44
44
|
: null;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
exports.default = mobx_react_1.inject(({ store }) => ({
|
|
47
|
+
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
48
48
|
store,
|
|
49
49
|
overrides: store.config.overrides
|
|
50
50
|
}))(OverridableComponent);
|
|
@@ -36,12 +36,12 @@ const lite_1 = __importDefault(require("mime/lite"));
|
|
|
36
36
|
const react_1 = __importStar(require("react"));
|
|
37
37
|
const VoiceRecorder = (props) => {
|
|
38
38
|
var _a;
|
|
39
|
-
const [isRecording, setIsRecording] = react_1.useState(false);
|
|
40
|
-
const mediaRecorder = react_1.useRef(null);
|
|
41
|
-
const mediaChunks = react_1.useRef([]);
|
|
42
|
-
const mediaStream = react_1.useRef(null);
|
|
43
|
-
const isCancelled = react_1.useRef(false);
|
|
44
|
-
const getMediaStream = react_1.useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const [isRecording, setIsRecording] = (0, react_1.useState)(false);
|
|
40
|
+
const mediaRecorder = (0, react_1.useRef)(null);
|
|
41
|
+
const mediaChunks = (0, react_1.useRef)([]);
|
|
42
|
+
const mediaStream = (0, react_1.useRef)(null);
|
|
43
|
+
const isCancelled = (0, react_1.useRef)(false);
|
|
44
|
+
const getMediaStream = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
45
|
var _b;
|
|
46
46
|
try {
|
|
47
47
|
const stream = yield window.navigator.mediaDevices.getUserMedia({ audio: true, video: false });
|
|
@@ -52,7 +52,7 @@ const VoiceRecorder = (props) => {
|
|
|
52
52
|
(_b = props.onNotAvailable) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
53
53
|
}
|
|
54
54
|
}), []);
|
|
55
|
-
react_1.useEffect(() => {
|
|
55
|
+
(0, react_1.useEffect)(() => {
|
|
56
56
|
return () => {
|
|
57
57
|
var _a, _b, _c, _d;
|
|
58
58
|
(_a = mediaRecorder.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('dataavailable', onResult);
|
|
@@ -127,7 +127,7 @@ const VoiceRecorder = (props) => {
|
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
129
129
|
return (react_1.default.createElement(react_1.Fragment, null,
|
|
130
|
-
isRecording && (react_1.default.createElement("button", { className: classnames_1.default('bpw-send-button', props.className), onClick: cancelRecording })),
|
|
131
|
-
react_1.default.createElement("button", { className: classnames_1.default('bpw-send-button', props.className), onClick: isRecording ? stopRecording : startRecording })));
|
|
130
|
+
isRecording && (react_1.default.createElement("button", { className: (0, classnames_1.default)('bpw-send-button', props.className), onClick: cancelRecording })),
|
|
131
|
+
react_1.default.createElement("button", { className: (0, classnames_1.default)('bpw-send-button', props.className), onClick: isRecording ? stopRecording : startRecording })));
|
|
132
132
|
};
|
|
133
133
|
exports.default = VoiceRecorder;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WrappedComponentProps } from 'react-intl';
|
|
3
3
|
import { StoreDef } from '../../store';
|
|
4
|
-
declare const _default: React.
|
|
5
|
-
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<BotInfoProps, "intl"> & {
|
|
5
|
+
forwardedRef?: React.Ref<any> | undefined;
|
|
6
|
+
} & React.RefAttributes<any>> & {
|
|
7
|
+
WrappedComponent: React.ComponentType<BotInfoProps>;
|
|
6
8
|
} & import("mobx-react").IWrappedComponent<unknown>;
|
|
7
9
|
export default _default;
|
|
10
|
+
declare type BotInfoProps = WrappedComponentProps & Pick<StoreDef, 'botInfo' | 'botName' | 'avatarUrl' | 'toggleBotInfo' | 'startConversation' | 'isConversationStarted' | 'enableArrowNavigation' | 'updatePreferredLanguage' | 'preferredLanguage' | 'escapeHTML' | 'rtl'>;
|
|
@@ -56,13 +56,13 @@ class BotInfoPage extends React.Component {
|
|
|
56
56
|
(_a = this.btnEl) === null || _a === void 0 ? void 0 : _a.focus();
|
|
57
57
|
}
|
|
58
58
|
renderDescription(text) {
|
|
59
|
-
const html = utils_1.renderUnsafeHTML(text, this.props.escapeHTML);
|
|
59
|
+
const html = (0, utils_1.renderUnsafeHTML)(text, this.props.escapeHTML);
|
|
60
60
|
return React.createElement("div", { className: 'bpw-botinfo-description', dangerouslySetInnerHTML: { __html: html } });
|
|
61
61
|
}
|
|
62
62
|
render() {
|
|
63
63
|
const { botInfo, botName, avatarUrl } = this.props;
|
|
64
64
|
const onDismiss = this.props.isConversationStarted ? this.props.toggleBotInfo : this.props.startConversation;
|
|
65
|
-
return (React.createElement("div", { className: classnames_1.default('bpw-botinfo-container', {
|
|
65
|
+
return (React.createElement("div", { className: (0, classnames_1.default)('bpw-botinfo-container', {
|
|
66
66
|
'bpw-rtl': this.props.rtl
|
|
67
67
|
}) },
|
|
68
68
|
React.createElement(CoverPicture, { botInfo: botInfo }),
|
|
@@ -96,7 +96,7 @@ class BotInfoPage extends React.Component {
|
|
|
96
96
|
React.createElement("button", { tabIndex: 1, ref: (el) => (this.btnEl = el), className: 'bpw-botinfo-start-button', onClick: onDismiss.bind(this, undefined) }, this.props.isConversationStarted ? (React.createElement(react_intl_1.FormattedMessage, { id: 'botInfo.backToConversation' })) : (React.createElement(react_intl_1.FormattedMessage, { id: 'botInfo.startConversation' })))));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
exports.default = mobx_react_1.inject(({ store }) => ({
|
|
99
|
+
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
100
100
|
botName: store.botName,
|
|
101
101
|
botInfo: store.botInfo,
|
|
102
102
|
avatarUrl: store.botAvatarUrl,
|
|
@@ -107,4 +107,4 @@ exports.default = mobx_react_1.inject(({ store }) => ({
|
|
|
107
107
|
preferredLanguage: store.preferredLanguage,
|
|
108
108
|
escapeHTML: store.escapeHTML,
|
|
109
109
|
rtl: store.rtl
|
|
110
|
-
}))(react_intl_1.injectIntl(mobx_react_1.observer(BotInfoPage)));
|
|
110
|
+
}))((0, react_intl_1.injectIntl)((0, mobx_react_1.observer)(BotInfoPage)));
|
|
@@ -27,8 +27,8 @@ const react_1 = __importStar(require("react"));
|
|
|
27
27
|
const ThumbsDown_1 = __importDefault(require("../../icons/ThumbsDown"));
|
|
28
28
|
const ThumbsUp_1 = __importDefault(require("../../icons/ThumbsUp"));
|
|
29
29
|
const InlineFeedback = ({ messageFeedbacks, messageId, onFeedback, intl }) => {
|
|
30
|
-
const [feedbackSent, setFeedbackSent] = react_1.useState(false);
|
|
31
|
-
react_1.useEffect(() => {
|
|
30
|
+
const [feedbackSent, setFeedbackSent] = (0, react_1.useState)(false);
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
32
|
if (messageFeedbacks && messageFeedbacks.find((x) => x.messageId === messageId && x.feedback != null)) {
|
|
33
33
|
setFeedbackSent(true);
|
|
34
34
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WrappedComponentProps } from 'react-intl';
|
|
3
3
|
import { StoreDef } from '../../store';
|
|
4
4
|
import { Renderer } from '../../typings';
|
|
5
|
-
declare const _default: React.
|
|
6
|
-
|
|
5
|
+
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<MessageProps, "intl"> & {
|
|
6
|
+
forwardedRef?: React.Ref<any> | undefined;
|
|
7
|
+
} & React.RefAttributes<any>> & {
|
|
8
|
+
WrappedComponent: React.ComponentType<MessageProps>;
|
|
7
9
|
} & import("mobx-react").IWrappedComponent<unknown>;
|
|
8
10
|
export default _default;
|
|
11
|
+
declare type MessageProps = Renderer.Message & WrappedComponentProps & Pick<StoreDef, 'intl'>;
|
|
@@ -31,13 +31,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
32
|
};
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
const messaging_components_1 = __importDefault(require("@botpress/messaging-components"));
|
|
34
35
|
const classnames_1 = __importDefault(require("classnames"));
|
|
35
36
|
const mobx_react_1 = require("mobx-react");
|
|
36
37
|
const react_1 = __importStar(require("react"));
|
|
37
38
|
const react_intl_1 = require("react-intl");
|
|
38
39
|
const ContextMenu_1 = require("../ContextMenu");
|
|
39
|
-
const renderer_1 = require("./renderer");
|
|
40
|
-
const Dropdown_1 = require("./renderer/Dropdown");
|
|
41
40
|
class Message extends react_1.Component {
|
|
42
41
|
constructor() {
|
|
43
42
|
super(...arguments);
|
|
@@ -46,101 +45,12 @@ class Message extends react_1.Component {
|
|
|
46
45
|
showMore: false
|
|
47
46
|
};
|
|
48
47
|
this.handleContextMenu = (e) => {
|
|
49
|
-
ContextMenu_1.showContextMenu(e, this.props);
|
|
48
|
+
(0, ContextMenu_1.showContextMenu)(e, this.props);
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
51
|
static getDerivedStateFromError(_error) {
|
|
53
52
|
return { hasError: true };
|
|
54
53
|
}
|
|
55
|
-
render_text(textMessage) {
|
|
56
|
-
const { text, markdown } = this.props.payload;
|
|
57
|
-
const message = textMessage || text;
|
|
58
|
-
return (react_1.default.createElement(renderer_1.Text, { markdown: markdown, text: message, intl: this.props.intl, maxLength: this.props.payload.trimLength, escapeHTML: this.props.store.escapeHTML }));
|
|
59
|
-
}
|
|
60
|
-
render_quick_reply() {
|
|
61
|
-
return this.render_text();
|
|
62
|
-
}
|
|
63
|
-
render_login_prompt() {
|
|
64
|
-
return (react_1.default.createElement(renderer_1.LoginPrompt, { isLastMessage: this.props.isLastGroup && this.props.isLastOfGroup, isBotMessage: this.props.isBotMessage, onSendData: this.props.onSendData }));
|
|
65
|
-
}
|
|
66
|
-
render_carousel() {
|
|
67
|
-
return react_1.default.createElement(renderer_1.Carousel, { onSendData: this.props.onSendData, carousel: this.props.payload });
|
|
68
|
-
}
|
|
69
|
-
render_typing() {
|
|
70
|
-
return (react_1.default.createElement("div", { className: 'bpw-typing-group' },
|
|
71
|
-
react_1.default.createElement("div", { className: 'bpw-typing-bubble' }),
|
|
72
|
-
react_1.default.createElement("div", { className: 'bpw-typing-bubble' }),
|
|
73
|
-
react_1.default.createElement("div", { className: 'bpw-typing-bubble' })));
|
|
74
|
-
}
|
|
75
|
-
render_audio() {
|
|
76
|
-
return react_1.default.createElement(renderer_1.FileMessage, { file: this.props.payload, escapeTextHTML: this.props.store.escapeHTML });
|
|
77
|
-
}
|
|
78
|
-
render_video() {
|
|
79
|
-
return react_1.default.createElement(renderer_1.FileMessage, { file: this.props.payload, escapeTextHTML: this.props.store.escapeHTML });
|
|
80
|
-
}
|
|
81
|
-
render_image() {
|
|
82
|
-
return react_1.default.createElement(renderer_1.FileMessage, { file: this.props.payload, escapeTextHTML: this.props.store.escapeHTML });
|
|
83
|
-
}
|
|
84
|
-
render_file() {
|
|
85
|
-
return react_1.default.createElement(renderer_1.FileMessage, { file: this.props.payload, escapeTextHTML: this.props.store.escapeHTML });
|
|
86
|
-
}
|
|
87
|
-
render_voice() {
|
|
88
|
-
return (react_1.default.createElement(renderer_1.VoiceMessage, { file: this.props.payload, shouldPlay: this.props.shouldPlay, onAudioEnded: this.props.onAudioEnded }));
|
|
89
|
-
}
|
|
90
|
-
render_custom() {
|
|
91
|
-
// This doesn't work at the moment. We can't get the InjectedModuleView
|
|
92
|
-
/*
|
|
93
|
-
const { module = undefined, component = undefined, wrapped = undefined } = this.props.payload || {}
|
|
94
|
-
if (!module || !component) {
|
|
95
|
-
return this.render_unsupported()
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// TODO: Remove eventually, it's for backward compatibility
|
|
99
|
-
if (module === 'extensions' && component === 'Dropdown') {
|
|
100
|
-
return this.render_dropdown()
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const InjectedModuleView = this.props.store!.bp.getModuleInjector()
|
|
104
|
-
|
|
105
|
-
const messageDataProps = { ...this.props.payload }
|
|
106
|
-
delete messageDataProps.module
|
|
107
|
-
delete messageDataProps.component
|
|
108
|
-
|
|
109
|
-
const sanitizedProps = pick(this.props, [
|
|
110
|
-
'messageId',
|
|
111
|
-
'isLastGroup',
|
|
112
|
-
'isLastOfGroup',
|
|
113
|
-
'isBotMessage',
|
|
114
|
-
'onSendData',
|
|
115
|
-
'onFileUpload',
|
|
116
|
-
'sentOn',
|
|
117
|
-
'store',
|
|
118
|
-
'className',
|
|
119
|
-
'intl'
|
|
120
|
-
])
|
|
121
|
-
|
|
122
|
-
const props = {
|
|
123
|
-
...sanitizedProps,
|
|
124
|
-
...messageDataProps,
|
|
125
|
-
keyboard: Keyboard,
|
|
126
|
-
children: wrapped && <Message {...sanitizedProps} keyboard={Keyboard} noBubble payload={wrapped} />
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return <InjectedModuleView moduleName={module} componentName={component} lite extraProps={props} />
|
|
130
|
-
*/
|
|
131
|
-
}
|
|
132
|
-
render_session_reset() {
|
|
133
|
-
return this.render_text(this.props.store.intl.formatMessage({ id: 'store.resetSessionMessage' }));
|
|
134
|
-
}
|
|
135
|
-
render_visit() {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
render_unsupported() {
|
|
139
|
-
return '*Unsupported message type*';
|
|
140
|
-
}
|
|
141
|
-
render_dropdown() {
|
|
142
|
-
return react_1.default.createElement(Dropdown_1.Dropdown, Object.assign({}, this.props, this.props.payload, { escapeHTML: this.props.store.escapeHTML }));
|
|
143
|
-
}
|
|
144
54
|
renderTimestamp() {
|
|
145
55
|
return (react_1.default.createElement("span", { className: "bpw-message-timestamp" }, this.props.store.intl.formatTime(new Date(this.props.sentOn), { hour: 'numeric', minute: 'numeric' })));
|
|
146
56
|
}
|
|
@@ -156,18 +66,33 @@ class Message extends react_1.Component {
|
|
|
156
66
|
}
|
|
157
67
|
const type = this.props.type || (this.props.payload && this.props.payload.type);
|
|
158
68
|
const wrappedType = this.props.payload && this.props.payload.wrapped && this.props.payload.wrapped.type;
|
|
159
|
-
const renderer = (this[`render_${type}`] || this.render_unsupported).bind(this);
|
|
160
69
|
const wrappedClass = `bpw-bubble-${wrappedType}`;
|
|
161
70
|
const isEmulator = this.props.store.config.isEmulator;
|
|
162
|
-
const rendered =
|
|
71
|
+
const rendered = (react_1.default.createElement(messaging_components_1.default, { key: this.props.messageId, content: this.props.payload, config: {
|
|
72
|
+
messageId: this.props.messageId,
|
|
73
|
+
noMessageBubble: this.props.noBubble,
|
|
74
|
+
isLastOfGroup: this.props.isLastOfGroup,
|
|
75
|
+
isLastGroup: this.props.isLastGroup,
|
|
76
|
+
isBotMessage: this.props.isBotMessage,
|
|
77
|
+
sentOn: this.props.sentOn,
|
|
78
|
+
onSendData: this.props.onSendData,
|
|
79
|
+
onFileUpload: this.props.onFileUpload,
|
|
80
|
+
store: this.props.store,
|
|
81
|
+
onAudioEnded: this.props.onAudioEnded,
|
|
82
|
+
shouldPlay: this.props.shouldPlay,
|
|
83
|
+
intl: this.props.store.intl,
|
|
84
|
+
escapeHTML: true,
|
|
85
|
+
isInEmulator: this.props.store.config.isEmulator,
|
|
86
|
+
showTimestamp: this.props.store.config.showTimestamp
|
|
87
|
+
} }));
|
|
163
88
|
if (rendered === null) {
|
|
164
89
|
return null;
|
|
165
90
|
}
|
|
166
91
|
const additionalStyle = (this.props.payload && this.props.payload['web-style']) || {};
|
|
167
92
|
if (this.props.noBubble || ((_b = (_a = this.props.payload) === null || _a === void 0 ? void 0 : _a.wrapped) === null || _b === void 0 ? void 0 : _b.noBubble)) {
|
|
168
|
-
return (react_1.default.createElement("div", { className: classnames_1.default(this.props.className, wrappedClass), style: additionalStyle }, rendered));
|
|
93
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(this.props.className, wrappedClass), style: additionalStyle }, rendered));
|
|
169
94
|
}
|
|
170
|
-
return (react_1.default.createElement("div", { className: classnames_1.default(this.props.className, wrappedClass, 'bpw-chat-bubble', `bpw-bubble-${type}`, {
|
|
95
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(this.props.className, wrappedClass, 'bpw-chat-bubble', `bpw-bubble-${type}`, {
|
|
171
96
|
'bpw-bubble-highlight': this.props.isHighlighted,
|
|
172
97
|
'bpw-msg-hovering': isEmulator
|
|
173
98
|
}), "data-from": this.props.fromLabel, onClick: () => this.onMessageClicked(), tabIndex: -1, style: additionalStyle },
|
|
@@ -181,6 +106,6 @@ class Message extends react_1.Component {
|
|
|
181
106
|
this.props.inlineFeedback));
|
|
182
107
|
}
|
|
183
108
|
}
|
|
184
|
-
exports.default = mobx_react_1.inject(({ store }) => ({
|
|
109
|
+
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
185
110
|
intl: store.intl
|
|
186
|
-
}))(react_intl_1.injectIntl(mobx_react_1.observer(Message)));
|
|
111
|
+
}))((0, react_intl_1.injectIntl)((0, mobx_react_1.observer)(Message)));
|
|
@@ -66,7 +66,7 @@ class MessageGroup extends react_1.default.Component {
|
|
|
66
66
|
if (this.state.hasError) {
|
|
67
67
|
return '* Cannot display message *';
|
|
68
68
|
}
|
|
69
|
-
return (react_1.default.createElement("div", { role: "main", className: classnames_1.default('bpw-message-big-container', {
|
|
69
|
+
return (react_1.default.createElement("div", { role: "main", className: (0, classnames_1.default)('bpw-message-big-container', {
|
|
70
70
|
'bpw-from-user': !isBot,
|
|
71
71
|
'bpw-from-bot': isBot
|
|
72
72
|
}) },
|
|
@@ -75,23 +75,15 @@ class MessageGroup extends react_1.default.Component {
|
|
|
75
75
|
showUserName && react_1.default.createElement("div", { className: 'bpw-message-username' }, userName),
|
|
76
76
|
react_1.default.createElement("div", { "aria-live": "assertive", role: "log", className: 'bpw-message-group' },
|
|
77
77
|
react_1.default.createElement("span", { "data-from": fromLabel, className: "from hidden", "aria-hidden": "true" }, fromLabel),
|
|
78
|
-
sortBy_1.default(messages, ['sent_on', 'eventId']).map((message, i, messages) => {
|
|
78
|
+
(0, sortBy_1.default)(messages, ['sent_on', 'eventId']).map((message, i, messages) => {
|
|
79
79
|
const isLastMsg = i === messages.length - 1;
|
|
80
80
|
const payload = this.convertPayloadFromOldFormat(message);
|
|
81
|
-
/*
|
|
82
|
-
// TODO: use the components package
|
|
83
|
-
if (payload?.wrapped) {
|
|
84
|
-
payload = { ...payload, wrapped: renderPayload(payload.wrapped) }
|
|
85
|
-
} else {
|
|
86
|
-
payload = renderPayload(payload)
|
|
87
|
-
}
|
|
88
|
-
*/
|
|
89
81
|
const showInlineFeedback = isBot && isLastMsg && (payload.wrapped ? payload.wrapped.collectFeedback : payload.collectFeedback);
|
|
90
|
-
return (react_1.default.createElement(Message_1.default, { key: message.id
|
|
82
|
+
return (react_1.default.createElement(Message_1.default, { key: `${message.id}-${message.payload.type}`, isHighlighted: this.props.highlightedMessages && this.props.highlightedMessages.includes(message.id), inlineFeedback: showInlineFeedback && (react_1.default.createElement(InlineFeedback_1.InlineFeedback, { intl: this.props.store.intl, messageId: message.id, onFeedback: this.props.onFeedback, messageFeedbacks: this.props.store.messageFeedbacks })), messageId: message.id, noBubble: !!payload.noBubble, fromLabel: fromLabel, isLastOfGroup: i >= this.props.messages.length - 1, isLastGroup: this.props.isLastGroup, isBotMessage: !message.authorId, payload: payload, sentOn: message.sentOn, onSendData: this.props.onSendData, onFileUpload: this.props.onFileUpload, store: this.props.store, onAudioEnded: this.onAudioEnded, shouldPlay: this.state.audioPlayingIndex === i }));
|
|
91
83
|
})))));
|
|
92
84
|
}
|
|
93
85
|
}
|
|
94
|
-
exports.default = mobx_react_1.inject(({ store }) => ({
|
|
86
|
+
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
95
87
|
store,
|
|
96
88
|
onFeedback: store.sendFeedback,
|
|
97
89
|
onSendData: store.sendData,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WrappedComponentProps } from 'react-intl';
|
|
3
3
|
import { StoreDef } from '../../store';
|
|
4
|
-
declare const _default: React.
|
|
5
|
-
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<MessageListProps, "intl"> & {
|
|
5
|
+
forwardedRef?: React.Ref<any> | undefined;
|
|
6
|
+
} & React.RefAttributes<any>> & {
|
|
7
|
+
WrappedComponent: React.ComponentType<MessageListProps>;
|
|
6
8
|
} & import("mobx-react").IWrappedComponent<unknown>;
|
|
7
9
|
export default _default;
|
|
10
|
+
declare type MessageListProps = WrappedComponentProps & Pick<StoreDef, 'intl' | 'isBotTyping' | 'focusedArea' | 'focusPrevious' | 'focusNext' | 'botAvatarUrl' | 'isEmulator' | 'botName' | 'enableArrowNavigation' | 'showUserAvatar' | 'currentMessages' | 'preferredLanguage'>;
|