beem-component 1.4.7 → 1.5.0
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/dist/components/ChatComponents/ChatBody/chatBody.js +46 -38
- package/dist/components/ChatComponents/ChatBody/chatBody.stories.js +5 -1
- package/dist/components/ChatComponents/ChatBody/sessionDetails.js +39 -0
- package/package.json +1 -1
- package/src/App.js +58 -4
- package/src/lib/components/ChatComponents/ChatBody/chatBody.js +97 -77
- package/src/lib/components/ChatComponents/ChatBody/chatBody.stories.js +1 -0
- package/src/lib/components/ChatComponents/ChatBody/sessionDetails.js +22 -0
|
@@ -19,11 +19,13 @@ var _avatars = _interopRequireDefault(require("../../Avatars/avatars"));
|
|
|
19
19
|
|
|
20
20
|
var _iconStyles = require("../../iconStyles");
|
|
21
21
|
|
|
22
|
+
var _sessionDetails = require("./sessionDetails");
|
|
23
|
+
|
|
22
24
|
var _colors = require("../../colors");
|
|
23
25
|
|
|
24
26
|
var _excluded = ["state", "file", "src", "fileName", "onDownload"],
|
|
25
27
|
_excluded2 = ["state", "src", "fileName"],
|
|
26
|
-
_excluded3 = ["children", "state", "displayTime", "status", "session", "src", "file", "fileName"];
|
|
28
|
+
_excluded3 = ["children", "state", "displayTime", "status", "session", "src", "file", "fileName", "sessionDetails"];
|
|
27
29
|
|
|
28
30
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
29
31
|
|
|
@@ -37,25 +39,27 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
37
39
|
|
|
38
40
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
39
41
|
|
|
40
|
-
var BmChat = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n height: 100%;\n ", "\n"])),
|
|
42
|
+
var BmChat = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n height: 100%;\n ", "\n"])), ""
|
|
41
43
|
/* border: 0.071rem solid ${BmGrey400}; */
|
|
42
44
|
);
|
|
43
45
|
|
|
44
46
|
BmChat.Body = _styledComponents.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column-reverse;\n padding: 0rem 1rem;\n flex-grow: 1;\n overflow: auto;\n height: 100%;\n"])));
|
|
45
47
|
|
|
46
|
-
var Details = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: ", ";\n > *:not(:last-child) {\n margin-right: 1rem;\n margin-bottom: 0.5rem;\n }\n overflow-wrap: break-word !important;\n word-wrap: break-word !important;\n margin: 0rem;\n flex-grow: 1;\n"])), function (_ref) {
|
|
48
|
+
var Details = _styledComponents.default.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n justify-content: ", ";\n > *:not(:last-child) {\n margin-right: 1rem;\n margin-bottom: 0.5rem;\n }\n overflow-wrap: break-word !important;\n word-wrap: break-word !important;\n margin: 0rem;\n flex-grow: 1;\n ", "\n"])), function (_ref) {
|
|
47
49
|
var state = _ref.state;
|
|
48
50
|
|
|
49
|
-
if (state ===
|
|
50
|
-
return
|
|
51
|
+
if (state === "inbound") {
|
|
52
|
+
return "flex-start";
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
if (state ===
|
|
54
|
-
return
|
|
55
|
+
if (state === "outbound") {
|
|
56
|
+
return "flex-end";
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
+
return "row";
|
|
60
|
+
}, ""
|
|
61
|
+
/* border: 1px solid red; */
|
|
62
|
+
);
|
|
59
63
|
|
|
60
64
|
var MessageDetails = _styledComponents.default.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n max-width: 70%;\n > * {\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n }\n"])));
|
|
61
65
|
|
|
@@ -63,8 +67,8 @@ var Messages = _styledComponents.default.div(_templateObject5 || (_templateObjec
|
|
|
63
67
|
var state = _ref2.state;
|
|
64
68
|
|
|
65
69
|
if (state) {
|
|
66
|
-
if (state ===
|
|
67
|
-
if (state ===
|
|
70
|
+
if (state === "inbound") return "".concat(_colors.BmPrimaryWhite);
|
|
71
|
+
if (state === "outbound") return "".concat(_colors.BmPrimaryBlue);
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
return "".concat(_colors.BmPrimaryWhite);
|
|
@@ -72,8 +76,8 @@ var Messages = _styledComponents.default.div(_templateObject5 || (_templateObjec
|
|
|
72
76
|
var state = _ref3.state;
|
|
73
77
|
|
|
74
78
|
if (state) {
|
|
75
|
-
if (state ===
|
|
76
|
-
if (state ===
|
|
79
|
+
if (state === "inbound") return "".concat(_colors.BmPrimaryBlack);
|
|
80
|
+
if (state === "outbound") return "".concat(_colors.BmPrimaryWhite);
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
return "".concat(_colors.BmPrimaryWhite);
|
|
@@ -81,8 +85,8 @@ var Messages = _styledComponents.default.div(_templateObject5 || (_templateObjec
|
|
|
81
85
|
var state = _ref4.state;
|
|
82
86
|
|
|
83
87
|
if (state) {
|
|
84
|
-
if (state ===
|
|
85
|
-
if (state ===
|
|
88
|
+
if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
|
|
89
|
+
if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
return "".concat(_colors.BmPrimaryWhite);
|
|
@@ -93,14 +97,14 @@ var MessagesSubDetails = _styledComponents.default.div(_templateObject6 || (_tem
|
|
|
93
97
|
var handleState = function handleState(_ref5) {
|
|
94
98
|
var session = _ref5.session;
|
|
95
99
|
|
|
96
|
-
if (session ===
|
|
100
|
+
if (session === "bot") {
|
|
97
101
|
return /*#__PURE__*/_react.default.createElement(_avatars.default, {
|
|
98
102
|
size: "small",
|
|
99
103
|
user: "chatbot"
|
|
100
104
|
});
|
|
101
105
|
}
|
|
102
106
|
|
|
103
|
-
if (session ===
|
|
107
|
+
if (session === "live") {
|
|
104
108
|
return /*#__PURE__*/_react.default.createElement(_avatars.default, {
|
|
105
109
|
size: "small",
|
|
106
110
|
user: "employee"
|
|
@@ -113,8 +117,8 @@ var FileAttachmentWrapper = _styledComponents.default.div(_templateObject7 || (_
|
|
|
113
117
|
var state = _ref6.state;
|
|
114
118
|
|
|
115
119
|
if (state) {
|
|
116
|
-
if (state ===
|
|
117
|
-
if (state ===
|
|
120
|
+
if (state === "inbound") return "".concat(_colors.BmPrimaryWhite);
|
|
121
|
+
if (state === "outbound") return "".concat(_colors.BmPrimaryBlue);
|
|
118
122
|
}
|
|
119
123
|
|
|
120
124
|
return "".concat(_colors.BmPrimaryWhite);
|
|
@@ -122,8 +126,8 @@ var FileAttachmentWrapper = _styledComponents.default.div(_templateObject7 || (_
|
|
|
122
126
|
var state = _ref7.state;
|
|
123
127
|
|
|
124
128
|
if (state) {
|
|
125
|
-
if (state ===
|
|
126
|
-
if (state ===
|
|
129
|
+
if (state === "inbound") return "".concat(_colors.BmPrimaryBlack);
|
|
130
|
+
if (state === "outbound") return "".concat(_colors.BmPrimaryWhite);
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
return "".concat(_colors.BmPrimaryWhite);
|
|
@@ -131,8 +135,8 @@ var FileAttachmentWrapper = _styledComponents.default.div(_templateObject7 || (_
|
|
|
131
135
|
var state = _ref8.state;
|
|
132
136
|
|
|
133
137
|
if (state) {
|
|
134
|
-
if (state ===
|
|
135
|
-
if (state ===
|
|
138
|
+
if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
|
|
139
|
+
if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
return "".concat(_colors.BmPrimaryWhite);
|
|
@@ -140,14 +144,14 @@ var FileAttachmentWrapper = _styledComponents.default.div(_templateObject7 || (_
|
|
|
140
144
|
var state = _ref9.state;
|
|
141
145
|
|
|
142
146
|
if (state) {
|
|
143
|
-
if (state ===
|
|
144
|
-
if (state ===
|
|
147
|
+
if (state === "inbound") return "".concat(_colors.BmPrimaryBlue);
|
|
148
|
+
if (state === "outbound") return "".concat(_colors.BmPrimaryWhite);
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
return "".concat(_colors.BmPrimaryWhite);
|
|
148
|
-
},
|
|
152
|
+
}, ""
|
|
149
153
|
/* max-width: 100%; */
|
|
150
|
-
,
|
|
154
|
+
, ""
|
|
151
155
|
/* max-height: 100%; */
|
|
152
156
|
);
|
|
153
157
|
|
|
@@ -174,8 +178,8 @@ var BmImageWrapper = _styledComponents.default.div(_templateObject8 || (_templat
|
|
|
174
178
|
var state = _ref11.state;
|
|
175
179
|
|
|
176
180
|
if (state) {
|
|
177
|
-
if (state ===
|
|
178
|
-
if (state ===
|
|
181
|
+
if (state === "inbound") return "".concat(_colors.BmPrimaryBlack);
|
|
182
|
+
if (state === "outbound") return "".concat(_colors.BmPrimaryWhite);
|
|
179
183
|
}
|
|
180
184
|
|
|
181
185
|
return "".concat(_colors.BmPrimaryWhite);
|
|
@@ -183,8 +187,8 @@ var BmImageWrapper = _styledComponents.default.div(_templateObject8 || (_templat
|
|
|
183
187
|
var state = _ref12.state;
|
|
184
188
|
|
|
185
189
|
if (state) {
|
|
186
|
-
if (state ===
|
|
187
|
-
if (state ===
|
|
190
|
+
if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
|
|
191
|
+
if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
|
|
188
192
|
}
|
|
189
193
|
|
|
190
194
|
return "".concat(_colors.BmPrimaryWhite);
|
|
@@ -192,7 +196,7 @@ var BmImageWrapper = _styledComponents.default.div(_templateObject8 || (_templat
|
|
|
192
196
|
|
|
193
197
|
exports.BmImageWrapper = BmImageWrapper;
|
|
194
198
|
|
|
195
|
-
var BmImage = _styledComponents.default.img(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n ", "\n width: 100%;\n object-fit: cover;\n flex-grow: 1;\n"])),
|
|
199
|
+
var BmImage = _styledComponents.default.img(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n ", "\n width: 100%;\n object-fit: cover;\n flex-grow: 1;\n"])), ""
|
|
196
200
|
/* Fix width */
|
|
197
201
|
);
|
|
198
202
|
|
|
@@ -232,11 +236,15 @@ BmChat.Details = function (_ref14) {
|
|
|
232
236
|
src = _ref14.src,
|
|
233
237
|
file = _ref14.file,
|
|
234
238
|
fileName = _ref14.fileName,
|
|
239
|
+
sessionDetails = _ref14.sessionDetails,
|
|
235
240
|
rest = _objectWithoutProperties(_ref14, _excluded3);
|
|
236
241
|
|
|
237
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
242
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, sessionDetails && /*#__PURE__*/_react.default.createElement(_sessionDetails.SessionDetails, _extends({
|
|
243
|
+
time: sessionDetails.time,
|
|
244
|
+
message: sessionDetails.message
|
|
245
|
+
}, rest)), /*#__PURE__*/_react.default.createElement(Details, _extends({
|
|
238
246
|
state: state
|
|
239
|
-
}, rest), /*#__PURE__*/_react.default.createElement(MessageState, null, state ===
|
|
247
|
+
}, rest), /*#__PURE__*/_react.default.createElement(MessageState, null, state === "inbound" && session && handleState({
|
|
240
248
|
state: state,
|
|
241
249
|
session: session
|
|
242
250
|
})), /*#__PURE__*/_react.default.createElement(MessageDetails, null, src && /*#__PURE__*/_react.default.createElement(BmImageChat, _extends({
|
|
@@ -249,18 +257,18 @@ BmChat.Details = function (_ref14) {
|
|
|
249
257
|
file: file,
|
|
250
258
|
fileName: fileName,
|
|
251
259
|
state: state
|
|
252
|
-
}, rest)), /*#__PURE__*/_react.default.createElement(MessagesSubDetails, null, displayTime && displayTime, status ===
|
|
260
|
+
}, rest)), /*#__PURE__*/_react.default.createElement(MessagesSubDetails, null, displayTime && displayTime, status === "sent" && /*#__PURE__*/_react.default.createElement(_iconStyles.BmIcons, {
|
|
253
261
|
icon: /*#__PURE__*/_react.default.createElement(_icons.DoneAll, null),
|
|
254
262
|
color: "".concat(_colors.BmSecondaryDarkGreen),
|
|
255
263
|
size: "small"
|
|
256
|
-
}), status ===
|
|
264
|
+
}), status === "failed" && /*#__PURE__*/_react.default.createElement(_iconStyles.BmIcons, {
|
|
257
265
|
icon: /*#__PURE__*/_react.default.createElement(_icons.Done, null),
|
|
258
266
|
color: "".concat(_colors.BmPrimaryBlack),
|
|
259
267
|
size: "small"
|
|
260
|
-
}))), /*#__PURE__*/_react.default.createElement(MessageState, null, state ===
|
|
268
|
+
}))), /*#__PURE__*/_react.default.createElement(MessageState, null, state === "outbound" && session && handleState({
|
|
261
269
|
state: state,
|
|
262
270
|
session: session
|
|
263
|
-
})));
|
|
271
|
+
}))));
|
|
264
272
|
};
|
|
265
273
|
|
|
266
274
|
BmChat.Footer = _styledComponents.default.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n padding: 0.5rem 0.5rem;\n > *:not(:last-child) {\n margin-bottom: 0.5rem;\n }\n"])));
|
|
@@ -38,7 +38,11 @@ var ChatBody = function ChatBody() {
|
|
|
38
38
|
state: "inbound",
|
|
39
39
|
session: "bot",
|
|
40
40
|
displayTime: /*#__PURE__*/_react.default.createElement("p", null, "12:00pm"),
|
|
41
|
-
status: "sent"
|
|
41
|
+
status: "sent",
|
|
42
|
+
sessionDetails: {
|
|
43
|
+
message: /*#__PURE__*/_react.default.createElement("h3", null, "Session Message"),
|
|
44
|
+
time: /*#__PURE__*/_react.default.createElement("p", null, "12:00pm")
|
|
45
|
+
}
|
|
42
46
|
}, /*#__PURE__*/_react.default.createElement("p", null, "Inbound Text Message")), /*#__PURE__*/_react.default.createElement(_chatBody.default.Details, {
|
|
43
47
|
state: "inbound",
|
|
44
48
|
session: "live",
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SessionDetails = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
var _colors = require("../../colors");
|
|
11
|
+
|
|
12
|
+
var _excluded = ["message", "time"];
|
|
13
|
+
|
|
14
|
+
var _templateObject;
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
19
|
+
|
|
20
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
21
|
+
|
|
22
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
23
|
+
|
|
24
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
25
|
+
|
|
26
|
+
var SessionDetailsWrapper = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n text-align: center;\n border-bottom: 0.071rem solid ", ";\n margin: 0.5rem;\n"])), _colors.BmGrey200);
|
|
27
|
+
|
|
28
|
+
var SessionDetails = function SessionDetails(_ref) {
|
|
29
|
+
var message = _ref.message,
|
|
30
|
+
time = _ref.time,
|
|
31
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
|
|
33
|
+
return /*#__PURE__*/React.createElement(SessionDetailsWrapper, _extends({
|
|
34
|
+
time: time,
|
|
35
|
+
message: message
|
|
36
|
+
}, rest), /*#__PURE__*/React.createElement("p", null, "\xA0"), message || /*#__PURE__*/React.createElement("p", null, "\xA0"), time || /*#__PURE__*/React.createElement("p", null, "\xA0"));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.SessionDetails = SessionDetails;
|
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -1,13 +1,67 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { GlobalStyle, BmChat } from "./lib/components";
|
|
3
|
+
import image from "../src/lib/assets/chart-img.png";
|
|
3
4
|
|
|
4
5
|
const App = () => {
|
|
5
6
|
return (
|
|
6
7
|
<>
|
|
7
8
|
<GlobalStyle />
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
|
|
9
|
+
<BmChat>
|
|
10
|
+
<BmChat.Body>
|
|
11
|
+
<BmChat.Details
|
|
12
|
+
state="inbound"
|
|
13
|
+
session="bot"
|
|
14
|
+
displayTime={<p>12:00pm</p>}
|
|
15
|
+
status="sent"
|
|
16
|
+
>
|
|
17
|
+
<p>Inbound Text Message</p>
|
|
18
|
+
</BmChat.Details>
|
|
19
|
+
<BmChat.Details
|
|
20
|
+
state="inbound"
|
|
21
|
+
session="live"
|
|
22
|
+
displayTime={<p>12:00pm</p>}
|
|
23
|
+
status="sent"
|
|
24
|
+
fileName={<p>chat.png</p>}
|
|
25
|
+
src={image}
|
|
26
|
+
sessionDetails={{ message: <h3>tejal</h3>, time: <p>today</p> }}
|
|
27
|
+
/>
|
|
28
|
+
<BmChat.Details
|
|
29
|
+
state="inbound"
|
|
30
|
+
session="live"
|
|
31
|
+
displayTime={<p>10:00am</p>}
|
|
32
|
+
status="failed"
|
|
33
|
+
fileName={<p>file.csv</p>}
|
|
34
|
+
file={image}
|
|
35
|
+
/>
|
|
36
|
+
<BmChat.Details
|
|
37
|
+
state="outbound"
|
|
38
|
+
session="bot"
|
|
39
|
+
displayTime={<p>12:00pm</p>}
|
|
40
|
+
status="sent"
|
|
41
|
+
>
|
|
42
|
+
<p>Outbound Text Message</p>
|
|
43
|
+
</BmChat.Details>
|
|
44
|
+
<BmChat.Details
|
|
45
|
+
state="outbound"
|
|
46
|
+
session="live"
|
|
47
|
+
displayTime={<p>12:00pm</p>}
|
|
48
|
+
status="sent"
|
|
49
|
+
fileName={<p>chat.png</p>}
|
|
50
|
+
src={image}
|
|
51
|
+
/>
|
|
52
|
+
<BmChat.Details
|
|
53
|
+
state="outbound"
|
|
54
|
+
session="live"
|
|
55
|
+
displayTime={<p>10:00am</p>}
|
|
56
|
+
status="failed"
|
|
57
|
+
fileName={<p>file.csv</p>}
|
|
58
|
+
file={image}
|
|
59
|
+
onDownload={() => {
|
|
60
|
+
alert("hello");
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
</BmChat.Body>
|
|
64
|
+
</BmChat>
|
|
11
65
|
</>
|
|
12
66
|
);
|
|
13
67
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Done, DoneAll } from
|
|
3
|
-
import FilePresentIcon from
|
|
4
|
-
import DownloadIcon from
|
|
5
|
-
import styled from
|
|
6
|
-
import BmAvatar from
|
|
7
|
-
import { BmIcons } from
|
|
8
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Done, DoneAll } from "@material-ui/icons";
|
|
3
|
+
import FilePresentIcon from "@mui/icons-material/FilePresent";
|
|
4
|
+
import DownloadIcon from "@mui/icons-material/Download";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import BmAvatar from "../../Avatars/avatars";
|
|
7
|
+
import { BmIcons } from "../../iconStyles";
|
|
8
|
+
import { SessionDetails } from "./sessionDetails";
|
|
9
9
|
import {
|
|
10
10
|
BmPrimaryWhite,
|
|
11
11
|
BmPrimaryBlue,
|
|
12
12
|
BmPrimaryBlack,
|
|
13
13
|
BmSecondaryDarkGreen,
|
|
14
14
|
BmGrey200,
|
|
15
|
-
} from
|
|
15
|
+
} from "../../colors";
|
|
16
16
|
|
|
17
17
|
const BmChat = styled.div`
|
|
18
18
|
display: flex;
|
|
19
19
|
flex-direction: column;
|
|
20
20
|
height: 100%;
|
|
21
|
-
${
|
|
21
|
+
${"" /* border: 0.071rem solid ${BmGrey400}; */}
|
|
22
22
|
`;
|
|
23
23
|
|
|
24
24
|
BmChat.Body = styled.div`
|
|
@@ -33,13 +33,13 @@ BmChat.Body = styled.div`
|
|
|
33
33
|
const Details = styled.div`
|
|
34
34
|
display: flex;
|
|
35
35
|
justify-content: ${({ state }) => {
|
|
36
|
-
if (state ===
|
|
37
|
-
return
|
|
36
|
+
if (state === "inbound") {
|
|
37
|
+
return "flex-start";
|
|
38
38
|
}
|
|
39
|
-
if (state ===
|
|
40
|
-
return
|
|
39
|
+
if (state === "outbound") {
|
|
40
|
+
return "flex-end";
|
|
41
41
|
}
|
|
42
|
-
return
|
|
42
|
+
return "row";
|
|
43
43
|
}};
|
|
44
44
|
> *:not(:last-child) {
|
|
45
45
|
margin-right: 1rem;
|
|
@@ -49,6 +49,7 @@ const Details = styled.div`
|
|
|
49
49
|
word-wrap: break-word !important;
|
|
50
50
|
margin: 0rem;
|
|
51
51
|
flex-grow: 1;
|
|
52
|
+
${"" /* border: 1px solid red; */}
|
|
52
53
|
`;
|
|
53
54
|
|
|
54
55
|
const MessageDetails = styled.div`
|
|
@@ -68,22 +69,22 @@ const Messages = styled.div`
|
|
|
68
69
|
padding: 0.5rem;
|
|
69
70
|
background: ${({ state }) => {
|
|
70
71
|
if (state) {
|
|
71
|
-
if (state ===
|
|
72
|
-
if (state ===
|
|
72
|
+
if (state === "inbound") return `${BmPrimaryWhite}`;
|
|
73
|
+
if (state === "outbound") return `${BmPrimaryBlue}`;
|
|
73
74
|
}
|
|
74
75
|
return `${BmPrimaryWhite}`;
|
|
75
76
|
}};
|
|
76
77
|
color: ${({ state }) => {
|
|
77
78
|
if (state) {
|
|
78
|
-
if (state ===
|
|
79
|
-
if (state ===
|
|
79
|
+
if (state === "inbound") return `${BmPrimaryBlack}`;
|
|
80
|
+
if (state === "outbound") return `${BmPrimaryWhite}`;
|
|
80
81
|
}
|
|
81
82
|
return `${BmPrimaryWhite}`;
|
|
82
83
|
}};
|
|
83
84
|
border-radius: ${({ state }) => {
|
|
84
85
|
if (state) {
|
|
85
|
-
if (state ===
|
|
86
|
-
if (state ===
|
|
86
|
+
if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
|
|
87
|
+
if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
|
|
87
88
|
}
|
|
88
89
|
return `${BmPrimaryWhite}`;
|
|
89
90
|
}};
|
|
@@ -103,11 +104,11 @@ const MessagesSubDetails = styled.div`
|
|
|
103
104
|
`;
|
|
104
105
|
|
|
105
106
|
const handleState = ({ session }) => {
|
|
106
|
-
if (session ===
|
|
107
|
-
return <BmAvatar size=
|
|
107
|
+
if (session === "bot") {
|
|
108
|
+
return <BmAvatar size="small" user="chatbot" />;
|
|
108
109
|
}
|
|
109
|
-
if (session ===
|
|
110
|
-
return <BmAvatar size=
|
|
110
|
+
if (session === "live") {
|
|
111
|
+
return <BmAvatar size="small" user="employee" />;
|
|
111
112
|
}
|
|
112
113
|
};
|
|
113
114
|
|
|
@@ -119,22 +120,22 @@ const FileAttachmentWrapper = styled.div`
|
|
|
119
120
|
padding: 1rem;
|
|
120
121
|
background: ${({ state }) => {
|
|
121
122
|
if (state) {
|
|
122
|
-
if (state ===
|
|
123
|
-
if (state ===
|
|
123
|
+
if (state === "inbound") return `${BmPrimaryWhite}`;
|
|
124
|
+
if (state === "outbound") return `${BmPrimaryBlue}`;
|
|
124
125
|
}
|
|
125
126
|
return `${BmPrimaryWhite}`;
|
|
126
127
|
}};
|
|
127
128
|
color: ${({ state }) => {
|
|
128
129
|
if (state) {
|
|
129
|
-
if (state ===
|
|
130
|
-
if (state ===
|
|
130
|
+
if (state === "inbound") return `${BmPrimaryBlack}`;
|
|
131
|
+
if (state === "outbound") return `${BmPrimaryWhite}`;
|
|
131
132
|
}
|
|
132
133
|
return `${BmPrimaryWhite}`;
|
|
133
134
|
}};
|
|
134
135
|
border-radius: ${({ state }) => {
|
|
135
136
|
if (state) {
|
|
136
|
-
if (state ===
|
|
137
|
-
if (state ===
|
|
137
|
+
if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
|
|
138
|
+
if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
|
|
138
139
|
}
|
|
139
140
|
return `${BmPrimaryWhite}`;
|
|
140
141
|
}};
|
|
@@ -151,14 +152,14 @@ const FileAttachmentWrapper = styled.div`
|
|
|
151
152
|
align-items: center;
|
|
152
153
|
color: ${({ state }) => {
|
|
153
154
|
if (state) {
|
|
154
|
-
if (state ===
|
|
155
|
-
if (state ===
|
|
155
|
+
if (state === "inbound") return `${BmPrimaryBlue}`;
|
|
156
|
+
if (state === "outbound") return `${BmPrimaryWhite}`;
|
|
156
157
|
}
|
|
157
158
|
return `${BmPrimaryWhite}`;
|
|
158
159
|
}};
|
|
159
160
|
}
|
|
160
|
-
${
|
|
161
|
-
${
|
|
161
|
+
${"" /* max-width: 100%; */}
|
|
162
|
+
${"" /* max-height: 100%; */}
|
|
162
163
|
`;
|
|
163
164
|
|
|
164
165
|
const BmFileAttachment = ({
|
|
@@ -183,15 +184,15 @@ export const BmImageWrapper = styled.div`
|
|
|
183
184
|
flex-direction: column;
|
|
184
185
|
color: ${({ state }) => {
|
|
185
186
|
if (state) {
|
|
186
|
-
if (state ===
|
|
187
|
-
if (state ===
|
|
187
|
+
if (state === "inbound") return `${BmPrimaryBlack}`;
|
|
188
|
+
if (state === "outbound") return `${BmPrimaryWhite}`;
|
|
188
189
|
}
|
|
189
190
|
return `${BmPrimaryWhite}`;
|
|
190
191
|
}};
|
|
191
192
|
border-radius: ${({ state }) => {
|
|
192
193
|
if (state) {
|
|
193
|
-
if (state ===
|
|
194
|
-
if (state ===
|
|
194
|
+
if (state === "inbound") return "0.21875rem 0.21875rem 0.21875rem 0rem";
|
|
195
|
+
if (state === "outbound") return "0.21875rem 0.21875rem 0rem 0.21875rem";
|
|
195
196
|
}
|
|
196
197
|
return `${BmPrimaryWhite}`;
|
|
197
198
|
}};
|
|
@@ -199,7 +200,7 @@ export const BmImageWrapper = styled.div`
|
|
|
199
200
|
`;
|
|
200
201
|
|
|
201
202
|
export const BmImage = styled.img`
|
|
202
|
-
${
|
|
203
|
+
${"" /* Fix width */}
|
|
203
204
|
width: 100%;
|
|
204
205
|
object-fit: cover;
|
|
205
206
|
flex-grow: 1;
|
|
@@ -209,7 +210,7 @@ export const BmImageChat = ({ state, src, fileName, ...rest }) => {
|
|
|
209
210
|
return (
|
|
210
211
|
<>
|
|
211
212
|
<BmImageWrapper state={state} {...rest}>
|
|
212
|
-
<BmImage src={src} alt=
|
|
213
|
+
<BmImage src={src} alt="src" />
|
|
213
214
|
{fileName && (
|
|
214
215
|
<BmFileAttachment
|
|
215
216
|
state={state}
|
|
@@ -240,48 +241,67 @@ BmChat.Details = ({
|
|
|
240
241
|
src,
|
|
241
242
|
file,
|
|
242
243
|
fileName,
|
|
244
|
+
sessionDetails,
|
|
243
245
|
...rest
|
|
244
246
|
}) => {
|
|
245
247
|
return (
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
<MessagesSubDetails>
|
|
268
|
-
{displayTime && displayTime}
|
|
269
|
-
{status === 'sent' && (
|
|
270
|
-
<BmIcons
|
|
271
|
-
icon={<DoneAll />}
|
|
272
|
-
color={`${BmSecondaryDarkGreen}`}
|
|
273
|
-
size='small'
|
|
248
|
+
<>
|
|
249
|
+
{sessionDetails && (
|
|
250
|
+
<SessionDetails
|
|
251
|
+
time={sessionDetails.time}
|
|
252
|
+
message={sessionDetails.message}
|
|
253
|
+
{...rest}
|
|
254
|
+
/>
|
|
255
|
+
)}
|
|
256
|
+
<Details state={state} {...rest}>
|
|
257
|
+
{/* Adding for mobile */}
|
|
258
|
+
<MessageState>
|
|
259
|
+
{state === "inbound" && session && handleState({ state, session })}
|
|
260
|
+
</MessageState>
|
|
261
|
+
<MessageDetails>
|
|
262
|
+
{/* For Images */}
|
|
263
|
+
{src && (
|
|
264
|
+
<BmImageChat
|
|
265
|
+
state={state}
|
|
266
|
+
src={src}
|
|
267
|
+
fileName={fileName}
|
|
268
|
+
{...rest}
|
|
274
269
|
/>
|
|
275
270
|
)}
|
|
276
|
-
{
|
|
277
|
-
|
|
271
|
+
{/* For Messages */}
|
|
272
|
+
{children && <Messages state={state}>{children}</Messages>}
|
|
273
|
+
{/* For files */}
|
|
274
|
+
{file && (
|
|
275
|
+
<BmFileAttachment
|
|
276
|
+
file={file}
|
|
277
|
+
fileName={fileName}
|
|
278
|
+
state={state}
|
|
279
|
+
{...rest}
|
|
280
|
+
/>
|
|
278
281
|
)}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
282
|
+
<MessagesSubDetails>
|
|
283
|
+
{displayTime && displayTime}
|
|
284
|
+
{status === "sent" && (
|
|
285
|
+
<BmIcons
|
|
286
|
+
icon={<DoneAll />}
|
|
287
|
+
color={`${BmSecondaryDarkGreen}`}
|
|
288
|
+
size="small"
|
|
289
|
+
/>
|
|
290
|
+
)}
|
|
291
|
+
{status === "failed" && (
|
|
292
|
+
<BmIcons
|
|
293
|
+
icon={<Done />}
|
|
294
|
+
color={`${BmPrimaryBlack}`}
|
|
295
|
+
size="small"
|
|
296
|
+
/>
|
|
297
|
+
)}
|
|
298
|
+
</MessagesSubDetails>
|
|
299
|
+
</MessageDetails>
|
|
300
|
+
<MessageState>
|
|
301
|
+
{state === "outbound" && session && handleState({ state, session })}
|
|
302
|
+
</MessageState>
|
|
303
|
+
</Details>
|
|
304
|
+
</>
|
|
285
305
|
);
|
|
286
306
|
};
|
|
287
307
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { BmGrey200 } from "../../colors";
|
|
3
|
+
|
|
4
|
+
const SessionDetailsWrapper = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
align-items: center;
|
|
9
|
+
text-align: center;
|
|
10
|
+
border-bottom: 0.071rem solid ${BmGrey200};
|
|
11
|
+
margin: 0.5rem;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const SessionDetails = ({ message, time, ...rest }) => {
|
|
15
|
+
return (
|
|
16
|
+
<SessionDetailsWrapper time={time} message={message} {...rest}>
|
|
17
|
+
<p> </p>
|
|
18
|
+
{message || <p> </p>}
|
|
19
|
+
{time || <p> </p>}
|
|
20
|
+
</SessionDetailsWrapper>
|
|
21
|
+
);
|
|
22
|
+
};
|