@telia-ace/widget-conversation 1.0.14 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +5 -5
- package/README.md +256 -256
- package/dist/agent.d.ts +17 -17
- package/dist/conversation-controller.d.ts +88 -88
- package/dist/conversation-form-adapter.d.ts +7 -7
- package/dist/conversation-platform.d.ts +50 -49
- package/dist/conversation-provider.d.ts +22 -22
- package/dist/conversation.js +6 -805
- package/dist/conversation.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +9 -866
- package/dist/index.js.map +1 -1
- package/dist/index2.js +1678 -0
- package/dist/index2.js.map +1 -0
- package/dist/resolve-entity-value.d.ts +10 -10
- package/dist/return-button.js.map +1 -1
- package/dist/types.d.ts +110 -110
- package/dist/ui/conversation/conversation-component.d.ts +37 -37
- package/dist/ui/conversation/conversation-content.d.ts +12 -11
- package/dist/ui/conversation/conversation-input.d.ts +6 -6
- package/dist/ui/conversation/conversation-loader.d.ts +8 -8
- package/dist/ui/conversation/conversation-message.d.ts +7 -7
- package/dist/ui/conversation/conversation-styles.d.ts +11 -11
- package/dist/ui/conversation/conversation.d.ts +6 -6
- package/dist/ui/conversation/index.d.ts +3 -2
- package/dist/ui/conversation/message-types/agent.d.ts +11 -11
- package/dist/ui/conversation/message-types/custom-message-list-item.d.ts +9 -9
- package/dist/ui/conversation/message-types/custom.d.ts +9 -9
- package/dist/ui/conversation/message-types/index.d.ts +5 -5
- package/dist/ui/conversation/message-types/system.d.ts +12 -12
- package/dist/ui/conversation/message-types/timestamp.d.ts +8 -8
- package/dist/ui/conversation/message-types/user.d.ts +8 -8
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/return-button/index.d.ts +2 -2
- package/dist/ui/return-button/return-button-component.d.ts +19 -19
- package/dist/ui/return-button/return-button.d.ts +6 -6
- package/dist/user.d.ts +7 -7
- package/dist/utils/custom-message.d.ts +3 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/open-chat-widget.d.ts +4 -4
- package/package.json +8 -8
package/dist/conversation.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
16
14
|
}
|
|
17
15
|
return a;
|
|
18
16
|
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
17
|
var __objRest = (source, exclude) => {
|
|
21
18
|
var target = {};
|
|
22
19
|
for (var prop in source)
|
|
@@ -29,12 +26,12 @@ var __objRest = (source, exclude) => {
|
|
|
29
26
|
}
|
|
30
27
|
return target;
|
|
31
28
|
};
|
|
32
|
-
import { Input, Button, borderTabStyle, SymbolBadge, useDispatch, useProperties, useScroll,
|
|
33
|
-
import { appendClassNames
|
|
34
|
-
import React, { useState, useEffect,
|
|
35
|
-
import styled, { css
|
|
29
|
+
import { Input, Button, borderTabStyle, SymbolBadge, useDispatch, useProperties, useScroll, invertedHoverButton, Html, List, buttonCss, Lightbox, useTransitionEnd, headingElement } from "@telia-ace/widget-ui";
|
|
30
|
+
import { appendClassNames } from "@telia-ace/widget-utilities";
|
|
31
|
+
import React, { useState, useEffect, useRef, useCallback } from "react";
|
|
32
|
+
import styled, { css } from "styled-components";
|
|
33
|
+
import { C as ContentBundle, M as MessageContainer, a as MessageContent, L as Loader, b as ConversationMessageType, S as SystemMessage, c as ConversationContent, A as AgentMessage, U as UserMessage } from "./index2.js";
|
|
36
34
|
import { FormComponent } from "@telia-ace/widget-forms";
|
|
37
|
-
import { ConversationMessageListItemType, ConversationMessageType } from "./index.js";
|
|
38
35
|
import "@telia-ace/widget-core";
|
|
39
36
|
import "@telia-ace/widget-services";
|
|
40
37
|
import "@telia-ace/widget-plugins";
|
|
@@ -123,7 +120,7 @@ const ConversationInput = ({ className }) => {
|
|
|
123
120
|
title: secondaryAction.label,
|
|
124
121
|
"aria-label": secondaryAction.label
|
|
125
122
|
}, /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
126
|
-
size:
|
|
123
|
+
size: 24,
|
|
127
124
|
symbol: { type: "Svg", content: secondaryAction.icon || "browse" }
|
|
128
125
|
})), multiline ? /* @__PURE__ */ React.createElement(StyledTextArea, {
|
|
129
126
|
value: inputText,
|
|
@@ -263,805 +260,9 @@ const SendSymbol = styled((_a) => {
|
|
|
263
260
|
}};
|
|
264
261
|
}
|
|
265
262
|
`;
|
|
266
|
-
const Avatar = styled.div`
|
|
267
|
-
width: ${(p) => p.avatarSize || "32px"};
|
|
268
|
-
height: ${(p) => p.avatarSize || "32px"};
|
|
269
|
-
border-radius: 50%;
|
|
270
|
-
background-color: ${(p) => {
|
|
271
|
-
var _a;
|
|
272
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.accent;
|
|
273
|
-
}};
|
|
274
|
-
border: ${(p) => p.theme.border};
|
|
275
|
-
grid-area: avatar;
|
|
276
|
-
align-self: flex-end;
|
|
277
|
-
justify-self: center;
|
|
278
|
-
overflow: hidden;
|
|
279
|
-
margin-right: ${(p) => {
|
|
280
|
-
var _a;
|
|
281
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
282
|
-
}};
|
|
283
|
-
display: flex;
|
|
284
|
-
justify-content: center;
|
|
285
|
-
align-items: center;
|
|
286
|
-
color: ${(p) => {
|
|
287
|
-
var _a;
|
|
288
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
289
|
-
}};
|
|
290
|
-
|
|
291
|
-
> img {
|
|
292
|
-
height: 100%;
|
|
293
|
-
width: 100%;
|
|
294
|
-
object-fit: cover;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
> svg {
|
|
298
|
-
width: 90%;
|
|
299
|
-
height: 90%;
|
|
300
|
-
padding: 10%;
|
|
301
|
-
color: ${(p) => {
|
|
302
|
-
var _a;
|
|
303
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
304
|
-
}};
|
|
305
|
-
|
|
306
|
-
line,
|
|
307
|
-
path,
|
|
308
|
-
circle,
|
|
309
|
-
fill {
|
|
310
|
-
stroke: ${(p) => {
|
|
311
|
-
var _a;
|
|
312
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
313
|
-
}};
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
`;
|
|
317
|
-
const LoaderAnimation = keyframes`
|
|
318
|
-
0% {
|
|
319
|
-
opacity: 0;
|
|
320
|
-
}
|
|
321
|
-
75% {
|
|
322
|
-
opacity: 1;
|
|
323
|
-
}
|
|
324
|
-
100% {
|
|
325
|
-
opacity: 0;
|
|
326
|
-
}
|
|
327
|
-
`;
|
|
328
|
-
const Loader = styled.div`
|
|
329
|
-
display: flex;
|
|
330
|
-
justify-content: center;
|
|
331
|
-
> div {
|
|
332
|
-
height: 10px;
|
|
333
|
-
width: 10px;
|
|
334
|
-
border-radius: 50%;
|
|
335
|
-
margin: 5px;
|
|
336
|
-
background-color: ${(p) => {
|
|
337
|
-
var _a;
|
|
338
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
339
|
-
}};
|
|
340
|
-
animation: ${LoaderAnimation} 1s infinite;
|
|
341
|
-
}
|
|
342
|
-
> div:nth-child(2) {
|
|
343
|
-
animation-delay: 100ms;
|
|
344
|
-
}
|
|
345
|
-
> div:nth-child(3) {
|
|
346
|
-
animation-delay: 200ms;
|
|
347
|
-
}
|
|
348
|
-
`;
|
|
349
|
-
const ContentBundle = styled.div`
|
|
350
|
-
grid-area: content;
|
|
351
|
-
max-width: 100%;
|
|
352
|
-
overflow: hidden;
|
|
353
|
-
`;
|
|
354
|
-
const MessageTitle = styled(Typography)`
|
|
355
|
-
font-size: ${(p) => {
|
|
356
|
-
var _a;
|
|
357
|
-
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
358
|
-
}};
|
|
359
|
-
font-weight: normal;
|
|
360
|
-
margin: 0;
|
|
361
|
-
`;
|
|
362
|
-
const MessageContainer = styled.div`
|
|
363
|
-
display: flex;
|
|
364
|
-
`;
|
|
365
|
-
const MessageContent = styled.div`
|
|
366
|
-
background-color: ${(p) => {
|
|
367
|
-
var _a, _b;
|
|
368
|
-
return p.user ? (_a = p.theme.colors) == null ? void 0 : _a.primary : (_b = p.theme.colors) == null ? void 0 : _b.accent;
|
|
369
|
-
}};
|
|
370
|
-
color: ${(p) => {
|
|
371
|
-
var _a, _b;
|
|
372
|
-
return p.user ? (_a = p.theme.colors) == null ? void 0 : _a.accent : (_b = p.theme.colors) == null ? void 0 : _b.text;
|
|
373
|
-
}};
|
|
374
|
-
border-radius: 5px; // TODO: prop?
|
|
375
|
-
border: 1px solid rgb(231, 231, 231);
|
|
376
|
-
padding-top: calc(${(p) => {
|
|
377
|
-
var _a;
|
|
378
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
|
|
379
|
-
}} - ${(p) => {
|
|
380
|
-
var _a;
|
|
381
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
382
|
-
}});
|
|
383
|
-
padding-bottom: calc(${(p) => {
|
|
384
|
-
var _a;
|
|
385
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
|
|
386
|
-
}} - ${(p) => {
|
|
387
|
-
var _a;
|
|
388
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
389
|
-
}});
|
|
390
|
-
margin-top: ${(p) => {
|
|
391
|
-
var _a;
|
|
392
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
393
|
-
}};
|
|
394
|
-
display: inline-block;
|
|
395
|
-
&& > * {
|
|
396
|
-
overflow-wrap: break-word;
|
|
397
|
-
word-wrap: break-word;
|
|
398
|
-
word-break: break-all;
|
|
399
|
-
word-break: break-word;
|
|
400
|
-
hyphens: auto;
|
|
401
|
-
}
|
|
402
|
-
max-width: 100%;
|
|
403
|
-
${(p) => p.fullWidth && "width: 100%;"}
|
|
404
|
-
|
|
405
|
-
${(p) => !p.user && css`
|
|
406
|
-
border: ${p.theme.border};
|
|
407
|
-
`}
|
|
408
|
-
${(p) => p.user && "margin-left: auto"};
|
|
409
|
-
|
|
410
|
-
${(p) => p.stacked === "first" && p.user && css`
|
|
411
|
-
border-bottom-right-radius: 1px; // TODO: Prop?
|
|
412
|
-
`}
|
|
413
|
-
${(p) => p.stacked === "middle" && p.user && css`
|
|
414
|
-
border-bottom-right-radius: 1px;
|
|
415
|
-
border-top-right-radius: 1px;
|
|
416
|
-
`}
|
|
417
|
-
${(p) => p.stacked === "last" && p.user && css`
|
|
418
|
-
border-top-right-radius: 1px;
|
|
419
|
-
`}
|
|
420
|
-
${(p) => p.stacked === "first" && !p.user && css`
|
|
421
|
-
border-bottom-left-radius: 1px;
|
|
422
|
-
`}
|
|
423
|
-
${(p) => p.stacked === "middle" && !p.user && css`
|
|
424
|
-
border-bottom-left-radius: 1px;
|
|
425
|
-
border-top-left-radius: 1px;
|
|
426
|
-
`}
|
|
427
|
-
${(p) => p.stacked === "last" && !p.user && css`
|
|
428
|
-
border-top-left-radius: 1px;
|
|
429
|
-
`};
|
|
430
|
-
|
|
431
|
-
${(p) => !p.stacked && css`
|
|
432
|
-
${p.user ? "border-bottom-right-radius: 1px;" : "border-bottom-left-radius: 1px;"}
|
|
433
|
-
`};
|
|
434
|
-
|
|
435
|
-
transition: border-radius 500ms linear;
|
|
436
|
-
`;
|
|
437
|
-
const MessageContentPart = styled.div`
|
|
438
|
-
padding: ${(p) => {
|
|
439
|
-
var _a;
|
|
440
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
441
|
-
}} ${(p) => {
|
|
442
|
-
var _a;
|
|
443
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
|
|
444
|
-
}};
|
|
445
|
-
|
|
446
|
-
${(p) => p.noPadding && css`
|
|
447
|
-
padding: 0;
|
|
448
|
-
`}
|
|
449
|
-
|
|
450
|
-
margin-bottom: ${(p) => {
|
|
451
|
-
var _a;
|
|
452
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
453
|
-
}};
|
|
454
|
-
&:last-child {
|
|
455
|
-
margin-bottom: 0;
|
|
456
|
-
}
|
|
457
|
-
`;
|
|
458
263
|
const ConversationLoader = ({ className, agentData }) => {
|
|
459
264
|
return /* @__PURE__ */ React.createElement(ContentBundle, null, /* @__PURE__ */ React.createElement(MessageContainer, null, /* @__PURE__ */ React.createElement(MessageContent, null, /* @__PURE__ */ React.createElement(Loader, null, /* @__PURE__ */ React.createElement("div", null), /* @__PURE__ */ React.createElement("div", null), /* @__PURE__ */ React.createElement("div", null)))));
|
|
460
265
|
};
|
|
461
|
-
const StyledTimestamp = styled.p`
|
|
462
|
-
&& {
|
|
463
|
-
font-size: ${(p) => {
|
|
464
|
-
var _a;
|
|
465
|
-
return (_a = p.theme.fonts) == null ? void 0 : _a.small;
|
|
466
|
-
}};
|
|
467
|
-
font-weight: 300;
|
|
468
|
-
}
|
|
469
|
-
padding-top: ${(p) => {
|
|
470
|
-
var _a;
|
|
471
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
472
|
-
}};
|
|
473
|
-
margin: 0;
|
|
474
|
-
line-height: 1.5em;
|
|
475
|
-
grid-area: info;
|
|
476
|
-
color: ${(p) => {
|
|
477
|
-
var _a;
|
|
478
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
479
|
-
}};
|
|
480
|
-
`;
|
|
481
|
-
const getTimestamp = (raw) => {
|
|
482
|
-
return new Date(raw).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
483
|
-
};
|
|
484
|
-
const Timestamp = ({ className, name, timestamp }) => {
|
|
485
|
-
if (!name && !timestamp) {
|
|
486
|
-
return null;
|
|
487
|
-
}
|
|
488
|
-
let output = "";
|
|
489
|
-
if (name) {
|
|
490
|
-
if (timestamp) {
|
|
491
|
-
output = `${name}: ${getTimestamp(timestamp)}`;
|
|
492
|
-
} else {
|
|
493
|
-
output = name;
|
|
494
|
-
}
|
|
495
|
-
} else if (timestamp) {
|
|
496
|
-
output = getTimestamp(timestamp);
|
|
497
|
-
}
|
|
498
|
-
return /* @__PURE__ */ React.createElement(StyledTimestamp, null, output);
|
|
499
|
-
};
|
|
500
|
-
const AgentMessage = ({ className, children, sender, timestamp }) => {
|
|
501
|
-
const { avatar, name } = sender;
|
|
502
|
-
const { avatarSize } = useProperties();
|
|
503
|
-
return /* @__PURE__ */ React.createElement(StyledAgentMessage, {
|
|
504
|
-
hasAvatar: !!avatar,
|
|
505
|
-
className: appendClassNames(className, "humany-conversation-agent-message")
|
|
506
|
-
}, avatar && /* @__PURE__ */ React.createElement(Avatar, {
|
|
507
|
-
avatarSize
|
|
508
|
-
}, typeof avatar === "string" ? /* @__PURE__ */ React.createElement("img", {
|
|
509
|
-
src: avatar
|
|
510
|
-
}) : /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
511
|
-
symbol: avatar
|
|
512
|
-
})), children, /* @__PURE__ */ React.createElement(Timestamp, {
|
|
513
|
-
name,
|
|
514
|
-
timestamp
|
|
515
|
-
}));
|
|
516
|
-
};
|
|
517
|
-
const StyledAgentMessage = styled.div`
|
|
518
|
-
display: grid;
|
|
519
|
-
margin-right: 10%;
|
|
520
|
-
width: 90%;
|
|
521
|
-
${(p) => p.hasAvatar ? css`
|
|
522
|
-
grid-template-columns: auto 1fr;
|
|
523
|
-
grid-template-rows: 1fr auto;
|
|
524
|
-
grid-template-areas:
|
|
525
|
-
'avatar content'
|
|
526
|
-
'. info';
|
|
527
|
-
` : css`
|
|
528
|
-
grid-template-columns: 1fr;
|
|
529
|
-
grid-template-rows: 1fr auto;
|
|
530
|
-
grid-template-areas:
|
|
531
|
-
'content'
|
|
532
|
-
'info';
|
|
533
|
-
`};
|
|
534
|
-
`;
|
|
535
|
-
const CustomMessage = (props) => {
|
|
536
|
-
const CustomComponent = useComponent(props.type);
|
|
537
|
-
if (!CustomComponent) {
|
|
538
|
-
return null;
|
|
539
|
-
}
|
|
540
|
-
return /* @__PURE__ */ React.createElement(Suspense, {
|
|
541
|
-
fallback: null
|
|
542
|
-
}, /* @__PURE__ */ React.createElement(MessageContent, {
|
|
543
|
-
user: props.isUser,
|
|
544
|
-
stacked: !!props.stacked && props.stacked,
|
|
545
|
-
fullWidth: !!props.content.form || !!props.content.actions
|
|
546
|
-
}, /* @__PURE__ */ React.createElement(MessageContentPart, {
|
|
547
|
-
noPadding: !!props.content.noPadding && props.content.noPadding
|
|
548
|
-
}, /* @__PURE__ */ React.createElement(CustomComponent, __spreadValues({}, props.content)))));
|
|
549
|
-
};
|
|
550
|
-
const SystemMessage = ({
|
|
551
|
-
className,
|
|
552
|
-
children,
|
|
553
|
-
timestamp,
|
|
554
|
-
discrete,
|
|
555
|
-
fullWidth
|
|
556
|
-
}) => {
|
|
557
|
-
return /* @__PURE__ */ React.createElement(StyledSystemMessage, {
|
|
558
|
-
className: appendClassNames(className, "humany-conversation-system-message"),
|
|
559
|
-
fullWidth
|
|
560
|
-
}, discrete ? /* @__PURE__ */ React.createElement(Discrete, {
|
|
561
|
-
className: "humany-conversation-discrete-message"
|
|
562
|
-
}, children, /* @__PURE__ */ React.createElement(Timestamp, {
|
|
563
|
-
timestamp
|
|
564
|
-
})) : /* @__PURE__ */ React.createElement(React.Fragment, null, children, /* @__PURE__ */ React.createElement(Timestamp, {
|
|
565
|
-
timestamp
|
|
566
|
-
})));
|
|
567
|
-
};
|
|
568
|
-
const StyledSystemMessage = styled.div`
|
|
569
|
-
${(p) => p.fullWidth && "width: 100%"};
|
|
570
|
-
padding: 0 ${(p) => {
|
|
571
|
-
var _a;
|
|
572
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.large;
|
|
573
|
-
}};
|
|
574
|
-
overflow: auto;
|
|
575
|
-
`;
|
|
576
|
-
const Discrete = styled.div`
|
|
577
|
-
text-align: center;
|
|
578
|
-
word-wrap: break-word;
|
|
579
|
-
font-size: ${(p) => {
|
|
580
|
-
var _a;
|
|
581
|
-
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
582
|
-
}};
|
|
583
|
-
color: ${(p) => {
|
|
584
|
-
var _a;
|
|
585
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.text;
|
|
586
|
-
}};
|
|
587
|
-
> p {
|
|
588
|
-
margin: 0;
|
|
589
|
-
}
|
|
590
|
-
`;
|
|
591
|
-
const UserMessage = ({ className, children, timestamp }) => {
|
|
592
|
-
const { userLabel = "" } = useProperties();
|
|
593
|
-
return /* @__PURE__ */ React.createElement(StyledUserMessage, {
|
|
594
|
-
className: appendClassNames(className, "humany-conversation-user-message")
|
|
595
|
-
}, children, /* @__PURE__ */ React.createElement(Timestamp, {
|
|
596
|
-
name: userLabel,
|
|
597
|
-
timestamp
|
|
598
|
-
}));
|
|
599
|
-
};
|
|
600
|
-
const StyledUserMessage = styled.div`
|
|
601
|
-
margin-left: 10%;
|
|
602
|
-
width: 90%;
|
|
603
|
-
display: flex;
|
|
604
|
-
flex-direction: column;
|
|
605
|
-
align-items: flex-end;
|
|
606
|
-
`;
|
|
607
|
-
const CustomMessageListItem = ({ type, content = {} }) => {
|
|
608
|
-
const Component = useComponent(type);
|
|
609
|
-
if (!Component || !type) {
|
|
610
|
-
return null;
|
|
611
|
-
}
|
|
612
|
-
return /* @__PURE__ */ React.createElement(Component, __spreadValues({}, content));
|
|
613
|
-
};
|
|
614
|
-
const imageLightboxRenderer$1 = (attrs) => /* @__PURE__ */ React.createElement(Lightbox, {
|
|
615
|
-
attrs
|
|
616
|
-
});
|
|
617
|
-
const htmlParseInstructions$1 = {
|
|
618
|
-
transform: {
|
|
619
|
-
img: imageLightboxRenderer$1
|
|
620
|
-
}
|
|
621
|
-
};
|
|
622
|
-
const ConversationContent = ({ content, isUser, stacked }) => {
|
|
623
|
-
const dispatch = useDispatch();
|
|
624
|
-
const { title, body, actions, form, type, items } = content;
|
|
625
|
-
if (type)
|
|
626
|
-
return /* @__PURE__ */ React.createElement(CustomMessage, {
|
|
627
|
-
type,
|
|
628
|
-
content,
|
|
629
|
-
isUser,
|
|
630
|
-
stacked
|
|
631
|
-
});
|
|
632
|
-
return /* @__PURE__ */ React.createElement(MessageContent, {
|
|
633
|
-
noPadding: true,
|
|
634
|
-
user: isUser,
|
|
635
|
-
stacked: !!stacked && stacked,
|
|
636
|
-
fullWidth: !!form || !!actions
|
|
637
|
-
}, title && /* @__PURE__ */ React.createElement(MessageContentPart, null, /* @__PURE__ */ React.createElement(MessageTitle, {
|
|
638
|
-
variant: "h2"
|
|
639
|
-
}, title)), body && /* @__PURE__ */ React.createElement(MessageContentPart, null, /* @__PURE__ */ React.createElement(StyledHtml, {
|
|
640
|
-
html: body,
|
|
641
|
-
htmlParseInstruction: htmlParseInstructions$1
|
|
642
|
-
})), form && /* @__PURE__ */ React.createElement(MessageContentPart, null, /* @__PURE__ */ React.createElement(StyledForm, __spreadProps(__spreadValues({}, form), {
|
|
643
|
-
onChange: (key, data) => {
|
|
644
|
-
dispatch("form", {
|
|
645
|
-
data,
|
|
646
|
-
formKey: form.schema.id,
|
|
647
|
-
actionKey: key
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
}))), actions && /* @__PURE__ */ React.createElement(MessageContentPart, null, /* @__PURE__ */ React.createElement(StyledActionList, {
|
|
651
|
-
items: Object.keys(actions).map((i) => {
|
|
652
|
-
return { label: actions[i], actionKey: i };
|
|
653
|
-
}),
|
|
654
|
-
renderItem: (item) => {
|
|
655
|
-
return /* @__PURE__ */ React.createElement("li", {
|
|
656
|
-
key: item.actionKey
|
|
657
|
-
}, /* @__PURE__ */ React.createElement(StyledActionButton, {
|
|
658
|
-
onClick: () => {
|
|
659
|
-
dispatch("action", item.actionKey);
|
|
660
|
-
}
|
|
661
|
-
}, item.label));
|
|
662
|
-
}
|
|
663
|
-
})), items && /* @__PURE__ */ React.createElement(Fragment, null, /* @__PURE__ */ React.createElement(MessageContentPart, {
|
|
664
|
-
key: uuid(),
|
|
665
|
-
noPadding: true
|
|
666
|
-
}, /* @__PURE__ */ React.createElement(StyledActionList, {
|
|
667
|
-
items: items.map(([type2, content2]) => {
|
|
668
|
-
return { type: type2, content: content2 };
|
|
669
|
-
}),
|
|
670
|
-
renderItem: (item) => {
|
|
671
|
-
const itemKey = uuid();
|
|
672
|
-
switch (item.type) {
|
|
673
|
-
case ConversationMessageListItemType.Header: {
|
|
674
|
-
return /* @__PURE__ */ React.createElement(ConversationListItem, {
|
|
675
|
-
key: itemKey
|
|
676
|
-
}, /* @__PURE__ */ React.createElement(HeaderText, null, item.content));
|
|
677
|
-
}
|
|
678
|
-
case ConversationMessageListItemType.Text: {
|
|
679
|
-
return /* @__PURE__ */ React.createElement(ConversationListItem, {
|
|
680
|
-
key: itemKey
|
|
681
|
-
}, /* @__PURE__ */ React.createElement("span", null, item.content));
|
|
682
|
-
}
|
|
683
|
-
case ConversationMessageListItemType.HTML: {
|
|
684
|
-
return /* @__PURE__ */ React.createElement(ConversationListItem, {
|
|
685
|
-
key: itemKey
|
|
686
|
-
}, /* @__PURE__ */ React.createElement(StyledHtml, {
|
|
687
|
-
html: item.content.body,
|
|
688
|
-
htmlParseInstruction: htmlParseInstructions$1
|
|
689
|
-
}));
|
|
690
|
-
}
|
|
691
|
-
case ConversationMessageListItemType.Separator: {
|
|
692
|
-
return /* @__PURE__ */ React.createElement(ConversationListItem, {
|
|
693
|
-
key: itemKey,
|
|
694
|
-
noPadding: true
|
|
695
|
-
}, /* @__PURE__ */ React.createElement(SeparatorPadding, null, /* @__PURE__ */ React.createElement(Separator, null)));
|
|
696
|
-
}
|
|
697
|
-
case ConversationMessageListItemType.LinkList: {
|
|
698
|
-
return /* @__PURE__ */ React.createElement(ConversationListItem, {
|
|
699
|
-
key: itemKey
|
|
700
|
-
}, /* @__PURE__ */ React.createElement(StyledLinkList, {
|
|
701
|
-
items: Object.keys(item.content.actions).map((i) => {
|
|
702
|
-
return {
|
|
703
|
-
label: item.content.actions[i],
|
|
704
|
-
actionKey: i
|
|
705
|
-
};
|
|
706
|
-
}),
|
|
707
|
-
renderItem: (item2) => {
|
|
708
|
-
return /* @__PURE__ */ React.createElement("li", {
|
|
709
|
-
key: item2.actionKey
|
|
710
|
-
}, /* @__PURE__ */ React.createElement(StyledLinkButton, {
|
|
711
|
-
help: item2.actionKey === "help",
|
|
712
|
-
onClick: () => {
|
|
713
|
-
dispatch("action", item2.actionKey);
|
|
714
|
-
}
|
|
715
|
-
}, item2.label, item2.actionKey === "help" && /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
716
|
-
size: 14,
|
|
717
|
-
symbol: {
|
|
718
|
-
type: "Svg",
|
|
719
|
-
content: "caret-down"
|
|
720
|
-
}
|
|
721
|
-
})));
|
|
722
|
-
}
|
|
723
|
-
}));
|
|
724
|
-
}
|
|
725
|
-
case ConversationMessageListItemType.ButtonList: {
|
|
726
|
-
return /* @__PURE__ */ React.createElement(ConversationListItem, {
|
|
727
|
-
key: itemKey
|
|
728
|
-
}, /* @__PURE__ */ React.createElement(StyledButtonList, {
|
|
729
|
-
items: Object.keys(item.content.actions).map((i) => {
|
|
730
|
-
return {
|
|
731
|
-
label: item.content.actions[i],
|
|
732
|
-
actionKey: i
|
|
733
|
-
};
|
|
734
|
-
}),
|
|
735
|
-
renderItem: (item2) => {
|
|
736
|
-
return /* @__PURE__ */ React.createElement("li", {
|
|
737
|
-
key: item2.actionKey
|
|
738
|
-
}, /* @__PURE__ */ React.createElement(StyledButtonListButton, {
|
|
739
|
-
onClick: () => {
|
|
740
|
-
dispatch("action", item2.actionKey);
|
|
741
|
-
}
|
|
742
|
-
}, item2.label));
|
|
743
|
-
}
|
|
744
|
-
}));
|
|
745
|
-
}
|
|
746
|
-
case ConversationMessageListItemType.NoGoodAlternative: {
|
|
747
|
-
return /* @__PURE__ */ React.createElement(ConversationListItem, {
|
|
748
|
-
key: itemKey
|
|
749
|
-
}, /* @__PURE__ */ React.createElement(NoGoodAlternativeWrapper, {
|
|
750
|
-
onClick: () => {
|
|
751
|
-
dispatch("action", "help");
|
|
752
|
-
}
|
|
753
|
-
}, /* @__PURE__ */ React.createElement(SymbolBadge, {
|
|
754
|
-
size: 14,
|
|
755
|
-
symbol: {
|
|
756
|
-
type: "FontAwesome",
|
|
757
|
-
content: "meh-o"
|
|
758
|
-
}
|
|
759
|
-
}), /* @__PURE__ */ React.createElement("span", null, item.content.body)));
|
|
760
|
-
}
|
|
761
|
-
case ConversationMessageListItemType.FeedbackList: {
|
|
762
|
-
return /* @__PURE__ */ React.createElement(ConversationListItem, {
|
|
763
|
-
key: itemKey
|
|
764
|
-
}, /* @__PURE__ */ React.createElement(StyledButtonList, {
|
|
765
|
-
items: Object.keys(item.content.actions).map((i) => {
|
|
766
|
-
return {
|
|
767
|
-
label: item.content.actions[i],
|
|
768
|
-
actionKey: i
|
|
769
|
-
};
|
|
770
|
-
}),
|
|
771
|
-
renderItem: (item2) => {
|
|
772
|
-
return /* @__PURE__ */ React.createElement(FeedbackItem, {
|
|
773
|
-
key: item2.actionKey
|
|
774
|
-
}, /* @__PURE__ */ React.createElement(FeedbackButton, {
|
|
775
|
-
className: "humany-feedback-button",
|
|
776
|
-
disabled: false,
|
|
777
|
-
"aria-pressed": true,
|
|
778
|
-
"data-selected": true,
|
|
779
|
-
"data-direction": "vertical",
|
|
780
|
-
onClick: () => {
|
|
781
|
-
dispatch("action", item2.actionKey);
|
|
782
|
-
}
|
|
783
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
784
|
-
faIcon: item2.actionKey == "yes" ? "smile-o" : "frown-o"
|
|
785
|
-
}), /* @__PURE__ */ React.createElement("span", null, item2.label)));
|
|
786
|
-
}
|
|
787
|
-
}));
|
|
788
|
-
}
|
|
789
|
-
default: {
|
|
790
|
-
return /* @__PURE__ */ React.createElement(ConversationListItem, {
|
|
791
|
-
key: itemKey,
|
|
792
|
-
noPadding: true
|
|
793
|
-
}, /* @__PURE__ */ React.createElement(CustomMessageListItem, {
|
|
794
|
-
type: item.type,
|
|
795
|
-
content: item.content
|
|
796
|
-
}));
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
}))));
|
|
801
|
-
};
|
|
802
|
-
const StyledForm = styled(FormComponent)`
|
|
803
|
-
& button.humany-form-component-button {
|
|
804
|
-
${(p) => {
|
|
805
|
-
var _a, _b;
|
|
806
|
-
return invertedHoverButton({
|
|
807
|
-
active: false,
|
|
808
|
-
primaryColor: (_a = p.theme.colors) == null ? void 0 : _a.primary,
|
|
809
|
-
secondaryColor: (_b = p.theme.colors) == null ? void 0 : _b.accent
|
|
810
|
-
});
|
|
811
|
-
}};
|
|
812
|
-
display: block;
|
|
813
|
-
width: 100%;
|
|
814
|
-
margin-bottom: ${(p) => {
|
|
815
|
-
var _a;
|
|
816
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
817
|
-
}};
|
|
818
|
-
}
|
|
819
|
-
& button.humany-form-component-submit {
|
|
820
|
-
width: 100%;
|
|
821
|
-
margin: 0;
|
|
822
|
-
:not(:last-child) {
|
|
823
|
-
margin-bottom: ${(p) => {
|
|
824
|
-
var _a;
|
|
825
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
826
|
-
}};
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
`;
|
|
830
|
-
const StyledHtml = styled(Html)`
|
|
831
|
-
white-space: pre-wrap;
|
|
832
|
-
a {
|
|
833
|
-
color: ${(p) => p.theme.colors.link};
|
|
834
|
-
&:focus {
|
|
835
|
-
${(p) => {
|
|
836
|
-
var _a;
|
|
837
|
-
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && borderTabStyle;
|
|
838
|
-
}};
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
`;
|
|
842
|
-
const StyledActionList = styled(List)`
|
|
843
|
-
padding: 0;
|
|
844
|
-
list-style: none;
|
|
845
|
-
margin: 0 -${(p) => {
|
|
846
|
-
var _a;
|
|
847
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
848
|
-
}};
|
|
849
|
-
> li {
|
|
850
|
-
margin: ${(p) => {
|
|
851
|
-
var _a;
|
|
852
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
853
|
-
}};
|
|
854
|
-
}
|
|
855
|
-
`;
|
|
856
|
-
const StyledButtonList = styled(List)`
|
|
857
|
-
padding: 0;
|
|
858
|
-
list-style: none;
|
|
859
|
-
> li {
|
|
860
|
-
margin: ${(p) => {
|
|
861
|
-
var _a;
|
|
862
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
863
|
-
}} ${(p) => {
|
|
864
|
-
var _a;
|
|
865
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
866
|
-
}};
|
|
867
|
-
margin-left: 0;
|
|
868
|
-
display: inline-block;
|
|
869
|
-
}
|
|
870
|
-
`;
|
|
871
|
-
const StyledButtonListButton = styled.button`
|
|
872
|
-
${buttonCss};
|
|
873
|
-
display: block;
|
|
874
|
-
text-align: left;
|
|
875
|
-
background-color: ${(p) => {
|
|
876
|
-
var _a;
|
|
877
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.primary;
|
|
878
|
-
}};
|
|
879
|
-
width: 100%;
|
|
880
|
-
color: #fff;
|
|
881
|
-
&:focus {
|
|
882
|
-
${(p) => {
|
|
883
|
-
var _a;
|
|
884
|
-
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
|
|
885
|
-
${borderTabStyle}
|
|
886
|
-
background-color: transparent;
|
|
887
|
-
`;
|
|
888
|
-
}}
|
|
889
|
-
}
|
|
890
|
-
`;
|
|
891
|
-
const StyledLinkList = styled(List)`
|
|
892
|
-
padding: 0;
|
|
893
|
-
list-style: none;
|
|
894
|
-
> li {
|
|
895
|
-
margin-bottom: ${(p) => {
|
|
896
|
-
var _a;
|
|
897
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
898
|
-
}};
|
|
899
|
-
|
|
900
|
-
&:last-child {
|
|
901
|
-
margin-bottom: 0;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
`;
|
|
905
|
-
const HeaderText = styled.strong`
|
|
906
|
-
font-size: ${(p) => {
|
|
907
|
-
var _a;
|
|
908
|
-
return (_a = p.theme.fonts) == null ? void 0 : _a.huge;
|
|
909
|
-
}};
|
|
910
|
-
`;
|
|
911
|
-
const StyledLinkButton = styled.button`
|
|
912
|
-
display: block;
|
|
913
|
-
background-color: transparent;
|
|
914
|
-
text-align: left;
|
|
915
|
-
border: none;
|
|
916
|
-
padding: 0;
|
|
917
|
-
font-weight: 300;
|
|
918
|
-
font-family: inherit;
|
|
919
|
-
cursor: pointer;
|
|
920
|
-
color: ${(p) => {
|
|
921
|
-
var _a;
|
|
922
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.primary;
|
|
923
|
-
}};
|
|
924
|
-
|
|
925
|
-
${(p) => {
|
|
926
|
-
var _a, _b;
|
|
927
|
-
return p.help && css`
|
|
928
|
-
color: ${(_a = p.theme.colors) == null ? void 0 : _a.text};
|
|
929
|
-
text-decoration: underline;
|
|
930
|
-
|
|
931
|
-
i,
|
|
932
|
-
svg {
|
|
933
|
-
margin-left: ${(_b = p.theme.sizes) == null ? void 0 : _b.small};
|
|
934
|
-
}
|
|
935
|
-
`;
|
|
936
|
-
}}
|
|
937
|
-
`;
|
|
938
|
-
const StyledActionButton = styled.button`
|
|
939
|
-
${buttonCss};
|
|
940
|
-
display: block;
|
|
941
|
-
background-color: ${(p) => {
|
|
942
|
-
var _a;
|
|
943
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.primary;
|
|
944
|
-
}};
|
|
945
|
-
width: 100%;
|
|
946
|
-
color: #fff;
|
|
947
|
-
font-family: Lato;
|
|
948
|
-
font-size: ${(p) => {
|
|
949
|
-
var _a;
|
|
950
|
-
return (_a = p.theme.fonts) == null ? void 0 : _a.huge;
|
|
951
|
-
}};
|
|
952
|
-
font-weight: 300;
|
|
953
|
-
&:focus {
|
|
954
|
-
${(p) => {
|
|
955
|
-
var _a;
|
|
956
|
-
return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
|
|
957
|
-
${borderTabStyle}
|
|
958
|
-
background-color: transparent;
|
|
959
|
-
`;
|
|
960
|
-
}}
|
|
961
|
-
}
|
|
962
|
-
`;
|
|
963
|
-
const SeparatorPadding = styled.div`
|
|
964
|
-
padding-top: calc(${(p) => {
|
|
965
|
-
var _a;
|
|
966
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
|
|
967
|
-
}} - ${(p) => {
|
|
968
|
-
var _a;
|
|
969
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
970
|
-
}});
|
|
971
|
-
padding-bottom: calc(${(p) => {
|
|
972
|
-
var _a;
|
|
973
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
|
|
974
|
-
}} - ${(p) => {
|
|
975
|
-
var _a;
|
|
976
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
977
|
-
}});
|
|
978
|
-
`;
|
|
979
|
-
const Separator = styled.div`
|
|
980
|
-
background-color: #efefef;
|
|
981
|
-
height: 1px;
|
|
982
|
-
width: 100%;
|
|
983
|
-
`;
|
|
984
|
-
const NoGoodAlternativeWrapper = styled.div`
|
|
985
|
-
display: flex;
|
|
986
|
-
align-items: center;
|
|
987
|
-
justify-content: center;
|
|
988
|
-
cursor: pointer;
|
|
989
|
-
|
|
990
|
-
> i,
|
|
991
|
-
svg {
|
|
992
|
-
margin-right: ${(p) => {
|
|
993
|
-
var _a;
|
|
994
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
995
|
-
}};
|
|
996
|
-
}
|
|
997
|
-
`;
|
|
998
|
-
const ConversationListItem = styled.li`
|
|
999
|
-
padding-left: ${(p) => {
|
|
1000
|
-
var _a;
|
|
1001
|
-
return p.noPadding ? 0 : (_a = p.theme.sizes) == null ? void 0 : _a.medium;
|
|
1002
|
-
}};
|
|
1003
|
-
padding-right: ${(p) => {
|
|
1004
|
-
var _a;
|
|
1005
|
-
return p.noPadding ? 0 : (_a = p.theme.sizes) == null ? void 0 : _a.medium;
|
|
1006
|
-
}};
|
|
1007
|
-
`;
|
|
1008
|
-
const FeedbackItem = styled.li`
|
|
1009
|
-
@media (min-width: 768px) {
|
|
1010
|
-
display: list-item !important;
|
|
1011
|
-
margin-right: 0 !important;
|
|
1012
|
-
margin-top: ${(p) => {
|
|
1013
|
-
var _a;
|
|
1014
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
|
|
1015
|
-
}} !important;
|
|
1016
|
-
}
|
|
1017
|
-
`;
|
|
1018
|
-
const FeedbackButton = styled.button`
|
|
1019
|
-
@media (min-width: 768px) {
|
|
1020
|
-
min-width: 100%;
|
|
1021
|
-
margin-right: 0;
|
|
1022
|
-
}
|
|
1023
|
-
display: inline-block;
|
|
1024
|
-
font-size: ${(p) => {
|
|
1025
|
-
var _a;
|
|
1026
|
-
return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
|
|
1027
|
-
}};
|
|
1028
|
-
border-color: ${(p) => {
|
|
1029
|
-
var _a;
|
|
1030
|
-
return (_a = p.theme.colors) == null ? void 0 : _a.primary;
|
|
1031
|
-
}} !important;
|
|
1032
|
-
font-weight: 300;
|
|
1033
|
-
&& {
|
|
1034
|
-
margin-right: ${(p) => {
|
|
1035
|
-
var _a;
|
|
1036
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
1037
|
-
}};
|
|
1038
|
-
}
|
|
1039
|
-
${(p) => {
|
|
1040
|
-
var _a, _b;
|
|
1041
|
-
return p["data-direction"] === "horizontal" && css`
|
|
1042
|
-
width: 225px;
|
|
1043
|
-
max-width: calc(50% - ${(_a = p.theme.sizes) == null ? void 0 : _a.large} - ${(_b = p.theme.sizes) == null ? void 0 : _b.small});
|
|
1044
|
-
`;
|
|
1045
|
-
}}
|
|
1046
|
-
${(p) => p["data-direction"] === "vertical" && css`
|
|
1047
|
-
min-width: 150px;
|
|
1048
|
-
`}
|
|
1049
|
-
${(p) => {
|
|
1050
|
-
var _a;
|
|
1051
|
-
return invertedHoverButton({
|
|
1052
|
-
primaryColor: `${(_a = p.theme.colors) == null ? void 0 : _a.primary}`,
|
|
1053
|
-
secondaryColor: "#FFFFFF"
|
|
1054
|
-
});
|
|
1055
|
-
}}
|
|
1056
|
-
i {
|
|
1057
|
-
margin: 0 ${(p) => {
|
|
1058
|
-
var _a;
|
|
1059
|
-
return (_a = p.theme.sizes) == null ? void 0 : _a.small;
|
|
1060
|
-
}} 0 0;
|
|
1061
|
-
}
|
|
1062
|
-
span {
|
|
1063
|
-
}
|
|
1064
|
-
`;
|
|
1065
266
|
const imageLightboxRenderer = (attrs) => /* @__PURE__ */ React.createElement(Lightbox, {
|
|
1066
267
|
attrs
|
|
1067
268
|
});
|