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