@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
package/dist/store/index.js
CHANGED
|
@@ -24,12 +24,12 @@ const is_valid_1 = __importDefault(require("date-fns/is_valid"));
|
|
|
24
24
|
const merge_1 = __importDefault(require("lodash/merge"));
|
|
25
25
|
const mobx_1 = require("mobx");
|
|
26
26
|
const api_1 = __importDefault(require("../core/api"));
|
|
27
|
+
const main_1 = require("../main");
|
|
27
28
|
const translations_1 = require("../translations");
|
|
28
29
|
const utils_1 = require("../utils");
|
|
29
30
|
const composer_1 = __importDefault(require("./composer"));
|
|
30
31
|
const view_1 = __importDefault(require("./view"));
|
|
31
|
-
translations_1.
|
|
32
|
-
const chosenLocale = translations_1.getUserLocale();
|
|
32
|
+
const chosenLocale = (0, translations_1.getUserLocale)();
|
|
33
33
|
class RootStore {
|
|
34
34
|
constructor(options, config) {
|
|
35
35
|
this.conversations = [];
|
|
@@ -66,14 +66,10 @@ class RootStore {
|
|
|
66
66
|
}
|
|
67
67
|
get botAvatarUrl() {
|
|
68
68
|
var _a, _b, _c;
|
|
69
|
-
return ((
|
|
70
|
-
((_c = this.config) === null || _c === void 0 ? void 0 : _c.avatarUrl) ||
|
|
71
|
-
(this.config.isEmulator
|
|
72
|
-
? `${window.ROOT_PATH}/assets/modules/channel-web/images/emulator-default.svg`
|
|
73
|
-
: undefined));
|
|
69
|
+
return ((_b = (_a = this.botInfo) === null || _a === void 0 ? void 0 : _a.details) === null || _b === void 0 ? void 0 : _b.avatarUrl) || ((_c = this.config) === null || _c === void 0 ? void 0 : _c.avatarUrl) || undefined;
|
|
74
70
|
}
|
|
75
71
|
get rtl() {
|
|
76
|
-
return utils_1.isRTLLocale(this.preferredLanguage);
|
|
72
|
+
return (0, utils_1.isRTLLocale)(this.preferredLanguage);
|
|
77
73
|
}
|
|
78
74
|
get escapeHTML() {
|
|
79
75
|
var _a, _b;
|
|
@@ -94,6 +90,14 @@ class RootStore {
|
|
|
94
90
|
updateMessages(messages) {
|
|
95
91
|
this.currentConversation.messages = messages;
|
|
96
92
|
}
|
|
93
|
+
updateLastMessage(conversationId, message) {
|
|
94
|
+
for (const conversation of this.conversations) {
|
|
95
|
+
if (conversation.id === conversationId) {
|
|
96
|
+
conversation.lastMessage = message;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
97
101
|
clearMessages() {
|
|
98
102
|
this.currentConversation.messages = [];
|
|
99
103
|
}
|
|
@@ -144,10 +148,10 @@ class RootStore {
|
|
|
144
148
|
return;
|
|
145
149
|
}
|
|
146
150
|
let start = new Date();
|
|
147
|
-
if (is_before_1.default(start, this.currentConversation.typingUntil)) {
|
|
151
|
+
if ((0, is_before_1.default)(start, this.currentConversation.typingUntil)) {
|
|
148
152
|
start = this.currentConversation.typingUntil;
|
|
149
153
|
}
|
|
150
|
-
this.currentConversation.typingUntil = new Date(+start + event.timeInMs);
|
|
154
|
+
this.currentConversation.typingUntil = new Date(+start + (event.timeInMs || main_1.DEFAULT_TYPING_DELAY));
|
|
151
155
|
this._startTypingTimer();
|
|
152
156
|
});
|
|
153
157
|
}
|
|
@@ -157,7 +161,7 @@ class RootStore {
|
|
|
157
161
|
try {
|
|
158
162
|
yield this.fetchConversations();
|
|
159
163
|
yield this.fetchConversation(this.config.conversationId);
|
|
160
|
-
mobx_1.runInAction('-> setInitialized', () => {
|
|
164
|
+
(0, mobx_1.runInAction)('-> setInitialized', () => {
|
|
161
165
|
this.isInitialized = true;
|
|
162
166
|
this.postMessage('webchatReady');
|
|
163
167
|
});
|
|
@@ -167,13 +171,12 @@ class RootStore {
|
|
|
167
171
|
yield this.createConversation();
|
|
168
172
|
}
|
|
169
173
|
yield this.fetchPreferences();
|
|
170
|
-
yield this.sendUserVisit();
|
|
171
174
|
});
|
|
172
175
|
}
|
|
173
176
|
fetchBotInfo() {
|
|
174
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
178
|
const botInfo = yield this.api.fetchBotInfo();
|
|
176
|
-
mobx_1.runInAction('-> setBotInfo', () => {
|
|
179
|
+
(0, mobx_1.runInAction)('-> setBotInfo', () => {
|
|
177
180
|
this.botInfo = botInfo;
|
|
178
181
|
});
|
|
179
182
|
this.mergeConfig({
|
|
@@ -189,7 +192,7 @@ class RootStore {
|
|
|
189
192
|
if (!preferences.language) {
|
|
190
193
|
return;
|
|
191
194
|
}
|
|
192
|
-
mobx_1.runInAction('-> setPreferredLanguage', () => {
|
|
195
|
+
(0, mobx_1.runInAction)('-> setPreferredLanguage', () => {
|
|
193
196
|
this.updateBotUILanguage(preferences.language);
|
|
194
197
|
});
|
|
195
198
|
});
|
|
@@ -198,7 +201,7 @@ class RootStore {
|
|
|
198
201
|
fetchConversations() {
|
|
199
202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
203
|
const conversations = yield this.api.fetchConversations();
|
|
201
|
-
mobx_1.runInAction('-> setConversations', () => {
|
|
204
|
+
(0, mobx_1.runInAction)('-> setConversations', () => {
|
|
202
205
|
if (!(conversations === null || conversations === void 0 ? void 0 : conversations.length)) {
|
|
203
206
|
this.view.showBotInfo();
|
|
204
207
|
}
|
|
@@ -218,7 +221,7 @@ class RootStore {
|
|
|
218
221
|
conversation.messages = conversation.messages.sort((a, b) => new Date(a.sentOn).getTime() - new Date(b.sentOn).getTime());
|
|
219
222
|
yield this.extractFeedback(conversation.messages);
|
|
220
223
|
}
|
|
221
|
-
mobx_1.runInAction('-> setConversation', () => {
|
|
224
|
+
(0, mobx_1.runInAction)('-> setConversation', () => {
|
|
222
225
|
this.currentConversation = conversation;
|
|
223
226
|
this.view.hideConversations();
|
|
224
227
|
});
|
|
@@ -237,7 +240,7 @@ class RootStore {
|
|
|
237
240
|
this.composer.updateMessage('');
|
|
238
241
|
try {
|
|
239
242
|
yield this.sendData({ type: 'text', text: userMessage });
|
|
240
|
-
utils_1.trackMessage('sent');
|
|
243
|
+
(0, utils_1.trackMessage)('sent');
|
|
241
244
|
this.composer.addMessageToHistory(userMessage);
|
|
242
245
|
}
|
|
243
246
|
catch (e) {
|
|
@@ -257,6 +260,7 @@ class RootStore {
|
|
|
257
260
|
createConversation() {
|
|
258
261
|
return __awaiter(this, void 0, void 0, function* () {
|
|
259
262
|
const newId = yield this.api.createConversation();
|
|
263
|
+
yield this.api.startConversation();
|
|
260
264
|
yield this.fetchConversations();
|
|
261
265
|
yield this.fetchConversation(newId);
|
|
262
266
|
return newId;
|
|
@@ -276,21 +280,12 @@ class RootStore {
|
|
|
276
280
|
return this.api.resetSession(this.currentConversationId);
|
|
277
281
|
});
|
|
278
282
|
}
|
|
279
|
-
sendUserVisit() {
|
|
280
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
281
|
-
yield this.sendData({
|
|
282
|
-
type: 'visit',
|
|
283
|
-
text: 'User visit',
|
|
284
|
-
timezone: -(new Date().getTimezoneOffset() / 60),
|
|
285
|
-
language: translations_1.getUserLocale()
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
283
|
extractFeedback(messages) {
|
|
290
284
|
return __awaiter(this, void 0, void 0, function* () {
|
|
291
285
|
const feedbackMessageIds = messages.filter((x) => x.payload && x.payload.collectFeedback).map((x) => x.id);
|
|
292
|
-
|
|
293
|
-
|
|
286
|
+
// TODO: store feedback somewhere
|
|
287
|
+
const feedbackInfo = feedbackMessageIds.map((x) => ({ messageId: x, feedback: 1 }));
|
|
288
|
+
(0, mobx_1.runInAction)('-> setFeedbackInfo', () => {
|
|
294
289
|
this.messageFeedbacks = feedbackInfo;
|
|
295
290
|
});
|
|
296
291
|
});
|
|
@@ -305,7 +300,7 @@ class RootStore {
|
|
|
305
300
|
try {
|
|
306
301
|
const { txt, name } = yield this.api.downloadConversation(this.currentConversationId);
|
|
307
302
|
const blobFile = new Blob([txt]);
|
|
308
|
-
utils_1.downloadFile(name, blobFile);
|
|
303
|
+
(0, utils_1.downloadFile)(name, blobFile);
|
|
309
304
|
}
|
|
310
305
|
catch (err) {
|
|
311
306
|
console.error('Error trying to download conversation');
|
|
@@ -325,7 +320,8 @@ class RootStore {
|
|
|
325
320
|
return this.api.sendEvent(data, this.currentConversationId)
|
|
326
321
|
}
|
|
327
322
|
*/
|
|
328
|
-
yield this.api.sendMessage(data, this.currentConversationId);
|
|
323
|
+
const message = yield this.api.sendMessage(data, this.currentConversationId);
|
|
324
|
+
this.updateLastMessage(this.currentConversationId, message);
|
|
329
325
|
});
|
|
330
326
|
}
|
|
331
327
|
uploadFile(title, payload, file) {
|
|
@@ -341,7 +337,7 @@ class RootStore {
|
|
|
341
337
|
}
|
|
342
338
|
/** Use this method to replace a value or add a new config */
|
|
343
339
|
mergeConfig(config) {
|
|
344
|
-
this.config = merge_1.default(this.config, config);
|
|
340
|
+
this.config = (0, merge_1.default)(this.config, config);
|
|
345
341
|
this._applyConfig();
|
|
346
342
|
}
|
|
347
343
|
/** This replaces all the configurations by this object */
|
|
@@ -363,7 +359,7 @@ class RootStore {
|
|
|
363
359
|
else if (window.USE_SESSION_STORAGE !== this.config.useSessionStorage) {
|
|
364
360
|
console.warn('[WebChat] "useSessionStorage" value cannot be altered once the webchat is initialized');
|
|
365
361
|
}
|
|
366
|
-
const locale = this.config.locale ? translations_1.getUserLocale(this.config.locale) : chosenLocale;
|
|
362
|
+
const locale = this.config.locale ? (0, translations_1.getUserLocale)(this.config.locale) : chosenLocale;
|
|
367
363
|
this.updateBotUILanguage(locale);
|
|
368
364
|
document.documentElement.setAttribute('lang', locale);
|
|
369
365
|
this.publishConfigChanged();
|
|
@@ -395,7 +391,7 @@ class RootStore {
|
|
|
395
391
|
this.isBotTyping.set(true);
|
|
396
392
|
this._typingInterval = setInterval(() => {
|
|
397
393
|
const typeUntil = new Date(this.currentConversation && this.currentConversation.typingUntil);
|
|
398
|
-
if (!typeUntil || !is_valid_1.default(typeUntil) || is_before_1.default(typeUntil, new Date())) {
|
|
394
|
+
if (!typeUntil || !(0, is_valid_1.default)(typeUntil) || (0, is_before_1.default)(typeUntil, new Date())) {
|
|
399
395
|
this._expireTyping();
|
|
400
396
|
}
|
|
401
397
|
else {
|
|
@@ -411,8 +407,8 @@ class RootStore {
|
|
|
411
407
|
this._typingInterval = undefined;
|
|
412
408
|
}
|
|
413
409
|
updateBotUILanguage(lang) {
|
|
414
|
-
lang = translations_1.getUserLocale(lang); // Ensure language is supported
|
|
415
|
-
mobx_1.runInAction('-> setBotUILanguage', () => {
|
|
410
|
+
lang = (0, translations_1.getUserLocale)(lang); // Ensure language is supported
|
|
411
|
+
(0, mobx_1.runInAction)('-> setBotUILanguage', () => {
|
|
416
412
|
var _a;
|
|
417
413
|
this.botUILanguage = lang;
|
|
418
414
|
this.preferredLanguage = lang;
|
|
@@ -422,7 +418,7 @@ class RootStore {
|
|
|
422
418
|
emptyDelayedMessagesQueue(removeAll) {
|
|
423
419
|
while (this.delayedMessages.length) {
|
|
424
420
|
const message = this.delayedMessages[0];
|
|
425
|
-
if (removeAll || is_before_1.default(message.showAt, new Date())) {
|
|
421
|
+
if (removeAll || (0, is_before_1.default)(message.showAt, new Date())) {
|
|
426
422
|
this.currentConversation.messages.push(message.message);
|
|
427
423
|
this.delayedMessages.shift();
|
|
428
424
|
}
|
|
@@ -517,6 +513,9 @@ __decorate([
|
|
|
517
513
|
__decorate([
|
|
518
514
|
mobx_1.action.bound
|
|
519
515
|
], RootStore.prototype, "updateMessages", null);
|
|
516
|
+
__decorate([
|
|
517
|
+
mobx_1.action.bound
|
|
518
|
+
], RootStore.prototype, "updateLastMessage", null);
|
|
520
519
|
__decorate([
|
|
521
520
|
mobx_1.action.bound
|
|
522
521
|
], RootStore.prototype, "clearMessages", null);
|
|
@@ -565,9 +564,6 @@ __decorate([
|
|
|
565
564
|
__decorate([
|
|
566
565
|
mobx_1.action.bound
|
|
567
566
|
], RootStore.prototype, "resetSession", null);
|
|
568
|
-
__decorate([
|
|
569
|
-
mobx_1.action.bound
|
|
570
|
-
], RootStore.prototype, "sendUserVisit", null);
|
|
571
567
|
__decorate([
|
|
572
568
|
mobx_1.action.bound
|
|
573
569
|
], RootStore.prototype, "extractFeedback", null);
|
package/dist/store/view.js
CHANGED
|
@@ -157,7 +157,7 @@ class ViewStore {
|
|
|
157
157
|
/** Updates one or multiple properties of a specific button */
|
|
158
158
|
updateHeaderButton(buttonId, newProps) {
|
|
159
159
|
const button = this.customButtons.find((btn) => btn.id === buttonId);
|
|
160
|
-
button && merge_1.default(button, newProps);
|
|
160
|
+
button && (0, merge_1.default)(button, newProps);
|
|
161
161
|
}
|
|
162
162
|
removeHeaderButton(buttonId) {
|
|
163
163
|
this.customButtons = this.customButtons.filter((btn) => btn.id !== buttonId);
|
|
@@ -195,7 +195,7 @@ class ViewStore {
|
|
|
195
195
|
}
|
|
196
196
|
_endAnimation(finalView) {
|
|
197
197
|
setTimeout(() => {
|
|
198
|
-
mobx_1.runInAction(() => {
|
|
198
|
+
(0, mobx_1.runInAction)(() => {
|
|
199
199
|
this.activeView = finalView;
|
|
200
200
|
});
|
|
201
201
|
}, constants_1.default.ANIM_DURATION);
|
|
@@ -4,5 +4,4 @@ declare const translations: {
|
|
|
4
4
|
[lang: string]: any;
|
|
5
5
|
};
|
|
6
6
|
declare const getUserLocale: (manualLocale?: Locale) => string;
|
|
7
|
-
|
|
8
|
-
export { initializeLocale, translations, DEFAULT_LOCALE as defaultLocale, getUserLocale };
|
|
7
|
+
export { translations, DEFAULT_LOCALE as defaultLocale, getUserLocale };
|
|
@@ -3,17 +3,17 @@ 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
|
-
exports.getUserLocale = exports.defaultLocale = exports.translations =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
exports.getUserLocale = exports.defaultLocale = exports.translations = void 0;
|
|
7
|
+
require('@formatjs/intl-pluralrules/polyfill');
|
|
8
|
+
require('@formatjs/intl-pluralrules/locale-data/ar');
|
|
9
|
+
require('@formatjs/intl-pluralrules/locale-data/de');
|
|
10
|
+
require('@formatjs/intl-pluralrules/locale-data/en');
|
|
11
|
+
require('@formatjs/intl-pluralrules/locale-data/es');
|
|
12
|
+
require('@formatjs/intl-pluralrules/locale-data/fr');
|
|
13
|
+
require('@formatjs/intl-pluralrules/locale-data/it');
|
|
14
|
+
require('@formatjs/intl-pluralrules/locale-data/pt');
|
|
15
|
+
require('@formatjs/intl-pluralrules/locale-data/ru');
|
|
16
|
+
require('@formatjs/intl-pluralrules/locale-data/uk');
|
|
17
17
|
const ar_json_1 = __importDefault(require("./ar.json"));
|
|
18
18
|
const de_json_1 = __importDefault(require("./de.json"));
|
|
19
19
|
const en_json_1 = __importDefault(require("./en.json"));
|
|
@@ -53,17 +53,3 @@ const getUserLocale = (manualLocale = 'browser') => {
|
|
|
53
53
|
return translations[browserLocale] ? browserLocale : DEFAULT_LOCALE;
|
|
54
54
|
};
|
|
55
55
|
exports.getUserLocale = getUserLocale;
|
|
56
|
-
const initializeLocale = () => {
|
|
57
|
-
react_intl_1.addLocaleData([
|
|
58
|
-
...en_1.default,
|
|
59
|
-
...fr_1.default,
|
|
60
|
-
...pt_1.default,
|
|
61
|
-
...es_1.default,
|
|
62
|
-
...ar_1.default,
|
|
63
|
-
...ru_1.default,
|
|
64
|
-
...uk_1.default,
|
|
65
|
-
...de_1.default,
|
|
66
|
-
...it_1.default
|
|
67
|
-
]);
|
|
68
|
-
};
|
|
69
|
-
exports.initializeLocale = initializeLocale;
|
package/dist/typings.d.ts
CHANGED
|
@@ -206,6 +206,8 @@ export interface Config {
|
|
|
206
206
|
chatId?: string;
|
|
207
207
|
/** CSS class to be applied to iframe */
|
|
208
208
|
className?: string;
|
|
209
|
+
/** Key used to encrypt data in the localStorage */
|
|
210
|
+
encryptionKey?: string;
|
|
209
211
|
}
|
|
210
212
|
export declare type OverridableComponents = 'below_conversation' | 'before_container' | 'composer';
|
|
211
213
|
export interface Overrides {
|
|
@@ -260,7 +262,7 @@ export interface Message {
|
|
|
260
262
|
authorId: uuid | undefined;
|
|
261
263
|
sentOn: Date;
|
|
262
264
|
payload: any;
|
|
263
|
-
timeInMs
|
|
265
|
+
timeInMs?: number;
|
|
264
266
|
}
|
|
265
267
|
export interface QueuedMessage {
|
|
266
268
|
message: Message;
|
package/dist/utils.js
CHANGED
|
@@ -70,7 +70,7 @@ const renderUnsafeHTML = (message = '', escaped) => {
|
|
|
70
70
|
if (escaped) {
|
|
71
71
|
message = message.replace(/</g, '<').replace(/>/g, '>');
|
|
72
72
|
}
|
|
73
|
-
const html = snarkdown_1.default(message);
|
|
73
|
+
const html = (0, snarkdown_1.default)(message);
|
|
74
74
|
return html.replace(/<a href/gi, '<a target="_blank" href');
|
|
75
75
|
};
|
|
76
76
|
exports.renderUnsafeHTML = renderUnsafeHTML;
|
package/package.json
CHANGED
|
@@ -1,29 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/webchat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"source": "src/index.tsx",
|
|
7
7
|
"license": "AGPL-3.0",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "yarn
|
|
10
|
-
"watch": "yarn
|
|
9
|
+
"build": "yarn && yarn run -T tsc --build",
|
|
10
|
+
"watch": "yarn && yarn run -T tsc --build --watch",
|
|
11
|
+
"prepublish": "yarn run -T rimraf dist && yarn --immutable && yarn run -T tsc --build && yarn run -T rimraf dist/.tsbuildinfo"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
14
|
"dist"
|
|
14
15
|
],
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/crypto-js": "^4.1.1",
|
|
18
|
+
"@types/lodash": "^4.14.178",
|
|
19
|
+
"@types/mime": "^2.0.3",
|
|
20
|
+
"@types/node": "^16.11.13",
|
|
21
|
+
"@types/react": "^17.0.38",
|
|
22
|
+
"@types/react-dom": "^17.0.11",
|
|
23
|
+
"@types/uuid": "^8.3.4",
|
|
24
|
+
"prop-types": "^15.8.1"
|
|
25
|
+
},
|
|
15
26
|
"dependencies": {
|
|
16
27
|
"@blueprintjs/core": "^3.23.1",
|
|
17
|
-
"@botpress/messaging-
|
|
28
|
+
"@botpress/messaging-components": "0.2.0",
|
|
29
|
+
"@botpress/messaging-socket": "1.1.0",
|
|
30
|
+
"@formatjs/intl-pluralrules": "^4.1.6",
|
|
31
|
+
"@formatjs/intl-utils": "^3.8.4",
|
|
18
32
|
"@juggle/resize-observer": "^3.0.2",
|
|
33
|
+
"axios": "^0.25.0",
|
|
34
|
+
"classnames": "^2.3.1",
|
|
35
|
+
"crypto-js": "^4.1.1",
|
|
19
36
|
"date-fns": "^1.30.1",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"react
|
|
24
|
-
"react-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
37
|
+
"lodash": "^4.17.21",
|
|
38
|
+
"mime": "^3.0.0",
|
|
39
|
+
"mobx": "5.15.7",
|
|
40
|
+
"mobx-react": "^6.2.1",
|
|
41
|
+
"mobx-react-lite": "2.0.0",
|
|
42
|
+
"query-string": "^7.1.0",
|
|
43
|
+
"react": "^17.0.2",
|
|
44
|
+
"react-dom": "^17.0.2",
|
|
45
|
+
"react-ga": "^2.7.0",
|
|
46
|
+
"react-intl": "^3.12.1",
|
|
47
|
+
"snarkdown": "^2.0.0",
|
|
48
|
+
"uuid": "^8.3.2"
|
|
28
49
|
}
|
|
29
|
-
}
|
|
50
|
+
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export declare class Prepend extends React.Component<Partial<KeyboardElementsProps>> {
|
|
3
|
-
render(): JSX.Element;
|
|
4
|
-
}
|
|
5
|
-
export declare class Append extends React.Component<Partial<KeyboardElementsProps>> {
|
|
6
|
-
render(): JSX.Element;
|
|
7
|
-
}
|
|
8
|
-
export declare class Default extends React.Component<Partial<KeyboardElementsProps>> {
|
|
9
|
-
static prependRef: React.RefObject<HTMLDivElement>;
|
|
10
|
-
static appendRef: React.RefObject<HTMLDivElement>;
|
|
11
|
-
static isReady: () => boolean;
|
|
12
|
-
render(): JSX.Element;
|
|
13
|
-
}
|
|
14
|
-
interface KeyboardElementsProps {
|
|
15
|
-
/** When true, the keyboard is appended at the end. Otherwise, it is prepended */
|
|
16
|
-
append?: boolean;
|
|
17
|
-
index?: number;
|
|
18
|
-
visible?: boolean;
|
|
19
|
-
/** A keyboard can be any kind of element */
|
|
20
|
-
keyboard?: any;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
@@ -1,86 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.Default = exports.Append = exports.Prepend = void 0;
|
|
23
|
-
const React = __importStar(require("react"));
|
|
24
|
-
const ReactDOM = __importStar(require("react-dom"));
|
|
25
|
-
class KeyboardElements extends React.Component {
|
|
26
|
-
constructor(props) {
|
|
27
|
-
super(props);
|
|
28
|
-
this.container = document.createElement('div');
|
|
29
|
-
}
|
|
30
|
-
insertChildAt(child, index = 0, parent) {
|
|
31
|
-
if (index >= parent.children.length) {
|
|
32
|
-
parent.appendChild(child);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
parent.insertBefore(child, parent.children[index]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
componentDidMount() {
|
|
39
|
-
if (this.props.append) {
|
|
40
|
-
this.insertChildAt(this.container, this.props.index, Default.appendRef.current);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
this.insertChildAt(this.container, this.props.index, Default.prependRef.current);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
componentWillUnmount() {
|
|
47
|
-
var _a, _b;
|
|
48
|
-
if (this.props.append) {
|
|
49
|
-
(_a = Default.appendRef.current) === null || _a === void 0 ? void 0 : _a.removeChild(this.container);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
(_b = Default.prependRef.current) === null || _b === void 0 ? void 0 : _b.removeChild(this.container);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
render() {
|
|
56
|
-
return ReactDOM.createPortal(this.props.children, this.container);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
class Prepend extends React.Component {
|
|
60
|
-
render() {
|
|
61
|
-
return (React.createElement("div", null,
|
|
62
|
-
this.props.visible && React.createElement(KeyboardElements, { index: this.props.index }, this.props.keyboard),
|
|
63
|
-
this.props.children));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.Prepend = Prepend;
|
|
67
|
-
class Append extends React.Component {
|
|
68
|
-
render() {
|
|
69
|
-
return (React.createElement("div", null,
|
|
70
|
-
this.props.visible && React.createElement(KeyboardElements, { append: true }, this.props.keyboard),
|
|
71
|
-
this.props.children));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.Append = Append;
|
|
75
|
-
class Default extends React.Component {
|
|
76
|
-
render() {
|
|
77
|
-
return (React.createElement("div", { className: 'bpw-keyboard' },
|
|
78
|
-
React.createElement("div", { ref: Default.prependRef }),
|
|
79
|
-
this.props.children,
|
|
80
|
-
React.createElement("div", { ref: Default.appendRef })));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.Default = Default;
|
|
84
|
-
Default.prependRef = React.createRef();
|
|
85
|
-
Default.appendRef = React.createRef();
|
|
86
|
-
Default.isReady = () => Default.appendRef.current !== null;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Component } from 'react';
|
|
2
|
-
import { HTMLInputEvent, Renderer } from '../../../typings';
|
|
3
|
-
/**
|
|
4
|
-
* A simple button, with a possibility to be used as a file upload button
|
|
5
|
-
*
|
|
6
|
-
* @param {object} buttons The list of buttons to display (object with a label and a payload)
|
|
7
|
-
* @param {function} onButtonClicked Called when the button is clicked with the label and the payload
|
|
8
|
-
* @param {function} onFileUpload This is called when a file is uploaded
|
|
9
|
-
*/
|
|
10
|
-
export declare class Button extends Component<Renderer.Button> {
|
|
11
|
-
constructor(props: Renderer.Button);
|
|
12
|
-
handleButtonClick: (e: any) => void;
|
|
13
|
-
handleFileUpload: (event: HTMLInputEvent) => void;
|
|
14
|
-
renderFileUpload(accept: string): JSX.Element;
|
|
15
|
-
render(): JSX.Element;
|
|
16
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.Button = void 0;
|
|
23
|
-
const react_1 = __importStar(require("react"));
|
|
24
|
-
const FileInput_1 = require("./FileInput");
|
|
25
|
-
/**
|
|
26
|
-
* A simple button, with a possibility to be used as a file upload button
|
|
27
|
-
*
|
|
28
|
-
* @param {object} buttons The list of buttons to display (object with a label and a payload)
|
|
29
|
-
* @param {function} onButtonClicked Called when the button is clicked with the label and the payload
|
|
30
|
-
* @param {function} onFileUpload This is called when a file is uploaded
|
|
31
|
-
*/
|
|
32
|
-
class Button extends react_1.Component {
|
|
33
|
-
constructor(props) {
|
|
34
|
-
super(props);
|
|
35
|
-
this.handleButtonClick = (e) => {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
if (this.props.preventDoubleClick) {
|
|
38
|
-
e.target.disabled = true;
|
|
39
|
-
}
|
|
40
|
-
(_b = (_a = this.props).onButtonClick) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.label, this.props.payload);
|
|
41
|
-
};
|
|
42
|
-
this.handleFileUpload = (event) => {
|
|
43
|
-
var _a, _b;
|
|
44
|
-
if (!event.target.files) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
48
|
-
(_b = (_a = this.props).onFileUpload) === null || _b === void 0 ? void 0 : _b.call(_a, this.props.label, this.props.payload, event.target.files[0]);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
renderFileUpload(accept) {
|
|
52
|
-
return (react_1.default.createElement("button", { className: 'bpw-button' },
|
|
53
|
-
react_1.default.createElement("span", null, this.props.label),
|
|
54
|
-
react_1.default.createElement(FileInput_1.FileInput, { name: 'uploadField', accept: accept, className: 'bpw-file-message', placeholder: this.props.label, onFileChanged: this.handleFileUpload })));
|
|
55
|
-
}
|
|
56
|
-
render() {
|
|
57
|
-
if (this.props.payload === 'BOTPRESS.IMAGE_UPLOAD') {
|
|
58
|
-
return this.renderFileUpload('image/*');
|
|
59
|
-
}
|
|
60
|
-
if (this.props.payload === 'BOTPRESS.FILE_UPLOAD') {
|
|
61
|
-
return this.renderFileUpload('*/*');
|
|
62
|
-
}
|
|
63
|
-
return (react_1.default.createElement("button", { className: 'bpw-button', onClick: this.handleButtonClick }, this.props.label));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.Button = Button;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Renderer } from '../../../typings';
|
|
3
|
-
export declare class Carousel extends React.Component<ICarouselProps, ICarouselState> {
|
|
4
|
-
private ref;
|
|
5
|
-
state: {
|
|
6
|
-
adjustedWidth: number;
|
|
7
|
-
};
|
|
8
|
-
componentDidMount(): void;
|
|
9
|
-
renderCarousel(): JSX.Element;
|
|
10
|
-
render(): JSX.Element;
|
|
11
|
-
}
|
|
12
|
-
export declare const Card: (props: any) => JSX.Element;
|
|
13
|
-
interface ICarouselProps {
|
|
14
|
-
carousel: Renderer.Carousel;
|
|
15
|
-
onSendData: any;
|
|
16
|
-
style?: object;
|
|
17
|
-
}
|
|
18
|
-
interface ICarouselState {
|
|
19
|
-
adjustedWidth: number;
|
|
20
|
-
}
|
|
21
|
-
export {};
|