oa-componentbook 0.18.6 → 0.18.7
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.
|
@@ -13,11 +13,12 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
|
13
13
|
var _relativeTime = _interopRequireDefault(require("dayjs/plugin/relativeTime"));
|
|
14
14
|
var _lodash = require("lodash");
|
|
15
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
|
-
var _icons = require("@material-ui/icons");
|
|
17
16
|
var _TextArea = _interopRequireDefault(require("../../components/oa-component-textarea/TextArea"));
|
|
17
|
+
var _icons = require("@material-ui/icons");
|
|
18
18
|
var _CustomButton = _interopRequireDefault(require("../../components/oa-component-button/CustomButton"));
|
|
19
19
|
var _CustomDrawer = _interopRequireDefault(require("../../components/oa-component-drawer/CustomDrawer"));
|
|
20
20
|
var _Typography = _interopRequireDefault(require("../../components/oa-component-typography/Typography"));
|
|
21
|
+
var _system = require("@material-ui/system");
|
|
21
22
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
22
23
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -32,7 +33,8 @@ const stylesObj = {
|
|
|
32
33
|
padding: '10px 8px',
|
|
33
34
|
backgroundColor: '#DAF1FC',
|
|
34
35
|
borderRadius: '4px',
|
|
35
|
-
maxWidth: '500px'
|
|
36
|
+
maxWidth: '500px',
|
|
37
|
+
marginTop: '12px'
|
|
36
38
|
},
|
|
37
39
|
chatContainer: {
|
|
38
40
|
display: 'flex',
|
|
@@ -52,9 +54,17 @@ function ChatWidget(_ref) {
|
|
|
52
54
|
headerTitle,
|
|
53
55
|
bodyTitle,
|
|
54
56
|
initialMsg,
|
|
55
|
-
onMessageInput
|
|
57
|
+
onMessageInput,
|
|
58
|
+
clearInput
|
|
56
59
|
} = _ref;
|
|
57
60
|
const [message, setMessage] = (0, _react.useState)(initialMsg || '');
|
|
61
|
+
const onClearInput = () => {
|
|
62
|
+
clearInput && setMessage('');
|
|
63
|
+
};
|
|
64
|
+
const onMsgSend = () => {
|
|
65
|
+
onMessageInput(message);
|
|
66
|
+
onClearInput();
|
|
67
|
+
};
|
|
58
68
|
return /*#__PURE__*/_react.default.createElement(_CustomDrawer.default, {
|
|
59
69
|
open: show,
|
|
60
70
|
onClose: onClose,
|
|
@@ -70,18 +80,21 @@ function ChatWidget(_ref) {
|
|
|
70
80
|
}, "Reply to Query"), /*#__PURE__*/_react.default.createElement(_TextArea.default, {
|
|
71
81
|
name: "message",
|
|
72
82
|
value: message,
|
|
73
|
-
placeholder:
|
|
83
|
+
placeholder: 'Type here...',
|
|
84
|
+
style: {
|
|
85
|
+
marginTop: '7px'
|
|
86
|
+
},
|
|
74
87
|
onChange: e => setMessage(e.target.value)
|
|
75
88
|
}), /*#__PURE__*/_react.default.createElement(_CustomButton.default, {
|
|
76
|
-
onClick:
|
|
89
|
+
onClick: onMsgSend,
|
|
77
90
|
style: {
|
|
78
91
|
width: '120px',
|
|
79
92
|
color: 'white',
|
|
80
93
|
float: 'right',
|
|
81
94
|
marginTop: '12px'
|
|
82
95
|
},
|
|
83
|
-
size:
|
|
84
|
-
label:
|
|
96
|
+
size: 'small',
|
|
97
|
+
label: 'Send Reply'
|
|
85
98
|
})),
|
|
86
99
|
styles: {
|
|
87
100
|
body: {
|
|
@@ -104,12 +117,12 @@ function ChatWidget(_ref) {
|
|
|
104
117
|
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
105
118
|
level: 5,
|
|
106
119
|
style: {
|
|
107
|
-
|
|
120
|
+
fontSize: '24px',
|
|
121
|
+
fontWeight: 'bold'
|
|
108
122
|
}
|
|
109
123
|
}, bodyTitle), /*#__PURE__*/_react.default.createElement(_antd.Divider, {
|
|
110
124
|
style: {
|
|
111
|
-
margin:
|
|
112
|
-
marginBottom: '10px'
|
|
125
|
+
margin: '12px'
|
|
113
126
|
}
|
|
114
127
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
115
128
|
className: "flex flex-column",
|
|
@@ -119,118 +132,122 @@ function ChatWidget(_ref) {
|
|
|
119
132
|
flex: 9,
|
|
120
133
|
padding: '0 40px 20px 0'
|
|
121
134
|
}
|
|
122
|
-
}, isContentLoading ? [...Array((0, _lodash.random)(2, 5))].map((_, ind) =>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
135
|
+
}, isContentLoading ? [...Array((0, _lodash.random)(2, 5))].map((_, ind) => {
|
|
136
|
+
return ind % 2 ?
|
|
137
|
+
/*#__PURE__*/
|
|
138
|
+
// Info : This container is to show the loading of the chats (our chats) in the right side of chat body while chats are fetching.
|
|
139
|
+
_react.default.createElement(_antd.Skeleton, {
|
|
140
|
+
loading: isContentLoading,
|
|
141
|
+
avatar: true,
|
|
142
|
+
active: true,
|
|
143
|
+
title: false
|
|
144
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
145
|
+
style: {
|
|
146
|
+
display: 'flex',
|
|
147
|
+
gap: '10px'
|
|
148
|
+
}
|
|
149
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
150
|
+
maxWidth: "90%",
|
|
151
|
+
flexDirection: "column",
|
|
152
|
+
style: _objectSpread({}, stylesObj.chatUi),
|
|
153
|
+
gap: "2px"
|
|
154
|
+
}, /*#__PURE__*/_react.default.createElement(_Typography.default, null), /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
155
|
+
style: {
|
|
156
|
+
fontSize: "10px",
|
|
157
|
+
alignSelf: "flex-end",
|
|
158
|
+
width: "fit-content"
|
|
159
|
+
}
|
|
160
|
+
}, (0, _dayjs.default)().fromNow())))) :
|
|
161
|
+
/*#__PURE__*/
|
|
162
|
+
// Info : This container is to show the loading of the chats (other user) in the left side of chat body while chats are fetching.
|
|
163
|
+
_react.default.createElement(_antd.Skeleton, {
|
|
164
|
+
loading: isContentLoading,
|
|
165
|
+
avatar: true,
|
|
166
|
+
active: true,
|
|
167
|
+
title: false,
|
|
168
|
+
style: {
|
|
169
|
+
transform: "scale(-1, 1)"
|
|
170
|
+
}
|
|
171
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
172
|
+
maxWidth: "90%",
|
|
173
|
+
flexDirection: "column",
|
|
174
|
+
style: _objectSpread({}, stylesObj.chatUi),
|
|
175
|
+
gap: "2px"
|
|
176
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
177
|
+
style: _objectSpread({
|
|
178
|
+
display: "flex",
|
|
179
|
+
flexDirection: "column",
|
|
180
|
+
gap: '2px',
|
|
181
|
+
maxWidth: '90%'
|
|
182
|
+
}, stylesObj.chatUi)
|
|
183
|
+
}, /*#__PURE__*/_react.default.createElement(_Typography.default, null), /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
184
|
+
type: "secondary",
|
|
185
|
+
style: {
|
|
186
|
+
fontSize: "10px",
|
|
187
|
+
alignSelf: "flex-end",
|
|
188
|
+
width: "fit-content"
|
|
189
|
+
}
|
|
190
|
+
}, (0, _dayjs.default)().fromNow()))));
|
|
191
|
+
}) : queryMessages !== null && queryMessages !== void 0 && queryMessages.length ? queryMessages.map(message => {
|
|
192
|
+
return message.isUser ?
|
|
193
|
+
/*#__PURE__*/
|
|
194
|
+
// Info : This is the chat box of right side which will show messages from user.
|
|
195
|
+
_react.default.createElement("div", {
|
|
196
|
+
style: {
|
|
197
|
+
display: 'flex',
|
|
198
|
+
alignItems: 'flex-start',
|
|
199
|
+
justifyContent: 'flex-end'
|
|
200
|
+
}
|
|
201
|
+
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
202
|
+
style: _objectSpread(_objectSpread({
|
|
203
|
+
display: "flex",
|
|
204
|
+
flexDirection: "column",
|
|
205
|
+
gap: '2px',
|
|
206
|
+
maxWidth: '90%'
|
|
207
|
+
}, stylesObj.chatUi), {}, {
|
|
208
|
+
backgroundColor: '#f6f6f6'
|
|
209
|
+
})
|
|
210
|
+
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
211
|
+
style: {
|
|
212
|
+
whiteSpace: "pre-line"
|
|
213
|
+
}
|
|
214
|
+
}, message.message)), /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
215
|
+
color: 'lightgray',
|
|
216
|
+
style: {
|
|
217
|
+
marginTop: '10px',
|
|
218
|
+
fontSize: "10px",
|
|
219
|
+
alignSelf: "flex-end",
|
|
220
|
+
width: "fit-content"
|
|
221
|
+
}
|
|
222
|
+
}, message.createdAt))) :
|
|
223
|
+
/*#__PURE__*/
|
|
224
|
+
// Info : This is the chat box of left side which will show messages from other user.
|
|
225
|
+
_react.default.createElement("div", {
|
|
226
|
+
style: {
|
|
227
|
+
display: 'flex',
|
|
228
|
+
alignItems: 'flex-start',
|
|
229
|
+
flexDirection: 'column'
|
|
230
|
+
}
|
|
231
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
232
|
+
style: _objectSpread({
|
|
233
|
+
display: 'flex',
|
|
234
|
+
flexDirection: 'column',
|
|
235
|
+
gap: '2px',
|
|
236
|
+
maxWidth: '90%'
|
|
237
|
+
}, stylesObj.chatUi)
|
|
238
|
+
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
239
|
+
style: {
|
|
240
|
+
whiteSpace: "pre-line"
|
|
241
|
+
}
|
|
242
|
+
}, message.message)), /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
243
|
+
color: 'lightgray',
|
|
244
|
+
style: {
|
|
245
|
+
marginTop: '10px',
|
|
246
|
+
fontSize: "10px",
|
|
247
|
+
width: "fit-content"
|
|
248
|
+
}
|
|
249
|
+
}, message.createdAt));
|
|
250
|
+
}) : /*#__PURE__*/_react.default.createElement(_antd.Alert, {
|
|
234
251
|
type: "info",
|
|
235
252
|
message: "Send a chat to start your chat history for this ticket."
|
|
236
253
|
}))));
|
|
@@ -243,7 +260,8 @@ ChatWidget.propTypes = {
|
|
|
243
260
|
headerTitle: _propTypes.default.string,
|
|
244
261
|
bodyTittle: _propTypes.default.string,
|
|
245
262
|
onMessageInput: _propTypes.default.func,
|
|
246
|
-
initialMsg: _propTypes.default.string
|
|
263
|
+
initialMsg: _propTypes.default.string,
|
|
264
|
+
clearInput: _propTypes.default.bool
|
|
247
265
|
};
|
|
248
266
|
ChatWidget.defaultProps = {
|
|
249
267
|
show: false,
|
|
@@ -253,8 +271,9 @@ ChatWidget.defaultProps = {
|
|
|
253
271
|
isContentLoading: true,
|
|
254
272
|
headerTitle: 'Header Title',
|
|
255
273
|
bodyTitle: 'Body Title',
|
|
256
|
-
onMessageInput: msg => alert(
|
|
274
|
+
onMessageInput: msg => alert('This is your msg :' + msg),
|
|
257
275
|
initialMsg: '',
|
|
276
|
+
clearInput: true,
|
|
258
277
|
queryMessages: [{
|
|
259
278
|
createdAt: 'Today 4:00pm',
|
|
260
279
|
isUser: false,
|