@telia-ace/widget-conversation 1.0.11 → 1.0.14
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/{lib-esm → dist}/agent.d.ts +0 -0
- package/{lib-esm → dist}/conversation-controller.d.ts +0 -0
- package/{lib-esm → dist}/conversation-form-adapter.d.ts +0 -0
- package/{lib-esm → dist}/conversation-platform.d.ts +0 -0
- package/{lib-esm → dist}/conversation-provider.d.ts +0 -0
- package/dist/conversation.js +1357 -0
- package/dist/conversation.js.map +1 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +867 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/resolve-entity-value.d.ts +0 -0
- package/dist/return-button.js +174 -0
- package/dist/return-button.js.map +1 -0
- package/{lib-esm → dist}/types.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-component.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-content.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-input.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-loader.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-message.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-styles.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/agent.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/custom-message-list-item.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/custom.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/system.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/timestamp.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/user.d.ts +0 -0
- package/{lib-esm → dist}/ui/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/return-button/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/return-button/return-button-component.d.ts +0 -0
- package/{lib-esm → dist}/ui/return-button/return-button.d.ts +0 -0
- package/{lib-esm → dist}/user.d.ts +0 -0
- package/{lib-esm → dist}/utils/custom-message.d.ts +0 -0
- package/{lib-esm → dist}/utils/index.d.ts +0 -0
- package/{lib-esm → dist}/utils/open-chat-widget.d.ts +0 -0
- 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.d.ts +0 -9
- 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.d.ts +0 -110
- 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.d.ts +0 -11
- 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.d.ts +0 -8
- package/lib/ui/conversation/conversation-loader.js +0 -18
- package/lib/ui/conversation/conversation-message.d.ts +0 -7
- 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.d.ts +0 -6
- package/lib/ui/conversation/conversation.js +0 -139
- package/lib/ui/conversation/index.d.ts +0 -2
- 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.d.ts +0 -9
- package/lib/ui/conversation/message-types/custom-message-list-item.js +0 -27
- package/lib/ui/conversation/message-types/custom.d.ts +0 -9
- package/lib/ui/conversation/message-types/custom.js +0 -50
- package/lib/ui/conversation/message-types/index.d.ts +0 -5
- 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.d.ts +0 -8
- 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.d.ts +0 -19
- package/lib/ui/return-button/return-button-component.js +0 -70
- package/lib/ui/return-button/return-button.d.ts +0 -6
- package/lib/ui/return-button/return-button.js +0 -82
- package/lib/user.d.ts +0 -7
- 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.js +0 -6
- package/lib-esm/resolve-entity-value.js +0 -18
- package/lib-esm/types.js +0 -16
- package/lib-esm/ui/conversation/conversation-component.js +0 -127
- 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.js +0 -13
- 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.js +0 -111
- 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.js +0 -22
- package/lib-esm/ui/conversation/message-types/custom.js +0 -25
- 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.js +0 -31
- package/lib-esm/ui/conversation/message-types/user.js +0 -19
- 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.js +0 -44
- package/lib-esm/ui/return-button/return-button.js +0 -54
- 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,318 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.ConversationController = exports.getNormalizedMessageSettings = exports.ConversationMessageType = exports.ConversationEntry = void 0;
|
|
26
|
-
var widget_forms_1 = require("@telia-ace/widget-forms");
|
|
27
|
-
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
28
|
-
var conversation_provider_1 = require("./conversation-provider");
|
|
29
|
-
var user_1 = require("./user");
|
|
30
|
-
var ConversationEntry = /** @class */ (function () {
|
|
31
|
-
function ConversationEntry(writer) {
|
|
32
|
-
this.writer = writer;
|
|
33
|
-
}
|
|
34
|
-
ConversationEntry.prototype.update = function (content) {
|
|
35
|
-
var normalized = this.getNormalizedSettings(content);
|
|
36
|
-
// const normalized = typeof content === 'string' ? { body: content } : content;
|
|
37
|
-
this.writer(normalized);
|
|
38
|
-
};
|
|
39
|
-
ConversationEntry.prototype.remove = function () {
|
|
40
|
-
this.writer(null);
|
|
41
|
-
};
|
|
42
|
-
ConversationEntry.prototype.getNormalizedSettings = function (content) {
|
|
43
|
-
if (typeof content === 'string')
|
|
44
|
-
return { body: content };
|
|
45
|
-
else if (content.length > -1 && typeof content === 'object')
|
|
46
|
-
return { items: content };
|
|
47
|
-
else
|
|
48
|
-
return content;
|
|
49
|
-
};
|
|
50
|
-
return ConversationEntry;
|
|
51
|
-
}());
|
|
52
|
-
exports.ConversationEntry = ConversationEntry;
|
|
53
|
-
var ConversationMessageType;
|
|
54
|
-
(function (ConversationMessageType) {
|
|
55
|
-
ConversationMessageType["User"] = "user";
|
|
56
|
-
ConversationMessageType["Agent"] = "agent";
|
|
57
|
-
ConversationMessageType["System"] = "system";
|
|
58
|
-
})(ConversationMessageType = exports.ConversationMessageType || (exports.ConversationMessageType = {}));
|
|
59
|
-
var getNormalizedMessageSettings = function (settings) {
|
|
60
|
-
var content;
|
|
61
|
-
var key = (0, widget_utilities_1.uuid)();
|
|
62
|
-
var timestamp = Date.now();
|
|
63
|
-
if (Array.isArray(settings) && settings.length > -1) {
|
|
64
|
-
if (typeof settings[0] === 'string') {
|
|
65
|
-
content = { items: [settings] };
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
content = { items: settings };
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else if (typeof settings === 'string') {
|
|
72
|
-
content = { body: settings };
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
settings = settings || {};
|
|
76
|
-
if (settings.type) {
|
|
77
|
-
content = __assign({}, settings);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
content = {
|
|
81
|
-
body: settings.body,
|
|
82
|
-
actions: settings.actions,
|
|
83
|
-
title: settings.title,
|
|
84
|
-
};
|
|
85
|
-
if (settings.key) {
|
|
86
|
-
key = settings.key;
|
|
87
|
-
}
|
|
88
|
-
if (settings.timestamp) {
|
|
89
|
-
timestamp = settings.timestamp;
|
|
90
|
-
}
|
|
91
|
-
if (settings.form) {
|
|
92
|
-
var builder = widget_forms_1.FormBuilder.create(key);
|
|
93
|
-
settings.form(builder);
|
|
94
|
-
var builtForm = builder.get();
|
|
95
|
-
content.form = builtForm;
|
|
96
|
-
}
|
|
97
|
-
if (settings.timestamp === null) {
|
|
98
|
-
timestamp = null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return { content: content, key: key, timestamp: timestamp };
|
|
103
|
-
};
|
|
104
|
-
exports.getNormalizedMessageSettings = getNormalizedMessageSettings;
|
|
105
|
-
var removeTypingState = function (typingActors, sender) {
|
|
106
|
-
if (!sender) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
var senderString = JSON.stringify(sender);
|
|
110
|
-
var indexToRemove = typingActors.findIndex(function (item) {
|
|
111
|
-
return senderString === JSON.stringify(item);
|
|
112
|
-
});
|
|
113
|
-
if (indexToRemove > -1) {
|
|
114
|
-
return typingActors.splice(indexToRemove, 1);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Manages the stream of messages inside a `ConversationComponent` and provides external read-write
|
|
119
|
-
* access to it as well as exposing emitted actions.
|
|
120
|
-
*/
|
|
121
|
-
var ConversationController = /** @class */ (function () {
|
|
122
|
-
function ConversationController(container, id) {
|
|
123
|
-
var _this = this;
|
|
124
|
-
this.container = container;
|
|
125
|
-
this.id = id;
|
|
126
|
-
this.formHandlers = {};
|
|
127
|
-
/**
|
|
128
|
-
* Represents the current end user.
|
|
129
|
-
*/
|
|
130
|
-
this.user = new user_1.User(this);
|
|
131
|
-
this.providers = [];
|
|
132
|
-
this.active = false;
|
|
133
|
-
this.registeredProviders = [];
|
|
134
|
-
this.loaders = 0;
|
|
135
|
-
this.componentMounted = false;
|
|
136
|
-
this.messages = [];
|
|
137
|
-
this.typingActors = [];
|
|
138
|
-
this.print = function (settings) {
|
|
139
|
-
var normalized = (0, exports.getNormalizedMessageSettings)(settings);
|
|
140
|
-
return _this.createEntry(normalized.key, normalized.content, ConversationMessageType.System, undefined, normalized.timestamp);
|
|
141
|
-
};
|
|
142
|
-
var widget = container.get('$widget');
|
|
143
|
-
this.events = widget.events.createChild(this);
|
|
144
|
-
}
|
|
145
|
-
ConversationController.prototype.setProviders = function (providers) {
|
|
146
|
-
var _this = this;
|
|
147
|
-
var removed = [];
|
|
148
|
-
var added = [];
|
|
149
|
-
// remove
|
|
150
|
-
this.providers
|
|
151
|
-
.reduce(function (acc, provider) {
|
|
152
|
-
if (providers.indexOf(provider) === -1) {
|
|
153
|
-
acc.push(provider);
|
|
154
|
-
}
|
|
155
|
-
return acc;
|
|
156
|
-
}, [])
|
|
157
|
-
.forEach(function (providerToRemove) {
|
|
158
|
-
var indexToRemove = _this.providers.indexOf(providerToRemove);
|
|
159
|
-
if (indexToRemove > -1) {
|
|
160
|
-
removed.push(providerToRemove);
|
|
161
|
-
_this.providers.splice(indexToRemove, 1);
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
// add
|
|
165
|
-
providers.forEach(function (provider) {
|
|
166
|
-
if (_this.providers.indexOf(provider) === -1) {
|
|
167
|
-
added.push(provider);
|
|
168
|
-
_this.providers.push(provider);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
if (added.length || removed.length) {
|
|
172
|
-
this.events.dispatch('conversation:providers-changed', { added: added, removed: removed });
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
ConversationController.prototype.createProvider = function (name) {
|
|
176
|
-
var index = this.providerIndex(name);
|
|
177
|
-
if (index > -1) {
|
|
178
|
-
return this.registeredProviders[index];
|
|
179
|
-
}
|
|
180
|
-
var provider = conversation_provider_1.ConversationProvider.create(name, this.container, this);
|
|
181
|
-
this.registeredProviders.push(provider);
|
|
182
|
-
return provider;
|
|
183
|
-
};
|
|
184
|
-
ConversationController.prototype.providerIndex = function (name) {
|
|
185
|
-
return this.registeredProviders.findIndex(function (p) { return p.name === name; });
|
|
186
|
-
};
|
|
187
|
-
ConversationController.prototype.dispose = function () {
|
|
188
|
-
this.registeredProviders.forEach(function (provider) { return provider.dispose(); });
|
|
189
|
-
this.messages = [];
|
|
190
|
-
this.events.dispatch('conversation:controller-disposed', this);
|
|
191
|
-
this.active = false;
|
|
192
|
-
};
|
|
193
|
-
ConversationController.prototype.onDispose = function (fn) {
|
|
194
|
-
return this.events.subscribe('conversation:controller-disposed', fn);
|
|
195
|
-
};
|
|
196
|
-
ConversationController.prototype.onStarted = function (fn) {
|
|
197
|
-
return this.events.subscribe('conversation:started', fn);
|
|
198
|
-
};
|
|
199
|
-
ConversationController.prototype.disposeProvider = function (target) {
|
|
200
|
-
var index = this.providerIndex(target.name);
|
|
201
|
-
index > -1 && this.registeredProviders.splice(index, 1);
|
|
202
|
-
this.events.dispatch('conversation:providers-changed', { removed: [target.name] });
|
|
203
|
-
if (!this.registeredProviders.length) {
|
|
204
|
-
this.dispose();
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
ConversationController.prototype.onProvidersChange = function (fn) {
|
|
208
|
-
return this.events.subscribe('conversation:providers-changed', fn);
|
|
209
|
-
};
|
|
210
|
-
ConversationController.prototype.setComponentMountedState = function (mounted) {
|
|
211
|
-
if (this.componentMounted === mounted) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
this.componentMounted = mounted;
|
|
215
|
-
if (mounted) {
|
|
216
|
-
this.events.dispatch('conversation:unread-message', false);
|
|
217
|
-
this.events.dispatch('conversation:started', true);
|
|
218
|
-
this.active = true;
|
|
219
|
-
}
|
|
220
|
-
this.events.dispatch('conversation:component-mount-changed', mounted);
|
|
221
|
-
};
|
|
222
|
-
ConversationController.prototype.getComponentMountedState = function () {
|
|
223
|
-
return this.componentMounted;
|
|
224
|
-
};
|
|
225
|
-
ConversationController.prototype.onUnreadMessage = function (fn) {
|
|
226
|
-
return this.events.subscribe('conversation:unread-message', fn);
|
|
227
|
-
};
|
|
228
|
-
ConversationController.prototype.createEntry = function (key, content, type, sender, timestamp) {
|
|
229
|
-
var _this = this;
|
|
230
|
-
var message = {
|
|
231
|
-
key: key,
|
|
232
|
-
content: content,
|
|
233
|
-
type: type,
|
|
234
|
-
sender: sender || null,
|
|
235
|
-
timestamp: timestamp || timestamp === null ? timestamp : Date.now(),
|
|
236
|
-
};
|
|
237
|
-
this.messages.push(message);
|
|
238
|
-
message.type === ConversationMessageType.Agent &&
|
|
239
|
-
removeTypingState(this.typingActors, sender);
|
|
240
|
-
var entry = new ConversationEntry(function (updated) {
|
|
241
|
-
if (updated !== null) {
|
|
242
|
-
var _a = updated.timestamp, updatedTimestamp = _a === void 0 ? undefined : _a, content_1 = __rest(updated, ["timestamp"]);
|
|
243
|
-
message.content = content_1;
|
|
244
|
-
if (updatedTimestamp) {
|
|
245
|
-
message.timestamp = updatedTimestamp;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
var indexToRemove = _this.messages.indexOf(message);
|
|
250
|
-
message.content = null;
|
|
251
|
-
if (indexToRemove > -1) {
|
|
252
|
-
_this.messages.splice(indexToRemove, 1);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
_this.events.dispatch('conversation:message-updated', { message: message });
|
|
256
|
-
_this.update();
|
|
257
|
-
});
|
|
258
|
-
this.events.dispatch('conversation:message-created', { message: message });
|
|
259
|
-
this.update();
|
|
260
|
-
if (!this.componentMounted) {
|
|
261
|
-
this.events.dispatch('conversation:unread-message', true);
|
|
262
|
-
}
|
|
263
|
-
return entry;
|
|
264
|
-
};
|
|
265
|
-
ConversationController.prototype.update = function () {
|
|
266
|
-
this.events.dispatch('conversation:updated', {
|
|
267
|
-
messages: this.messages,
|
|
268
|
-
loading: this.loaders > 0,
|
|
269
|
-
typingActors: this.typingActors,
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
ConversationController.prototype.getMessageStream = function () {
|
|
273
|
-
return {
|
|
274
|
-
messages: this.messages,
|
|
275
|
-
loading: this.loaders > 0,
|
|
276
|
-
typingActors: this.typingActors,
|
|
277
|
-
};
|
|
278
|
-
};
|
|
279
|
-
ConversationController.prototype.setTypingState = function (sender, type) {
|
|
280
|
-
var _this = this;
|
|
281
|
-
if (this.typingActors.indexOf(sender) === -1) {
|
|
282
|
-
this.typingActors.push(sender);
|
|
283
|
-
this.update();
|
|
284
|
-
}
|
|
285
|
-
return function () {
|
|
286
|
-
removeTypingState(_this.typingActors, sender);
|
|
287
|
-
_this.update();
|
|
288
|
-
};
|
|
289
|
-
};
|
|
290
|
-
/**
|
|
291
|
-
* Displays a loader in the conversation.
|
|
292
|
-
*/
|
|
293
|
-
ConversationController.prototype.loader = function () {
|
|
294
|
-
var _this = this;
|
|
295
|
-
this.loaders = this.loaders + 1;
|
|
296
|
-
var dismissed = false;
|
|
297
|
-
if (this.loaders === 1) {
|
|
298
|
-
this.update();
|
|
299
|
-
}
|
|
300
|
-
return function () {
|
|
301
|
-
if (!dismissed) {
|
|
302
|
-
dismissed = true;
|
|
303
|
-
_this.loaders = _this.loaders - 1;
|
|
304
|
-
if (_this.loaders === 0) {
|
|
305
|
-
_this.update();
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
};
|
|
310
|
-
ConversationController.prototype.submitForm = function (key, handler) {
|
|
311
|
-
this.formHandlers[key] = __assign(__assign({}, this.formHandlers[key]), { submit: handler });
|
|
312
|
-
};
|
|
313
|
-
ConversationController.prototype.validateForm = function (key, handler) {
|
|
314
|
-
this.formHandlers[key] = __assign(__assign({}, this.formHandlers[key]), { validate: handler });
|
|
315
|
-
};
|
|
316
|
-
return ConversationController;
|
|
317
|
-
}());
|
|
318
|
-
exports.ConversationController = ConversationController;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ConversationPlatform } from '.';
|
|
2
|
-
export declare class ConversationFormAdapter {
|
|
3
|
-
private platform;
|
|
4
|
-
constructor(platform: ConversationPlatform);
|
|
5
|
-
submit: (invoke: any, cancel: any) => (contactMethod: any) => Promise<any>;
|
|
6
|
-
updateContactMethod: (contactMethod: any, errors?: any) => void;
|
|
7
|
-
}
|
|
@@ -1,88 +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.ConversationFormAdapter = void 0;
|
|
40
|
-
var ConversationFormAdapter /*implements Adapter*/ = /** @class */ (function () {
|
|
41
|
-
function ConversationFormAdapter(platform) {
|
|
42
|
-
var _this = this;
|
|
43
|
-
this.platform = platform;
|
|
44
|
-
this.submit = function (invoke /*InvokeAdapterDelegate*/, cancel /*CancelAdapterDelegate*/) {
|
|
45
|
-
return function (contactMethod) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
46
|
-
return [2 /*return*/];
|
|
47
|
-
}); }); };
|
|
48
|
-
};
|
|
49
|
-
// this.platform.container
|
|
50
|
-
// .getAsync('data')
|
|
51
|
-
// .then((dataSource: any/* DataSource */) =>
|
|
52
|
-
// dataSource
|
|
53
|
-
// .read()
|
|
54
|
-
// .then((entries: any) => {
|
|
55
|
-
// const { entryId } = contactMethod;
|
|
56
|
-
// const entry = entries.find((e: any) => e.id === entryId);
|
|
57
|
-
// if (entry) {
|
|
58
|
-
// const { submit, validate } = this.platform.formHandlers[entry.content.key];
|
|
59
|
-
// const { values } = { values: {} }/*extractFormValues(contactMethod.body.form)*/;
|
|
60
|
-
// if (validate) {
|
|
61
|
-
// return validate(values)
|
|
62
|
-
// .then((result) => {
|
|
63
|
-
// const { valid, errors } = result;
|
|
64
|
-
// if (valid) {
|
|
65
|
-
// return submit(values)
|
|
66
|
-
// .then(() => {
|
|
67
|
-
// this.updateContactMethod(contactMethod);
|
|
68
|
-
// return {};
|
|
69
|
-
// });
|
|
70
|
-
// }
|
|
71
|
-
// this.updateContactMethod(contactMethod, errors);
|
|
72
|
-
// return {};
|
|
73
|
-
// });
|
|
74
|
-
// }
|
|
75
|
-
// return submit(values)
|
|
76
|
-
// .then(() => {
|
|
77
|
-
// this.updateContactMethod(contactMethod);
|
|
78
|
-
// return {};
|
|
79
|
-
// });
|
|
80
|
-
// }
|
|
81
|
-
// return {};
|
|
82
|
-
// }),
|
|
83
|
-
// )
|
|
84
|
-
this.updateContactMethod = function (contactMethod, errors) { };
|
|
85
|
-
}
|
|
86
|
-
return ConversationFormAdapter;
|
|
87
|
-
}());
|
|
88
|
-
exports.ConversationFormAdapter = ConversationFormAdapter;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { ComponentNodeController, ComponentPlatform } from '@telia-ace/widget-core';
|
|
2
|
-
import { RouteData } from '@telia-ace/widget-routing';
|
|
3
|
-
import { Container, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
4
|
-
import { ConversationController } from './conversation-controller';
|
|
5
|
-
import { ConversationProvider } from './conversation-provider';
|
|
6
|
-
export declare type ConversationHandler = (conversation: ConversationProvider, component: ComponentNodeController) => void | (() => void);
|
|
7
|
-
export declare type UnregisterControllerDelegate = () => void;
|
|
8
|
-
export declare type ConversationProviderRegistration = {
|
|
9
|
-
name: string;
|
|
10
|
-
handler: ConversationHandler;
|
|
11
|
-
};
|
|
12
|
-
export declare enum ConversationEndedBehavior {
|
|
13
|
-
Deactivate = "deactivate",
|
|
14
|
-
Navigate = "navigate",
|
|
15
|
-
None = "none"
|
|
16
|
-
}
|
|
17
|
-
export declare type SessionInfo = {
|
|
18
|
-
id?: string;
|
|
19
|
-
route?: RouteData;
|
|
20
|
-
conversationEndedBehavior?: ConversationEndedBehavior;
|
|
21
|
-
};
|
|
22
|
-
export declare class ConversationPlatform {
|
|
23
|
-
private container;
|
|
24
|
-
private components;
|
|
25
|
-
events: EventManager;
|
|
26
|
-
private controllers;
|
|
27
|
-
private providers;
|
|
28
|
-
private disposeProviders;
|
|
29
|
-
private subscriptions;
|
|
30
|
-
private storageWriter;
|
|
31
|
-
private router;
|
|
32
|
-
private buttonQuery;
|
|
33
|
-
private sessionInfo;
|
|
34
|
-
constructor(container: Container, components: ComponentPlatform);
|
|
35
|
-
initialize(): void;
|
|
36
|
-
addSubscription(sub: EventSubscriptionCancellation): void;
|
|
37
|
-
static getInstance(container: Container, key?: string): Promise<ConversationPlatform>;
|
|
38
|
-
navigateToConversationIfActive(id: string): Promise<void>;
|
|
39
|
-
setConversationEndedBehavior(behavior: ConversationEndedBehavior): Promise<void>;
|
|
40
|
-
createController(id: string): ConversationController;
|
|
41
|
-
registerProvider(name: string, handler: ConversationHandler): void;
|
|
42
|
-
registerController(conversation: ConversationController, component: ComponentNodeController): boolean;
|
|
43
|
-
private writeToComponents;
|
|
44
|
-
private invokeHandler;
|
|
45
|
-
getComponentRoute(): Promise<RouteData | undefined>;
|
|
46
|
-
dispose(): void;
|
|
47
|
-
static handleContactMethodClick(event: any, container: Container, contactMethod: any, callback?: Function): Promise<void>;
|
|
48
|
-
static handleContactMethodSubmit(container: Container, contactMethod: any): Promise<any>;
|
|
49
|
-
}
|