@telia-ace/widget-conversation 1.0.16 → 1.0.19

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.
Files changed (40) hide show
  1. package/README.md +82 -116
  2. package/dist/{ui → components}/conversation/conversation.d.ts +0 -0
  3. package/dist/{ui/conversation/conversation-component.d.ts → components/conversation/plugin.d.ts} +8 -2
  4. package/dist/components/conversation/ui/content.d.ts +2 -0
  5. package/dist/{ui/conversation/conversation-input.d.ts → components/conversation/ui/input.d.ts} +0 -0
  6. package/dist/{ui/conversation/conversation-loader.d.ts → components/conversation/ui/loader.d.ts} +1 -1
  7. package/dist/components/conversation/ui/message-list-items/button-list.d.ts +8 -0
  8. package/dist/{ui/conversation/message-types/custom-message-list-item.d.ts → components/conversation/ui/message-list-items/custom.d.ts} +2 -2
  9. package/dist/components/conversation/ui/message-list-items/html.d.ts +5 -0
  10. package/dist/components/conversation/ui/message-list-items/link-list.d.ts +8 -0
  11. package/dist/components/conversation/ui/message-list-items/separator.d.ts +2 -0
  12. package/dist/components/conversation/ui/message-list-items/text.d.ts +6 -0
  13. package/dist/{ui/conversation → components/conversation/ui}/message-types/agent.d.ts +1 -1
  14. package/dist/{ui/conversation → components/conversation/ui}/message-types/index.d.ts +0 -1
  15. package/dist/components/conversation/ui/message-types/message-list.d.ts +9 -0
  16. package/dist/{ui/conversation → components/conversation/ui}/message-types/system.d.ts +0 -0
  17. package/dist/{ui/conversation → components/conversation/ui}/message-types/timestamp.d.ts +0 -0
  18. package/dist/{ui/conversation → components/conversation/ui}/message-types/user.d.ts +0 -0
  19. package/dist/components/conversation/ui/message.d.ts +7 -0
  20. package/dist/components/conversation/ui/overlay-outlets.d.ts +13 -0
  21. package/dist/components/conversation/ui/styles.d.ts +27 -0
  22. package/dist/{ui/return-button/return-button-component.d.ts → components/return-button/plugin.d.ts} +1 -2
  23. package/dist/{ui → components}/return-button/return-button.d.ts +0 -0
  24. package/dist/conversation-platform.d.ts +1 -2
  25. package/dist/conversation.js +525 -559
  26. package/dist/conversation.js.map +1 -1
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.js +36 -19
  29. package/dist/index.js.map +1 -1
  30. package/dist/return-button.js.map +1 -1
  31. package/dist/types.d.ts +27 -26
  32. package/dist/utils/map-actions.d.ts +1 -0
  33. package/package.json +8 -8
  34. package/dist/ui/conversation/conversation-content.d.ts +0 -11
  35. package/dist/ui/conversation/conversation-message.d.ts +0 -7
  36. package/dist/ui/conversation/conversation-styles.d.ts +0 -11
  37. package/dist/ui/conversation/index.d.ts +0 -2
  38. package/dist/ui/conversation/message-types/custom.d.ts +0 -9
  39. package/dist/ui/index.d.ts +0 -2
  40. package/dist/ui/return-button/index.d.ts +0 -2
@@ -29,9 +29,9 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { Input, Button, borderTabStyle, SymbolBadge, useDispatch, useProperties, useScroll, Typography, useComponent, invertedHoverButton, Html, List, buttonCss, Lightbox, useTransitionEnd, headingElement } from "@telia-ace/widget-ui";
32
+ import { Input, Button, borderTabStyle, SymbolBadge, useDispatch, useProperties, useScroll, Typography, invertedHoverButton, List, buttonCss, Html as Html$1, genericHtml, Lightbox, ItemList, itemList, useComponent, list, headingElement, usePrevious, useTransitionEnd, WidgetOverlayOutlet } from "@telia-ace/widget-ui";
33
33
  import { appendClassNames, uuid } from "@telia-ace/widget-utilities";
34
- import React, { useState, useEffect, Suspense, Fragment, useRef, useCallback } from "react";
34
+ import React, { useState, useEffect, Suspense, useCallback, useRef } from "react";
35
35
  import styled, { css, keyframes } from "styled-components";
36
36
  import { FormComponent } from "@telia-ace/widget-forms";
37
37
  import { ConversationMessageListItemType, ConversationMessageType } from "./index.js";
@@ -82,7 +82,9 @@ const ConversationInput = ({ className }) => {
82
82
  return;
83
83
  }
84
84
  e.preventDefault();
85
- dispatch("action", secondaryAction.action);
85
+ dispatch("action", __spreadValues({
86
+ actionKey: secondaryAction.action
87
+ }, secondaryAction));
86
88
  };
