@telia-ace/widget-conversation 1.0.12 → 1.0.15
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/LICENSE.txt +5 -5
- package/README.md +256 -256
- package/{lib-esm → dist}/agent.d.ts +17 -17
- package/{lib-esm → dist}/conversation-controller.d.ts +88 -88
- package/{lib-esm → dist}/conversation-form-adapter.d.ts +7 -7
- package/{lib-esm → dist}/conversation-platform.d.ts +50 -49
- package/{lib-esm → dist}/conversation-provider.d.ts +22 -22
- package/dist/conversation.js +558 -0
- package/dist/conversation.js.map +1 -0
- package/{lib → dist}/index.d.ts +9 -9
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/index2.js +1678 -0
- package/dist/index2.js.map +1 -0
- package/{lib-esm → dist}/resolve-entity-value.d.ts +10 -10
- package/dist/return-button.js +174 -0
- package/dist/return-button.js.map +1 -0
- package/{lib → dist}/types.d.ts +110 -110
- package/{lib-esm → dist}/ui/conversation/conversation-component.d.ts +37 -37
- package/{lib → dist}/ui/conversation/conversation-content.d.ts +12 -11
- package/{lib-esm → dist}/ui/conversation/conversation-input.d.ts +6 -6
- package/{lib → dist}/ui/conversation/conversation-loader.d.ts +8 -8
- package/{lib → dist}/ui/conversation/conversation-message.d.ts +7 -7
- package/{lib-esm → dist}/ui/conversation/conversation-styles.d.ts +11 -11
- package/{lib → dist}/ui/conversation/conversation.d.ts +6 -6
- package/{lib → dist}/ui/conversation/index.d.ts +3 -2
- package/{lib-esm → dist}/ui/conversation/message-types/agent.d.ts +11 -11
- package/{lib → dist}/ui/conversation/message-types/custom-message-list-item.d.ts +9 -9
- package/{lib → dist}/ui/conversation/message-types/custom.d.ts +9 -9
- package/{lib → dist}/ui/conversation/message-types/index.d.ts +5 -5
- package/{lib-esm → dist}/ui/conversation/message-types/system.d.ts +12 -12
- package/{lib → dist}/ui/conversation/message-types/timestamp.d.ts +8 -8
- package/{lib-esm → dist}/ui/conversation/message-types/user.d.ts +8 -8
- package/dist/ui/index.d.ts +2 -0
- package/{lib-esm → dist}/ui/return-button/index.d.ts +2 -2
- package/{lib → dist}/ui/return-button/return-button-component.d.ts +19 -19
- package/{lib → dist}/ui/return-button/return-button.d.ts +6 -6
- package/{lib → dist}/user.d.ts +7 -7
- package/{lib-esm → dist}/utils/custom-message.d.ts +3 -3
- package/{lib-esm → dist}/utils/index.d.ts +1 -1
- package/{lib-esm → dist}/utils/open-chat-widget.d.ts +4 -4
- package/package.json +15 -16
- package/lib/agent.d.ts +0 -17
- package/lib/agent.js +0 -37
- package/lib/conversation-controller.d.ts +0 -88
- package/lib/conversation-controller.js +0 -318
- package/lib/conversation-form-adapter.d.ts +0 -7
- package/lib/conversation-form-adapter.js +0 -88
- package/lib/conversation-platform.d.ts +0 -49
- package/lib/conversation-platform.js +0 -295
- package/lib/conversation-provider.d.ts +0 -22
- package/lib/conversation-provider.js +0 -73
- package/lib/index.js +0 -17
- package/lib/resolve-entity-value.d.ts +0 -10
- package/lib/resolve-entity-value.js +0 -22
- package/lib/types.js +0 -19
- package/lib/ui/conversation/conversation-component.d.ts +0 -37
- package/lib/ui/conversation/conversation-component.js +0 -152
- package/lib/ui/conversation/conversation-content.js +0 -240
- package/lib/ui/conversation/conversation-input.d.ts +0 -6
- package/lib/ui/conversation/conversation-input.js +0 -163
- package/lib/ui/conversation/conversation-loader.js +0 -18
- package/lib/ui/conversation/conversation-message.js +0 -141
- package/lib/ui/conversation/conversation-styles.d.ts +0 -11
- package/lib/ui/conversation/conversation-styles.js +0 -65
- package/lib/ui/conversation/conversation.js +0 -139
- package/lib/ui/conversation/index.js +0 -7
- package/lib/ui/conversation/message-types/agent.d.ts +0 -11
- package/lib/ui/conversation/message-types/agent.js +0 -54
- package/lib/ui/conversation/message-types/custom-message-list-item.js +0 -27
- package/lib/ui/conversation/message-types/custom.js +0 -50
- package/lib/ui/conversation/message-types/index.js +0 -16
- package/lib/ui/conversation/message-types/system.d.ts +0 -12
- package/lib/ui/conversation/message-types/system.js +0 -26
- package/lib/ui/conversation/message-types/timestamp.js +0 -36
- package/lib/ui/conversation/message-types/user.d.ts +0 -8
- package/lib/ui/conversation/message-types/user.js +0 -24
- package/lib/ui/index.d.ts +0 -2
- package/lib/ui/index.js +0 -10
- package/lib/ui/return-button/index.d.ts +0 -2
- package/lib/ui/return-button/index.js +0 -7
- package/lib/ui/return-button/return-button-component.js +0 -70
- package/lib/ui/return-button/return-button.js +0 -82
- package/lib/user.js +0 -16
- package/lib/utils/custom-message.d.ts +0 -3
- package/lib/utils/custom-message.js +0 -56
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -7
- package/lib/utils/open-chat-widget.d.ts +0 -4
- package/lib/utils/open-chat-widget.js +0 -148
- package/lib-esm/agent.js +0 -34
- package/lib-esm/conversation-controller.js +0 -314
- package/lib-esm/conversation-form-adapter.js +0 -85
- package/lib-esm/conversation-platform.js +0 -292
- package/lib-esm/conversation-provider.js +0 -70
- package/lib-esm/index.d.ts +0 -9
- package/lib-esm/index.js +0 -6
- package/lib-esm/resolve-entity-value.js +0 -18
- package/lib-esm/types.d.ts +0 -110
- package/lib-esm/types.js +0 -16
- package/lib-esm/ui/conversation/conversation-component.js +0 -127
- package/lib-esm/ui/conversation/conversation-content.d.ts +0 -11
- package/lib-esm/ui/conversation/conversation-content.js +0 -212
- package/lib-esm/ui/conversation/conversation-input.js +0 -138
- package/lib-esm/ui/conversation/conversation-loader.d.ts +0 -8
- package/lib-esm/ui/conversation/conversation-loader.js +0 -13
- package/lib-esm/ui/conversation/conversation-message.d.ts +0 -7
- package/lib-esm/ui/conversation/conversation-message.js +0 -113
- package/lib-esm/ui/conversation/conversation-styles.js +0 -39
- package/lib-esm/ui/conversation/conversation.d.ts +0 -6
- package/lib-esm/ui/conversation/conversation.js +0 -111
- package/lib-esm/ui/conversation/index.d.ts +0 -2
- package/lib-esm/ui/conversation/index.js +0 -2
- package/lib-esm/ui/conversation/message-types/agent.js +0 -25
- package/lib-esm/ui/conversation/message-types/custom-message-list-item.d.ts +0 -9
- package/lib-esm/ui/conversation/message-types/custom-message-list-item.js +0 -22
- package/lib-esm/ui/conversation/message-types/custom.d.ts +0 -9
- package/lib-esm/ui/conversation/message-types/custom.js +0 -25
- package/lib-esm/ui/conversation/message-types/index.d.ts +0 -5
- package/lib-esm/ui/conversation/message-types/index.js +0 -5
- package/lib-esm/ui/conversation/message-types/system.js +0 -20
- package/lib-esm/ui/conversation/message-types/timestamp.d.ts +0 -8
- package/lib-esm/ui/conversation/message-types/timestamp.js +0 -31
- package/lib-esm/ui/conversation/message-types/user.js +0 -19
- package/lib-esm/ui/index.d.ts +0 -2
- package/lib-esm/ui/index.js +0 -2
- package/lib-esm/ui/return-button/index.js +0 -2
- package/lib-esm/ui/return-button/return-button-component.d.ts +0 -19
- package/lib-esm/ui/return-button/return-button-component.js +0 -44
- package/lib-esm/ui/return-button/return-button.d.ts +0 -6
- package/lib-esm/ui/return-button/return-button.js +0 -54
- package/lib-esm/user.d.ts +0 -7
- package/lib-esm/user.js +0 -13
- package/lib-esm/utils/custom-message.js +0 -52
- package/lib-esm/utils/index.js +0 -1
- package/lib-esm/utils/open-chat-widget.js +0 -142
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
-
if (mod && mod.__esModule) return mod;
|
|
24
|
-
var result = {};
|
|
25
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
-
__setModuleDefault(result, mod);
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
30
|
-
var t = {};
|
|
31
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
32
|
-
t[p] = s[p];
|
|
33
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
34
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
35
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
36
|
-
t[p[i]] = s[p[i]];
|
|
37
|
-
}
|
|
38
|
-
return t;
|
|
39
|
-
};
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
// import { Component } from '@telia-ace/widget-types-grid';
|
|
45
|
-
var widget_ui_1 = require("@telia-ace/widget-ui");
|
|
46
|
-
var react_1 = __importDefault(require("react"));
|
|
47
|
-
var styled_components_1 = __importStar(require("styled-components"));
|
|
48
|
-
var ReturnButton = function (_a) {
|
|
49
|
-
var className = _a.className, other = __rest(_a, ["className"]);
|
|
50
|
-
var _b = (0, widget_ui_1.useProperties)(), label = _b.label, active = _b.active, _c = _b.mode, mode = _c === void 0 ? 'flat' : _c, _d = _b.alert, alert = _d === void 0 ? {} : _d;
|
|
51
|
-
var symbol = alert.symbol, alertLabel = alert.label, showAlert = alert.show;
|
|
52
|
-
// const [showAlert, setShowAlert] = useState(show);
|
|
53
|
-
var dispatch = (0, widget_ui_1.useDispatch)();
|
|
54
|
-
if (!active) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return (react_1.default.createElement(StyledHighlightedButton, { className: className, mode: mode, "aria-label": label, onClick: function () {
|
|
58
|
-
dispatch('toggle');
|
|
59
|
-
} },
|
|
60
|
-
react_1.default.createElement(StyledLabel, null, label),
|
|
61
|
-
symbol && (react_1.default.createElement(StyledIconHolder, { showAlert: showAlert },
|
|
62
|
-
react_1.default.createElement(widget_ui_1.SymbolBadge, { symbol: symbol, title: alertLabel, size: 20 })))));
|
|
63
|
-
};
|
|
64
|
-
var FlashingColorAnimation = function (props) {
|
|
65
|
-
var _a, _b, _c;
|
|
66
|
-
return (0, styled_components_1.keyframes)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% {\n background-color: ", ";\n }\n 50% {\n background-color: ", ";\n }\n 100 {\n background-color: ", ";\n }\n"], ["\n 0% {\n background-color: ", ";\n }\n 50% {\n background-color: ", ";\n }\n 100 {\n background-color: ", ";\n }\n"])), (_a = props.theme.colors) === null || _a === void 0 ? void 0 : _a.primary, (_b = props.theme.colors) === null || _b === void 0 ? void 0 : _b.accent, (_c = props.theme.colors) === null || _c === void 0 ? void 0 : _c.primary);
|
|
67
|
-
};
|
|
68
|
-
var ScrollingGradientAnimation = function (props) { return (0, styled_components_1.keyframes)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n 0% {\n background-position:0% 51%\n }\n 50% {\n background-position:100% 0%\n }\n 100% {\n background-position:0% 51%\n }\n"], ["\n 0% {\n background-position:0% 51%\n }\n 50% {\n background-position:100% 0%\n }\n 100% {\n background-position:0% 51%\n }\n"]))); };
|
|
69
|
-
var PulsatingIcon = (0, styled_components_1.keyframes)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n 0% {\n transform: rotate(0deg) scale(1.00);\n }\n 50% {\n transform: rotate(0deg) scale(1.00);\n }\n 55% {\n transform: rotate(-3deg) scale(0.80);\n }\n 60% {\n transform: rotate(-3deg) scale(0.80);\n }\n 65% {\n transform: rotate(3deg) scale(1.20);\n }\n 70% {\n transform: rotate(-3deg) scale(1.20);\n }\n 75% {\n transform: rotate(3deg) scale(1.20);\n }\n 80% {\n transform: rotate(-3deg) scale(1.20);\n }\n 85% {\n transform: rotate(3deg) scale(1.20);\n }\n 90% {\n transform: rotate(-3deg) scale(1.20);\n }\n 95% {\n transform: rotate(3deg) scale(1.20);\n }\n 100% {\n transform: rotate(0deg) scale(1);\n }\n"], ["\n 0% {\n transform: rotate(0deg) scale(1.00);\n }\n 50% {\n transform: rotate(0deg) scale(1.00);\n }\n 55% {\n transform: rotate(-3deg) scale(0.80);\n }\n 60% {\n transform: rotate(-3deg) scale(0.80);\n }\n 65% {\n transform: rotate(3deg) scale(1.20);\n }\n 70% {\n transform: rotate(-3deg) scale(1.20);\n }\n 75% {\n transform: rotate(3deg) scale(1.20);\n }\n 80% {\n transform: rotate(-3deg) scale(1.20);\n }\n 85% {\n transform: rotate(3deg) scale(1.20);\n }\n 90% {\n transform: rotate(-3deg) scale(1.20);\n }\n 95% {\n transform: rotate(3deg) scale(1.20);\n }\n 100% {\n transform: rotate(0deg) scale(1);\n }\n"])));
|
|
70
|
-
var StyledIconHolder = styled_components_1.default.span(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n flex-grow: 0;\n transform: translateX(", ");\n opacity: ", ";\n transition: transform 0.5s ease, opacity 0.3s ease;\n"], ["\n flex-grow: 0;\n transform: translateX(", ");\n opacity: ", ";\n transition: transform 0.5s ease, opacity 0.3s ease;\n"])), function (p) { return (p.showAlert ? '0px' : '50px'); }, function (p) { return (p.showAlert ? 1 : 0); });
|
|
71
|
-
var StyledLabel = styled_components_1.default.span(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n flex: 1;\n font-weight: 300;\n"], ["\n flex: 1;\n font-weight: 300;\n"])));
|
|
72
|
-
var flashingStyle = (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n animation: ", " 1s ease infinite;\n"], ["\n animation: ", " 1s ease infinite;\n"])), FlashingColorAnimation);
|
|
73
|
-
var flashingGradientStyle = (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background: linear-gradient(\n 155deg,\n ", ",\n ", "\n );\n background-position: 0px 0px;\n background-size: 200% 200%;\n animation: ", " 1.5s ease infinite;\n"], ["\n background: linear-gradient(\n 155deg,\n ", ",\n ", "\n );\n background-position: 0px 0px;\n background-size: 200% 200%;\n animation: ", " 1.5s ease infinite;\n"])), function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.accent; }, ScrollingGradientAnimation);
|
|
74
|
-
var StyledHighlightedButton = (0, styled_components_1.default)(widget_ui_1.Button)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n overflow: hidden;\n padding: ", ";\n border-radius: ", ";\n color: ", ";\n ", "\n background-color: ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n i,\n svg {\n animation: ", " 3s ease infinite;\n }\n\n &:focus {\n ", "\n background: ", ";\n color: ", ";\n }\n"], ["\n overflow: hidden;\n padding: ", ";\n border-radius: ", ";\n color: ", ";\n ", "\n background-color: ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n i,\n svg {\n animation: ", " 3s ease infinite;\n }\n\n &:focus {\n ", "\n background: ", ";\n color: ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, function (p) { return p.theme.borderRadius; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) {
|
|
75
|
-
return p.mode === 'flashing'
|
|
76
|
-
? flashingStyle
|
|
77
|
-
: p.mode === 'flashingGradient'
|
|
78
|
-
? flashingGradientStyle
|
|
79
|
-
: '';
|
|
80
|
-
}, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, PulsatingIcon, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && widget_ui_1.borderTabStyle; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; });
|
|
81
|
-
exports.default = ReturnButton;
|
|
82
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
package/lib/user.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.User = void 0;
|
|
4
|
-
var conversation_controller_1 = require("./conversation-controller");
|
|
5
|
-
var User = /** @class */ (function () {
|
|
6
|
-
function User(controller) {
|
|
7
|
-
var _this = this;
|
|
8
|
-
this.controller = controller;
|
|
9
|
-
this.print = function (settings) {
|
|
10
|
-
var normalized = (0, conversation_controller_1.getNormalizedMessageSettings)(settings);
|
|
11
|
-
return _this.controller.createEntry(normalized.key, normalized.content, conversation_controller_1.ConversationMessageType.User, undefined, normalized.timestamp);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
return User;
|
|
15
|
-
}());
|
|
16
|
-
exports.User = User;
|
|
@@ -1,56 +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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.registerCustomMessageComponent = void 0;
|
|
40
|
-
var react_1 = require("react");
|
|
41
|
-
var __1 = require("..");
|
|
42
|
-
var registerCustomMessageComponent = function (container, type, component) {
|
|
43
|
-
return container.getAsync('componentResolver').then(function (o) { return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
-
var platform;
|
|
45
|
-
return __generator(this, function (_a) {
|
|
46
|
-
switch (_a.label) {
|
|
47
|
-
case 0: return [4 /*yield*/, __1.ConversationPlatform.getInstance(container)];
|
|
48
|
-
case 1:
|
|
49
|
-
platform = _a.sent();
|
|
50
|
-
platform.addSubscription(o.registerComponent(type, (0, react_1.lazy)(function () { return component; })));
|
|
51
|
-
return [2 /*return*/];
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}); });
|
|
55
|
-
};
|
|
56
|
-
exports.registerCustomMessageComponent = registerCustomMessageComponent;
|
package/lib/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { navigateToConversation, openChatWidget, shouldPreventDefault } from './open-chat-widget';
|
package/lib/utils/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shouldPreventDefault = exports.openChatWidget = exports.navigateToConversation = void 0;
|
|
4
|
-
var open_chat_widget_1 = require("./open-chat-widget");
|
|
5
|
-
Object.defineProperty(exports, "navigateToConversation", { enumerable: true, get: function () { return open_chat_widget_1.navigateToConversation; } });
|
|
6
|
-
Object.defineProperty(exports, "openChatWidget", { enumerable: true, get: function () { return open_chat_widget_1.openChatWidget; } });
|
|
7
|
-
Object.defineProperty(exports, "shouldPreventDefault", { enumerable: true, get: function () { return open_chat_widget_1.shouldPreventDefault; } });
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Container } from '@webprovisions/platform';
|
|
2
|
-
export declare const shouldPreventDefault: (container: Container) => boolean;
|
|
3
|
-
export declare const openChatWidget: (container: Container, contactMethod: any, triggerDOMTarget?: HTMLElement | undefined) => boolean | Promise<void> | Promise<boolean>;
|
|
4
|
-
export declare const navigateToConversation: (container: Container, contactMethod: any, routeName?: string) => any;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.navigateToConversation = exports.openChatWidget = exports.shouldPreventDefault = void 0;
|
|
4
|
-
var widget_plugins_1 = require("@telia-ace/widget-plugins");
|
|
5
|
-
var widget_services_1 = require("@telia-ace/widget-services");
|
|
6
|
-
var __1 = require("../");
|
|
7
|
-
var getParentWidget = function (widgetName, implementation) {
|
|
8
|
-
var mainWidgetName = widgetName.split('_contact');
|
|
9
|
-
return implementation.widgets.get(mainWidgetName[0]);
|
|
10
|
-
};
|
|
11
|
-
var getSeparateWidget = function (container) {
|
|
12
|
-
var originWidget = container.get('$widget');
|
|
13
|
-
var _a = container.get('$widget'), name = _a.name, implementation = _a.implementation;
|
|
14
|
-
var mainWidget = name.indexOf('_contact') > -1 ? getParentWidget(name, implementation) : originWidget;
|
|
15
|
-
var data = container.get('$settings').data;
|
|
16
|
-
var trigger = mainWidget.container.get('$settings').trigger;
|
|
17
|
-
var chatWidgetName = "".concat(name
|
|
18
|
-
.replace('_contact-method', '')
|
|
19
|
-
.replace('_contact', ''), "_contact-method");
|
|
20
|
-
var chatWidget = implementation.widgets.get(chatWidgetName);
|
|
21
|
-
if (chatWidget && !trigger) {
|
|
22
|
-
return { chatWidget: chatWidget, mainWidget: mainWidget, data: data };
|
|
23
|
-
}
|
|
24
|
-
return { mainWidget: mainWidget, data: data };
|
|
25
|
-
};
|
|
26
|
-
var shouldPreventDefault = function (container) {
|
|
27
|
-
var chatWidget = getSeparateWidget(container).chatWidget;
|
|
28
|
-
return !!chatWidget;
|
|
29
|
-
};
|
|
30
|
-
exports.shouldPreventDefault = shouldPreventDefault;
|
|
31
|
-
var openChatWidget = function (container, contactMethod /*ContactMethodType*/, triggerDOMTarget) {
|
|
32
|
-
var _a = getSeparateWidget(container), mainWidget = _a.mainWidget, data = _a.data, chatWidget = _a.chatWidget;
|
|
33
|
-
if (chatWidget) {
|
|
34
|
-
if (chatWidget.state === 'activated') {
|
|
35
|
-
return chatWidget.invoke('open').then(function () {
|
|
36
|
-
chatWidget.container.getAsync('conversation').then(function (conversation) {
|
|
37
|
-
conversation
|
|
38
|
-
.navigateToConversationIfActive(contactMethod.id)
|
|
39
|
-
.then(function () { return (0, widget_plugins_1.closeAllModals)(container); });
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return chatWidget
|
|
44
|
-
.activate()
|
|
45
|
-
.then(function () {
|
|
46
|
-
var trigger = chatWidget.container.get('$settings').trigger;
|
|
47
|
-
trigger.action = 'hide'; // could be default in configuration
|
|
48
|
-
return chatWidget
|
|
49
|
-
.invoke('setSettings', function () { return ({
|
|
50
|
-
data: data,
|
|
51
|
-
trigger: trigger,
|
|
52
|
-
activate: true,
|
|
53
|
-
}); })
|
|
54
|
-
.then(function () {
|
|
55
|
-
return chatWidget.container
|
|
56
|
-
.getAsync('components')
|
|
57
|
-
.then(function (components) {
|
|
58
|
-
/**
|
|
59
|
-
* Could cause issues if target widget is no longer as specific for this use case
|
|
60
|
-
*/
|
|
61
|
-
var contactMethodsQuery = components
|
|
62
|
-
.components()
|
|
63
|
-
.ofType('contact-method');
|
|
64
|
-
components.write({
|
|
65
|
-
key: 'setContactMethodId',
|
|
66
|
-
attributes: {
|
|
67
|
-
properties: {
|
|
68
|
-
id: contactMethod.id,
|
|
69
|
-
guideId: contactMethod.guideId,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
target: contactMethodsQuery,
|
|
73
|
-
provider: 'localStorage',
|
|
74
|
-
});
|
|
75
|
-
var conversationsQuery = components
|
|
76
|
-
.components()
|
|
77
|
-
.ofType('conversation');
|
|
78
|
-
components.write({
|
|
79
|
-
key: 'setConversationProvider',
|
|
80
|
-
attributes: {
|
|
81
|
-
properties: { providers: [contactMethod.clientName] },
|
|
82
|
-
},
|
|
83
|
-
target: conversationsQuery,
|
|
84
|
-
provider: 'localStorage',
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
})
|
|
89
|
-
.then(function () {
|
|
90
|
-
return chatWidget.invoke('attach', {
|
|
91
|
-
key: 'contact-method',
|
|
92
|
-
triggerDOMElement: triggerDOMTarget,
|
|
93
|
-
withRenderState: 'open',
|
|
94
|
-
});
|
|
95
|
-
})
|
|
96
|
-
.then(function () {
|
|
97
|
-
(0, widget_services_1.createStorageWriter)(chatWidget.container, 'activeStickyWidget', widget_services_1.StorageCategory.Necessary, {
|
|
98
|
-
medium: widget_services_1.StorageMedium.Local,
|
|
99
|
-
scope: widget_services_1.StorageScope.Implementation,
|
|
100
|
-
}).then(function (write) { return write(chatWidget.name); });
|
|
101
|
-
return chatWidget.container
|
|
102
|
-
.getAsync('conversation')
|
|
103
|
-
.then(function (platform) {
|
|
104
|
-
platform.setConversationEndedBehavior(__1.ConversationEndedBehavior.Deactivate);
|
|
105
|
-
})
|
|
106
|
-
.then(function () { return (0, widget_plugins_1.closeAllModals)(container); })
|
|
107
|
-
.then(function () { return false; });
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
mainWidget.container.getAsync('conversation').then(function (platform) {
|
|
111
|
-
return platform
|
|
112
|
-
.navigateToConversationIfActive(contactMethod.id)
|
|
113
|
-
.then(function () { return platform.setConversationEndedBehavior(__1.ConversationEndedBehavior.Navigate); });
|
|
114
|
-
});
|
|
115
|
-
return chatWidget ? false : true;
|
|
116
|
-
};
|
|
117
|
-
exports.openChatWidget = openChatWidget;
|
|
118
|
-
var navigateToConversation = function (container, contactMethod /*ContactMethodType*/, routeName) {
|
|
119
|
-
if (routeName === void 0) { routeName = 'conversation'; }
|
|
120
|
-
var _a = getSeparateWidget(container), mainWidget = _a.mainWidget, chatWidget = _a.chatWidget;
|
|
121
|
-
if (chatWidget) {
|
|
122
|
-
return chatWidget.container.getAsync('router').then(function (router) {
|
|
123
|
-
router.navigate(routeName, { id: contactMethod.id });
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
return mainWidget.container.getAsync('conversation').then(function (platform) {
|
|
127
|
-
var _a;
|
|
128
|
-
(_a = platform.setConversationEndedBehavior(__1.ConversationEndedBehavior.Navigate)) === null || _a === void 0 ? void 0 : _a.then(function () {
|
|
129
|
-
mainWidget.container.getAsync('router').then(function (router) {
|
|
130
|
-
mainWidget.container
|
|
131
|
-
.getAsync('components')
|
|
132
|
-
.then(function (components) {
|
|
133
|
-
var conversationQuery = components.components().ofType('conversation');
|
|
134
|
-
components.write({
|
|
135
|
-
key: 'setConversationProvider',
|
|
136
|
-
attributes: { properties: { providers: [contactMethod.clientName] } },
|
|
137
|
-
target: conversationQuery,
|
|
138
|
-
provider: 'localStorage',
|
|
139
|
-
});
|
|
140
|
-
})
|
|
141
|
-
.then(function () {
|
|
142
|
-
router.navigate(routeName, { id: contactMethod.id });
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
exports.navigateToConversation = navigateToConversation;
|
package/lib-esm/agent.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ConversationMessageType, getNormalizedMessageSettings, } from './conversation-controller';
|
|
2
|
-
var Agent = /** @class */ (function () {
|
|
3
|
-
function Agent(provider, settings) {
|
|
4
|
-
var _this = this;
|
|
5
|
-
this.provider = provider;
|
|
6
|
-
this.print = function (settings) {
|
|
7
|
-
var sender = { name: _this.name, avatar: _this.avatar };
|
|
8
|
-
var normalized = getNormalizedMessageSettings(settings);
|
|
9
|
-
return _this.provider.createEntry(normalized.key, normalized.content, ConversationMessageType.Agent, sender, normalized.timestamp);
|
|
10
|
-
};
|
|
11
|
-
this.typing = function () {
|
|
12
|
-
return _this.provider.setTypingState({ name: _this.name, avatar: _this.avatar });
|
|
13
|
-
};
|
|
14
|
-
this.name = settings.name;
|
|
15
|
-
this.avatar = settings.avatar;
|
|
16
|
-
}
|
|
17
|
-
Agent.prototype.update = function (settings) {
|
|
18
|
-
var name = settings.name, avatar = settings.avatar;
|
|
19
|
-
if (avatar === null) {
|
|
20
|
-
this.avatar = undefined;
|
|
21
|
-
}
|
|
22
|
-
else if (avatar) {
|
|
23
|
-
this.avatar = avatar;
|
|
24
|
-
}
|
|
25
|
-
if (name === null) {
|
|
26
|
-
this.name = undefined;
|
|
27
|
-
}
|
|
28
|
-
else if (name) {
|
|
29
|
-
this.name = name;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
return Agent;
|
|
33
|
-
}());
|
|
34
|
-
export { Agent };
|