@telia-ace/widget-conversation 1.0.2 → 1.0.6

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.
@@ -10,6 +10,7 @@ export declare type ConversationMessageSettings = {
10
10
  };
11
11
  form?: (builder: FormBuilder) => void;
12
12
  type?: string;
13
+ items?: ConversationMessageList[];
13
14
  [key: string]: any;
14
15
  };
15
16
  export declare type NormalizedMessageSettings = {
@@ -17,15 +18,34 @@ export declare type NormalizedMessageSettings = {
17
18
  key: string;
18
19
  timestamp: number | null;
19
20
  };
21
+ export declare type ConversationMessageList = {
22
+ header?: string;
23
+ itemKey: string;
24
+ type?: ConversationMessageListType;
25
+ items: ConversationMessageListItem[];
26
+ };
27
+ export declare type ConversationMessageListItem = {
28
+ icon?: string;
29
+ type?: ConversationMessageListItemType;
30
+ actions?: {
31
+ [actionKey: string]: any;
32
+ };
33
+ form?: Form;
34
+ body?: string;
35
+ key: string;
36
+ [key: string]: any;
37
+ };
20
38
  export declare type ConversationMessageContent = {
21
39
  title?: string;
22
40
  body?: string;
23
41
  actions?: {
24
42
  [actionKey: string]: any;
25
43
  };
44
+ items?: ConverstationMessageItem<any>[];
26
45
  form?: Form;
27
46
  [key: string]: any;
28
47
  };
48
+ export declare type ConverstationMessageItem<T, R = ItemPayload> = R extends [T, any] ? R : never;
29
49
  export declare type ConversationMessageUpdateSettings = ConversationMessageContent & {
30
50
  timestamp?: number;
31
51
  };
@@ -33,3 +53,58 @@ export declare type ConversationMessageSender = {
33
53
  name?: string;
34
54
  avatar?: string | Symbol;
35
55
  };
56
+ export declare enum ConversationMessageListType {
57
+ Ordinary = "ordinary",
58
+ Seperator = "seperator"
59
+ }
60
+ export declare enum ConversationMessageListItemType {
61
+ Header = "header",
62
+ LinkList = "link-list",
63
+ Separator = "separator",
64
+ NoGoodAlternative = "no-good-alternative",
65
+ ButtonList = "button-list",
66
+ Text = "text",
67
+ HTML = "html",
68
+ FeedbackList = "feedback-list"
69
+ }
70
+ declare type LinkListItem = [
71
+ ConversationMessageListItemType.LinkList,
72
+ {
73
+ actions: {
74
+ [key: string]: string;
75
+ };
76
+ }
77
+ ];
78
+ declare type HeaderItem = [ConversationMessageListItemType.Header, string];
79
+ declare type TextItem = [ConversationMessageListItemType.Text, string];
80
+ declare type SeparatorItem = [ConversationMessageListItemType.Separator, undefined];
81
+ declare type NoGoodAlternativeItem = [
82
+ ConversationMessageListItemType.NoGoodAlternative,
83
+ {
84
+ body: string;
85
+ }
86
+ ];
87
+ declare type ButtonListItem = [
88
+ ConversationMessageListItemType.ButtonList,
89
+ {
90
+ actions: {
91
+ [key: string]: string;
92
+ };
93
+ }
94
+ ];
95
+ declare type FeedbackListItem = [
96
+ ConversationMessageListItemType.FeedbackList,
97
+ {
98
+ actions: {
99
+ [key: string]: string;
100
+ };
101
+ }
102
+ ];
103
+ declare type HTMLItem = [
104
+ ConversationMessageListItemType.HTML,
105
+ {
106
+ body: string;
107
+ }
108
+ ];
109
+ declare type ItemPayload = LinkListItem | HeaderItem | TextItem | SeparatorItem | NoGoodAlternativeItem | ButtonListItem | HTMLItem | FeedbackListItem;
110
+ export {};
package/lib-esm/types.js CHANGED
@@ -1 +1,16 @@
1
- export {};
1
+ export var ConversationMessageListType;
2
+ (function (ConversationMessageListType) {
3
+ ConversationMessageListType["Ordinary"] = "ordinary";
4
+ ConversationMessageListType["Seperator"] = "seperator";
5
+ })(ConversationMessageListType || (ConversationMessageListType = {}));
6
+ export var ConversationMessageListItemType;
7
+ (function (ConversationMessageListItemType) {
8
+ ConversationMessageListItemType["Header"] = "header";
9
+ ConversationMessageListItemType["LinkList"] = "link-list";
10
+ ConversationMessageListItemType["Separator"] = "separator";
11
+ ConversationMessageListItemType["NoGoodAlternative"] = "no-good-alternative";
12
+ ConversationMessageListItemType["ButtonList"] = "button-list";
13
+ ConversationMessageListItemType["Text"] = "text";
14
+ ConversationMessageListItemType["HTML"] = "html";
15
+ ConversationMessageListItemType["FeedbackList"] = "feedback-list";
16
+ })(ConversationMessageListItemType || (ConversationMessageListItemType = {}));
@@ -13,10 +13,28 @@ var __assign = (this && this.__assign) || function () {
13
13
  };
14
14
  return __assign.apply(this, arguments);
15
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
+ };
16
32
  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';
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';
19
36
  import styled, { css } from 'styled-components';