87
89
  const calculateHeight = (value) => {
88
90
  if (multiline && inputRef.current) {
@@ -117,7 +119,7 @@ const ConversationInput = ({ className }) => {
117
119
  className: appendClassNames("humany-conversation-input", className),
118
120
  "data-has-focus": inputFocus,
119
121
  scrollableCss
120
- }, secondaryAction && /* @__PURE__ */ React.createElement(StyledButton, {
122
+ }, secondaryAction && /* @__PURE__ */ React.createElement(SecondaryActionButton, {
121
123
  disabled: inputDisabled,
122
124
  onClick: onSecondaryActionButtonClick,
123
125
  title: secondaryAction.label,
@@ -164,13 +166,10 @@ const StyledTextArea = styled(Input)`
164
166
  line-height: 1.2em;
165
167
  height: 1.2em;
166
168
  padding: 0;
167
- margin: ${(p) => {
169
+ margin: calc(${(p) => {
168
170
  var _a;
169
171
  return (_a = p.theme.sizes) == null ? void 0 : _a.small;
170
- }} ${(p) => {
171
- var _a;
172
- return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
173
- }};
172
+ }} * 2);
174
173
  font-size: ${(p) => {
175
174
  var _a;
176
175
  return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
@@ -222,6 +221,13 @@ const StyledButton = styled(Button)`
222
221
  }};
223
222
  }
224
223
  `;
224
+ const SecondaryActionButton = styled(StyledButton)`
225
+ border-right: ${(p) => p.theme.border};
226
+ margin: ${(p) => {
227
+ var _a;
228
+ return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
229
+ }} 0;
230
+ `;
225
231
  const Wrapper$1 = styled.div`
226
232
  ${(p) => p.grow ? css`
227
233
  min-height: 50px;
@@ -349,7 +355,6 @@ const Loader = styled.div`
349
355
  const ContentBundle = styled.div`
350
356
  grid-area: content;
351
357
  max-width: 100%;
352
- overflow: hidden;
353
358
  `;
354
359
  const MessageTitle = styled(Typography)`
355
360
  font-size: ${(p) => {
@@ -361,37 +366,17 @@ const MessageTitle = styled(Typography)`
361
366
  `;
362
367
  const MessageContainer = styled.div`
363
368
  display: flex;
369
+ justify-content: ${(p) => p.user ? "end" : "start"};
364
370
  `;
365
371
  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
- }});
372
+ ${(p) => !p.user && p.stacked && nonUserMessageStyling(p.stacked, p.theme)}
373
+ ${(p) => p.user && p.stacked && userMessageStyling(p.stacked, p.theme)}
374
+
375
+ display: inline-block;
390
376
  margin-top: ${(p) => {
391
377
  var _a;
392
378
  return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
393
379
  }};
394
- display: inline-block;
395
380
  && > * {
396
381
  overflow-wrap: break-word;
397
382
  word-wrap: break-word;
@@ -401,63 +386,196 @@ const MessageContent = styled.div`
401
386
  }
402
387
  max-width: 100%;
403
388
  ${(p) => p.fullWidth && "width: 100%;"}
389
+ `;
390
+ const nonUserMessageStyling = (stacked, theme) => {
391
+ var _a, _b;
392
+ const colors = css`
393
+ background-color: ${(_a = theme.colors) == null ? void 0 : _a.accent};
394
+ color: ${(_b = theme.colors) == null ? void 0 : _b.text};
395
+ ${theme.border && `border: ${theme.border};`};
396
+ `;
397
+ if (!theme.borderRadius) {
398
+ return colors;
399
+ }
400
+ return css`
401
+ ${colors}
404
402
 
405
- ${(p) => !p.user && css`
406
- border: ${p.theme.border};
407
- `}
408
- ${(p) => p.user && "margin-left: auto"};
403
+ border-top-right-radius: ${theme.borderRadius};
404
+ border-bottom-right-radius: ${theme.borderRadius};
409
405
 
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;
406
+ ${stacked === "first" && `
407
+ border-top-left-radius: ${theme.borderRadius};
416
408
  `}
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;
409
+
410
+ ${stacked === "last" && `
411
+ border-bottom-left-radius: ${theme.borderRadius};
426
412
  `}
427
- ${(p) => p.stacked === "last" && !p.user && css`
428
- border-top-left-radius: 1px;
429
- `};
413
+ `;
414
+ };
415
+ const userMessageStyling = (stacked, theme) => {
416
+ var _a, _b;
417
+ const colors = css`
418
+ background-color: ${(_a = theme.colors) == null ? void 0 : _a.primary};
419
+ color: ${(_b = theme.colors) == null ? void 0 : _b.accent};
420
+ `;
421
+ if (!theme.borderRadius) {
422
+ return colors;
423
+ }
424
+ return css`
425
+ ${colors}
430
426
 
431
- ${(p) => !p.stacked && css`
432
- ${p.user ? "border-bottom-right-radius: 1px;" : "border-bottom-left-radius: 1px;"}
433
- `};
427
+ border-top-left-radius: ${theme.borderRadius};
428
+ border-bottom-left-radius: ${theme.borderRadius};
434
429
 
435
- transition: border-radius 500ms linear;
436
- `;
430
+ ${stacked === "first" && `
431
+ border-top-right-radius: ${theme.borderRadius};
432
+ `}
433
+
434
+ ${stacked === "last" && `
435
+ border-bottom-right-radius: ${theme.borderRadius};
436
+ `}
437
+ `;
438
+ };
437
439
  const MessageContentPart = styled.div`
438
- padding: ${(p) => {
440
+ margin-bottom: ${(p) => {
439
441
  var _a;
440
442
  return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
441
- }} ${(p) => {
443
+ }};
444
+ &:last-child {
445
+ margin-bottom: 0;
446
+ }
447
+ `;
448
+ const messageContentPadding = css`
449
+ margin: ${(p) => {
450
+ var _a;
451
+ return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
452
+ }} 0;
453
+ padding: 0 ${(p) => {
454
+ var _a;
455
+ return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
456
+ }};
457
+ `;
458
+ const StyledForm = styled(FormComponent)`
459
+ margin: ${(p) => {
460
+ var _a;
461
+ return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
462
+ }} 0;
463
+ padding: 0 ${(p) => {
442
464
  var _a;
443
465
  return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
444
466
  }};
445
-
446
- ${(p) => p.noPadding && css`
447
- padding: 0;
448
- `}
449
-
450
- margin-bottom: ${(p) => {
467
+ & button.humany-form-component-button {
468
+ ${(p) => {
469
+ var _a, _b;
470
+ return invertedHoverButton({
471
+ active: false,
472
+ primaryColor: (_a = p.theme.colors) == null ? void 0 : _a.primary,
473
+ secondaryColor: (_b = p.theme.colors) == null ? void 0 : _b.accent
474
+ });
475
+ }};
476
+ display: block;
477
+ width: 100%;
478
+ margin-bottom: ${(p) => {
451
479
  var _a;
452
480
  return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
453
481
  }};
454
- &:last-child {
455
- margin-bottom: 0;
482
+ }
483
+ & button.humany-form-component-submit {
484
+ width: 100%;
485
+ margin: 0;
486
+ :not(:last-child) {
487
+ margin-bottom: ${(p) => {
488
+ var _a;
489
+ return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
490
+ }};
491
+ }
492
+ }
493
+ `;
494
+ const StyledActionList = styled(List)`
495
+ padding: 0;
496
+ list-style: none;
497
+ button {
498
+ font-size: inherit;
499
+ }
500
+ margin: ${(p) => {
501
+ var _a;
502
+ return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
503
+ }} 0;
504
+ padding: 0 ${(p) => {
505
+ var _a;
506
+ return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
507
+ }};
508
+ display: flex;
509
+ gap: ${(p) => {
510
+ var _a;
511
+ return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
512
+ }};
513
+ `;
514
+ const StyledActionButton = styled.button`
515
+ ${buttonCss};
516
+ display: block;
517
+ background-color: ${(p) => {
518
+ var _a;
519
+ return (_a = p.theme.colors) == null ? void 0 : _a.primary;
520
+ }};
521
+ width: 100%;
522
+ color: #fff;
523
+ margin: ${(p) => {
524
+ var _a;
525
+ return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
526
+ }} 0;
527
+ padding: 0 ${(p) => {
528
+ var _a;
529
+ return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
530
+ }};
531
+ font-family: Lato;
532
+ font-size: ${(p) => {
533
+ var _a;
534
+ return (_a = p.theme.fonts) == null ? void 0 : _a.huge;
535
+ }};
536
+ font-weight: 300;
537
+ &:focus {
538
+ ${(p) => {
539
+ var _a;
540
+ return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
541
+ ${borderTabStyle}
542
+ background-color: transparent;
543
+ `;
544
+ }}
456
545
  }
