@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,240 +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 __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __read = (this && this.__read) || function (o, n) {
41
- var m = typeof Symbol === "function" && o[Symbol.iterator];
42
- if (!m) return o;
43
- var i = m.call(o), r, ar = [], e;
44
- try {
45
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
46
- }
47
- catch (error) { e = { error: error }; }
48
- finally {
49
- try {
50
- if (r && !r.done && (m = i["return"])) m.call(i);
51
- }
52
- finally { if (e) throw e.error; }
53
- }
54
- return ar;
55
- };
56
- var __importDefault = (this && this.__importDefault) || function (mod) {
57
- return (mod && mod.__esModule) ? mod : { "default": mod };
58
- };
59
- Object.defineProperty(exports, "__esModule", { value: true });
60
- var widget_forms_1 = require("@telia-ace/widget-forms");
61
- var widget_ui_1 = require("@telia-ace/widget-ui");
62
- var widget_utilities_1 = require("@telia-ace/widget-utilities");
63
- var react_1 = __importStar(require("react"));
64
- var styled_components_1 = __importStar(require("styled-components"));
65
- var types_1 = require("../../types");
66
- var conversation_styles_1 = require("./conversation-styles");
67
- var message_types_1 = require("./message-types");
68
- var custom_message_list_item_1 = __importDefault(require("./message-types/custom-message-list-item"));
69
- var imageLightboxRenderer = function (attrs) { return react_1.default.createElement(widget_ui_1.Lightbox, { attrs: attrs }); };
70
- var htmlParseInstructions = {
71
- transform: {
72
- img: imageLightboxRenderer,
73
- },
74
- };
75
- var ConversationContent = function (_a) {
76
- var content = _a.content, isUser = _a.isUser, stacked = _a.stacked;
77
- var dispatch = (0, widget_ui_1.useDispatch)();
78
- var title = content.title, body = content.body, actions = content.actions, form = content.form, type = content.type, items = content.items;
79
- if (type)
80
- return react_1.default.createElement(message_types_1.CustomMessage, { type: type, content: content, isUser: isUser, stacked: stacked });
81
- return (react_1.default.createElement(conversation_styles_1.MessageContent, { noPadding: true, user: isUser, stacked: !!stacked && stacked, fullWidth: !!form || !!actions },
82
- title && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
83
- react_1.default.createElement(conversation_styles_1.MessageTitle, { variant: "h2" }, title))),
84
- body && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
85
- react_1.default.createElement(StyledHtml, { html: body, htmlParseInstruction: htmlParseInstructions }))),
86
- form && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
87
- react_1.default.createElement(StyledForm, __assign({}, form, { onChange: function (key, data) {
88
- dispatch('form', {
89
- data: data,
90
- formKey: form.schema.id,
91
- actionKey: key,
92
- });
93
- } })))),
94
- actions && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
95
- react_1.default.createElement(StyledActionList, { items: Object.keys(actions).map(function (i) {
96
- return { label: actions[i], actionKey: i };
97
- }), renderItem: function (item) {
98
- return (react_1.default.createElement("li", { key: item.actionKey },
99
- react_1.default.createElement(StyledActionButton, { onClick: function () {
100
- dispatch('action', item.actionKey);
101
- } }, item.label)));
102
- } }))),
103
- items && (react_1.default.createElement(react_1.Fragment, null,
104
- react_1.default.createElement(conversation_styles_1.MessageContentPart, { key: (0, widget_utilities_1.uuid)(), noPadding: true },
105
- react_1.default.createElement(StyledActionList, { items: items.map(function (_a) {
106
- var _b = __read(_a, 2), type = _b[0], content = _b[1];
107
- return { type: type, content: content };
108
- }), renderItem: function (item) {
109
- var itemKey = (0, widget_utilities_1.uuid)();
110
- switch (item.type) {
111
- case types_1.ConversationMessageListItemType.Header: {
112
- return (react_1.default.createElement(ConversationListItem, { key: itemKey },
113
- react_1.default.createElement(HeaderText, null, item.content)));
114
- }
115
- case types_1.ConversationMessageListItemType.Text: {
116
- return (react_1.default.createElement(ConversationListItem, { key: itemKey },
117
- react_1.default.createElement("span", null, item.content)));
118
- }
119
- case types_1.ConversationMessageListItemType.HTML: {
120
- return (react_1.default.createElement(ConversationListItem, { key: itemKey },
121
- react_1.default.createElement(StyledHtml, { html: item.content.body, htmlParseInstruction: htmlParseInstructions })));
122
- }
123
- case types_1.ConversationMessageListItemType.Separator: {
124
- return (react_1.default.createElement(ConversationListItem, { key: itemKey, noPadding: true },
125
- react_1.default.createElement(SeparatorPadding, null,
126
- react_1.default.createElement(Separator, null))));
127
- }
128
- case types_1.ConversationMessageListItemType.LinkList: {
129
- return (react_1.default.createElement(ConversationListItem, { key: itemKey },
130
- react_1.default.createElement(StyledLinkList, { items: Object.keys(item.content.actions).map(function (i) {
131
- return {
132
- label: item.content.actions[i],
133
- actionKey: i,
134
- };
135
- }), renderItem: function (item) {
136
- return (react_1.default.createElement("li", { key: item.actionKey },
137
- react_1.default.createElement(StyledLinkButton, { help: item.actionKey === 'help', onClick: function () {
138
- dispatch('action', item.actionKey);
139
- } },
140
- item.label,
141
- item.actionKey === 'help' && (react_1.default.createElement(widget_ui_1.SymbolBadge, { size: 14, symbol: {
142
- type: 'Svg',
143
- content: 'caret-down',
144
- } })))));
145
- } })));
146
- }
147
- case types_1.ConversationMessageListItemType.ButtonList: {
148
- return (react_1.default.createElement(ConversationListItem, { key: itemKey },
149
- react_1.default.createElement(StyledButtonList, { items: Object.keys(item.content.actions).map(function (i) {
150
- return {
151
- label: item.content.actions[i],
152
- actionKey: i,
153
- };
154
- }), renderItem: function (item) {
155
- return (react_1.default.createElement("li", { key: item.actionKey },
156
- react_1.default.createElement(StyledButtonListButton, { onClick: function () {
157
- dispatch('action', item.actionKey);
158
- } }, item.label)));
159
- } })));
160
- }
161
- case types_1.ConversationMessageListItemType.NoGoodAlternative: {
162
- return (react_1.default.createElement(ConversationListItem, { key: itemKey },
163
- react_1.default.createElement(NoGoodAlternativeWrapper, { onClick: function () {
164
- dispatch('action', 'help');
165
- } },
166
- react_1.default.createElement(widget_ui_1.SymbolBadge, { size: 14, symbol: {
167
- type: 'FontAwesome',
168
- content: 'meh-o',
169
- } }),
170
- react_1.default.createElement("span", null, item.content.body))));
171
- }
172
- case types_1.ConversationMessageListItemType.FeedbackList: {
173
- return (react_1.default.createElement(ConversationListItem, { key: itemKey },
174
- react_1.default.createElement(StyledButtonList, { items: Object.keys(item.content.actions).map(function (i) {
175
- return {
176
- label: item.content.actions[i],
177
- actionKey: i,
178
- };
179
- }), renderItem: function (item) {
180
- return (react_1.default.createElement(FeedbackItem, { key: item.actionKey },
181
- react_1.default.createElement(FeedbackButton, { className: "humany-feedback-button", disabled: false, "aria-pressed": true, "data-selected": true, "data-direction": 'vertical', onClick: function () {
182
- dispatch('action', item.actionKey);
183
- } },
184
- react_1.default.createElement(widget_ui_1.Icon, { faIcon: item.actionKey == 'yes'
185
- ? 'smile-o'
186
- : 'frown-o' }),
187
- react_1.default.createElement("span", null, item.label))));
188
- } })));
189
- }
190
- default: {
191
- return (react_1.default.createElement(ConversationListItem, { key: itemKey, noPadding: true },
192
- react_1.default.createElement(custom_message_list_item_1.default, { type: item.type, content: item.content })));
193
- }
194
- }
195
- } }))))));
196
- };
197
- var StyledForm = (0, styled_components_1.default)(widget_forms_1.FormComponent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n & button.humany-form-component-button {\n ", ";\n display: block;\n width: 100%;\n margin-bottom: ", ";\n }\n & button.humany-form-component-submit {\n width: 100%;\n margin: 0;\n :not(:last-child) {\n margin-bottom: ", ";\n }\n }\n"], ["\n & button.humany-form-component-button {\n ", ";\n display: block;\n width: 100%;\n margin-bottom: ", ";\n }\n & button.humany-form-component-submit {\n width: 100%;\n margin: 0;\n :not(:last-child) {\n margin-bottom: ", ";\n }\n }\n"])), function (p) {
198
- var _a, _b;
199
- return (0, widget_ui_1.invertedHoverButton)({
200
- active: false,
201
- primaryColor: (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
202
- secondaryColor: (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.accent,
203
- });
204
- }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
205
- var StyledHtml = (0, styled_components_1.default)(widget_ui_1.Html)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n white-space: pre-wrap;\n a {\n color: ", ";\n &:focus {\n ", ";\n }\n }\n"], ["\n white-space: pre-wrap;\n a {\n color: ", ";\n &:focus {\n ", ";\n }\n }\n"])), function (p) { return p.theme.colors.link; }, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && widget_ui_1.borderTabStyle; });
206
- var StyledActionList = (0, styled_components_1.default)(widget_ui_1.List)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 0;\n list-style: none;\n margin: 0 -", ";\n > li {\n margin: ", ";\n }\n"], ["\n padding: 0;\n list-style: none;\n margin: 0 -", ";\n > li {\n margin: ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
207
- var StyledButtonList = (0, styled_components_1.default)(widget_ui_1.List)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding: 0;\n list-style: none;\n > li {\n margin: ", " ", ";\n margin-left: 0;\n display: inline-block;\n }\n"], ["\n padding: 0;\n list-style: none;\n > li {\n margin: ", " ", ";\n margin-left: 0;\n display: inline-block;\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
208
- var StyledButtonListButton = styled_components_1.default.button(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ";\n display: block;\n text-align: left;\n background-color: ", ";\n width: 100%;\n color: #fff;\n &:focus {\n ", "\n }\n"], ["\n ", ";\n display: block;\n text-align: left;\n background-color: ", ";\n width: 100%;\n color: #fff;\n &:focus {\n ", "\n }\n"])), widget_ui_1.buttonCss, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) {
209
- var _a;
210
- return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n background-color: transparent;\n "], ["\n ", "\n background-color: transparent;\n "])), widget_ui_1.borderTabStyle);
211
- });
212
- var StyledLinkList = (0, styled_components_1.default)(widget_ui_1.List)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding: 0;\n list-style: none;\n > li {\n margin-bottom: ", ";\n\n &:last-child {\n margin-bottom: 0;\n }\n }\n"], ["\n padding: 0;\n list-style: none;\n > li {\n margin-bottom: ", ";\n\n &:last-child {\n margin-bottom: 0;\n }\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
213
- var HeaderText = styled_components_1.default.strong(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n font-size: ", ";\n"], ["\n font-size: ", ";\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.huge; });
214
- var StyledLinkButton = styled_components_1.default.button(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display: block;\n background-color: transparent;\n text-align: left;\n border: none;\n padding: 0;\n font-weight: 300;\n font-family: inherit;\n cursor: pointer;\n color: ", ";\n\n ", "\n"], ["\n display: block;\n background-color: transparent;\n text-align: left;\n border: none;\n padding: 0;\n font-weight: 300;\n font-family: inherit;\n cursor: pointer;\n color: ", ";\n\n ", "\n"])), function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) {
215
- var _a, _b;
216
- return p.help && (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n color: ", ";\n text-decoration: underline;\n\n i,\n svg {\n margin-left: ", ";\n }\n "], ["\n color: ", ";\n text-decoration: underline;\n\n i,\n svg {\n margin-left: ", ";\n }\n "])), (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text, (_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.small);
217
- });
218
- var StyledActionButton = styled_components_1.default.button(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n ", ";\n display: block;\n background-color: ", ";\n width: 100%;\n color: #fff;\n font-family: Lato;\n font-size: ", ";\n font-weight: 300;\n &:focus {\n ", "\n }\n"], ["\n ", ";\n display: block;\n background-color: ", ";\n width: 100%;\n color: #fff;\n font-family: Lato;\n font-size: ", ";\n font-weight: 300;\n &:focus {\n ", "\n }\n"])), widget_ui_1.buttonCss, 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.fonts) === null || _a === void 0 ? void 0 : _a.huge; }, function (p) {
219
- var _a;
220
- return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n ", "\n background-color: transparent;\n "], ["\n ", "\n background-color: transparent;\n "])), widget_ui_1.borderTabStyle);
221
- });
222
- var SeparatorPadding = styled_components_1.default.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n padding-top: calc(", " - ", ");\n padding-bottom: calc(", " - ", ");\n"], ["\n padding-top: calc(", " - ", ");\n padding-bottom: calc(", " - ", ");\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
223
- var Separator = styled_components_1.default.div(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n background-color: #efefef;\n height: 1px;\n width: 100%;\n"], ["\n background-color: #efefef;\n height: 1px;\n width: 100%;\n"])));
224
- var NoGoodAlternativeWrapper = styled_components_1.default.div(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n\n > i,\n svg {\n margin-right: ", ";\n }\n"], ["\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n\n > i,\n svg {\n margin-right: ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; });
225
- var ConversationListItem = styled_components_1.default.li(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n"], ["\n padding-left: ", ";\n padding-right: ", ";\n"])), function (p) { var _a; return (p.noPadding ? 0 : (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium); }, function (p) { var _a; return (p.noPadding ? 0 : (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium); });
226
- var FeedbackItem = styled_components_1.default.li(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n @media (min-width: 768px) {\n display: list-item !important;\n margin-right: 0 !important;\n margin-top: ", " !important;\n }\n"], ["\n @media (min-width: 768px) {\n display: list-item !important;\n margin-right: 0 !important;\n margin-top: ", " !important;\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
227
- var FeedbackButton = styled_components_1.default.button(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n @media (min-width: 768px) {\n min-width: 100%;\n margin-right: 0;\n }\n display: inline-block;\n font-size: ", ";\n border-color: ", " !important;\n font-weight: 300;\n && {\n margin-right: ", ";\n }\n ", "\n ", "\n ", "\n i {\n margin: 0 ", " 0 0;\n }\n span {\n }\n"], ["\n @media (min-width: 768px) {\n min-width: 100%;\n margin-right: 0;\n }\n display: inline-block;\n font-size: ", ";\n border-color: ", " !important;\n font-weight: 300;\n && {\n margin-right: ", ";\n }\n ", "\n ", "\n ", "\n i {\n margin: 0 ", " 0 0;\n }\n span {\n }\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, 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.sizes) === null || _a === void 0 ? void 0 : _a.small; }, function (p) {
228
- var _a, _b;
229
- return p['data-direction'] === 'horizontal' && (0, styled_components_1.css)(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n width: 225px;\n max-width: calc(50% - ", " - ", ");\n "], ["\n width: 225px;\n max-width: calc(50% - ", " - ", ");\n "])), (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large, (_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.small);
230
- }, function (p) {
231
- return p['data-direction'] === 'vertical' && (0, styled_components_1.css)(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n min-width: 150px;\n "], ["\n min-width: 150px;\n "])));
232
- }, function (p) {
233
- var _a;
234
- return (0, widget_ui_1.invertedHoverButton)({
235
- primaryColor: "".concat((_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary),
236
- secondaryColor: '#FFFFFF',
237
- });
238
- }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; });
239
- exports.default = ConversationContent;
240
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- declare type Props = {
3
- className?: string;
4
- };
5
- declare const ConversationInput: React.FC<Props>;
6
- export default ConversationInput;
@@ -1,163 +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 __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __rest = (this && this.__rest) || function (s, e) {
41
- var t = {};
42
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
43
- t[p] = s[p];
44
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
45
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
46
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
47
- t[p[i]] = s[p[i]];
48
- }
49
- return t;
50
- };
51
- var __read = (this && this.__read) || function (o, n) {
52
- var m = typeof Symbol === "function" && o[Symbol.iterator];
53
- if (!m) return o;
54
- var i = m.call(o), r, ar = [], e;
55
- try {
56
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
57
- }
58
- catch (error) { e = { error: error }; }
59
- finally {
60
- try {
61
- if (r && !r.done && (m = i["return"])) m.call(i);
62
- }
63
- finally { if (e) throw e.error; }
64
- }
65
- return ar;
66
- };
67
- Object.defineProperty(exports, "__esModule", { value: true });
68
- var widget_ui_1 = require("@telia-ace/widget-ui");
69
- var widget_utilities_1 = require("@telia-ace/widget-utilities");
70
- var react_1 = __importStar(require("react"));
71
- var styled_components_1 = __importStar(require("styled-components"));
72
- var ConversationInput = function (_a) {
73
- var className = _a.className;
74
- var _b = __read((0, react_1.useState)(''), 2), inputText = _b[0], setInputText = _b[1];
75
- var _c = __read((0, react_1.useState)(false), 2), inputFocus = _c[0], setInputFocus = _c[1];
76
- var _d = __read((0, react_1.useState)(0), 2), calculatedLineHeight = _d[0], setCalculatedLineHeight = _d[1];
77
- var _e = __read((0, react_1.useState)(0), 2), textareaMaxHeight = _e[0], setTextareaMaxHeight = _e[1];
78
- var dispatch = (0, widget_ui_1.useDispatch)();
79
- var _f = (0, widget_ui_1.useProperties)(), _g = _f.inputPlaceholder, inputPlaceholder = _g === void 0 ? 'Type your message' : _g, _h = _f.inputHidden, inputHidden = _h === void 0 ? false : _h, _j = _f.inputDisabled, inputDisabled = _j === void 0 ? false : _j, _k = _f.sendButtonLabel, sendButtonLabel = _k === void 0 ? 'Send message' : _k, _l = _f.inputMultiline, multiline = _l === void 0 ? true : _l, secondaryAction = _f.secondaryAction;
80
- var _m = __read((0, widget_ui_1.useScroll)(true), 2), scrollableCss = _m[0], inputRef = _m[1];
81
- (0, react_1.useEffect)(function () {
82
- if (inputRef.current) {
83
- var _a = getComputedStyle(inputRef.current), lineHeight = _a.lineHeight, maxHeight = _a.maxHeight;
84
- if (lineHeight && lineHeight.indexOf('px') > -1) {
85
- var lineHeightNumber = lineHeight.split('px');
86
- var calcLH = parseInt(lineHeightNumber[0], 10);
87
- setCalculatedLineHeight(calcLH);
88
- var maxHeightNumber = maxHeight.split('px');
89
- setTextareaMaxHeight(parseInt(maxHeightNumber[0], 10));
90
- }
91
- }
92
- }, [inputRef.current]);
93
- var submit = function (e) {
94
- if (!e.shiftKey || !multiline) {
95
- e.preventDefault();
96
- if (inputText && inputText.length > 0) {
97
- dispatch('user-submit', { text: inputText });
98
- setInputText('');
99
- onChange('');
100
- }
101
- }
102
- else if (inputText.length < 1) {
103
- e.preventDefault();
104
- }
105
- };
106
- var onSecondaryActionButtonClick = function (e) {
107
- if (!secondaryAction) {
108
- return;
109
- }
110
- e.preventDefault();
111
- dispatch('action', secondaryAction.action);
112
- };
113
- var calculateHeight = function (value) {
114
- if (multiline && inputRef.current) {
115
- var scrollHeight = inputRef.current.scrollHeight;
116
- if (scrollHeight > calculatedLineHeight) {
117
- inputRef.current.style.height = 'auto';
118
- var areaHeight = scrollHeight;
119
- if (value.length < 1) {
120
- areaHeight = calculatedLineHeight;
121
- }
122
- inputRef.current.style.height = "".concat(areaHeight, "px");
123
- if (areaHeight >= textareaMaxHeight) {
124
- inputRef.current.style.overflowY = 'scroll';
125
- }
126
- else {
127
- inputRef.current.style.overflowY = 'hidden';
128
- }
129
- }
130
- }
131
- };
132
- var onChange = function (value) {
133
- calculateHeight(value);
134
- setInputText(value);
135
- if (value && value.length > 0) {
136
- dispatch('user-typing', { textLength: value.length });
137
- }
138
- };
139
- if (inputHidden) {
140
- return null;
141
- }
142
- return (react_1.default.createElement(Wrapper, { grow: multiline, className: (0, widget_utilities_1.appendClassNames)('humany-conversation-input', className), "data-has-focus": inputFocus, scrollableCss: scrollableCss },
143
- secondaryAction && (react_1.default.createElement(StyledButton, { disabled: inputDisabled, onClick: onSecondaryActionButtonClick, title: secondaryAction.label, "aria-label": secondaryAction.label },
144
- react_1.default.createElement(widget_ui_1.SymbolBadge, { size: 22, symbol: { type: 'Svg', content: secondaryAction.icon || 'browse' } }))),
145
- multiline ? (react_1.default.createElement(StyledTextArea, { value: inputText, onChange: onChange, onEnter: submit, disabled: inputDisabled, "aria-label": inputPlaceholder, placeholder: inputPlaceholder, onFocusChange: setInputFocus, type: 'textarea', rows: 1, ref: inputRef })) : (react_1.default.createElement(StyledInput, { value: inputText, onChange: onChange, onEnter: submit, disabled: inputDisabled, "aria-label": inputPlaceholder, placeholder: inputPlaceholder, onFocusChange: setInputFocus })),
146
- react_1.default.createElement(StyledButton, { disabled: inputDisabled, onClick: submit, title: sendButtonLabel, "aria-label": sendButtonLabel },
147
- react_1.default.createElement(SendSymbol, { size: 22, symbol: { type: 'Svg', content: 'send' }, hasContent: inputText && inputText.length }))));
148
- };
149
- var StyledTextArea = (0, styled_components_1.default)(widget_ui_1.Input)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n resize: none;\n flex: 1;\n flex-shrink: 1;\n min-height: 1.2em;\n max-height: 148px;\n line-height: 1.2em;\n height: 1.2em;\n padding: 0;\n margin: ", " ", ";\n font-size: ", ";\n border: none;\n transition: height 200ms linear;\n outline: none;\n"], ["\n resize: none;\n flex: 1;\n flex-shrink: 1;\n min-height: 1.2em;\n max-height: 148px;\n line-height: 1.2em;\n height: 1.2em;\n padding: 0;\n margin: ", " ", ";\n font-size: ", ";\n border: none;\n transition: height 200ms linear;\n outline: none;\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; });
150
- var StyledInput = (0, styled_components_1.default)(widget_ui_1.Input)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n flex: 1;\n border: none;\n background-color: transparent;\n font-weight: 300;\n font-size: ", ";\n line-height: 1.2em;\n outline: none;\n padding-left: ", ";\n color: ", ";\n &::placeholder {\n color: ", ";\n font-style: italic;\n }\n"], ["\n flex: 1;\n border: none;\n background-color: transparent;\n font-weight: 300;\n font-size: ", ";\n line-height: 1.2em;\n outline: none;\n padding-left: ", ";\n color: ", ";\n &::placeholder {\n color: ", ";\n font-style: italic;\n }\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, 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.textLight; });
151
- var StyledButton = (0, styled_components_1.default)(widget_ui_1.Button)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n flex: 0 0 50px;\n align-self: stretch;\n background-color: transparent;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n color: #a6a6a6;\n &:focus {\n ", ";\n }\n"], ["\n flex: 0 0 50px;\n align-self: stretch;\n background-color: transparent;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n color: #a6a6a6;\n &:focus {\n ", ";\n }\n"])), function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && widget_ui_1.borderTabStyle; });
152
- var Wrapper = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n ", "\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n background-color: ", ";\n border-top: ", ";\n ", "\n ", " {\n ", "\n }\n"], ["\n ", "\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n background-color: ", ";\n border-top: ", ";\n ", "\n ", " {\n ", "\n }\n"])), function (p) {
153
- return p.grow
154
- ? (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n min-height: 50px;\n max-height: 150px;\n "], ["\n min-height: 50px;\n max-height: 150px;\n "]))) : (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n height: 50px;\n "], ["\n height: 50px;\n "])));
155
- }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.accent; }, function (p) { return p.theme.inputBorder; }, function (p) {
156
- return p['data-has-focus'] && (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])), function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && widget_ui_1.borderTabStyle; });
157
- }, StyledTextArea, function (p) { return !!p.scrollableCss && p.scrollableCss; });
158
- var SendSymbol = (0, styled_components_1.default)(function (_a) {
159
- var hasContent = _a.hasContent, other = __rest(_a, ["hasContent"]);
160
- return react_1.default.createElement(widget_ui_1.SymbolBadge, __assign({}, other));
161
- })(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n line,\n path {\n stroke: ", ";\n fill: ", ";\n }\n"], ["\n line,\n path {\n stroke: ", ";\n fill: ", ";\n }\n"])), function (p) { var _a; return (p.hasContent ? (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary : '#a6a6a6'); }, function (p) { var _a; return (p.hasContent ? (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary : '#a6a6a6'); });
162
- exports.default = ConversationInput;
163
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
@@ -1,18 +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
- var react_1 = __importDefault(require("react"));
7
- var conversation_styles_1 = require("./conversation-styles");
8
- var ConversationLoader = function (_a) {
9
- var className = _a.className, agentData = _a.agentData;
10
- return (react_1.default.createElement(conversation_styles_1.ContentBundle, null,
11
- react_1.default.createElement(conversation_styles_1.MessageContainer, null,
12
- react_1.default.createElement(conversation_styles_1.MessageContent, null,
13
- react_1.default.createElement(conversation_styles_1.Loader, null,
14
- react_1.default.createElement("div", null),
15
- react_1.default.createElement("div", null),
16
- react_1.default.createElement("div", null))))));
17
- };
18
- exports.default = ConversationLoader;
@@ -1,141 +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 __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
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
- var widget_forms_1 = require("@telia-ace/widget-forms");
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 conversation_controller_1 = require("../../conversation-controller");
49
- var conversation_content_1 = __importDefault(require("./conversation-content"));
50
- var conversation_styles_1 = require("./conversation-styles");
51
- var message_types_1 = require("./message-types");
52
- var imageLightboxRenderer = function (attrs) { return react_1.default.createElement(widget_ui_1.Lightbox, { attrs: attrs }); };
53
- var htmlParseInstructions = {
54
- transform: {
55
- img: imageLightboxRenderer,
56
- },
57
- };
58
- var ConversationMessageComponent = function (_a) {
59
- var className = _a.className, timestamp = _a.timestamp, sender = _a.sender, type = _a.type, content = _a.content;
60
- var dispatch = (0, widget_ui_1.useDispatch)();
61
- var getMessageStackPosition = function (index) {
62
- var messageOrder = undefined;
63
- if (content.length > 1) {
64
- messageOrder = index === 0 ? 'first' : index + 1 === content.length ? 'last' : 'middle';
65
- }
66
- return messageOrder;
67
- };
68
- var renderContent = function (content, isUser, stacked) {
69
- if (isUser === void 0) { isUser = false; }
70
- var title = content.title, body = content.body, actions = content.actions, form = content.form;
71
- return (react_1.default.createElement(conversation_styles_1.MessageContent, { user: isUser, stacked: !!stacked && stacked, fullWidth: !!form || !!actions },
72
- title && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
73
- react_1.default.createElement(conversation_styles_1.MessageTitle, { variant: "h2" }, title))),
74
- body && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
75
- react_1.default.createElement(StyledHtml, { html: body, htmlParseInstruction: htmlParseInstructions }))),
76
- form && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
77
- react_1.default.createElement(StyledForm, __assign({}, form, { onChange: function (key, data) {
78
- dispatch('form', {
79
- data: data,
80
- formKey: form.schema.id,
81
- actionKey: key,
82
- });
83
- } })))),
84
- actions && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
85
- react_1.default.createElement(StyledActionList, { items: Object.keys(actions).map(function (i) {
86
- return { label: actions[i], actionKey: i };
87
- }), renderItem: function (item) {
88
- return (react_1.default.createElement("li", { key: item.actionKey },
89
- react_1.default.createElement(StyledActionButton, { onClick: function () {
90
- dispatch('action', item.actionKey);
91
- } }, item.label)));
92
- } })))));
93
- };
94
- var createSystemMessage = function () {
95
- return (react_1.default.createElement(react_1.default.Fragment, null, content.map(function (item) {
96
- var key = item.key, body = item.body, title = item.title, form = item.form, actions = item.actions;
97
- var discrete = !!body && !title && !form && !actions;
98
- return (react_1.default.createElement(message_types_1.SystemMessage, { className: className, key: key, discrete: discrete, timestamp: timestamp, fullWidth: !!form || !!actions }, discrete && body ? (react_1.default.createElement(widget_ui_1.Html, { html: body, htmlParseInstruction: htmlParseInstructions })) : (react_1.default.createElement(conversation_content_1.default, { content: item, isUser: false }))));
99
- })));
100
- };
101
- var createAgentMessage = function () {
102
- return (react_1.default.createElement(message_types_1.AgentMessage, { sender: sender, timestamp: timestamp, className: className },
103
- react_1.default.createElement(conversation_styles_1.ContentBundle, null, content.map(function (item, index) {
104
- return (react_1.default.createElement(conversation_styles_1.MessageContainer, { key: item.key },
105
- react_1.default.createElement(conversation_content_1.default, { content: item, isUser: false, stacked: getMessageStackPosition(index) })));
106
- }))));
107
- };
108
- var createUserMessage = function () {
109
- return (react_1.default.createElement(message_types_1.UserMessage, { timestamp: timestamp, className: className },
110
- react_1.default.createElement(conversation_styles_1.ContentBundle, null, content.map(function (item, index) {
111
- return (react_1.default.createElement(conversation_styles_1.MessageContainer, { key: item.key },
112
- react_1.default.createElement(conversation_content_1.default, { content: item, isUser: true, stacked: getMessageStackPosition(index) })));
113
- }))));
114
- };
115
- switch (type) {
116
- case conversation_controller_1.ConversationMessageType.System:
117
- return createSystemMessage();
118
- case conversation_controller_1.ConversationMessageType.Agent:
119
- return createAgentMessage();
120
- case conversation_controller_1.ConversationMessageType.User:
121
- return createUserMessage();
122
- default:
123
- return null;
124
- }
125
- };
126
- var StyledForm = (0, styled_components_1.default)(widget_forms_1.FormComponent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n & button.humany-form-component-button {\n ", ";\n display: block;\n width: 100%;\n margin-bottom: ", ";\n }\n\n & button.humany-form-component-submit {\n width: 100%;\n margin: 0;\n :not(:last-child) {\n margin-bottom: ", ";\n }\n }\n"], ["\n & button.humany-form-component-button {\n ", ";\n display: block;\n width: 100%;\n margin-bottom: ", ";\n }\n\n & button.humany-form-component-submit {\n width: 100%;\n margin: 0;\n :not(:last-child) {\n margin-bottom: ", ";\n }\n }\n"])), function (p) {
127
- var _a, _b;
128
- return (0, widget_ui_1.invertedHoverButton)({
129
- active: false,
130
- primaryColor: (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
131
- secondaryColor: (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.accent,
132
- });
133
- }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
134
- var StyledHtml = (0, styled_components_1.default)(widget_ui_1.Html)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n white-space: pre-wrap;\n\n a {\n color: ", ";\n &:focus {\n ", ";\n }\n }\n"], ["\n white-space: pre-wrap;\n\n a {\n color: ", ";\n &:focus {\n ", ";\n }\n }\n"])), function (p) { return p.theme.colors.link; }, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && widget_ui_1.borderTabStyle; });
135
- var StyledActionList = (0, styled_components_1.default)(widget_ui_1.List)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 0;\n list-style: none;\n margin: 0 -", ";\n > li {\n margin: ", ";\n }\n"], ["\n padding: 0;\n list-style: none;\n margin: 0 -", ";\n > li {\n margin: ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
136
- var StyledActionButton = styled_components_1.default.button(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", ";\n display: block;\n background-color: ", ";\n width: 100%;\n color: #fff;\n &:focus {\n ", "\n }\n"], ["\n ", ";\n display: block;\n background-color: ", ";\n width: 100%;\n color: #fff;\n &:focus {\n ", "\n }\n"])), widget_ui_1.buttonCss, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) {
137
- var _a;
138
- return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", "\n background-color: transparent;\n "], ["\n ", "\n background-color: transparent;\n "])), widget_ui_1.borderTabStyle);
139
- });
140
- exports.default = ConversationMessageComponent;
141
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -1,11 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const Avatar: import("styled-components").StyledComponent<"div", any, any, never>;
3
- export declare const LoaderAnimation: import("styled-components").Keyframes;
4
- export declare const Loader: import("styled-components").StyledComponent<"div", any, {}, never>;
5
- export declare const ContentBundle: import("styled-components").StyledComponent<"div", any, {}, never>;
6
- export declare const MessageTitle: import("styled-components").StyledComponent<import("react").FC<import("@telia-ace/widget-ui").TypographyProps>, any, {}, never>;
7
- export declare const MessageContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
8
- export declare const MessageContent: import("styled-components").StyledComponent<"div", any, any, never>;
9
- export declare const MessageContentPart: import("styled-components").StyledComponent<"div", any, {
10
- noPadding?: boolean | undefined;
11
- }, never>;