@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.
Files changed (136) hide show
  1. package/LICENSE.txt +5 -5
  2. package/README.md +256 -256
  3. package/{lib-esm → dist}/agent.d.ts +17 -17
  4. package/{lib-esm → dist}/conversation-controller.d.ts +88 -88
  5. package/{lib-esm → dist}/conversation-form-adapter.d.ts +7 -7
  6. package/{lib-esm → dist}/conversation-platform.d.ts +50 -49
  7. package/{lib-esm → dist}/conversation-provider.d.ts +22 -22
  8. package/dist/conversation.js +558 -0
  9. package/dist/conversation.js.map +1 -0
  10. package/{lib → dist}/index.d.ts +9 -9
  11. package/dist/index.js +10 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/index2.js +1678 -0
  14. package/dist/index2.js.map +1 -0
  15. package/{lib-esm → dist}/resolve-entity-value.d.ts +10 -10
  16. package/dist/return-button.js +174 -0
  17. package/dist/return-button.js.map +1 -0
  18. package/{lib → dist}/types.d.ts +110 -110
  19. package/{lib-esm → dist}/ui/conversation/conversation-component.d.ts +37 -37
  20. package/{lib → dist}/ui/conversation/conversation-content.d.ts +12 -11
  21. package/{lib-esm → dist}/ui/conversation/conversation-input.d.ts +6 -6
  22. package/{lib → dist}/ui/conversation/conversation-loader.d.ts +8 -8
  23. package/{lib → dist}/ui/conversation/conversation-message.d.ts +7 -7
  24. package/{lib-esm → dist}/ui/conversation/conversation-styles.d.ts +11 -11
  25. package/{lib → dist}/ui/conversation/conversation.d.ts +6 -6
  26. package/{lib → dist}/ui/conversation/index.d.ts +3 -2
  27. package/{lib-esm → dist}/ui/conversation/message-types/agent.d.ts +11 -11
  28. package/{lib → dist}/ui/conversation/message-types/custom-message-list-item.d.ts +9 -9
  29. package/{lib → dist}/ui/conversation/message-types/custom.d.ts +9 -9
  30. package/{lib → dist}/ui/conversation/message-types/index.d.ts +5 -5
  31. package/{lib-esm → dist}/ui/conversation/message-types/system.d.ts +12 -12
  32. package/{lib → dist}/ui/conversation/message-types/timestamp.d.ts +8 -8
  33. package/{lib-esm → dist}/ui/conversation/message-types/user.d.ts +8 -8
  34. package/dist/ui/index.d.ts +2 -0
  35. package/{lib-esm → dist}/ui/return-button/index.d.ts +2 -2
  36. package/{lib → dist}/ui/return-button/return-button-component.d.ts +19 -19
  37. package/{lib → dist}/ui/return-button/return-button.d.ts +6 -6
  38. package/{lib → dist}/user.d.ts +7 -7
  39. package/{lib-esm → dist}/utils/custom-message.d.ts +3 -3
  40. package/{lib-esm → dist}/utils/index.d.ts +1 -1
  41. package/{lib-esm → dist}/utils/open-chat-widget.d.ts +4 -4
  42. package/package.json +15 -16
  43. package/lib/agent.d.ts +0 -17
  44. package/lib/agent.js +0 -37
  45. package/lib/conversation-controller.d.ts +0 -88
  46. package/lib/conversation-controller.js +0 -318
  47. package/lib/conversation-form-adapter.d.ts +0 -7
  48. package/lib/conversation-form-adapter.js +0 -88
  49. package/lib/conversation-platform.d.ts +0 -49
  50. package/lib/conversation-platform.js +0 -295
  51. package/lib/conversation-provider.d.ts +0 -22
  52. package/lib/conversation-provider.js +0 -73
  53. package/lib/index.js +0 -17
  54. package/lib/resolve-entity-value.d.ts +0 -10
  55. package/lib/resolve-entity-value.js +0 -22
  56. package/lib/types.js +0 -19
  57. package/lib/ui/conversation/conversation-component.d.ts +0 -37
  58. package/lib/ui/conversation/conversation-component.js +0 -152
  59. package/lib/ui/conversation/conversation-content.js +0 -240
  60. package/lib/ui/conversation/conversation-input.d.ts +0 -6
  61. package/lib/ui/conversation/conversation-input.js +0 -163
  62. package/lib/ui/conversation/conversation-loader.js +0 -18
  63. package/lib/ui/conversation/conversation-message.js +0 -141
  64. package/lib/ui/conversation/conversation-styles.d.ts +0 -11
  65. package/lib/ui/conversation/conversation-styles.js +0 -65
  66. package/lib/ui/conversation/conversation.js +0 -139
  67. package/lib/ui/conversation/index.js +0 -7
  68. package/lib/ui/conversation/message-types/agent.d.ts +0 -11
  69. package/lib/ui/conversation/message-types/agent.js +0 -54
  70. package/lib/ui/conversation/message-types/custom-message-list-item.js +0 -27
  71. package/lib/ui/conversation/message-types/custom.js +0 -50
  72. package/lib/ui/conversation/message-types/index.js +0 -16
  73. package/lib/ui/conversation/message-types/system.d.ts +0 -12
  74. package/lib/ui/conversation/message-types/system.js +0 -26
  75. package/lib/ui/conversation/message-types/timestamp.js +0 -36
  76. package/lib/ui/conversation/message-types/user.d.ts +0 -8
  77. package/lib/ui/conversation/message-types/user.js +0 -24
  78. package/lib/ui/index.d.ts +0 -2
  79. package/lib/ui/index.js +0 -10
  80. package/lib/ui/return-button/index.d.ts +0 -2
  81. package/lib/ui/return-button/index.js +0 -7
  82. package/lib/ui/return-button/return-button-component.js +0 -70
  83. package/lib/ui/return-button/return-button.js +0 -82
  84. package/lib/user.js +0 -16
  85. package/lib/utils/custom-message.d.ts +0 -3
  86. package/lib/utils/custom-message.js +0 -56
  87. package/lib/utils/index.d.ts +0 -1
  88. package/lib/utils/index.js +0 -7
  89. package/lib/utils/open-chat-widget.d.ts +0 -4
  90. package/lib/utils/open-chat-widget.js +0 -148
  91. package/lib-esm/agent.js +0 -34
  92. package/lib-esm/conversation-controller.js +0 -314
  93. package/lib-esm/conversation-form-adapter.js +0 -85
  94. package/lib-esm/conversation-platform.js +0 -292
  95. package/lib-esm/conversation-provider.js +0 -70
  96. package/lib-esm/index.d.ts +0 -9
  97. package/lib-esm/index.js +0 -6
  98. package/lib-esm/resolve-entity-value.js +0 -18
  99. package/lib-esm/types.d.ts +0 -110
  100. package/lib-esm/types.js +0 -16
  101. package/lib-esm/ui/conversation/conversation-component.js +0 -127
  102. package/lib-esm/ui/conversation/conversation-content.d.ts +0 -11
  103. package/lib-esm/ui/conversation/conversation-content.js +0 -212
  104. package/lib-esm/ui/conversation/conversation-input.js +0 -138
  105. package/lib-esm/ui/conversation/conversation-loader.d.ts +0 -8
  106. package/lib-esm/ui/conversation/conversation-loader.js +0 -13
  107. package/lib-esm/ui/conversation/conversation-message.d.ts +0 -7
  108. package/lib-esm/ui/conversation/conversation-message.js +0 -113
  109. package/lib-esm/ui/conversation/conversation-styles.js +0 -39
  110. package/lib-esm/ui/conversation/conversation.d.ts +0 -6
  111. package/lib-esm/ui/conversation/conversation.js +0 -111
  112. package/lib-esm/ui/conversation/index.d.ts +0 -2
  113. package/lib-esm/ui/conversation/index.js +0 -2
  114. package/lib-esm/ui/conversation/message-types/agent.js +0 -25
  115. package/lib-esm/ui/conversation/message-types/custom-message-list-item.d.ts +0 -9
  116. package/lib-esm/ui/conversation/message-types/custom-message-list-item.js +0 -22
  117. package/lib-esm/ui/conversation/message-types/custom.d.ts +0 -9
  118. package/lib-esm/ui/conversation/message-types/custom.js +0 -25
  119. package/lib-esm/ui/conversation/message-types/index.d.ts +0 -5
  120. package/lib-esm/ui/conversation/message-types/index.js +0 -5
  121. package/lib-esm/ui/conversation/message-types/system.js +0 -20
  122. package/lib-esm/ui/conversation/message-types/timestamp.d.ts +0 -8
  123. package/lib-esm/ui/conversation/message-types/timestamp.js +0 -31
  124. package/lib-esm/ui/conversation/message-types/user.js +0 -19
  125. package/lib-esm/ui/index.d.ts +0 -2
  126. package/lib-esm/ui/index.js +0 -2
  127. package/lib-esm/ui/return-button/index.js +0 -2
  128. package/lib-esm/ui/return-button/return-button-component.d.ts +0 -19
  129. package/lib-esm/ui/return-button/return-button-component.js +0 -44
  130. package/lib-esm/ui/return-button/return-button.d.ts +0 -6
  131. package/lib-esm/ui/return-button/return-button.js +0 -54
  132. package/lib-esm/user.d.ts +0 -7
  133. package/lib-esm/user.js +0 -13
  134. package/lib-esm/utils/custom-message.js +0 -52
  135. package/lib-esm/utils/index.js +0 -1
  136. 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
- };