37
+ import { ConversationMessageListItemType, } from '../../types';
20
38
  import { MessageContent, MessageContentPart as Part, MessageTitle } from './conversation-styles';
21
39
  import { CustomMessage } from './message-types';
22
40
  var imageLightboxRenderer = function (attrs) { return React.createElement(Lightbox, { attrs: attrs }); };
@@ -28,10 +46,10 @@ var htmlParseInstructions = {
28
46
  var ConversationContent = function (_a) {
29
47
  var content = _a.content, isUser = _a.isUser, stacked = _a.stacked;
30
48
  var dispatch = useDispatch();
31
- var title = content.title, body = content.body, actions = content.actions, form = content.form, type = content.type;
49
+ var title = content.title, body = content.body, actions = content.actions, form = content.form, type = content.type, items = content.items;
32
50
  if (type)
33
51
  return React.createElement(CustomMessage, { type: type, content: content, isUser: isUser, stacked: stacked });
34
- return (React.createElement(MessageContent, { user: isUser, stacked: !!stacked && stacked, fullWidth: !!form || !!actions },
52
+ return (React.createElement(MessageContent, { noPadding: true, user: isUser, stacked: !!stacked && stacked, fullWidth: !!form || !!actions },
35
53
  title && (React.createElement(Part, null,
36
54
  React.createElement(MessageTitle, { variant: "h2" }, title))),
37
55
  body && (React.createElement(Part, null,
@@ -52,7 +70,99 @@ var ConversationContent = function (_a) {
52
70
  React.createElement(StyledActionButton, { onClick: function () {
53
71
  dispatch('action', item.actionKey);
54
72
  } }, item.label)));
55
- } })))));
73
+ } }))),
74
+ items && (React.createElement(Fragment, null,
75
+ React.createElement(Part, { key: uuid(), noPadding: true },
76
+ React.createElement(StyledActionList, { items: items.map(function (_a) {
77
+ var _b = __read(_a, 2), type = _b[0], content = _b[1];
78
+ return { type: type, content: content };
79
+ }), renderItem: function (item) {
80
+ var itemKey = uuid();
81
+ switch (item.type) {
82
+ case ConversationMessageListItemType.Header: {
83
+ return (React.createElement(ConversationListItem, { key: itemKey },
84
+ React.createElement("strong", null, item.content)));
85
+ }
86
+ case ConversationMessageListItemType.Text: {
87
+ return (React.createElement(ConversationListItem, { key: itemKey },
88
+ React.createElement("span", null, item.content)));
89
+ }
90
+ case ConversationMessageListItemType.HTML: {
91
+ return (React.createElement(ConversationListItem, { key: itemKey },
92
+ React.createElement(StyledHtml, { html: item.content.body, htmlParseInstruction: htmlParseInstructions })));
93
+ }
94
+ case ConversationMessageListItemType.Separator: {
95
+ return (React.createElement(ConversationListItem, { key: itemKey, noPadding: true },
96
+ React.createElement(Separator, null)));
97
+ }
98
+ case ConversationMessageListItemType.LinkList: {
99
+ return (React.createElement(ConversationListItem, { key: itemKey },
100
+ React.createElement(StyledLinkList, { items: Object.keys(item.content.actions).map(function (i) {
101
+ return {
102
+ label: item.content.actions[i],
103
+ actionKey: i,
104
+ };
105
+ }), renderItem: function (item) {
106
+ return (React.createElement("li", { key: item.actionKey },
107
+ React.createElement(StyledLinkButton, { help: item.actionKey === 'help', onClick: function () {
108
+ dispatch('action', item.actionKey);
109
+ } },
110
+ item.label,
111
+ item.actionKey === 'help' && (React.createElement(SymbolBadge, { size: 14, symbol: {
112
+ type: 'Svg',
113
+ content: 'caret-down',
114
+ } })))));
115
+ } })));
116
+ }
117
+ case ConversationMessageListItemType.ButtonList: {
118
+ return (React.createElement(ConversationListItem, { key: itemKey },
119
+ React.createElement(StyledButtonList, { items: Object.keys(item.content.actions).map(function (i) {
120
+ return {
121
+ label: item.content.actions[i],
122
+ actionKey: i,
123
+ };
124
+ }), renderItem: function (item) {
125
+ return (React.createElement("li", { key: item.actionKey },
126
+ React.createElement(StyledButtonListButton, { onClick: function () {
127
+ dispatch('action', item.actionKey);
128
+ } }, item.label)));
129
+ } })));
130
+ }
131
+ case ConversationMessageListItemType.NoGoodAlternative: {
132
+ return (React.createElement(ConversationListItem, { key: itemKey },
133
+ React.createElement(NoGoodAlternativeWrapper, { onClick: function () {
134
+ dispatch('action', 'help');
135
+ } },
136
+ React.createElement(SymbolBadge, { size: 14, symbol: {
137
+ type: 'FontAwesome',
138
+ content: 'meh-o',
139
+ } }),
140
+ React.createElement("span", null, item.content.body))));
141
+ }
142
+ case ConversationMessageListItemType.FeedbackList: {
143
+ return (React.createElement(ConversationListItem, { key: itemKey },
144
+ React.createElement(StyledButtonList, { items: Object.keys(item.content.actions).map(function (i) {
145
+ return {
146
+ label: item.content.actions[i],
147
+ actionKey: i,
148
+ };
149
+ }), renderItem: function (item) {
150
+ return (React.createElement("li", { key: item.actionKey },
151
+ React.createElement(FeedbackButton, { className: "humany-feedback-button", disabled: false, "aria-pressed": true, "data-selected": true, "data-direction": 'vertical', onClick: function () {
152
+ dispatch('action', item.actionKey);
153
+ } },
154
+ React.createElement(Icon, { faIcon: item.actionKey == 'yes'
155
+ ? 'smile-o'
156
+ : 'frown-o' }),
157
+ React.createElement("span", null, item.label))));
158
+ } })));
159
+ }
160
+ default: {
161
+ return (React.createElement(Fragment, null,
162
+ React.createElement("p", null, "Unknown message type")));
163
+ }
164
+ }
165
+ } }))))));
56
166
  };