457
546
  `;
458
547
  const ConversationLoader = ({ className, agentData }) => {
459
548
  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
549
  };
550
+ const imageLightboxRenderer = (attrs) => /* @__PURE__ */ React.createElement(Lightbox, {
551
+ attrs
552
+ });
553
+ const htmlParseInstructions = {
554
+ transform: {
555
+ img: imageLightboxRenderer
556
+ }
557
+ };
558
+ const Html = ({ body }) => {
559
+ return /* @__PURE__ */ React.createElement(StyledHtml, {
560
+ html: body,
561
+ htmlParseInstruction: htmlParseInstructions
562
+ });
563
+ };
564
+ const StyledHtml = styled(Html$1)`
565
+ ${genericHtml}
566
+ color: inherit;
567
+ white-space: pre-wrap;
568
+ ${messageContentPadding}
569
+ a {
570
+ color: ${(p) => p.theme.colors.link};
571
+ &:focus {
572
+ ${(p) => {
573
+ var _a;
574
+ return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && borderTabStyle;
575
+ }};
576
+ }
577
+ }
578
+ `;
461
579
  const StyledTimestamp = styled.p`
462
580
  && {
463
581
  font-size: ${(p) => {
@@ -532,21 +650,6 @@ const StyledAgentMessage = styled.div`
532
650
  'info';
533
651
  `};
534
652
  `;
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
653
  const SystemMessage = ({
551
654
  className,
552
655
  children,
@@ -604,241 +707,60 @@ const StyledUserMessage = styled.div`
604
707
  flex-direction: column;
605
708
  align-items: flex-end;
606
709
  `;
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
710
+ const mapActions = (actions) => Array.isArray(actions) ? actions : Object.keys(actions).map((i) => {
711
+ return {
712
+ label: actions[i],
713
+ actionKey: i
714
+ };
616
715
  });
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
- }),
716
+ const ButtonList = ({ header, actions, dispatch }) => {
717
+ return /* @__PURE__ */ React.createElement(StyledButtonList, {
718
+ header,
719
+ items: mapActions(actions),
654
720
  renderItem: (item) => {
655
721
  return /* @__PURE__ */ React.createElement("li", {
656
722
  key: item.actionKey
657
- }, /* @__PURE__ */ React.createElement(StyledActionButton, {
723
+ }, /* @__PURE__ */ React.createElement(StyledButtonListButton, {
658
724
  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
- const items2 = Array.isArray(item.content.actions) ? item.content.actions : Object.keys(item.content.actions).map((i) => {
699
- return {
700
- label: item.content.actions[i],
701
- actionKey: i
702
- };
703
- });
704
- return /* @__PURE__ */ React.createElement(ConversationListItem, {
705
- key: itemKey
706
- }, /* @__PURE__ */ React.createElement(StyledLinkList, {
707
- items: items2,
708
- renderItem: (item2) => {
709
- return /* @__PURE__ */ React.createElement("li", {
710
- key: item2.actionKey
711
- }, /* @__PURE__ */ React.createElement(StyledLinkButton, {
712
- help: item2.actionKey === "help",
713
- onClick: () => {
714
- dispatch("action", item2.actionKey);
715
- }
716
- }, item2.label, item2.actionKey === "help" && /* @__PURE__ */ React.createElement(SymbolBadge, {
717
- size: 14,
718
- symbol: {
719
- type: "Svg",
720
- content: "caret-down"
721
- }
722
- })));
723
- }
724
- }));
725
- }
726
- case ConversationMessageListItemType.ButtonList: {
727
- const items2 = Array.isArray(item.content.actions) ? item.content.actions : Object.keys(item.content.actions).map((i) => {
728
- return {
729
- label: item.content.actions[i],
730
- actionKey: i
731
- };
732
- });
733
- return /* @__PURE__ */ React.createElement(ConversationListItem, {
734
- key: itemKey
735
- }, /* @__PURE__ */ React.createElement(StyledButtonList, {
736
- items: items2,
737
- renderItem: (item2) => {
738
- return /* @__PURE__ */ React.createElement("li", {
739
- key: item2.actionKey
740
- }, /* @__PURE__ */ React.createElement(StyledButtonListButton, {
741
- onClick: () => {
742
- dispatch("action", item2.actionKey);
743
- }
744
- }, /* @__PURE__ */ React.createElement(SymbolBadge, {
745
- symbol: item2.symbol
746
- }), item2.label));
747
- }
748
- }));
749
- }
750
- default: {
751
- return /* @__PURE__ */ React.createElement(ConversationListItem, {
752
- key: itemKey,
753
- noPadding: true
754
- }, /* @__PURE__ */ React.createElement(CustomMessageListItem, {
755
- type: item.type,
756
- content: item.content
757
- }));
758
- }
759
- }
725
+ dispatch("action", item);
726
+ },
727
+ "aria-label": item.label,
728
+ title: item.label
729
+ }, /* @__PURE__ */ React.createElement(SymbolBadge, {
730
+ symbol: item.symbol
731
+ }), item.label));
760
732
  }
761
- }))));
762
- };
763
- const StyledForm = styled(FormComponent)`
764
- & button.humany-form-component-button {
765
- ${(p) => {
766
- var _a, _b;
767
- return invertedHoverButton({
768
- active: false,
769
- primaryColor: (_a = p.theme.colors) == null ? void 0 : _a.primary,
770
- secondaryColor: (_b = p.theme.colors) == null ? void 0 : _b.accent
771
733
  });
772
- }};
773
- display: block;
774
- width: 100%;
775
- margin-bottom: ${(p) => {
776
- var _a;
777
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
778
- }};
779
- }
780
- & button.humany-form-component-submit {
781
- width: 100%;
782
- margin: 0;
783
- :not(:last-child) {
784
- margin-bottom: ${(p) => {
734
+ };
735
+ const StyledButtonList = styled(ItemList)`
736
+ ${itemList}
737
+ > ul {
738
+ display: flex;
739
+ flex-wrap: wrap;
740
+ gap: ${(p) => {
785
741
  var _a;
786
742
  return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
787
743
  }};
744
+ > li {
745
+ margin: 0;
788
746
  }
789
747
  }
748
+ ${messageContentPadding}
790
749
  `;
791
- const StyledHtml = styled(Html)`
792
- white-space: pre-wrap;
793
- a {
794
- color: ${(p) => p.theme.colors.link};
795
- &:focus {
796
- ${(p) => {
797
- var _a;
798
- return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && borderTabStyle;
799
- }};
800
- }
801
- }
802
- `;
803
- const StyledActionList = styled(List)`
804
- padding: 0;
805
- list-style: none;
806
- margin: 0 -${(p) => {
807
- var _a;
808
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
809
- }};
810
- > li {
811
- margin: ${(p) => {
812
- var _a;
813
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
814
- }};
815
- }
816
- `;
817
- const StyledButtonList = styled(List)`
818
- padding: 0;
819
- list-style: none;
820
- > li {
821
- margin: ${(p) => {
822
- var _a;
823
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
824
- }} ${(p) => {
750
+ const StyledButtonListButton = styled(Button)`
751
+ ${buttonCss};
752
+
753
+ display: block;
754
+ padding: ${(p) => {
825
755
  var _a;
826
756
  return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
827
757
  }};
828
- margin-left: 0;
829
- display: inline-block;
830
- }
831
- `;
832
- const StyledButtonListButton = styled.button`
833
- ${buttonCss};
834
- display: block;
835
- text-align: left;
836
758
  background-color: ${(p) => {
837
759
  var _a;
838
760
  return (_a = p.theme.colors) == null ? void 0 : _a.primary;
839
761
  }};
840
762
  width: 100%;
841
- color: #fff;
763
+ color: #ffffff;
842
764
  &:focus {
843
765
  ${(p) => {
844
766
  var _a;
@@ -857,35 +779,58 @@ const StyledButtonListButton = styled.button`
857
779
  }};
858
780
  }
859
781
  `;
860
- const StyledLinkList = styled(List)`
861
- padding: 0;
862
- list-style: none;
863
- > li {
864
- margin-bottom: ${(p) => {
782
+ const Custom = ({ type, content = {} }) => {
783
+ const Component = useComponent(type);
784
+ if (!Component || !type) {
785
+ return null;
786
+ }
787
+ return /* @__PURE__ */ React.createElement(Suspense, {
788
+ fallback: null
789
+ }, /* @__PURE__ */ React.createElement(Component, __spreadValues({}, content)));
790
+ };
791
+ const LinkList = ({ header, actions, dispatch }) => {
792
+ return /* @__PURE__ */ React.createElement(StyledLinkList, {
793
+ header,
794
+ items: mapActions(actions),
795
+ renderItem: (item) => {
796
+ return /* @__PURE__ */ React.createElement("li", {
797
+ key: item.actionKey
798
+ }, /* @__PURE__ */ React.createElement(StyledLinkButton, {
799
+ help: item.actionKey === "help",
800
+ onClick: () => {
801
+ dispatch("action", item);
802
+ },
803
+ "aria-label": item.label,
804
+ title: item.label
805
+ }, item.label, item.actionKey === "help" && /* @__PURE__ */ React.createElement(SymbolBadge, {
806
+ size: 14,
807
+ symbol: {
808
+ type: "Svg",
809
+ content: "caret-down"
810
+ }
811
+ })));
812
+ }
813
+ });
814
+ };
815
+ const StyledLinkList = styled(ItemList)`
816
+ ${itemList}
817
+ ${messageContentPadding}
818
+ > ul {
819
+ display: flex;
820
+ flex-direction: column;
821
+ gap: ${(p) => {
865
822
  var _a;
866
823
  return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
867
824
  }};
868
-
869
- &:last-child {
870
- margin-bottom: 0;
825
+ > li {
826
+ margin: 0;
871
827
  }
872
828
  }
873
829
  `;
874
- const HeaderText = styled.strong`
875
- font-size: ${(p) => {
876
- var _a;
877
- return (_a = p.theme.fonts) == null ? void 0 : _a.huge;
878
- }};
879
- `;
880
- const StyledLinkButton = styled.button`
830
+ const StyledLinkButton = styled(Button)`
881
831
  display: block;
882
- background-color: transparent;
883
832
  text-align: left;
884
- border: none;
885
- padding: 0;
886
833
  font-weight: 300;
887
- font-family: inherit;
888
- cursor: pointer;
889
834
  color: ${(p) => {
890
835
  var _a;
891
836
  return (_a = p.theme.colors) == null ? void 0 : _a.primary;
@@ -903,167 +848,96 @@ const StyledLinkButton = styled.button`
903
848
  }
904
849
  `;
905
850
  }}
906
- `;
907
- styled(SymbolBadge)`
908
- font-size: ${(p) => {
909
- var _a;
910
- return (_a = p.theme.fonts) == null ? void 0 : _a.large;
911
- }} !important;
912
- margin-right: ${(p) => {
913
- var _a;
914
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
915
- }};
916
- `;
917
- const StyledActionButton = styled.button`
918
- ${buttonCss};
919
- display: block;
920
- background-color: ${(p) => {
921
- var _a;
922
- return (_a = p.theme.colors) == null ? void 0 : _a.primary;
923
- }};
924
- width: 100%;
925
- color: #fff;
926
- font-family: Lato;
927
- font-size: ${(p) => {
928
- var _a;
929
- return (_a = p.theme.fonts) == null ? void 0 : _a.huge;
930
- }};
931
- font-weight: 300;
851
+
932
852
  &:focus {
933
853
  ${(p) => {
934
- var _a;
854
+ var _a, _b;
935
855
  return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
936
856
  ${borderTabStyle}
937
- background-color: transparent;
857
+ span {
858
+ color: ${(_b = p.theme.colors) == null ? void 0 : _b.primary};
859
+ text-decoration: underline;
860
+ }
938
861
  `;
939
- }}
940
- }
941
- `;
942
- const SeparatorPadding = styled.div`
943
- padding-top: calc(${(p) => {
944
- var _a;
945
- return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
946
- }} - ${(p) => {
947
- var _a;
948
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
949
- }});
950
- padding-bottom: calc(${(p) => {
951
- var _a;
952
- return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
953
- }} - ${(p) => {
954
- var _a;
955
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
956
- }});
957
- `;
958
- const Separator = styled.div`
959
- background-color: #efefef;
960
- height: 1px;
961
- width: 100%;
962
- `;
963
- styled.div`
964
- display: flex;
965
- align-items: center;
966
- justify-content: center;
967
- cursor: pointer;
968
-
969
- > i,
970
- svg {
971
- margin-right: ${(p) => {
972
- var _a;
973
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
974
862
  }};
975
863
  }
976
864
  `;
977
- const ConversationListItem = styled.li`
978
- padding-left: ${(p) => {
979
- var _a;
980
- return p.noPadding ? 0 : (_a = p.theme.sizes) == null ? void 0 : _a.medium;
981
- }};
982
- padding-right: ${(p) => {
983
- var _a;
984
- return p.noPadding ? 0 : (_a = p.theme.sizes) == null ? void 0 : _a.medium;
985
- }};
865
+ const Separator = () => {
866
+ return /* @__PURE__ */ React.createElement(StyledSeparator, null);
867
+ };
868
+ const StyledSeparator = styled.div`
869
+ ${(p) => p.theme.border && `border-bottom: ${p.theme.border};`}
870
+ width: 100%;
986
871
  `;
987
- styled.li`
988
- @media (min-width: 768px) {
989
- display: list-item !important;
990
- margin-right: 0 !important;
991
- margin-top: ${(p) => {
992
- var _a;
993
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
994
- }} !important;
995
- }
872
+ const Text = ({ text }) => {
873
+ return /* @__PURE__ */ React.createElement(StyledTypography, {
874
+ variant: "span"
875
+ }, text);
876
+ };
877
+ const StyledTypography = styled(Typography)`
878
+ ${messageContentPadding}
996
879
  `;
997
- styled.button`
998
- @media (min-width: 768px) {
999
- min-width: 100%;
1000
- margin-right: 0;
1001
- }
1002
- display: inline-block;
1003
- font-size: ${(p) => {
1004
- var _a;
1005
- return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
1006
- }};
1007
- border-color: ${(p) => {
1008
- var _a;
1009
- return (_a = p.theme.colors) == null ? void 0 : _a.primary;
1010
- }} !important;
1011
- font-weight: 300;
1012
- && {
1013
- margin-right: ${(p) => {
1014
- var _a;
1015
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
1016
- }};
880
+ const mapItem = ([type, content]) => {
881
+ return { type, content, id: uuid() };
882
+ };
883
+ const MessageList = ({ items, dispatch }) => {
884
+ return /* @__PURE__ */ React.createElement(StyledList, {
885
+ items: items.map(mapItem),
886
+ renderLi: true,
887
+ renderItem: (item) => {
888
+ switch (item.type) {
889
+ case ConversationMessageListItemType.Text: {
890
+ return /* @__PURE__ */ React.createElement(Text, {
891
+ text: item.content
892
+ });
893
+ }
894
+ case ConversationMessageListItemType.HTML: {
895
+ return /* @__PURE__ */ React.createElement(Html, __spreadValues({}, item.content));
896
+ }
897
+ case ConversationMessageListItemType.Separator: {
898
+ return /* @__PURE__ */ React.createElement(Separator, __spreadValues({}, item.content));
899
+ }
900
+ case ConversationMessageListItemType.LinkList: {
901
+ return /* @__PURE__ */ React.createElement(LinkList, __spreadProps(__spreadValues({}, item.content), {
902
+ dispatch
903
+ }));
904
+ }
905
+ case ConversationMessageListItemType.ButtonList: {
906
+ return /* @__PURE__ */ React.createElement(ButtonList, __spreadProps(__spreadValues({}, item.content), {
907
+ dispatch
908
+ }));
909
+ }
910
+ default: {
911
+ return /* @__PURE__ */ React.createElement(Custom, {
912
+ type: item.type,
913
+ content: item.content
914
+ });
915
+ }
916
+ }
1017
917
  }
1018
- ${(p) => {
1019
- var _a, _b;
1020
- return p["data-direction"] === "horizontal" && css`
1021
- width: 225px;
1022
- max-width: calc(50% - ${(_a = p.theme.sizes) == null ? void 0 : _a.large} - ${(_b = p.theme.sizes) == null ? void 0 : _b.small});
1023
- `;
1024
- }}
1025
- ${(p) => p["data-direction"] === "vertical" && css`
1026
- min-width: 150px;
1027
- `}
1028
- ${(p) => {
1029
- var _a;
1030
- return invertedHoverButton({
1031
- primaryColor: `${(_a = p.theme.colors) == null ? void 0 : _a.primary}`,
1032
- secondaryColor: "#FFFFFF"
1033
918
  });
1034
- }}
1035
- i {
1036
- margin: 0 ${(p) => {
1037
- var _a;
1038
- return (_a = p.theme.sizes) == null ? void 0 : _a.small;
1039
- }} 0 0;
1040
- }
1041
- span {
919
+ };
920
+ const StyledList = styled(List)`
921
+ ${list}
922
+
923
+ > li {
924
+ margin: 0;
1042
925
  }
1043
926
  `;
1044
- const imageLightboxRenderer = (attrs) => /* @__PURE__ */ React.createElement(Lightbox, {
1045
- attrs
1046
- });
1047
- const htmlParseInstructions = {
1048
- transform: {
1049
- img: imageLightboxRenderer
1050
- }
1051
- };
1052
- const ConversationMessageComponent = ({
927
+ const ConversationMessage = ({
1053
928
  className,
1054
929
  timestamp,
1055
930
  sender,
1056
931
  type,
1057
932
  content
1058
933
  }) => {
1059
- useDispatch();
1060
- const getMessageStackPosition = (index) => {
1061
- let messageOrder = void 0;
934
+ const getMessageStackPosition = useCallback((index) => {
935
+ let messageOrder = "first";
1062
936
  if (content.length > 1) {
1063
937
  messageOrder = index === 0 ? "first" : index + 1 === content.length ? "last" : "middle";
1064
938
  }
1065
939
  return messageOrder;
1066
- };
940
+ }, [content]);
1067
941
  const createSystemMessage = () => {
1068
942
  return /* @__PURE__ */ React.createElement(React.Fragment, null, content.map((item) => {
1069
943
  const { key, body, title, form, actions } = item;
@@ -1075,9 +949,8 @@ const ConversationMessageComponent = ({
1075
949
  timestamp,
1076
950
  fullWidth: !!form || !!actions
1077
951
  }, discrete && body ? /* @__PURE__ */ React.createElement(Html, {
1078
- html: body,
1079
- htmlParseInstruction: htmlParseInstructions
1080
- }) : /* @__PURE__ */ React.createElement(ConversationContent, {
952
+ body
953
+ }) : /* @__PURE__ */ React.createElement(Message, {
1081
954
  content: item,
1082
955
  isUser: false
1083
956
  }));
@@ -1091,7 +964,7 @@ const ConversationMessageComponent = ({
1091
964
  }, /* @__PURE__ */ React.createElement(ContentBundle, null, content.map((item, index) => {
1092
965
  return /* @__PURE__ */ React.createElement(MessageContainer, {
1093
966
  key: item.key
1094
- }, /* @__PURE__ */ React.createElement(ConversationContent, {
967
+ }, /* @__PURE__ */ React.createElement(Message, {
1095
968
  content: item,
1096
969
  isUser: false,
1097
970
  stacked: getMessageStackPosition(index)
@@ -1104,8 +977,9 @@ const ConversationMessageComponent = ({
1104
977
  className
1105
978
  }, /* @__PURE__ */ React.createElement(ContentBundle, null, content.map((item, index) => {
1106
979
  return /* @__PURE__ */ React.createElement(MessageContainer, {
980
+ user: true,
1107
981
  key: item.key
1108
- }, /* @__PURE__ */ React.createElement(ConversationContent, {
982
+ }, /* @__PURE__ */ React.createElement(Message, {
1109
983
  content: item,
1110
984
  isUser: true,
1111
985
  stacked: getMessageStackPosition(index)
@@ -1123,86 +997,51 @@ const ConversationMessageComponent = ({
1123
997
  return null;
1124
998
  }
1125
999
  };
1126
- styled(FormComponent)`
1127
- & button.humany-form-component-button {
1128
- ${(p) => {
1129
- var _a, _b;
1130
- return invertedHoverButton({
1131
- active: false,
1132
- primaryColor: (_a = p.theme.colors) == null ? void 0 : _a.primary,
1133
- secondaryColor: (_b = p.theme.colors) == null ? void 0 : _b.accent
1134
- });
1135
- }};
1136
- display: block;
1137
- width: 100%;
1138
- margin-bottom: ${(p) => {
1139
- var _a;
1140
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
1141
- }};
1142
- }
1143
-
1144
- & button.humany-form-component-submit {
1145
- width: 100%;
1146
- margin: 0;
1147
- :not(:last-child) {
1148
- margin-bottom: ${(p) => {
1149
- var _a;
1150
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
1151
- }};
1152
- }
1000
+ const Message = ({ content, isUser, stacked }) => {
1001
+ const dispatch = useDispatch();
1002
+ const { title, body, actions, form, items } = content;
1003
+ return /* @__PURE__ */ React.createElement(MessageContent, {
1004
+ user: isUser,
1005
+ stacked,
1006
+ fullWidth: !!form || !!actions
1007
+ }, title && /* @__PURE__ */ React.createElement(MessageContentPart, null, /* @__PURE__ */ React.createElement(MessageTitle, {
1008
+ variant: "h2"
1009
+ }, title)), body && /* @__PURE__ */ React.createElement(MessageContentPart, null, /* @__PURE__ */ React.createElement(Html, {
1010
+ body
1011
+ })), form && /* @__PURE__ */ React.createElement(MessageContentPart, null, /* @__PURE__ */ React.createElement(StyledForm, __spreadProps(__spreadValues({}, form), {
1012
+ onChange: (key, data) => {
1013
+ dispatch("form", {
1014
+ data,
1015
+ formKey: form.schema.id,
1016
+ actionKey: key
1017
+ });
1153
1018
  }
1154
- `;
1155
- styled(Html)`
1156
- white-space: pre-wrap;
1157
-
1158
- a {
1159
- color: ${(p) => p.theme.colors.link};
1160
- &:focus {
1161
- ${(p) => {
1162
- var _a;
1163
- return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && borderTabStyle;
1164
- }};
1019
+ }))), actions && /* @__PURE__ */ React.createElement(MessageContentPart, null, /* @__PURE__ */ React.createElement(StyledActionList, {
1020
+ items: Object.keys(actions).map((i) => {
1021
+ return { label: actions[i], actionKey: i };
1022
+ }),
1023
+ renderItem: (item) => {
1024
+ return /* @__PURE__ */ React.createElement("li", {
1025
+ key: item.actionKey
1026
+ }, /* @__PURE__ */ React.createElement(StyledActionButton, {
1027
+ onClick: () => {
1028
+ dispatch("action", item.actionKey);
1165
1029
  }
1030
+ }, item.label));
1166
1031
  }
1167
- `;
1168
- styled(List)`
1169
- padding: 0;
1170
- list-style: none;
1171
- margin: 0 -${(p) => {
1172
- var _a;
1173
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
1174
- }};
1175
- > li {
1176
- margin: ${(p) => {
1177
- var _a;
1178
- return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
1179
- }};
1180
- }
1181
- `;
1182
- styled.button`
1183
- ${buttonCss};
1184
- display: block;
1185
- background-color: ${(p) => {
1186
- var _a;
1187
- return (_a = p.theme.colors) == null ? void 0 : _a.primary;
1188
- }};
1189
- width: 100%;
1190
- color: #fff;
1191
- &:focus {
1192
- ${(p) => {
1193
- var _a;
1194
- return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && css`
1195
- ${borderTabStyle}
1196
- background-color: transparent;
1197
- `;
1198
- }}
1199
- }
1200
- `;
1201
- const Conversation = ({ className }) => {
1032
+ })), items && /* @__PURE__ */ React.createElement(MessageList, {
1033
+ key: uuid(),
1034
+ items,
1035
+ dispatch
1036
+ }));
1037
+ };
1038
+ const ConversationContent = () => {
1202
1039
  const lastEntry = useRef(document.createElement("div"));
1203
1040
  const [scrollableCss, viewElem] = useScroll(true);
1204
1041
  const { messages, loading, typingActors } = useProperties();
1205
1042
  const [canSmooth, setCanSmooth] = useState(false);
1043
+ const previousMessages = usePrevious(messages);
1044
+ const previousTypingActors = usePrevious(typingActors);
1206
1045
  const scrollView = useCallback((lastEntry2, smooth = true) => {
1207
1046
  if (lastEntry2 !== null && lastEntry2.current !== null) {
1208
1047
  if (messages && messages.length === 1) {
@@ -1218,12 +1057,23 @@ const Conversation = ({ className }) => {
1218
1057
  behavior: smooth ? "smooth" : "auto"
1219
1058
  });
1220
1059
  }
1221
- }, 0);
1060
+ }, 150);
1222
1061
  }
1223
1062
  }, [lastEntry]);
1224
1063
  useEffect(() => {
1225
1064
  if (canSmooth) {
1226
- scrollView(lastEntry);
1065
+ const messageCountChanged = messages.length !== (previousMessages == null ? void 0 : previousMessages.length);
1066
+ const typingActorCountChanged = typingActors.length !== (previousTypingActors == null ? void 0 : previousTypingActors.length);
1067
+ const messageContentCountChanged = messages.reduce((changed, message, index) => {
1068
+ var _a;
1069
+ if (((_a = previousMessages == null ? void 0 : previousMessages[index]) == null ? void 0 : _a.content.length) !== message.content.length) {
1070
+ return true;
1071
+ }
1072
+ return changed;
1073
+ }, false);
1074
+ if (messageCountChanged || messageContentCountChanged || typingActorCountChanged) {
1075
+ scrollView(lastEntry);
1076
+ }
1227
1077
  }
1228
1078
  }, [messages, typingActors]);
1229
1079
  useTransitionEnd(() => {
@@ -1245,9 +1095,7 @@ const Conversation = ({ className }) => {
1245
1095
  }
1246
1096
  return null;
1247
1097
  };
1248
- return /* @__PURE__ */ React.createElement(Wrapper, {
1249
- className: appendClassNames(className, "humany-conversation-component")
1250
- }, /* @__PURE__ */ React.createElement(Scrollable, {
1098
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Scrollable, {
1251
1099
  tabIndex: 0,
1252
1100
  scrollableCss,
1253
1101
  ref: viewElem
@@ -1258,19 +1106,9 @@ const Conversation = ({ className }) => {
1258
1106
  tabIndex: -1,
1259
1107
  key: `${type}_${sender == null ? void 0 : sender.name}_${timestamp}_${content[0].key}`,
1260
1108
  ref: index + 1 < messages.length ? null : typingActors.length ? null : lastEntry
1261
- }, /* @__PURE__ */ React.createElement(ConversationMessageComponent, __spreadValues({}, message)));
1109
+ }, /* @__PURE__ */ React.createElement(ConversationMessage, __spreadValues({}, message)));
1262
1110
  }) : null, renderTypingActors(), loading && /* @__PURE__ */ React.createElement(MessageEntry, null, /* @__PURE__ */ React.createElement(ConversationLoader, null))), /* @__PURE__ */ React.createElement(ConversationInput, null));
1263
1111
  };
1264
- const Wrapper = styled.div`
1265
- position: absolute;
1266
- right: 0;
1267
- left: 0;
1268
- bottom: 0;
1269
- top: 0;
1270
- overflow: hidden;
1271
- display: flex;
1272
- flex-direction: column;
1273
- `;
1274
1112
  const Scrollable = styled.div`
1275
1113
  display: flex;
1276
1114
  flex-direction: column;
@@ -1309,13 +1147,6 @@ const MessageEntry = styled.div`
1309
1147
  }};
1310
1148
  }
1311
1149
 
1312
- * {
1313
- font-size: ${(p) => {
1314
- var _a;
1315
- return (_a = p.theme.fonts) == null ? void 0 : _a.normal;
1316
- }};
1317
- }
1318
-
1319
1150
  & span,
1320
1151
  p,
1321
1152
  a,
@@ -1332,5 +1163,140 @@ const MessageEntry = styled.div`
1332
1163
  font-weight: normal;
1333
1164
  `)}
1334
1165
  `;
1166
+ const OverlayOutlet = ({ dispatch }) => {
1167
+ const wrapperRef = useRef(null);
1168
+ useEffect(() => {
1169
+ if (wrapperRef.current && wrapperRef.current.parentNode) {
1170
+ dispatch("overlay-mounted", wrapperRef.current);
1171
+ }
1172
+ }, [wrapperRef]);
1173
+ return /* @__PURE__ */ React.createElement(WidgetOverlayOutlet, {
1174
+ portalId: "humany-conversation-overlay-portal",
1175
+ className: "humany-conversation-overlay-outlet",
1176
+ ref: wrapperRef
1177
+ });
1178
+ };
1179
+ const ConversationOverlayOutlet = ({
1180
+ dispatch,
1181
+ header,
1182
+ buttonLabel
1183
+ }) => {
1184
+ return /* @__PURE__ */ React.createElement(StyledWidgetOverlayOutlet, {
1185
+ portalId: "humany-conversation-portal",
1186
+ className: "humany-conversation-outlet"
1187
+ }, /* @__PURE__ */ React.createElement(ConversationOverlayHead, {
1188
+ className: "humany-conversation-outlet-head"
1189
+ }, /* @__PURE__ */ React.createElement(ConversationOverlayHeadButton, {
1190
+ className: "humany-conversation-outlet-head-button",
1191
+ "aria-label": buttonLabel,
1192
+ title: buttonLabel,
1193
+ onClick: () => dispatch("hide-overlay-conversation")
1194
+ }, /* @__PURE__ */ React.createElement(SymbolBadge, {
1195
+ symbol: {
1196
+ type: "Svg",
1197
+ content: "caret-down"
1198
+ },
1199
+ size: 20
1200
+ })), header && /* @__PURE__ */ React.createElement(ConversationOverlayHeader, {
1201
+ className: "humany-conversation-outlet-header",
1202
+ variant: "h1"
1203
+ }, header)), /* @__PURE__ */ React.createElement(ConversationContent, null));
1204
+ };
1205
+ const StyledWidgetOverlayOutlet = styled(WidgetOverlayOutlet)`
1206
+ z-index: 11;
1207
+ top: auto;
1208
+ height: 65%;
1209
+ background-color: #ffffff;
1210
+ display: flex;
1211
+ flex-direction: column;
1212
+ border-top-right-radius: ${(p) => {
1213
+ var _a;
1214
+ return (_a = p.theme.sizes) == null ? void 0 : _a.large;
1215
+ }};
1216
+ border-top-left-radius: ${(p) => {
1217
+ var _a;
1218
+ return (_a = p.theme.sizes) == null ? void 0 : _a.large;
1219
+ }};
1220
+ `;
1221
+ const ConversationOverlayHead = styled.div`
1222
+ display: flex;
1223
+ flex-direction: column;
1224
+ justify-content: center;
1225
+ align-items: center;
1226
+ gap: ${(p) => {
1227
+ var _a;
1228
+ return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
1229
+ }};
1230
+ padding: ${(p) => {
1231
+ var _a;
1232
+ return (_a = p.theme.sizes) == null ? void 0 : _a.normal;
1233
+ }};
1234
+ ${(p) => p.theme.border && `border-bottom: ${p.theme.border};`}
1235
+ `;
1236
+ const ConversationOverlayHeader = styled(Typography)`
1237
+ font-size: ${(p) => {
1238
+ var _a;
1239
+ return (_a = p.theme.fonts) == null ? void 0 : _a.medium;
1240
+ }};
1241
+ color: ${(p) => {
1242
+ var _a;
1243
+ return (_a = p.theme.colors) == null ? void 0 : _a.text;
1244
+ }};
1245
+ margin: 0;
1246
+ `;
1247
+ const ConversationOverlayHeadButton = styled(Button)`
1248
+ display: flex;
1249
+ align-items: center;
1250
+ justify-content: center;
1251
+ padding: ${(p) => {
1252
+ var _a;
1253
+ return (_a = p.theme.sizes) == null ? void 0 : _a.small;
1254
+ }} ${(p) => {
1255
+ var _a;
1256
+ return (_a = p.theme.sizes) == null ? void 0 : _a.medium;
1257
+ }};
1258
+ ${(p) => p.theme.borderRadius && `border-radius: ${p.theme.borderRadius};`}
1259
+
1260
+ &:focus {
1261
+ ${(p) => {
1262
+ var _a;
1263
+ return ((_a = p.theme.accessibility) == null ? void 0 : _a.isTabbing) && borderTabStyle;
1264
+ }};
1265
+ }
1266
+
1267
+ svg line {
1268
+ stroke: ${(p) => {
1269
+ var _a;
1270
+ return (_a = p.theme.colors) == null ? void 0 : _a.text;
1271
+ }};
1272
+ }
1273
+ `;
1274
+ const Conversation = ({ className }) => {
1275
+ const {
1276
+ overlay,
1277
+ overlayConversationHeader,
1278
+ overlayConversationCloseLabel
1279
+ } = useProperties();
1280
+ const dispatch = useDispatch();
1281
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Wrapper, {
1282
+ className: appendClassNames(className, "humany-conversation-component")
1283
+ }, /* @__PURE__ */ React.createElement(ConversationContent, null)), overlay && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(OverlayOutlet, {
1284
+ dispatch
1285
+ }), overlay.conversation && /* @__PURE__ */ React.createElement(ConversationOverlayOutlet, {
1286
+ dispatch,
1287
+ header: overlayConversationHeader,
1288
+ buttonLabel: overlayConversationCloseLabel
1289
+ })));
1290
+ };
1291
+ const Wrapper = styled.div`
1292
+ position: absolute;
1293
+ right: 0;
1294
+ left: 0;
1295
+ bottom: 0;
1296
+ top: 0;
1297
+ overflow: hidden;
1298
+ display: flex;
1299
+ flex-direction: column;
1300
+ `;
1335
1301
  export { Conversation as default };
1336
1302
  //# sourceMappingURL=conversation.js.map