@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,142 +0,0 @@
|
|
|
1
|
-
import { closeAllModals } from '@telia-ace/widget-plugins';
|
|
2
|
-
import { createStorageWriter, StorageCategory, StorageMedium, StorageScope, } from '@telia-ace/widget-services';
|
|
3
|
-
import { ConversationEndedBehavior } from '../';
|
|
4
|
-
var getParentWidget = function (widgetName, implementation) {
|
|
5
|
-
var mainWidgetName = widgetName.split('_contact');
|
|
6
|
-
return implementation.widgets.get(mainWidgetName[0]);
|
|
7
|
-
};
|
|
8
|
-
var getSeparateWidget = function (container) {
|
|
9
|
-
var originWidget = container.get('$widget');
|
|
10
|
-
var _a = container.get('$widget'), name = _a.name, implementation = _a.implementation;
|
|
11
|
-
var mainWidget = name.indexOf('_contact') > -1 ? getParentWidget(name, implementation) : originWidget;
|
|
12
|
-
var data = container.get('$settings').data;
|
|
13
|
-
var trigger = mainWidget.container.get('$settings').trigger;
|
|
14
|
-
var chatWidgetName = "".concat(name
|
|
15
|
-
.replace('_contact-method', '')
|
|
16
|
-
.replace('_contact', ''), "_contact-method");
|
|
17
|
-
var chatWidget = implementation.widgets.get(chatWidgetName);
|
|
18
|
-
if (chatWidget && !trigger) {
|
|
19
|
-
return { chatWidget: chatWidget, mainWidget: mainWidget, data: data };
|
|
20
|
-
}
|
|
21
|
-
return { mainWidget: mainWidget, data: data };
|
|
22
|
-
};
|
|
23
|
-
export var shouldPreventDefault = function (container) {
|
|
24
|
-
var chatWidget = getSeparateWidget(container).chatWidget;
|
|
25
|
-
return !!chatWidget;
|
|
26
|
-
};
|
|
27
|
-
export var openChatWidget = function (container, contactMethod /*ContactMethodType*/, triggerDOMTarget) {
|
|
28
|
-
var _a = getSeparateWidget(container), mainWidget = _a.mainWidget, data = _a.data, chatWidget = _a.chatWidget;
|
|
29
|
-
if (chatWidget) {
|
|
30
|
-
if (chatWidget.state === 'activated') {
|
|
31
|
-
return chatWidget.invoke('open').then(function () {
|
|
32
|
-
chatWidget.container.getAsync('conversation').then(function (conversation) {
|
|
33
|
-
conversation
|
|
34
|
-
.navigateToConversationIfActive(contactMethod.id)
|
|
35
|
-
.then(function () { return closeAllModals(container); });
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return chatWidget
|
|
40
|
-
.activate()
|
|
41
|
-
.then(function () {
|
|
42
|
-
var trigger = chatWidget.container.get('$settings').trigger;
|
|
43
|
-
trigger.action = 'hide'; // could be default in configuration
|
|
44
|
-
return chatWidget
|
|
45
|
-
.invoke('setSettings', function () { return ({
|
|
46
|
-
data: data,
|
|
47
|
-
trigger: trigger,
|
|
48
|
-
activate: true,
|
|
49
|
-
}); })
|
|
50
|
-
.then(function () {
|
|
51
|
-
return chatWidget.container
|
|
52
|
-
.getAsync('components')
|
|
53
|
-
.then(function (components) {
|
|
54
|
-
/**
|
|
55
|
-
* Could cause issues if target widget is no longer as specific for this use case
|
|
56
|
-
*/
|
|
57
|
-
var contactMethodsQuery = components
|
|
58
|
-
.components()
|
|
59
|
-
.ofType('contact-method');
|
|
60
|
-
components.write({
|
|
61
|
-
key: 'setContactMethodId',
|
|
62
|
-
attributes: {
|
|
63
|
-
properties: {
|
|
64
|
-
id: contactMethod.id,
|
|
65
|
-
guideId: contactMethod.guideId,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
target: contactMethodsQuery,
|
|
69
|
-
provider: 'localStorage',
|
|
70
|
-
});
|
|
71
|
-
var conversationsQuery = components
|
|
72
|
-
.components()
|
|
73
|
-
.ofType('conversation');
|
|
74
|
-
components.write({
|
|
75
|
-
key: 'setConversationProvider',
|
|
76
|
-
attributes: {
|
|
77
|
-
properties: { providers: [contactMethod.clientName] },
|
|
78
|
-
},
|
|
79
|
-
target: conversationsQuery,
|
|
80
|
-
provider: 'localStorage',
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
})
|
|
85
|
-
.then(function () {
|
|
86
|
-
return chatWidget.invoke('attach', {
|
|
87
|
-
key: 'contact-method',
|
|
88
|
-
triggerDOMElement: triggerDOMTarget,
|
|
89
|
-
withRenderState: 'open',
|
|
90
|
-
});
|
|
91
|
-
})
|
|
92
|
-
.then(function () {
|
|
93
|
-
createStorageWriter(chatWidget.container, 'activeStickyWidget', StorageCategory.Necessary, {
|
|
94
|
-
medium: StorageMedium.Local,
|
|
95
|
-
scope: StorageScope.Implementation,
|
|
96
|
-
}).then(function (write) { return write(chatWidget.name); });
|
|
97
|
-
return chatWidget.container
|
|
98
|
-
.getAsync('conversation')
|
|
99
|
-
.then(function (platform) {
|
|
100
|
-
platform.setConversationEndedBehavior(ConversationEndedBehavior.Deactivate);
|
|
101
|
-
})
|
|
102
|
-
.then(function () { return closeAllModals(container); })
|
|
103
|
-
.then(function () { return false; });
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
mainWidget.container.getAsync('conversation').then(function (platform) {
|
|
107
|
-
return platform
|
|
108
|
-
.navigateToConversationIfActive(contactMethod.id)
|
|
109
|
-
.then(function () { return platform.setConversationEndedBehavior(ConversationEndedBehavior.Navigate); });
|
|
110
|
-
});
|
|
111
|
-
return chatWidget ? false : true;
|
|
112
|
-
};
|
|
113
|
-
export var navigateToConversation = function (container, contactMethod /*ContactMethodType*/, routeName) {
|
|
114
|
-
if (routeName === void 0) { routeName = 'conversation'; }
|
|
115
|
-
var _a = getSeparateWidget(container), mainWidget = _a.mainWidget, chatWidget = _a.chatWidget;
|
|
116
|
-
if (chatWidget) {
|
|
117
|
-
return chatWidget.container.getAsync('router').then(function (router) {
|
|
118
|
-
router.navigate(routeName, { id: contactMethod.id });
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return mainWidget.container.getAsync('conversation').then(function (platform) {
|
|
122
|
-
var _a;
|
|
123
|
-
(_a = platform.setConversationEndedBehavior(ConversationEndedBehavior.Navigate)) === null || _a === void 0 ? void 0 : _a.then(function () {
|
|
124
|
-
mainWidget.container.getAsync('router').then(function (router) {
|
|
125
|
-
mainWidget.container
|
|
126
|
-
.getAsync('components')
|
|
127
|
-
.then(function (components) {
|
|
128
|
-
var conversationQuery = components.components().ofType('conversation');
|
|
129
|
-
components.write({
|
|
130
|
-
key: 'setConversationProvider',
|
|
131
|
-
attributes: { properties: { providers: [contactMethod.clientName] } },
|
|
132
|
-
target: conversationQuery,
|
|
133
|
-
provider: 'localStorage',
|
|
134
|
-
});
|
|
135
|
-
})
|
|
136
|
-
.then(function () {
|
|
137
|
-
router.navigate(routeName, { id: contactMethod.id });
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
};
|