57
167
  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) {
58
168
  var _a, _b;
@@ -64,9 +174,35 @@ var StyledForm = styled(FormComponent)(templateObject_1 || (templateObject_1 = _
64
174
  }, 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; });
65
175
  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; });
66
176
  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; });
67
- 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) {
177
+ 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; });
178
+ var StyledButtonListButton = styled.button(templateObject_6 || (templateObject_6 = __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) {
179
+ var _a;
180
+ 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);
181
+ });
182
+ 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; });
183
+ var StyledLinkButton = styled.button(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: block;\n background-color: transparent;\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 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) {
184
+ var _a, _b;
185
+ return p.help && css(templateObject_8 || (templateObject_8 = __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);
186
+ });
187
+ var StyledActionButton = styled.button(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n ", ";\n display: block;\n background-color: ", ";\n width: 100%;\n color: #fff;\n font-family: Lato;\n font-size: 1rem;\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: 1rem;\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) {
68
188
  var _a;
69
- 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);
189
+ return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && css(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n ", "\n background-color: transparent;\n "], ["\n ", "\n background-color: transparent;\n "])), borderTabStyle);
70
190
  });
191
+ var Separator = styled.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n background-color: #efefef;\n height: 1px;\n width: 100%;\n"], ["\n background-color: #efefef;\n height: 1px;\n width: 100%;\n"])));
192
+ var NoGoodAlternativeWrapper = styled.div(templateObject_13 || (templateObject_13 = __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; });
193
+ var ConversationListItem = styled.li(templateObject_14 || (templateObject_14 = __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); });
194
+ var FeedbackButton = styled.button(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n display: inline-block;\n font-size: ", ";\n background-color: #ffffff !important;\n color: ", " !important;\n border-color: ", " !important;\n font-weight: 300;\n && {\n margin-right: ", ";\n }\n ", "\n ", "\n ", "\n i {\n margin: 0 ", " 0 0;\n color: ", " !important;\n }\n span {\n color: ", " !important;\n }\n"], ["\n display: inline-block;\n font-size: ", ";\n background-color: #ffffff !important;\n color: ", " !important;\n border-color: ", " !important;\n font-weight: 300;\n && {\n margin-right: ", ";\n }\n ", "\n ", "\n ", "\n i {\n margin: 0 ", " 0 0;\n color: ", " !important;\n }\n span {\n color: ", " !important;\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.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) {
195
+ var _a, _b;
196
+ return p['data-direction'] === 'horizontal' && css(templateObject_15 || (templateObject_15 = __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);
197
+ }, function (p) {
198
+ return p['data-direction'] === 'vertical' && css(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n min-width: 150px;\n "], ["\n min-width: 150px;\n "])));
199
+ }, function (p) {
200
+ var _a;
201
+ return invertedHoverButton({
202
+ active: p['data-selected'],
203
+ primaryColor: (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
204
+ secondaryColor: '#FFFFFF',
205
+ });
206
+ }, 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.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; });
71
207
  export default ConversationContent;
72
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
208
+ 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;
@@ -6,4 +6,6 @@ export declare const ContentBundle: import("styled-components").StyledComponent<
6
6
  export declare const MessageTitle: import("styled-components").StyledComponent<import("react").FC<import("@telia-ace/widget-ui").TypographyProps>, any, {}, never>;
7
7
  export declare const MessageContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
8
8
  export declare const MessageContent: import("styled-components").StyledComponent<"div", any, any, never>;
9
- export declare const MessageContentPart: import("styled-components").StyledComponent<"div", any, {}, never>;
9
+ export declare const MessageContentPart: import("styled-components").StyledComponent<"div", any, {
10
+ noPadding?: boolean | undefined;
11
+ }, never>;
@@ -4,13 +4,13 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
4
4
  };
