@botpress/webchat 0.2.5 → 0.3.2
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/README.md +31 -0
- package/assets/fonts/roboto/roboto.woff2 +0 -0
- package/assets/fonts/roboto/roboto500.woff2 +0 -0
- package/assets/fonts/roboto.css +128 -0
- package/assets/notification.mp3 +0 -0
- package/dist/components/Composer.d.ts +4 -5
- package/dist/components/Composer.js +16 -25
- package/dist/components/Container.js +1 -4
- package/dist/components/ConversationList.d.ts +1 -1
- package/dist/components/ConversationList.js +5 -46
- package/dist/components/Header.d.ts +1 -3
- package/dist/components/Header.js +7 -37
- package/dist/components/common/BotInfo/index.d.ts +1 -1
- package/dist/components/common/BotInfo/index.js +4 -14
- package/dist/components/messages/InlineFeedback.d.ts +2 -1
- package/dist/components/messages/Message.js +3 -6
- package/dist/components/messages/MessageGroup.d.ts +1 -5
- package/dist/components/messages/MessageGroup.js +4 -7
- package/dist/components/messages/MessageList.d.ts +1 -1
- package/dist/components/messages/MessageList.js +7 -29
- package/dist/core/api.d.ts +2 -6
- package/dist/core/api.js +4 -32
- package/dist/core/constants.d.ts +4 -32
- package/dist/core/constants.js +18 -32
- package/dist/core/socket.d.ts +1 -7
- package/dist/core/socket.js +8 -30
- package/dist/index.d.ts +2 -8
- package/dist/index.js +6 -27
- package/dist/main.d.ts +2 -2
- package/dist/main.js +84 -135
- package/dist/store/composer.js +1 -1
- package/dist/store/index.d.ts +4 -8
- package/dist/store/index.js +25 -62
- package/dist/store/view.d.ts +3 -4
- package/dist/store/view.js +6 -13
- package/dist/translations/index.d.ts +2 -1
- package/dist/translations/index.js +36 -1
- package/dist/typings.d.ts +123 -55
- package/dist/utils/analytics.d.ts +5 -0
- package/dist/utils/analytics.js +37 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +27 -0
- package/package.json +6 -5
- package/dist/components/ContextMenu.d.ts +0 -2
- package/dist/components/ContextMenu.js +0 -24
- package/dist/components/OverridableComponent.d.ts +0 -24
- package/dist/components/OverridableComponent.js +0 -50
- package/dist/components/Stylesheet.d.ts +0 -5
- package/dist/components/Stylesheet.js +0 -7
- package/dist/components/common/MoreOptions/index.d.ts +0 -21
- package/dist/components/common/MoreOptions/index.js +0 -60
- package/dist/components/common/Overlay/index.d.ts +0 -7
- package/dist/components/common/Overlay/index.js +0 -36
- package/dist/icons/CloseChat.d.ts +0 -6
- package/dist/icons/CloseChat.js +0 -9
- package/dist/icons/Send.d.ts +0 -6
- package/dist/icons/Send.js +0 -8
- package/dist/utils.d.ts +0 -8
- package/dist/utils.js +0 -111
|
@@ -1,60 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const core_1 = require("@blueprintjs/core");
|
|
26
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
27
|
-
const react_1 = __importStar(require("react"));
|
|
28
|
-
const Overlay_1 = __importDefault(require("../Overlay"));
|
|
29
|
-
const style = __importStar(require("./style.module.scss"));
|
|
30
|
-
const MoreOptions = (props) => {
|
|
31
|
-
const { show, onToggle, className, items, element } = props;
|
|
32
|
-
const handleToggle = (e) => {
|
|
33
|
-
e.stopPropagation();
|
|
34
|
-
onToggle(!show);
|
|
35
|
-
};
|
|
36
|
-
const onAction = (e, action) => {
|
|
37
|
-
e.stopPropagation();
|
|
38
|
-
onToggle(false);
|
|
39
|
-
action();
|
|
40
|
-
};
|
|
41
|
-
return (react_1.default.createElement(react_1.Fragment, null,
|
|
42
|
-
!element && (react_1.default.createElement("button", { onClick: handleToggle, type: "button", className: (0, classnames_1.default)(style.moreBtn, 'more-options-btn', { [style.active]: show }) },
|
|
43
|
-
react_1.default.createElement("span", { className: style.moreBtnDots }))),
|
|
44
|
-
element,
|
|
45
|
-
show && (react_1.default.createElement("ul", { className: (0, classnames_1.default)(style.moreMenu, 'more-options-more-menu', className) }, items.map((item, index) => {
|
|
46
|
-
const { action, className, content, icon, label, type, selected } = item;
|
|
47
|
-
return (react_1.default.createElement("li", { key: index, className: className }, content ? (content) : (react_1.default.createElement(react_1.Fragment, null,
|
|
48
|
-
action && (react_1.default.createElement(core_1.Button, { icon: icon, minimal: true, className: (0, classnames_1.default)(style.moreMenuItem, {
|
|
49
|
-
[style.delete]: type === 'delete',
|
|
50
|
-
['more-options-selected-option']: selected
|
|
51
|
-
}), onClick: (e) => onAction(e, action) },
|
|
52
|
-
label,
|
|
53
|
-
selected && react_1.default.createElement(core_1.Icon, { icon: "tick", iconSize: 12 }))),
|
|
54
|
-
!action && (react_1.default.createElement("span", { className: (0, classnames_1.default)(style.moreMenuItem, style.noHover, { [style.delete]: type === 'delete' }) },
|
|
55
|
-
react_1.default.createElement(core_1.Icon, { icon: icon, iconSize: 16 }),
|
|
56
|
-
label))))));
|
|
57
|
-
}))),
|
|
58
|
-
show && react_1.default.createElement(Overlay_1.default, { onClick: handleToggle })));
|
|
59
|
-
};
|
|
60
|
-
exports.default = MoreOptions;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
export interface OverlayProps {
|
|
3
|
-
onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
4
|
-
onContextMenu?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
5
|
-
}
|
|
6
|
-
declare const Overlay: FC<OverlayProps>;
|
|
7
|
-
export default Overlay;
|
|
@@ -1,36 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const react_1 = __importDefault(require("react"));
|
|
26
|
-
const style = __importStar(require("./style.module.scss"));
|
|
27
|
-
const Overlay = ({ onClick, onContextMenu }) => (react_1.default.createElement("div", { onContextMenu: (e) => {
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
e.persist();
|
|
30
|
-
if (!onContextMenu) {
|
|
31
|
-
onClick(e);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
onContextMenu(e);
|
|
35
|
-
}, className: style.overlay, onClick: onClick }));
|
|
36
|
-
exports.default = Overlay;
|
package/dist/icons/CloseChat.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
exports.default = ({ height = 17, width = 17 }) => (react_1.default.createElement("i", null,
|
|
8
|
-
react_1.default.createElement("svg", { width: width, height: height, viewBox: "0 0 17 17", xmlns: "http://www.w3.org/2000/svg" },
|
|
9
|
-
react_1.default.createElement("path", { d: "M16.726 15.402c.365.366.365.96 0 1.324-.178.178-.416.274-.663.274-.246 0-.484-.096-.663-.274L8.323 9.648h.353L1.6 16.726c-.177.178-.416.274-.663.274-.246 0-.484-.096-.663-.274-.365-.365-.365-.958 0-1.324L7.35 8.324v.35L.275 1.6C-.09 1.233-.09.64.274.274c.367-.365.96-.365 1.326 0l7.076 7.078h-.353L15.4.274c.366-.365.96-.365 1.326 0 .365.366.365.958 0 1.324L9.65 8.675v-.35l7.076 7.077z", fill: "#FFF", fillRule: "evenodd" }))));
|
package/dist/icons/Send.d.ts
DELETED
package/dist/icons/Send.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
exports.default = ({ height = 16, width = 16 }) => (react_1.default.createElement("svg", { width: width, height: height, xmlns: "http://www.w3.org/2000/svg" },
|
|
8
|
-
react_1.default.createElement("path", { d: "M15.398 9.01l-13.87 6.865c-.536.267-1.176.081-1.422-.427A.953.953 0 010 15v-4.838l8.67-2.168L0 5.923V1.001C0 .47.407 0 1.004 0c.169 0 .416.04.567.116L15.403 7.07a1.084 1.084 0 01-.005 1.939z", fill: "#000", fillRule: "evenodd" })));
|
package/dist/utils.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const isIE: boolean;
|
|
2
|
-
export declare const downloadFile: (name: string, blob: Blob) => void;
|
|
3
|
-
export declare const checkLocationOrigin: () => void;
|
|
4
|
-
export declare const initializeAnalytics: () => void;
|
|
5
|
-
export declare const trackMessage: (direction: 'sent' | 'received') => void;
|
|
6
|
-
export declare const trackWebchatState: (state: 'show' | 'hide' | 'toggle') => void;
|
|
7
|
-
export declare const renderUnsafeHTML: (message: string | undefined, escaped: boolean) => string;
|
|
8
|
-
export declare const isRTLLocale: (locale: string | undefined | null) => boolean;
|
package/dist/utils.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isRTLLocale = exports.renderUnsafeHTML = exports.trackWebchatState = exports.trackMessage = exports.initializeAnalytics = exports.checkLocationOrigin = exports.downloadFile = exports.isIE = void 0;
|
|
7
|
-
const react_ga_1 = __importDefault(require("react-ga"));
|
|
8
|
-
const snarkdown_1 = __importDefault(require("snarkdown"));
|
|
9
|
-
exports.isIE = window.navigator.userAgent.match(/MSIE|Trident/) !== null;
|
|
10
|
-
const downloadFile = (name, blob) => {
|
|
11
|
-
const url = window.URL.createObjectURL(blob);
|
|
12
|
-
const link = document.createElement('a');
|
|
13
|
-
link.href = url;
|
|
14
|
-
link.setAttribute('download', name);
|
|
15
|
-
document.body.appendChild(link);
|
|
16
|
-
link.click();
|
|
17
|
-
document.body.removeChild(link);
|
|
18
|
-
window.URL.revokeObjectURL(url);
|
|
19
|
-
};
|
|
20
|
-
exports.downloadFile = downloadFile;
|
|
21
|
-
const checkLocationOrigin = () => {
|
|
22
|
-
if (!window.location.origin) {
|
|
23
|
-
const { protocol, hostname, port } = window.location;
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
window.location.origin = `${protocol}//${hostname}${port && `:${port}`}`;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
exports.checkLocationOrigin = checkLocationOrigin;
|
|
29
|
-
// TODO: does analytics still work?
|
|
30
|
-
const initializeAnalytics = () => {
|
|
31
|
-
if (window.SEND_USAGE_STATS) {
|
|
32
|
-
try {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
react_ga_1.default.initialize('UA-90044826-2', {
|
|
35
|
-
gaOptions: {
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
userId: window.UUID
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
react_ga_1.default.pageview(window.location.pathname + window.location.search);
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
console.error('Error init analytics', err);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
exports.initializeAnalytics = initializeAnalytics;
|
|
49
|
-
const trackMessage = (direction) => {
|
|
50
|
-
if (window.SEND_USAGE_STATS) {
|
|
51
|
-
try {
|
|
52
|
-
react_ga_1.default.event({ category: 'Interactions', action: `message ${direction}` });
|
|
53
|
-
}
|
|
54
|
-
finally {
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
exports.trackMessage = trackMessage;
|
|
59
|
-
const trackWebchatState = (state) => {
|
|
60
|
-
if (window.SEND_USAGE_STATS) {
|
|
61
|
-
try {
|
|
62
|
-
react_ga_1.default.event({ category: 'Display', action: state });
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
exports.trackWebchatState = trackWebchatState;
|
|
69
|
-
const renderUnsafeHTML = (message = '', escaped) => {
|
|
70
|
-
if (escaped) {
|
|
71
|
-
message = message.replace(/</g, '<').replace(/>/g, '>');
|
|
72
|
-
}
|
|
73
|
-
const html = (0, snarkdown_1.default)(message);
|
|
74
|
-
return html.replace(/<a href/gi, '<a target="_blank" href');
|
|
75
|
-
};
|
|
76
|
-
exports.renderUnsafeHTML = renderUnsafeHTML;
|
|
77
|
-
const rtlLocales = [
|
|
78
|
-
'ae' /* Avestan */,
|
|
79
|
-
'ar' /* 'العربية', Arabic */,
|
|
80
|
-
'arc' /* Aramaic */,
|
|
81
|
-
'bcc' /* 'بلوچی مکرانی', Southern Balochi */,
|
|
82
|
-
'bqi' /* 'بختياري', Bakthiari */,
|
|
83
|
-
'ckb' /* 'Soranî / کوردی', Sorani */,
|
|
84
|
-
'dv' /* Dhivehi */,
|
|
85
|
-
'fa' /* 'فارسی', Persian */,
|
|
86
|
-
'glk' /* 'گیلکی', Gilaki */,
|
|
87
|
-
'he' /* 'עברית', Hebrew */,
|
|
88
|
-
'ku' /* 'Kurdî / كوردی', Kurdish */,
|
|
89
|
-
'mzn' /* 'مازِرونی', Mazanderani */,
|
|
90
|
-
'nqo' /* N'Ko */,
|
|
91
|
-
'pnb' /* 'پنجابی', Western Punjabi */,
|
|
92
|
-
'ps' /* 'پښتو', Pashto, */,
|
|
93
|
-
'sd' /* 'سنڌي', Sindhi */,
|
|
94
|
-
'ug' /* 'Uyghurche / ئۇيغۇرچە', Uyghur */,
|
|
95
|
-
'ur' /* 'اردو', Urdu */,
|
|
96
|
-
'yi' /* 'ייִדיש', Yiddish */
|
|
97
|
-
];
|
|
98
|
-
// 'en-US' becomes ['en', '-us'] 'en' becomes ['en']
|
|
99
|
-
const localeRegex = /^([a-zA-Z]*)([_\-a-zA-Z]*)$/;
|
|
100
|
-
const isRTLLocale = (locale) => {
|
|
101
|
-
if (!locale) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
locale = locale.toLowerCase();
|
|
105
|
-
const matches = localeRegex.exec(locale);
|
|
106
|
-
if (!matches) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return rtlLocales.includes(matches[1]);
|
|
110
|
-
};
|
|
111
|
-
exports.isRTLLocale = isRTLLocale;
|