5
5
  import { Typography } from '@telia-ace/widget-ui';
6
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: 10px;\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: 10px;\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.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; });
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
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
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: auto;\n"], ["\n grid-area: content;\n max-width: 100%;\n overflow: auto;\n"])));
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
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
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 padding: ", ";\n background-color: ", ";\n color: ", ";\n border-radius: 5px; // TODO: prop?\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 padding: ", ";\n background-color: ", ";\n color: ", ";\n border-radius: 5px; // TODO: prop?\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; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, 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.normal; }, function (p) { return p.fullWidth && 'width: 100%;'; }, function (p) {
13
+ export var MessageContent = styled.div(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n background-color: ", ";\n color: ", ";\n border-radius: 5px; // TODO: prop?\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 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.normal; }, function (p) { return p.fullWidth && 'width: 100%;'; }, function (p) {
14
14
  return !p.user && css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n border: ", ";\n "], ["\n border: ", ";\n "])), p.theme.border);
15
15
  }, function (p) { return p.user && 'margin-left: auto'; }, function (p) {
16
16
  return p.stacked === 'first' &&
@@ -33,5 +33,7 @@ export var MessageContent = styled.div(templateObject_15 || (templateObject_15 =
33
33
  }, function (p) {
34
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
35
  });
36
- export var MessageContentPart = styled.div(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n margin-bottom: ", ";\n &:last-child {\n margin-bottom: 0;\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; });
37
- 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;
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.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;
@@ -14,12 +14,12 @@ import React, { Suspense } from 'react';
14
14
  import { MessageContent, MessageContentPart } from '../conversation-styles';
15
15
  var CustomMessage = function (props) {
16
16
  var CustomComponent = useComponent(props.type);
17
- if (typeof CustomComponent === 'undefined') {
17
+ if (!CustomComponent) {
18
18
  return null;
19
19
  }
20
20
  return (React.createElement(Suspense, { fallback: null },
21
21
  React.createElement(MessageContent, { user: props.isUser, stacked: !!props.stacked && props.stacked, fullWidth: !!props.content.form || !!props.content.actions },
22
- React.createElement(MessageContentPart, null,
22
+ React.createElement(MessageContentPart, { noPadding: !!props.content.noPadding && props.content.noPadding },
23
23
  React.createElement(CustomComponent, __assign({}, props.content))))));
24
24
  };
25
25
  export default CustomMessage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-conversation",
3
- "version": "1.0.2",
3
+ "version": "1.0.6",
4
4
  "description": "ACE Widget Conversation Platform",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
@@ -25,19 +25,21 @@
25
25
  "sideEffects": false,
26
26
  "typings": "lib/index.d.ts",
27
27
  "dependencies": {
28
- "@telia-ace/widget-core": "^1.0.1",
29
- "@telia-ace/widget-forms": "^1.0.2",
30
- "@telia-ace/widget-plugins": "^1.0.1",
31
- "@telia-ace/widget-routing": "^1.0.1",
32
- "@telia-ace/widget-services": "^1.0.1",
33
- "@telia-ace/widget-ui": "^1.0.2",
28
+ "@telia-ace/widget-core": "^1.0.4",
29
+ "@telia-ace/widget-forms": "^1.0.6",
30
+ "@telia-ace/widget-plugins": "^1.0.5",
31
+ "@telia-ace/widget-routing": "^1.0.5",
32
+ "@telia-ace/widget-services": "^1.0.4",
33
+ "@telia-ace/widget-ui": "^1.0.6",
34
34
  "@telia-ace/widget-utilities": "^1.0.1",
35
- "@webprovisions/platform": "^1.1.2",
35
+ "@webprovisions/platform": "^1.1.2"
36
+ },
37
+ "peerDependencies": {
36
38
  "react": "^16.8.0",
37
39
  "styled-components": "^4.3.2"
38
40
  },
39
41
  "devDependencies": {
40
42
  "@types/react": "^16.8.0"
41
43
  },
42
- "gitHead": "cfdc4aa8242f645bb32e1293c13539462d03a9c9"
44
+ "gitHead": "34cb85e421c0c4a5bd08ccd899291683a11b3cf9"
43
45
  }