@pega/cosmos-react-social 2.0.0-dev.2.0 → 2.0.0-dev.21.1

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 (133) hide show
  1. package/lib/components/Chat/Chat.d.ts.map +1 -1
  2. package/lib/components/Chat/Chat.js +9 -16
  3. package/lib/components/Chat/Chat.js.map +1 -1
  4. package/lib/components/Chat/Chat.types.d.ts +3 -3
  5. package/lib/components/Chat/Chat.types.d.ts.map +1 -1
  6. package/lib/components/Chat/Chat.types.js.map +1 -1
  7. package/lib/components/Chat/ChatBody.d.ts.map +1 -1
  8. package/lib/components/Chat/ChatBody.js +4 -3
  9. package/lib/components/Chat/ChatBody.js.map +1 -1
  10. package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
  11. package/lib/components/Chat/ChatComposer.js +36 -51
  12. package/lib/components/Chat/ChatComposer.js.map +1 -1
  13. package/lib/components/Chat/ChatHeader.d.ts.map +1 -1
  14. package/lib/components/Chat/ChatHeader.js +10 -13
  15. package/lib/components/Chat/ChatHeader.js.map +1 -1
  16. package/lib/components/Chat/ChatTranscript.d.ts.map +1 -1
  17. package/lib/components/Chat/ChatTranscript.js +15 -16
  18. package/lib/components/Chat/ChatTranscript.js.map +1 -1
  19. package/lib/components/Chat/Message.d.ts.map +1 -1
  20. package/lib/components/Chat/Message.js +41 -59
  21. package/lib/components/Chat/Message.js.map +1 -1
  22. package/lib/components/Chat/Message.styles.js +2 -2
  23. package/lib/components/Chat/Message.styles.js.map +1 -1
  24. package/lib/components/Chat/MessageList.d.ts.map +1 -1
  25. package/lib/components/Chat/MessageList.js +36 -41
  26. package/lib/components/Chat/MessageList.js.map +1 -1
  27. package/lib/components/Chat/RepeatingView.d.ts.map +1 -1
  28. package/lib/components/Chat/RepeatingView.js +10 -14
  29. package/lib/components/Chat/RepeatingView.js.map +1 -1
  30. package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
  31. package/lib/components/Chat/SuggestedReplyPicker.js +46 -54
  32. package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
  33. package/lib/components/Chat/SystemMessage.d.ts.map +1 -1
  34. package/lib/components/Chat/SystemMessage.js +4 -6
  35. package/lib/components/Chat/SystemMessage.js.map +1 -1
  36. package/lib/components/Chat/TranscriptMessage.d.ts.map +1 -1
  37. package/lib/components/Chat/TranscriptMessage.js +7 -13
  38. package/lib/components/Chat/TranscriptMessage.js.map +1 -1
  39. package/lib/components/Chat/TypeIndicator.d.ts.map +1 -1
  40. package/lib/components/Chat/TypeIndicator.js +3 -2
  41. package/lib/components/Chat/TypeIndicator.js.map +1 -1
  42. package/lib/components/Email/Email.d.ts.map +1 -1
  43. package/lib/components/Email/Email.js +102 -129
  44. package/lib/components/Email/Email.js.map +1 -1
  45. package/lib/components/Email/Email.styles.d.ts +8 -1
  46. package/lib/components/Email/Email.styles.d.ts.map +1 -1
  47. package/lib/components/Email/Email.styles.js +85 -4
  48. package/lib/components/Email/Email.styles.js.map +1 -1
  49. package/lib/components/Email/Email.types.d.ts +139 -62
  50. package/lib/components/Email/Email.types.d.ts.map +1 -1
  51. package/lib/components/Email/Email.types.js.map +1 -1
  52. package/lib/components/Email/EmailComposer.d.ts +4 -6
  53. package/lib/components/Email/EmailComposer.d.ts.map +1 -1
  54. package/lib/components/Email/EmailComposer.js +155 -73
  55. package/lib/components/Email/EmailComposer.js.map +1 -1
  56. package/lib/components/Email/EmailConversation.d.ts +7 -4
  57. package/lib/components/Email/EmailConversation.d.ts.map +1 -1
  58. package/lib/components/Email/EmailConversation.js +132 -76
  59. package/lib/components/Email/EmailConversation.js.map +1 -1
  60. package/lib/components/Email/EmailEntity.d.ts +6 -0
  61. package/lib/components/Email/EmailEntity.d.ts.map +1 -0
  62. package/lib/components/Email/EmailEntity.js +19 -0
  63. package/lib/components/Email/EmailEntity.js.map +1 -0
  64. package/lib/components/Email/EmailSelector.d.ts +14 -0
  65. package/lib/components/Email/EmailSelector.d.ts.map +1 -0
  66. package/lib/components/Email/EmailSelector.js +62 -0
  67. package/lib/components/Email/EmailSelector.js.map +1 -0
  68. package/lib/components/Email/EmailShell.d.ts.map +1 -1
  69. package/lib/components/Email/EmailShell.js +23 -31
  70. package/lib/components/Email/EmailShell.js.map +1 -1
  71. package/lib/components/Email/EmailSummaryItem.d.ts +10 -0
  72. package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -0
  73. package/lib/components/Email/EmailSummaryItem.js +93 -0
  74. package/lib/components/Email/EmailSummaryItem.js.map +1 -0
  75. package/lib/components/Email/EmailSummaryList.d.ts +6 -0
  76. package/lib/components/Email/EmailSummaryList.d.ts.map +1 -0
  77. package/lib/components/Email/EmailSummaryList.js +115 -0
  78. package/lib/components/Email/EmailSummaryList.js.map +1 -0
  79. package/lib/components/Email/ViewAnalysis.d.ts +6 -0
  80. package/lib/components/Email/ViewAnalysis.d.ts.map +1 -0
  81. package/lib/components/Email/ViewAnalysis.js +20 -0
  82. package/lib/components/Email/ViewAnalysis.js.map +1 -0
  83. package/lib/components/Feed/Feed.context.d.ts +16 -6
  84. package/lib/components/Feed/Feed.context.d.ts.map +1 -1
  85. package/lib/components/Feed/Feed.context.js +1 -0
  86. package/lib/components/Feed/Feed.context.js.map +1 -1
  87. package/lib/components/Feed/Feed.d.ts +13 -17
  88. package/lib/components/Feed/Feed.d.ts.map +1 -1
  89. package/lib/components/Feed/Feed.js +20 -31
  90. package/lib/components/Feed/Feed.js.map +1 -1
  91. package/lib/components/Feed/FeedAttachments.d.ts.map +1 -1
  92. package/lib/components/Feed/FeedAttachments.js +7 -6
  93. package/lib/components/Feed/FeedAttachments.js.map +1 -1
  94. package/lib/components/Feed/FeedButton.d.ts.map +1 -1
  95. package/lib/components/Feed/FeedButton.js.map +1 -1
  96. package/lib/components/Feed/FeedContent.d.ts.map +1 -1
  97. package/lib/components/Feed/FeedContent.js +12 -6
  98. package/lib/components/Feed/FeedContent.js.map +1 -1
  99. package/lib/components/Feed/FeedModalList.d.ts +15 -0
  100. package/lib/components/Feed/FeedModalList.d.ts.map +1 -0
  101. package/lib/components/Feed/FeedModalList.js +49 -0
  102. package/lib/components/Feed/FeedModalList.js.map +1 -0
  103. package/lib/components/Feed/FeedNewPost.d.ts +2 -1
  104. package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
  105. package/lib/components/Feed/FeedNewPost.js +44 -44
  106. package/lib/components/Feed/FeedNewPost.js.map +1 -1
  107. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -1
  108. package/lib/components/Feed/FeedNewPostTypeMenu.js +47 -79
  109. package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
  110. package/lib/components/Feed/FeedPost.d.ts +34 -12
  111. package/lib/components/Feed/FeedPost.d.ts.map +1 -1
  112. package/lib/components/Feed/FeedPost.js +165 -101
  113. package/lib/components/Feed/FeedPost.js.map +1 -1
  114. package/lib/components/Feed/FeedReply.d.ts +31 -13
  115. package/lib/components/Feed/FeedReply.d.ts.map +1 -1
  116. package/lib/components/Feed/FeedReply.js +123 -39
  117. package/lib/components/Feed/FeedReply.js.map +1 -1
  118. package/lib/components/Feed/FeedReplyInput.d.ts +6 -6
  119. package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
  120. package/lib/components/Feed/FeedReplyInput.js +43 -46
  121. package/lib/components/Feed/FeedReplyInput.js.map +1 -1
  122. package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
  123. package/lib/components/Feed/FeedRichText.js +81 -19
  124. package/lib/components/Feed/FeedRichText.js.map +1 -1
  125. package/lib/components/HashtagButton/HashtagButton.d.ts +6 -4
  126. package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -1
  127. package/lib/components/HashtagButton/HashtagButton.js +23 -17
  128. package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
  129. package/lib/components/MentionButton/MentionButton.d.ts +10 -4
  130. package/lib/components/MentionButton/MentionButton.d.ts.map +1 -1
  131. package/lib/components/MentionButton/MentionButton.js +34 -18
  132. package/lib/components/MentionButton/MentionButton.js.map +1 -1
  133. package/package.json +15 -16
@@ -1,7 +1,12 @@
1
- import React, { forwardRef } from 'react';
2
- import { Avatar, Flex, Icon, SummaryItem, Image, EmojiDisplay, useI18n } from '@pega/cosmos-react-core';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { Avatar, Flex, Icon, registerIcon, SummaryItem, Image, EmojiDisplay, useI18n } from '@pega/cosmos-react-core';
3
4
  import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
5
+ import * as downloadIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/download.icon';
6
+ import * as documentDocIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/document-doc.icon';
7
+ import * as chainUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chain-up.icon';
4
8
  import { StyledMessageContainer, StyledMessageMain, StyledMessageBubble, StyledMessageBubbleContent, StyledMediaList, StyledMediaListItem, StyledMediaThumbNail, StyledSummaryItem, StyledMediaLink, StyledMediaDownloadButton, StyledMetaInfoContainer, StyledMetaInfo, StyledBlinkingDot, StyledMediaButton, StyledMessageHeader, StyledMessageHeaderContent, StyledMessageHeaderMeta } from './Message.styles';
9
+ registerIcon(downloadIcon, documentDocIcon, chainUpIcon);
5
10
  const Message = forwardRef((props, ref) => {
6
11
  const { message, direction, variant, avatarInfo, timeStamp, attachments = [], pagePushLinks = [], status, typing, messageHeader, ...restProps } = props;
7
12
  const t = useI18n();
@@ -12,66 +17,43 @@ const Message = forwardRef((props, ref) => {
12
17
  else if (!timeStamp && status) {
13
18
  messageMetaJustify = 'end';
14
19
  }
15
- return (React.createElement(Flex, { as: StyledMessageContainer, ref: ref, container: {
16
- itemGap: 0.5,
20
+ return (_jsxs(Flex, { as: StyledMessageContainer, ref: ref, container: {
21
+ gap: 0.5,
17
22
  direction: direction === 'in' ? 'row' : 'row-reverse'
18
23
  }, item: {
19
24
  shrink: 0
20
- }, messageDirection: direction, variant: variant, typing: typing, messageHeader: messageHeader, ...restProps },
21
- avatarInfo && (React.createElement(Avatar, { name: avatarInfo.name, size: 'm', shape: 'circle', imageSrc: avatarInfo.imageSrc })),
22
- React.createElement(Flex, { container: {
23
- direction: 'column',
24
- alignItems: direction === 'in' ? 'start' : 'end',
25
- justify: 'center'
26
- }, as: StyledMessageMain },
27
- React.createElement(StyledMessageBubble, null,
28
- messageHeader && (React.createElement(Flex, { container: { itemGap: 0.5, justify: 'between' }, as: StyledMessageHeader },
29
- React.createElement(StyledMessageHeaderContent, null, messageHeader.content),
30
- React.createElement(StyledMessageHeaderMeta, null, messageHeader.meta))),
31
- message && (React.createElement(StyledMessageBubbleContent, null,
32
- React.createElement(EmojiDisplay, { content: message, size: 20 }))),
33
- (attachments.length > 0 || pagePushLinks.length > 0) && (React.createElement(StyledMediaList, null,
34
- attachments.map(attachment => {
35
- const { id, icon, name, meta, onDownload, onPreview, thumbnail } = attachment;
36
- return (React.createElement(Flex, { key: id, as: StyledMediaListItem, container: {
37
- direction: 'column'
38
- } },
39
- thumbnail && (React.createElement(Image, { as: StyledMediaThumbNail, src: thumbnail, onClick: (e) => {
40
- e.preventDefault();
41
- e.stopPropagation();
42
- onPreview === null || onPreview === void 0 ? void 0 : onPreview(id);
43
- }, alt: name })),
44
- React.createElement(SummaryItem, { as: StyledSummaryItem, primary: React.createElement(StyledMediaButton, { title: name, onClick: (e) => {
45
- e.preventDefault();
46
- e.stopPropagation();
47
- onPreview === null || onPreview === void 0 ? void 0 : onPreview(id);
48
- } }, name), secondary: meta, visual: React.createElement(Icon, { name: icon || 'document-doc' }), actions: React.createElement(BareButton, { "aria-label": t('download'), as: StyledMediaDownloadButton, onClick: (e) => {
49
- e.preventDefault();
50
- e.stopPropagation();
51
- onDownload === null || onDownload === void 0 ? void 0 : onDownload(id);
52
- } },
53
- React.createElement(Icon, { name: 'download' })) })));
54
- }),
55
- pagePushLinks.map(pagePushLink => {
56
- const { id, href, title, thumbnail } = pagePushLink;
57
- return (React.createElement(Flex, { as: StyledMediaListItem, key: id, container: {
58
- direction: 'column'
59
- } },
60
- thumbnail && (React.createElement(Image, { as: StyledMediaThumbNail, src: thumbnail, alt: title || href })),
61
- React.createElement(SummaryItem, { as: StyledSummaryItem, primary: React.createElement(StyledMediaLink, { title: title, href: href, target: '_blank', rel: 'noreferrer' }, href), visual: React.createElement(Icon, { name: 'chain-up' }) })));
62
- })))),
63
- !typing && (React.createElement(Flex, { as: StyledMetaInfoContainer, container: {
64
- justify: messageMetaJustify,
65
- itemGap: 1.5
66
- } },
67
- timeStamp && React.createElement(StyledMetaInfo, null, timeStamp),
68
- status && React.createElement(StyledMetaInfo, null, status))),
69
- typing && (React.createElement(Flex, { container: {
70
- itemGap: 0.25
71
- } },
72
- React.createElement(StyledBlinkingDot, { delay: 0 }),
73
- React.createElement(StyledBlinkingDot, { delay: 0.25 }),
74
- React.createElement(StyledBlinkingDot, { delay: 0.5 }))))));
25
+ }, messageDirection: direction, variant: variant, typing: typing, messageHeader: messageHeader, ...restProps, children: [avatarInfo && (_jsx(Avatar, { name: avatarInfo.name, size: 'm', shape: 'circle', imageSrc: avatarInfo.imageSrc }, void 0)), _jsxs(Flex, { container: {
26
+ direction: 'column',
27
+ alignItems: direction === 'in' ? 'start' : 'end',
28
+ justify: 'center'
29
+ }, as: StyledMessageMain, children: [_jsxs(StyledMessageBubble, { children: [messageHeader && (_jsxs(Flex, { container: { gap: 0.5, justify: 'between' }, as: StyledMessageHeader, children: [_jsx(StyledMessageHeaderContent, { children: messageHeader.content }, void 0), _jsx(StyledMessageHeaderMeta, { children: messageHeader.meta }, void 0)] }, void 0)), message && (_jsx(StyledMessageBubbleContent, { children: _jsx(EmojiDisplay, { content: message, size: 20 }, void 0) }, void 0)), (attachments.length > 0 || pagePushLinks.length > 0) && (_jsxs(StyledMediaList, { children: [attachments.map(attachment => {
30
+ const { id, icon, name, meta, onDownload, onPreview, thumbnail } = attachment;
31
+ return (_jsxs(Flex, { as: StyledMediaListItem, container: {
32
+ direction: 'column'
33
+ }, children: [thumbnail && (_jsx(Image, { as: StyledMediaThumbNail, src: thumbnail, onClick: (e) => {
34
+ e.preventDefault();
35
+ e.stopPropagation();
36
+ onPreview?.(id);
37
+ }, alt: name }, void 0)), _jsx(SummaryItem, { as: StyledSummaryItem, primary: _jsx(StyledMediaButton, { onClick: (e) => {
38
+ e.preventDefault();
39
+ e.stopPropagation();
40
+ onPreview?.(id);
41
+ }, children: name }, void 0), secondary: meta, visual: _jsx(Icon, { name: icon || 'document-doc' }, void 0), actions: _jsx(BareButton, { "aria-label": t('download'), as: StyledMediaDownloadButton, onClick: (e) => {
42
+ e.preventDefault();
43
+ e.stopPropagation();
44
+ onDownload?.(id);
45
+ }, children: _jsx(Icon, { name: 'download' }, void 0) }, void 0) }, void 0)] }, id));
46
+ }), pagePushLinks.map(pagePushLink => {
47
+ const { id, href, title, thumbnail } = pagePushLink;
48
+ return (_jsxs(Flex, { as: StyledMediaListItem, container: {
49
+ direction: 'column'
50
+ }, children: [thumbnail && (_jsx(Image, { as: StyledMediaThumbNail, src: thumbnail, alt: title || href }, void 0)), _jsx(SummaryItem, { as: StyledSummaryItem, primary: _jsx(StyledMediaLink, { "aria-label": title, href: href, target: '_blank', rel: 'noreferrer', children: href }, void 0), visual: _jsx(Icon, { name: 'chain-up' }, void 0) }, void 0)] }, id));
51
+ })] }, void 0))] }, void 0), !typing && (_jsxs(Flex, { as: StyledMetaInfoContainer, container: {
52
+ justify: messageMetaJustify,
53
+ gap: 1.5
54
+ }, children: [timeStamp && _jsx(StyledMetaInfo, { children: timeStamp }, void 0), status && _jsx(StyledMetaInfo, { children: status }, void 0)] }, void 0)), typing && (_jsxs(Flex, { container: {
55
+ gap: 0.25
56
+ }, children: [_jsx(StyledBlinkingDot, { delay: 0 }, void 0), _jsx(StyledBlinkingDot, { delay: 0.25 }, void 0), _jsx(StyledBlinkingDot, { delay: 0.5 }, void 0)] }, void 0))] }, void 0)] }, void 0));
75
57
  });
76
58
  export default Message;
77
59
  //# sourceMappingURL=Message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,UAAU,EAKX,MAAM,OAAO,CAAC;AAEf,OAAO,EAEL,MAAM,EACN,IAAI,EACJ,IAAI,EAEJ,WAAW,EACX,KAAK,EAEL,YAAY,EACZ,OAAO,EAER,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAGlF,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AA6C1B,MAAM,OAAO,GAAmD,UAAU,CACxE,CAAC,KAAoC,EAAE,GAAwB,EAAE,EAAE;IACjE,MAAM,EACJ,OAAO,EACP,SAAS,EACT,OAAO,EACP,UAAU,EACV,SAAS,EACT,WAAW,GAAG,EAAE,EAChB,aAAa,GAAG,EAAE,EAClB,MAAM,EACN,MAAM,EACN,aAAa,EACb,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,IAAI,kBAAkB,GAAkC,SAAS,CAAC;IAClE,IAAI,SAAS,IAAI,CAAC,MAAM,EAAE;QACxB,kBAAkB,GAAG,OAAO,CAAC;KAC9B;SAAM,IAAI,CAAC,SAAS,IAAI,MAAM,EAAE;QAC/B,kBAAkB,GAAG,KAAK,CAAC;KAC5B;IAED,OAAO,CACL,oBAAC,IAAI,IACH,EAAE,EAAE,sBAAsB,EAC1B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE;Y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AE,IAAI,GAAI;gBAClC,oBAAC,iBAAiB,IAAC,KAAK,EAAE,GAAG,GAAI,CAC5B,CACR,CACI,CACF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import React, {\n FunctionComponent,\n forwardRef,\n ReactNode,\n PropsWithoutRef,\n Ref,\n MouseEvent\n} from 'react';\n\nimport {\n AvatarProps,\n Avatar,\n Flex,\n Icon,\n LinkProps,\n SummaryItem,\n Image,\n FlexContainerProps,\n EmojiDisplay,\n useI18n,\n ForwardProps\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nimport { AttachmentItemProps } from './Chat.types';\nimport {\n StyledMessageContainer,\n StyledMessageMain,\n StyledMessageBubble,\n StyledMessageBubbleContent,\n StyledMediaList,\n StyledMediaListItem,\n StyledMediaThumbNail,\n StyledSummaryItem,\n StyledMediaLink,\n StyledMediaDownloadButton,\n StyledMetaInfoContainer,\n StyledMetaInfo,\n StyledBlinkingDot,\n StyledMediaButton,\n StyledMessageHeader,\n StyledMessageHeaderContent,\n StyledMessageHeaderMeta\n} from './Message.styles';\n\nexport interface MediaPageLinks extends Pick<LinkProps, 'href'> {\n /** Unique id for this push link */\n id: string;\n /** A string to be used as an image src for a thumbnail. */\n thumbnail?: AttachmentItemProps['thumbnail'];\n /** Additional information about the linked resource. */\n title?: string;\n}\n\nexport type MessageHeaderProps = {\n /** message header content */\n content?: ReactNode;\n /** meta data */\n meta?: ReactNode;\n};\n\nexport interface MessageProps {\n /** ref to the message wrapper */\n ref?: Ref<HTMLDivElement>;\n /** Message to be displayed */\n message?: ReactNode;\n /** Attachment list */\n attachments?: AttachmentItemProps[];\n /** Message page push links list */\n pagePushLinks?: MediaPageLinks[];\n /** 3 themes supported by default to differentiate between sender, receiver and other */\n variant: 'sender' | 'receiver' | 'other';\n /** timestamp of the message(Formatted) */\n timeStamp?: string;\n /** Incoming message/ outgoing message */\n direction: 'in' | 'out';\n /** Avatar information, can be image and name */\n avatarInfo?: Pick<AvatarProps, 'name' | 'imageSrc'>;\n /** Content type */\n contentType?: 'rich-text' | 'plain-text';\n /** Message status */\n status?: string;\n /** Indicates if this message is being currently typed */\n typing?: boolean;\n /** Message header */\n messageHeader?: MessageHeaderProps;\n}\n\nconst Message: FunctionComponent<MessageProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MessageProps>, ref: MessageProps['ref']) => {\n const {\n message,\n direction,\n variant,\n avatarInfo,\n timeStamp,\n attachments = [],\n pagePushLinks = [],\n status,\n typing,\n messageHeader,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n let messageMetaJustify: FlexContainerProps['justify'] = 'between';\n if (timeStamp && !status) {\n messageMetaJustify = 'start';\n } else if (!timeStamp && status) {\n messageMetaJustify = 'end';\n }\n\n return (\n <Flex\n as={StyledMessageContainer}\n ref={ref}\n container={{\n itemGap: 0.5,\n direction: direction === 'in' ? 'row' : 'row-reverse'\n }}\n item={{\n shrink: 0\n }}\n messageDirection={direction}\n variant={variant}\n typing={typing}\n messageHeader={messageHeader}\n {...restProps}\n >\n {avatarInfo && (\n <Avatar name={avatarInfo.name} size='m' shape='circle' imageSrc={avatarInfo.imageSrc} />\n )}\n <Flex\n container={{\n direction: 'column',\n alignItems: direction === 'in' ? 'start' : 'end',\n justify: 'center'\n }}\n as={StyledMessageMain}\n >\n <StyledMessageBubble>\n {messageHeader && (\n <Flex container={{ itemGap: 0.5, justify: 'between' }} as={StyledMessageHeader}>\n <StyledMessageHeaderContent>{messageHeader.content}</StyledMessageHeaderContent>\n <StyledMessageHeaderMeta>{messageHeader.meta}</StyledMessageHeaderMeta>\n </Flex>\n )}\n {message && (\n <StyledMessageBubbleContent>\n <EmojiDisplay content={message} size={20} />\n </StyledMessageBubbleContent>\n )}\n {(attachments.length > 0 || pagePushLinks.length > 0) && (\n <StyledMediaList>\n {attachments.map(attachment => {\n const { id, icon, name, meta, onDownload, onPreview, thumbnail } = attachment;\n return (\n <Flex\n key={id}\n as={StyledMediaListItem}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image\n as={StyledMediaThumbNail}\n src={thumbnail}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n alt={name}\n />\n )}\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaButton\n title={name}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n >\n {name}\n </StyledMediaButton>\n }\n secondary={meta}\n visual={<Icon name={icon || 'document-doc'} />}\n actions={\n <BareButton\n aria-label={t('download')}\n as={StyledMediaDownloadButton}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onDownload?.(id);\n }}\n >\n <Icon name='download' />\n </BareButton>\n }\n />\n </Flex>\n );\n })}\n {pagePushLinks.map(pagePushLink => {\n const { id, href, title, thumbnail } = pagePushLink;\n return (\n <Flex\n as={StyledMediaListItem}\n key={id}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image as={StyledMediaThumbNail} src={thumbnail} alt={title || href} />\n )}\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaLink\n title={title}\n href={href}\n target='_blank'\n rel='noreferrer'\n >\n {href}\n </StyledMediaLink>\n }\n visual={<Icon name='chain-up' />}\n />\n </Flex>\n );\n })}\n </StyledMediaList>\n )}\n </StyledMessageBubble>\n {!typing && (\n <Flex\n as={StyledMetaInfoContainer}\n container={{\n justify: messageMetaJustify,\n itemGap: 1.5\n }}\n >\n {timeStamp && <StyledMetaInfo>{timeStamp}</StyledMetaInfo>}\n {status && <StyledMetaInfo>{status}</StyledMetaInfo>}\n </Flex>\n )}\n {typing && (\n <Flex\n container={{\n itemGap: 0.25\n }}\n >\n <StyledBlinkingDot delay={0} />\n <StyledBlinkingDot delay={0.25} />\n <StyledBlinkingDot delay={0.5} />\n </Flex>\n )}\n </Flex>\n </Flex>\n );\n }\n);\n\nexport default Message;\n"]}
1
+ {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAA+C,MAAM,OAAO,CAAC;AAEnG,OAAO,EAEL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EAEZ,WAAW,EACX,KAAK,EAEL,YAAY,EACZ,OAAO,EAER,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAClF,OAAO,KAAK,YAAY,MAAM,iEAAiE,CAAC;AAChG,OAAO,KAAK,eAAe,MAAM,qEAAqE,CAAC;AACvG,OAAO,KAAK,WAAW,MAAM,iEAAiE,CAAC;AAG/F,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,CAAC,YAAY,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;AA6CzD,MAAM,OAAO,GAAmD,UAAU,CACxE,CAAC,KAAoC,EAAE,GAAwB,EAAE,EAAE;IACjE,MAAM,EACJ,OAAO,EACP,SAAS,EACT,OAAO,EACP,UAAU,EACV,SAAS,EACT,WAAW,GAAG,EAAE,EAChB,aAAa,GAAG,EAAE,EAClB,MAAM,EACN,MAAM,EACN,aAAa,EACb,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,IAAI,kBAAkB,GAAkC,SAAS,CAAC;IAClE,IAAI,SAAS,IAAI,CAAC,MAAM,EAAE;QACxB,kBAAkB,GAAG,OAAO,CAAC;KAC9B;SAAM,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IAAC,KAAK,EAAE,IAAI,WAAI,EAClC,KAAC,iBAAiB,IAAC,KAAK,EAAE,GAAG,WAAI,YAC5B,CACR,YACI,YACF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, ReactNode, PropsWithoutRef, Ref, MouseEvent } from 'react';\n\nimport {\n AvatarProps,\n Avatar,\n Flex,\n Icon,\n registerIcon,\n LinkProps,\n SummaryItem,\n Image,\n FlexContainerProps,\n EmojiDisplay,\n useI18n,\n ForwardProps\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as downloadIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/download.icon';\nimport * as documentDocIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/document-doc.icon';\nimport * as chainUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chain-up.icon';\n\nimport { AttachmentItemProps } from './Chat.types';\nimport {\n StyledMessageContainer,\n StyledMessageMain,\n StyledMessageBubble,\n StyledMessageBubbleContent,\n StyledMediaList,\n StyledMediaListItem,\n StyledMediaThumbNail,\n StyledSummaryItem,\n StyledMediaLink,\n StyledMediaDownloadButton,\n StyledMetaInfoContainer,\n StyledMetaInfo,\n StyledBlinkingDot,\n StyledMediaButton,\n StyledMessageHeader,\n StyledMessageHeaderContent,\n StyledMessageHeaderMeta\n} from './Message.styles';\n\nregisterIcon(downloadIcon, documentDocIcon, chainUpIcon);\n\nexport interface MediaPageLinks extends Pick<LinkProps, 'href'> {\n /** Unique id for this push link */\n id: string;\n /** A string to be used as an image src for a thumbnail. */\n thumbnail?: AttachmentItemProps['thumbnail'];\n /** Additional information about the linked resource. */\n title?: string;\n}\n\nexport type MessageHeaderProps = {\n /** message header content */\n content?: ReactNode;\n /** meta data */\n meta?: ReactNode;\n};\n\nexport interface MessageProps {\n /** ref to the message wrapper */\n ref?: Ref<HTMLDivElement>;\n /** Message to be displayed */\n message?: ReactNode;\n /** Attachment list */\n attachments?: AttachmentItemProps[];\n /** Message page push links list */\n pagePushLinks?: MediaPageLinks[];\n /** 3 themes supported by default to differentiate between sender, receiver and other */\n variant: 'sender' | 'receiver' | 'other';\n /** timestamp of the message(Formatted) */\n timeStamp?: string;\n /** Incoming message/ outgoing message */\n direction: 'in' | 'out';\n /** Avatar information, can be image and name */\n avatarInfo?: Pick<AvatarProps, 'name' | 'imageSrc'>;\n /** Content type */\n contentType?: 'rich-text' | 'plain-text';\n /** Message status */\n status?: string;\n /** Indicates if this message is being currently typed */\n typing?: boolean;\n /** Message header */\n messageHeader?: MessageHeaderProps;\n}\n\nconst Message: FunctionComponent<MessageProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MessageProps>, ref: MessageProps['ref']) => {\n const {\n message,\n direction,\n variant,\n avatarInfo,\n timeStamp,\n attachments = [],\n pagePushLinks = [],\n status,\n typing,\n messageHeader,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n let messageMetaJustify: FlexContainerProps['justify'] = 'between';\n if (timeStamp && !status) {\n messageMetaJustify = 'start';\n } else if (!timeStamp && status) {\n messageMetaJustify = 'end';\n }\n\n return (\n <Flex\n as={StyledMessageContainer}\n ref={ref}\n container={{\n gap: 0.5,\n direction: direction === 'in' ? 'row' : 'row-reverse'\n }}\n item={{\n shrink: 0\n }}\n messageDirection={direction}\n variant={variant}\n typing={typing}\n messageHeader={messageHeader}\n {...restProps}\n >\n {avatarInfo && (\n <Avatar name={avatarInfo.name} size='m' shape='circle' imageSrc={avatarInfo.imageSrc} />\n )}\n <Flex\n container={{\n direction: 'column',\n alignItems: direction === 'in' ? 'start' : 'end',\n justify: 'center'\n }}\n as={StyledMessageMain}\n >\n <StyledMessageBubble>\n {messageHeader && (\n <Flex container={{ gap: 0.5, justify: 'between' }} as={StyledMessageHeader}>\n <StyledMessageHeaderContent>{messageHeader.content}</StyledMessageHeaderContent>\n <StyledMessageHeaderMeta>{messageHeader.meta}</StyledMessageHeaderMeta>\n </Flex>\n )}\n {message && (\n <StyledMessageBubbleContent>\n <EmojiDisplay content={message} size={20} />\n </StyledMessageBubbleContent>\n )}\n {(attachments.length > 0 || pagePushLinks.length > 0) && (\n <StyledMediaList>\n {attachments.map(attachment => {\n const { id, icon, name, meta, onDownload, onPreview, thumbnail } = attachment;\n return (\n <Flex\n key={id}\n as={StyledMediaListItem}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image\n as={StyledMediaThumbNail}\n src={thumbnail}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n alt={name}\n />\n )}\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaButton\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n >\n {name}\n </StyledMediaButton>\n }\n secondary={meta}\n visual={<Icon name={icon || 'document-doc'} />}\n actions={\n <BareButton\n aria-label={t('download')}\n as={StyledMediaDownloadButton}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onDownload?.(id);\n }}\n >\n <Icon name='download' />\n </BareButton>\n }\n />\n </Flex>\n );\n })}\n {pagePushLinks.map(pagePushLink => {\n const { id, href, title, thumbnail } = pagePushLink;\n return (\n <Flex\n as={StyledMediaListItem}\n key={id}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image as={StyledMediaThumbNail} src={thumbnail} alt={title || href} />\n )}\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaLink\n aria-label={title}\n href={href}\n target='_blank'\n rel='noreferrer'\n >\n {href}\n </StyledMediaLink>\n }\n visual={<Icon name='chain-up' />}\n />\n </Flex>\n );\n })}\n </StyledMediaList>\n )}\n </StyledMessageBubble>\n {!typing && (\n <Flex\n as={StyledMetaInfoContainer}\n container={{\n justify: messageMetaJustify,\n gap: 1.5\n }}\n >\n {timeStamp && <StyledMetaInfo>{timeStamp}</StyledMetaInfo>}\n {status && <StyledMetaInfo>{status}</StyledMetaInfo>}\n </Flex>\n )}\n {typing && (\n <Flex\n container={{\n gap: 0.25\n }}\n >\n <StyledBlinkingDot delay={0} />\n <StyledBlinkingDot delay={0.25} />\n <StyledBlinkingDot delay={0.5} />\n </Flex>\n )}\n </Flex>\n </Flex>\n );\n }\n);\n\nexport default Message;\n"]}
@@ -175,14 +175,14 @@ export const StyledBlinkingDot = styled.div(({ delay = 0, theme }) => {
175
175
  return css `
176
176
  @keyframes Blinking {
177
177
  0% {
178
- background: ${theme.base.colors.gray.dark};
178
+ background: ${theme.base.colors.gray.medium};
179
179
  }
180
180
  100% {
181
181
  background: ${theme.base.colors.gray['extra-light']};
182
182
  }
183
183
  }
184
184
  animation: Blinking calc(4 * ${theme.base.animation.speed}) infinite;
185
- background: ${theme.base.colors.gray.light};
185
+ background: ${theme.base.colors.gray['extra-light']};
186
186
  border-radius: 50%;
187
187
  animation-delay: ${delay}s;
188
188
  height: 0.4rem;
@@ -1 +1 @@
1
- {"version":3,"file":"Message.styles.js","sourceRoot":"","sources":["../../../src/components/Chat/Message.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAElF,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEvD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAAA,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAA,EAAE,CAAC;AAE/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;A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kBAC3C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK;;uBAEvB,KAAK;;;GAGzB,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { rgba as polishedRgba } from 'polished';\n\nimport { defaultThemeProp, tryCatch } from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nexport const StyledMessageBubbleContent = styled.div``;\n\nexport const StyledMediaList = styled.ul``;\n\nexport const StyledMediaListItem = styled.li``;\n\nexport const StyledSummaryItem = styled.div``;\n\nexport const StyledMediaThumbNail = styled.img``;\n\nexport const StyledMediaDownloadButton = styled.button``;\n\nexport const StyledMediaLink = styled.a``;\n\nexport const StyledMediaButton = styled(BareButton)``;\n\nexport const StyledMessageMain = styled.div``;\n\nexport const StyledMessageBubble = styled.div``;\n\nexport const StyledMetaInfoContainer = styled.div``;\n\nexport const StyledMetaInfo = styled.span``;\n\nexport const StyledTypingIndicator = styled.div``;\n\nexport const StyledMessageHeader = styled.header``;\nexport const StyledMessageHeaderContent = styled.div``;\nexport const StyledMessageHeaderMeta = styled.div``;\n\ninterface StyledMessageContainerProps {\n variant: 'sender' | 'receiver' | 'other';\n messageDirection: 'in' | 'out' | string;\n typing: boolean;\n}\n\nexport const StyledMessageContainer = styled.div<StyledMessageContainerProps>(\n ({\n messageDirection,\n variant,\n typing,\n theme,\n theme: {\n base: {\n palette: {\n 'foreground-color': foregroundColor,\n 'secondary-background': secondaryBackground\n },\n transparency: { 'transparent-2': foregroundAlpha }\n },\n components: { button }\n }\n }) => {\n const messageHeaderTheme = theme.components.chat.messageBubble[variant].header;\n const messageContentTheme = theme.components.chat.messageBubble[variant].content;\n const padding = messageDirection === 'in' ? '0 2rem 0 0' : '0 0 0 2rem';\n const metaForegroundColor = tryCatch(() => polishedRgba(foregroundColor, foregroundAlpha));\n\n return css`\n padding: ${padding};\n margin-bottom: ${typing ? '0.5rem' : '0'};\n ${StyledMessageMain} {\n max-width: 90%;\n }\n ${StyledMessageBubble} {\n max-width: 100%;\n min-width: 100%;\n background: ${messageContentTheme['background-color']};\n border-radius: calc(3 * ${theme.base['border-radius']}) ${theme.base['border-radius']}\n calc(3 * ${theme.base['border-radius']}) calc(3 * ${theme.base['border-radius']});\n overflow: hidden;\n color: ${messageContentTheme['foreground-color']};\n display: inline-block;\n width: auto;\n margin-bottom: 0.25rem;\n\n label {\n color: inherit;\n }\n\n ${messageDirection === 'in' &&\n css`\n border-radius: ${theme.base['border-radius']} calc(3 * ${theme.base['border-radius']})\n calc(3 * ${theme.base['border-radius']}) calc(3 * ${theme.base['border-radius']});\n `}\n\n > ${StyledMessageBubbleContent} {\n padding: 0.5rem 1rem;\n word-break: break-word;\n white-space: pre-wrap;\n position: relative;\n }\n\n > ${StyledMediaList} {\n color: ${messageContentTheme['foreground-color']};\n max-width: 100%;\n\n ${StyledMediaDownloadButton} {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n color: ${messageContentTheme['foreground-color']};\n width: ${button.height};\n height: ${button.height};\n border: 0.0625rem solid transparent;\n &:enabled:hover,\n &:enabled:focus {\n background: ${messageContentTheme['background-color']};\n color: ${messageContentTheme['foreground-color']};\n border: 0.0625rem solid ${messageContentTheme['foreground-color']};\n border-radius: 50%;\n }\n svg {\n width: 50%;\n height: 50%;\n }\n }\n\n > ${StyledMediaListItem} {\n position: relative;\n ${StyledMediaThumbNail} {\n max-height: 12rem;\n width: 100%;\n object-fit: contain;\n background-color: ${secondaryBackground};\n }\n ${StyledSummaryItem} {\n padding: 0.5rem 1.5rem;\n font-size: 0.75rem;\n margin-top: 0.25rem;\n }\n ${StyledSummaryItem}::before {\n content: '';\n padding: 0.5rem 0;\n border-top: 0.0625rem solid ${messageContentTheme['foreground-color']};\n position: absolute;\n width: calc(100% - 2rem);\n left: 1rem;\n top: 0;\n }\n ${StyledMediaThumbNail} + ${StyledSummaryItem}::before {\n content: none;\n }\n svg {\n font-size: 1.6rem;\n }\n }\n }\n\n ${StyledMessageHeader} {\n padding: 0.5rem 1rem;\n color: ${messageHeaderTheme['foreground-color']};\n background-color: ${messageHeaderTheme['background-color']};\n }\n\n ${StyledMessageHeaderContent} {\n color: ${messageHeaderTheme['foreground-color']};\n margin-inline-end: ${theme.base.spacing};\n }\n ${StyledMessageHeaderMeta} {\n > a {\n color: ${messageHeaderTheme['foreground-color']};\n }\n }\n\n ${StyledMediaLink}, ${StyledMediaButton} {\n color: ${messageContentTheme['foreground-color']};\n font-size: inherit;\n text-decoration: none;\n font-weight: 700;\n overflow-x: hidden;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n max-width: 100%;\n &:hover {\n color: ${messageContentTheme['foreground-color']};\n text-decoration: underline;\n }\n &:visited {\n color: ${messageContentTheme['foreground-color']};\n }\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n }\n }\n\n ${StyledMetaInfoContainer} {\n width: 100%;\n padding: 0 0.5rem;\n ${StyledMetaInfo} {\n margin-bottom: 0.5rem;\n font-size: 0.7rem;\n color: ${metaForegroundColor};\n }\n }\n ${StyledTypingIndicator} {\n width: 4.5rem;\n position: relative;\n height: 2rem;\n }\n `;\n }\n);\nStyledMessageContainer.defaultProps = defaultThemeProp;\ninterface StyledBlinkingDotProps {\n delay?: number;\n}\n\nexport const StyledBlinkingDot = styled.div<StyledBlinkingDotProps>(({ delay = 0, theme }) => {\n return css`\n @keyframes Blinking {\n 0% {\n background: ${theme.base.colors.gray.dark};\n }\n 100% {\n background: ${theme.base.colors.gray['extra-light']};\n }\n }\n animation: Blinking calc(4 * ${theme.base.animation.speed}) infinite;\n background: ${theme.base.colors.gray.light};\n border-radius: 50%;\n animation-delay: ${delay}s;\n height: 0.4rem;\n width: 0.4rem;\n `;\n});\nStyledBlinkingDot.defaultProps = defaultThemeProp;\n"]}
1
+ {"version":3,"file":"Message.styles.js","sourceRoot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AAmB,CAAC,kBAAkB,CAAC;;;0BAGlC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;;;;;QAKzC,uBAAuB;;;UAGrB,cAAc;;;mBAGL,mBAAmB;;;QAG9B,qBAAqB;;;;;KAKxB,CAAC;AACJ,CAAC,CACF,CAAC;AACF,sBAAsB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAKvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAyB,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC3F,OAAO,GAAG,CAAA;;;sBAGU,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM;;;sBAG7B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;;;mCAGxB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;kBAC3C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;;uBAEhC,KAAK;;;GAGzB,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { rgba as polishedRgba } from 'polished';\n\nimport { defaultThemeProp, tryCatch } from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nexport const StyledMessageBubbleContent = styled.div``;\n\nexport const StyledMediaList = styled.ul``;\n\nexport const StyledMediaListItem = styled.li``;\n\nexport const StyledSummaryItem = styled.div``;\n\nexport const StyledMediaThumbNail = styled.img``;\n\nexport const StyledMediaDownloadButton = styled.button``;\n\nexport const StyledMediaLink = styled.a``;\n\nexport const StyledMediaButton = styled(BareButton)``;\n\nexport const StyledMessageMain = styled.div``;\n\nexport const StyledMessageBubble = styled.div``;\n\nexport const StyledMetaInfoContainer = styled.div``;\n\nexport const StyledMetaInfo = styled.span``;\n\nexport const StyledTypingIndicator = styled.div``;\n\nexport const StyledMessageHeader = styled.header``;\nexport const StyledMessageHeaderContent = styled.div``;\nexport const StyledMessageHeaderMeta = styled.div``;\n\ninterface StyledMessageContainerProps {\n variant: 'sender' | 'receiver' | 'other';\n messageDirection: 'in' | 'out' | string;\n typing: boolean;\n}\n\nexport const StyledMessageContainer = styled.div<StyledMessageContainerProps>(\n ({\n messageDirection,\n variant,\n typing,\n theme,\n theme: {\n base: {\n palette: {\n 'foreground-color': foregroundColor,\n 'secondary-background': secondaryBackground\n },\n transparency: { 'transparent-2': foregroundAlpha }\n },\n components: { button }\n }\n }) => {\n const messageHeaderTheme = theme.components.chat.messageBubble[variant].header;\n const messageContentTheme = theme.components.chat.messageBubble[variant].content;\n const padding = messageDirection === 'in' ? '0 2rem 0 0' : '0 0 0 2rem';\n const metaForegroundColor = tryCatch(() => polishedRgba(foregroundColor, foregroundAlpha));\n\n return css`\n padding: ${padding};\n margin-bottom: ${typing ? '0.5rem' : '0'};\n ${StyledMessageMain} {\n max-width: 90%;\n }\n ${StyledMessageBubble} {\n max-width: 100%;\n min-width: 100%;\n background: ${messageContentTheme['background-color']};\n border-radius: calc(3 * ${theme.base['border-radius']}) ${theme.base['border-radius']}\n calc(3 * ${theme.base['border-radius']}) calc(3 * ${theme.base['border-radius']});\n overflow: hidden;\n color: ${messageContentTheme['foreground-color']};\n display: inline-block;\n width: auto;\n margin-bottom: 0.25rem;\n\n label {\n color: inherit;\n }\n\n ${messageDirection === 'in' &&\n css`\n border-radius: ${theme.base['border-radius']} calc(3 * ${theme.base['border-radius']})\n calc(3 * ${theme.base['border-radius']}) calc(3 * ${theme.base['border-radius']});\n `}\n\n > ${StyledMessageBubbleContent} {\n padding: 0.5rem 1rem;\n word-break: break-word;\n white-space: pre-wrap;\n position: relative;\n }\n\n > ${StyledMediaList} {\n color: ${messageContentTheme['foreground-color']};\n max-width: 100%;\n\n ${StyledMediaDownloadButton} {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n color: ${messageContentTheme['foreground-color']};\n width: ${button.height};\n height: ${button.height};\n border: 0.0625rem solid transparent;\n &:enabled:hover,\n &:enabled:focus {\n background: ${messageContentTheme['background-color']};\n color: ${messageContentTheme['foreground-color']};\n border: 0.0625rem solid ${messageContentTheme['foreground-color']};\n border-radius: 50%;\n }\n svg {\n width: 50%;\n height: 50%;\n }\n }\n\n > ${StyledMediaListItem} {\n position: relative;\n ${StyledMediaThumbNail} {\n max-height: 12rem;\n width: 100%;\n object-fit: contain;\n background-color: ${secondaryBackground};\n }\n ${StyledSummaryItem} {\n padding: 0.5rem 1.5rem;\n font-size: 0.75rem;\n margin-top: 0.25rem;\n }\n ${StyledSummaryItem}::before {\n content: '';\n padding: 0.5rem 0;\n border-top: 0.0625rem solid ${messageContentTheme['foreground-color']};\n position: absolute;\n width: calc(100% - 2rem);\n left: 1rem;\n top: 0;\n }\n ${StyledMediaThumbNail} + ${StyledSummaryItem}::before {\n content: none;\n }\n svg {\n font-size: 1.6rem;\n }\n }\n }\n\n ${StyledMessageHeader} {\n padding: 0.5rem 1rem;\n color: ${messageHeaderTheme['foreground-color']};\n background-color: ${messageHeaderTheme['background-color']};\n }\n\n ${StyledMessageHeaderContent} {\n color: ${messageHeaderTheme['foreground-color']};\n margin-inline-end: ${theme.base.spacing};\n }\n ${StyledMessageHeaderMeta} {\n > a {\n color: ${messageHeaderTheme['foreground-color']};\n }\n }\n\n ${StyledMediaLink}, ${StyledMediaButton} {\n color: ${messageContentTheme['foreground-color']};\n font-size: inherit;\n text-decoration: none;\n font-weight: 700;\n overflow-x: hidden;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n max-width: 100%;\n &:hover {\n color: ${messageContentTheme['foreground-color']};\n text-decoration: underline;\n }\n &:visited {\n color: ${messageContentTheme['foreground-color']};\n }\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n }\n }\n\n ${StyledMetaInfoContainer} {\n width: 100%;\n padding: 0 0.5rem;\n ${StyledMetaInfo} {\n margin-bottom: 0.5rem;\n font-size: 0.7rem;\n color: ${metaForegroundColor};\n }\n }\n ${StyledTypingIndicator} {\n width: 4.5rem;\n position: relative;\n height: 2rem;\n }\n `;\n }\n);\nStyledMessageContainer.defaultProps = defaultThemeProp;\ninterface StyledBlinkingDotProps {\n delay?: number;\n}\n\nexport const StyledBlinkingDot = styled.div<StyledBlinkingDotProps>(({ delay = 0, theme }) => {\n return css`\n @keyframes Blinking {\n 0% {\n background: ${theme.base.colors.gray.medium};\n }\n 100% {\n background: ${theme.base.colors.gray['extra-light']};\n }\n }\n animation: Blinking calc(4 * ${theme.base.animation.speed}) infinite;\n background: ${theme.base.colors.gray['extra-light']};\n border-radius: 50%;\n animation-delay: ${delay}s;\n height: 0.4rem;\n width: 0.4rem;\n `;\n});\nStyledBlinkingDot.defaultProps = defaultThemeProp;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAc,EACZ,iBAAiB,EAGjB,GAAG,EAOJ,MAAM,OAAO,CAAC;AAGf,OAAO,EAQL,YAAY,EACZ,UAAU,EACX,MAAM,yBAAyB,CAAC;AAEjC,OAAsB,EACpB,kBAAkB,EAClB,gBAAgB,EAIjB,MAAM,iBAAiB,CAAC;AACzB,OAAgB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClD,OAAsB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAsB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,WAAW,gCAAgC;IAC/C,kBAAkB,EAAE,MAAM,OAAO,CAAC;IAClC,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,IAAI,CAAC;CAChC;AAED,oBAAY,oBAAoB,GAC5B,CAAC,YAAY,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;I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AC;AAIpE,MAAM,WAAW,gCAAgC;IAC/C,kBAAkB,EAAE,MAAM,OAAO,CAAC;IAClC,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,IAAI,CAAC;CAChC;AAED,oBAAY,oBAAoB,GAC5B,CAAC,YAAY,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,GAChE,CAAC,kBAAkB,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,GACrE,CAAC,kBAAkB,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAAC;AAE1E,MAAM,WAAW,gBACf,SAAQ,UAAU,CAAC,kBAAkB,EAAE,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC;IACnE,0BAA0B;IAC1B,QAAQ,EAAE,oBAAoB,EAAE,CAAC;IACjC,8BAA8B;IAC9B,GAAG,CAAC,EAAE,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC5C,4BAA4B;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,0BAA0B;IAC1B,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAID,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAsD7D,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,GAAG,YAAY,CAgInE,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,10 +1,13 @@
1
- import React, { forwardRef, useImperativeHandle, useRef, useCallback, useState, useLayoutEffect } from 'react';
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useImperativeHandle, useRef, useCallback, useState, useLayoutEffect } from 'react';
2
3
  import styled, { css } from 'styled-components';
3
- import { Button, Flex, Icon, StyledButton, useI18n, debounce, defaultThemeProp } from '@pega/cosmos-react-core';
4
+ import { Button, Flex, Icon, registerIcon, StyledButton, useI18n, debounce, defaultThemeProp } from '@pega/cosmos-react-core';
5
+ import * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';
4
6
  import RepeatingView, { StyledRepeatingView, StyledRepeatingViewItem, StyledRepeatingViewUL } from './RepeatingView';
5
7
  import Message from './Message';
6
8
  import SystemMessage from './SystemMessage';
7
9
  import TypeIndicator from './TypeIndicator';
10
+ registerIcon(caretDownIcon);
8
11
  const StyledMessageList = styled.div ``;
9
12
  export const NewMessageSeparatorId = 'new-message-separator';
10
13
  const StyledMessageListContainer = styled.div(props => {
@@ -45,7 +48,7 @@ const ScrollToLatest = props => {
45
48
  scrollContainerRef.current.scrollHeight - scrollContainerRef.current.offsetHeight;
46
49
  }
47
50
  });
48
- return React.createElement(React.Fragment, null);
51
+ return _jsx(_Fragment, {}, void 0);
49
52
  };
50
53
  const MessageList = forwardRef((props, ref) => {
51
54
  const { messages, unReadMessageCount = 0, onScrollToButtonClick, ...restProps } = props;
@@ -85,44 +88,36 @@ const MessageList = forwardRef((props, ref) => {
85
88
  scrollToLatestMessage,
86
89
  scrollToNewMessage
87
90
  }), [isScrolledToLatest, scrollToLatestMessage, scrollToNewMessage]);
88
- return (React.createElement(React.Fragment, null,
89
- React.createElement(Flex, { as: StyledMessageListContainer, item: {
90
- grow: 1
91
- }, container: {
92
- direction: 'column'
93
- }, ...restProps },
94
- (unReadMessageCount > 0 || displayScrollLatest) && (React.createElement(Button, { "aria-label": unReadMessageCount > 0
95
- ? t('scroll_to_unread_messages')
96
- : t('scroll_to_latest_message'), onClick: () => {
97
- if (unReadMessageCount > 0) {
98
- scrollToNewMessage();
99
- }
100
- else {
101
- scrollToLatestMessage();
102
- }
103
- onScrollToButtonClick === null || onScrollToButtonClick === void 0 ? void 0 : onScrollToButtonClick();
104
- }, icon: unReadMessageCount === 0 },
105
- React.createElement(Icon, { name: 'caret-down' }),
106
- unReadMessageCount > 0 && React.createElement(React.Fragment, null,
107
- "\u00A0 ",
108
- t('new_messages')))),
109
- React.createElement(RepeatingView, { as: StyledMessageList, container: { direction: 'column' }, ref: conversationRef, rows: messages, onScroll: debounce(onMessageListScroll, 100), ...restProps }, (item) => {
110
- const { id, type, ...messageListItemRestProps } = item;
111
- if (type === 'message') {
112
- return React.createElement(Message, { key: id, ...messageListItemRestProps });
113
- }
114
- if (type === 'system') {
115
- const extraProps = {};
116
- if (id === NewMessageSeparatorId) {
117
- extraProps['data-new-message-separator'] = NewMessageSeparatorId;
118
- }
119
- return (React.createElement(SystemMessage, { key: id, ...messageListItemRestProps, ...extraProps }));
120
- }
121
- if (type === 'typing') {
122
- return (React.createElement(TypeIndicator, { key: id, ...messageListItemRestProps }));
123
- }
124
- })),
125
- isScrolledToLatest() && React.createElement(ScrollToLatest, { scrollContainerRef: conversationRef })));
91
+ return (_jsxs(_Fragment, { children: [_jsxs(Flex, { as: StyledMessageListContainer, item: {
92
+ grow: 1
93
+ }, container: {
94
+ direction: 'column'
95
+ }, ...restProps, children: [(unReadMessageCount > 0 || displayScrollLatest) && (_jsxs(Button, { "aria-label": unReadMessageCount > 0
96
+ ? t('scroll_to_unread_messages')
97
+ : t('scroll_to_latest_message'), onClick: () => {
98
+ if (unReadMessageCount > 0) {
99
+ scrollToNewMessage();
100
+ }
101
+ else {
102
+ scrollToLatestMessage();
103
+ }
104
+ onScrollToButtonClick?.();
105
+ }, icon: unReadMessageCount === 0, children: [_jsx(Icon, { name: 'caret-down' }, void 0), unReadMessageCount > 0 && _jsxs(_Fragment, { children: ["\u00A0 ", t('new_messages')] }, void 0)] }, void 0)), _jsx(RepeatingView, { as: StyledMessageList, container: { direction: 'column' }, ref: conversationRef, rows: messages, onScroll: debounce(onMessageListScroll, 100), ...restProps, children: (item) => {
106
+ const { id, type, ...messageListItemRestProps } = item;
107
+ if (type === 'message') {
108
+ return _jsx(Message, { ...messageListItemRestProps }, id);
109
+ }
110
+ if (type === 'system') {
111
+ const extraProps = {};
112
+ if (id === NewMessageSeparatorId) {
113
+ extraProps['data-new-message-separator'] = NewMessageSeparatorId;
114
+ }
115
+ return (_jsx(SystemMessage, { ...messageListItemRestProps, ...extraProps }, id));
116
+ }
117
+ if (type === 'typing') {
118
+ return (_jsx(TypeIndicator, { ...messageListItemRestProps }, id));
119
+ }
120
+ } }, void 0)] }, void 0), isScrolledToLatest() && _jsx(ScrollToLatest, { scrollContainerRef: conversationRef }, void 0)] }, void 0));
126
121
  });
127
122
  export default MessageList;
128
123
  //# sourceMappingURL=MessageList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MessageList.js","sourceRoot":"","sources":["../../../src/components/Chat/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGZ,UAAU,EAEV,mBAAmB,EACnB,MAAM,EACN,WAAW,EACX,QAAQ,EACR,eAAe,EAEhB,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,aAAa,EAAE,EAGpB,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,OAAyB,MAAM,WAAW,CAAC;AAClD,OAAO,aAAqC,MAAM,iBAAiB,CAAC;AACpE,OAAO,aAAqC,MAAM,iBAAiB,CAAC;AAyBpE,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAE7D,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;IACpD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QAAQ,EAAE;oBACrB,MAAM,UAAU,GAA2B,EAAE,CAAC;oBAC9C,IAAI,EAAE,KAAK,qBAAqB,EAAE;wBAChC,UAAU,CAAC,4BAA4B,CAAC,GAAG,qBAAqB,CAAC;qBAClE;oBACD,OAAO,CACL,oBAAC,aAAa,IACZ,GAAG,EAAE,EAAE,KACF,wBAA+C,KAChD,UAAU,GACd,CACH,CAAC;iBACH;gBACD,IAAI,IAAI,KAAK,QAAQ,EAAE;oBACrB,OAAO,CACL,oBAAC,aAAa,IAAC,GAAG,EAAE,EAAE,KAAO,wBAA+C,GAAI,CACjF,CAAC;iBACH;YACH,CAAC,CACa,CACX;QACN,kBAAkB,EAAE,IAAI,oBAAC,cAAc,IAAC,kBAAkB,EAAE,eAAe,GAAI,CAC/E,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import React, {\n FunctionComponent,\n PropsWithoutRef,\n forwardRef,\n Ref,\n useImperativeHandle,\n useRef,\n useCallback,\n useState,\n useLayoutEffect,\n RefObject\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n Flex,\n Icon,\n StyledButton,\n useI18n,\n debounce,\n defaultThemeProp,\n ForwardProps,\n OmitStrict\n} from '@pega/cosmos-react-core';\n\nimport RepeatingView, {\n RepeatingViewProps,\n RepeatingViewRow,\n StyledRepeatingView,\n StyledRepeatingViewItem,\n StyledRepeatingViewUL\n} from './RepeatingView';\nimport Message, { MessageProps } from './Message';\nimport SystemMessage, { SystemMessageProps } from './SystemMessage';\nimport TypeIndicator, { TypeIndicatorProps } from './TypeIndicator';\n\nexport interface MessageListImperativeHandleProps {\n isScrolledToLatest: () => boolean;\n scrollToLatestMessage: () => void;\n scrollToNewMessage: () => void;\n}\n\nexport type MessageListItemProps =\n | (MessageProps & { type: 'message'; id: RepeatingViewRow['id'] })\n | (SystemMessageProps & { type: 'system'; id: RepeatingViewRow['id'] })\n | (TypeIndicatorProps & { type: 'typing'; id: RepeatingViewRow['id'] });\n\nexport interface MessageListProps\n extends OmitStrict<RepeatingViewProps, 'children' | 'rows' | 'ref'> {\n /** Messages Data array */\n messages: MessageListItemProps[];\n /** ref to the message list */\n ref?: Ref<MessageListImperativeHandleProps>;\n /** Total unread messages */\n unReadMessageCount?: number;\n /** on scroll to button */\n onScrollToButtonClick?: () => void;\n}\n\nconst StyledMessageList = styled.div``;\n\nexport const NewMessageSeparatorId = 'new-message-separator';\n\nconst StyledMessageListContainer = styled.div(props => {\n const {\n theme: {\n base: {\n shadow: { high: shadowHigh },\n colors: { white }\n }\n }\n } = props;\n return css`\n position: relative;\n overflow-y: hidden;\n > ${StyledMessageList} {\n overflow-y: auto;\n }\n > ${StyledButton} {\n position: absolute;\n bottom: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n box-shadow: ${shadowHigh};\n z-index: 1;\n background-color: ${white};\n }\n ${StyledRepeatingView} {\n overflow-y: hidden;\n }\n ${StyledRepeatingViewUL} {\n padding: 1rem;\n }\n\n ${StyledRepeatingViewItem} {\n padding: 0.125rem 0;\n }\n `;\n});\n\nStyledMessageListContainer.defaultProps = defaultThemeProp;\n\nconst ScrollToLatest: FunctionComponent<{\n scrollContainerRef: RefObject<HTMLUListElement>;\n}> = props => {\n const { scrollContainerRef } = props;\n useLayoutEffect(() => {\n if (scrollContainerRef.current) {\n scrollContainerRef.current.scrollTop =\n scrollContainerRef.current.scrollHeight - scrollContainerRef.current.offsetHeight;\n }\n });\n return <></>;\n};\n\nconst MessageList: FunctionComponent<MessageListProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MessageListProps>, ref: MessageListProps['ref']) => {\n const { messages, unReadMessageCount = 0, onScrollToButtonClick, ...restProps } = props;\n\n const t = useI18n();\n\n const conversationRef = useRef<HTMLUListElement>(null);\n\n const isScrolledToLatest: MessageListImperativeHandleProps['isScrolledToLatest'] =\n useCallback(() => {\n return conversationRef.current\n ? conversationRef.current.scrollHeight -\n conversationRef.current.scrollTop -\n conversationRef.current.offsetHeight <=\n 30\n : true;\n }, [conversationRef.current]);\n\n const scrollToLatestMessage: MessageListImperativeHandleProps['scrollToLatestMessage'] =\n useCallback(() => {\n if (conversationRef.current) {\n conversationRef.current.scrollTop = conversationRef.current.scrollHeight;\n }\n }, [conversationRef.current]);\n\n const [displayScrollLatest, setDisplayScrollToLatest] = useState(false);\n\n const onMessageListScroll = useCallback(() => {\n setDisplayScrollToLatest(!isScrolledToLatest());\n }, [isScrolledToLatest()]);\n\n const scrollToNewMessage: MessageListImperativeHandleProps['scrollToNewMessage'] =\n useCallback(() => {\n if (conversationRef.current) {\n setDisplayScrollToLatest(false);\n const newMessageIndicatorEle = conversationRef.current.querySelector<HTMLElement>(\n '[data-new-message-separator]'\n );\n if (newMessageIndicatorEle) {\n conversationRef.current.scrollTop = newMessageIndicatorEle.offsetTop;\n } else {\n conversationRef.current.scrollTop = conversationRef.current.scrollHeight;\n }\n }\n }, [conversationRef.current]);\n\n useImperativeHandle<MessageListImperativeHandleProps, MessageListImperativeHandleProps>(\n ref,\n () => ({\n isScrolledToLatest,\n scrollToLatestMessage,\n scrollToNewMessage\n }),\n [isScrolledToLatest, scrollToLatestMessage, scrollToNewMessage]\n );\n\n return (\n <>\n <Flex\n as={StyledMessageListContainer}\n item={{\n grow: 1\n }}\n container={{\n direction: 'column'\n }}\n {...restProps}\n >\n {(unReadMessageCount > 0 || displayScrollLatest) && (\n <Button\n aria-label={\n unReadMessageCount > 0\n ? t('scroll_to_unread_messages')\n : t('scroll_to_latest_message')\n }\n onClick={() => {\n if (unReadMessageCount > 0) {\n scrollToNewMessage();\n } else {\n scrollToLatestMessage();\n }\n onScrollToButtonClick?.();\n }}\n icon={unReadMessageCount === 0}\n >\n <Icon name='caret-down' />\n {unReadMessageCount > 0 && <>&nbsp; {t('new_messages')}</>}\n </Button>\n )}\n <RepeatingView\n as={StyledMessageList}\n container={{ direction: 'column' }}\n ref={conversationRef}\n rows={messages}\n onScroll={debounce(onMessageListScroll, 100)}\n {...restProps}\n >\n {(item: RepeatingViewRow) => {\n const { id, type, ...messageListItemRestProps } = item as MessageListItemProps;\n if (type === 'message') {\n return <Message key={id} {...(messageListItemRestProps as MessageProps)} />;\n }\n\n if (type === 'system') {\n const extraProps: Record<string, string> = {};\n if (id === NewMessageSeparatorId) {\n extraProps['data-new-message-separator'] = NewMessageSeparatorId;\n }\n return (\n <SystemMessage\n key={id}\n {...(messageListItemRestProps as SystemMessageProps)}\n {...extraProps}\n />\n );\n }\n if (type === 'typing') {\n return (\n <TypeIndicator key={id} {...(messageListItemRestProps as TypeIndicatorProps)} />\n );\n }\n }}\n </RepeatingView>\n </Flex>\n {isScrolledToLatest() && <ScrollToLatest scrollContainerRef={conversationRef} />}\n </>\n );\n }\n);\n\nexport default MessageList;\n"]}
1
+ {"version":3,"file":"MessageList.js","sourceRoot":"","sources":["../../../src/components/Chat/MessageList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAEV,mBAAmB,EACnB,MAAM,EACN,WAAW,EACX,QAAQ,EACR,eAAe,EAEhB,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AAEnG,OAAO,aAAa,EAAE,EAGpB,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,OAAyB,MAAM,WAAW,CAAC;AAClD,OAAO,aAAqC,MAAM,iBAAiB,CAAC;AACpE,OAAO,aAAqC,MAAM,iBAAiB,CAAC;AAEpE,YAAY,CAAC,aAAa,CAAC,CAAC;AAyB5B,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CA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,OAAO,KAAC,OAAO,OAAe,wBAAyC,IAAlD,EAAE,CAAoD,CAAC;6BAC7E;4BAED,IAAI,IAAI,KAAK,QAAQ,EAAE;gCACrB,MAAM,UAAU,GAA2B,EAAE,CAAC;gCAC9C,IAAI,EAAE,KAAK,qBAAqB,EAAE;oCAChC,UAAU,CAAC,4BAA4B,CAAC,GAAG,qBAAqB,CAAC;iCAClE;gCACD,OAAO,CACL,KAAC,aAAa,OAEP,wBAA+C,KAChD,UAAU,IAFT,EAAE,CAGP,CACH,CAAC;6BACH;4BACD,IAAI,IAAI,KAAK,QAAQ,EAAE;gCACrB,OAAO,CACL,KAAC,aAAa,OAAe,wBAA+C,IAAxD,EAAE,CAA0D,CACjF,CAAC;6BACH;wBACH,CAAC,WACa,YACX,EACN,kBAAkB,EAAE,IAAI,KAAC,cAAc,IAAC,kBAAkB,EAAE,eAAe,WAAI,YAC/E,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n FunctionComponent,\n PropsWithoutRef,\n forwardRef,\n Ref,\n useImperativeHandle,\n useRef,\n useCallback,\n useState,\n useLayoutEffect,\n RefObject\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n Flex,\n Icon,\n registerIcon,\n StyledButton,\n useI18n,\n debounce,\n defaultThemeProp,\n ForwardProps,\n OmitStrict\n} from '@pega/cosmos-react-core';\nimport * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';\n\nimport RepeatingView, {\n RepeatingViewProps,\n RepeatingViewRow,\n StyledRepeatingView,\n StyledRepeatingViewItem,\n StyledRepeatingViewUL\n} from './RepeatingView';\nimport Message, { MessageProps } from './Message';\nimport SystemMessage, { SystemMessageProps } from './SystemMessage';\nimport TypeIndicator, { TypeIndicatorProps } from './TypeIndicator';\n\nregisterIcon(caretDownIcon);\n\nexport interface MessageListImperativeHandleProps {\n isScrolledToLatest: () => boolean;\n scrollToLatestMessage: () => void;\n scrollToNewMessage: () => void;\n}\n\nexport type MessageListItemProps =\n | (MessageProps & { type: 'message'; id: RepeatingViewRow['id'] })\n | (SystemMessageProps & { type: 'system'; id: RepeatingViewRow['id'] })\n | (TypeIndicatorProps & { type: 'typing'; id: RepeatingViewRow['id'] });\n\nexport interface MessageListProps\n extends OmitStrict<RepeatingViewProps, 'children' | 'rows' | 'ref'> {\n /** Messages Data array */\n messages: MessageListItemProps[];\n /** ref to the message list */\n ref?: Ref<MessageListImperativeHandleProps>;\n /** Total unread messages */\n unReadMessageCount?: number;\n /** on scroll to button */\n onScrollToButtonClick?: () => void;\n}\n\nconst StyledMessageList = styled.div``;\n\nexport const NewMessageSeparatorId = 'new-message-separator';\n\nconst StyledMessageListContainer = styled.div(props => {\n const {\n theme: {\n base: {\n shadow: { high: shadowHigh },\n colors: { white }\n }\n }\n } = props;\n return css`\n position: relative;\n overflow-y: hidden;\n > ${StyledMessageList} {\n overflow-y: auto;\n }\n > ${StyledButton} {\n position: absolute;\n bottom: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n box-shadow: ${shadowHigh};\n z-index: 1;\n background-color: ${white};\n }\n ${StyledRepeatingView} {\n overflow-y: hidden;\n }\n ${StyledRepeatingViewUL} {\n padding: 1rem;\n }\n\n ${StyledRepeatingViewItem} {\n padding: 0.125rem 0;\n }\n `;\n});\n\nStyledMessageListContainer.defaultProps = defaultThemeProp;\n\nconst ScrollToLatest: FunctionComponent<{\n scrollContainerRef: RefObject<HTMLUListElement>;\n}> = props => {\n const { scrollContainerRef } = props;\n useLayoutEffect(() => {\n if (scrollContainerRef.current) {\n scrollContainerRef.current.scrollTop =\n scrollContainerRef.current.scrollHeight - scrollContainerRef.current.offsetHeight;\n }\n });\n return <></>;\n};\n\nconst MessageList: FunctionComponent<MessageListProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MessageListProps>, ref: MessageListProps['ref']) => {\n const { messages, unReadMessageCount = 0, onScrollToButtonClick, ...restProps } = props;\n\n const t = useI18n();\n\n const conversationRef = useRef<HTMLUListElement>(null);\n\n const isScrolledToLatest: MessageListImperativeHandleProps['isScrolledToLatest'] =\n useCallback(() => {\n return conversationRef.current\n ? conversationRef.current.scrollHeight -\n conversationRef.current.scrollTop -\n conversationRef.current.offsetHeight <=\n 30\n : true;\n }, [conversationRef.current]);\n\n const scrollToLatestMessage: MessageListImperativeHandleProps['scrollToLatestMessage'] =\n useCallback(() => {\n if (conversationRef.current) {\n conversationRef.current.scrollTop = conversationRef.current.scrollHeight;\n }\n }, [conversationRef.current]);\n\n const [displayScrollLatest, setDisplayScrollToLatest] = useState(false);\n\n const onMessageListScroll = useCallback(() => {\n setDisplayScrollToLatest(!isScrolledToLatest());\n }, [isScrolledToLatest()]);\n\n const scrollToNewMessage: MessageListImperativeHandleProps['scrollToNewMessage'] =\n useCallback(() => {\n if (conversationRef.current) {\n setDisplayScrollToLatest(false);\n const newMessageIndicatorEle = conversationRef.current.querySelector<HTMLElement>(\n '[data-new-message-separator]'\n );\n if (newMessageIndicatorEle) {\n conversationRef.current.scrollTop = newMessageIndicatorEle.offsetTop;\n } else {\n conversationRef.current.scrollTop = conversationRef.current.scrollHeight;\n }\n }\n }, [conversationRef.current]);\n\n useImperativeHandle<MessageListImperativeHandleProps, MessageListImperativeHandleProps>(\n ref,\n () => ({\n isScrolledToLatest,\n scrollToLatestMessage,\n scrollToNewMessage\n }),\n [isScrolledToLatest, scrollToLatestMessage, scrollToNewMessage]\n );\n\n return (\n <>\n <Flex\n as={StyledMessageListContainer}\n item={{\n grow: 1\n }}\n container={{\n direction: 'column'\n }}\n {...restProps}\n >\n {(unReadMessageCount > 0 || displayScrollLatest) && (\n <Button\n aria-label={\n unReadMessageCount > 0\n ? t('scroll_to_unread_messages')\n : t('scroll_to_latest_message')\n }\n onClick={() => {\n if (unReadMessageCount > 0) {\n scrollToNewMessage();\n } else {\n scrollToLatestMessage();\n }\n onScrollToButtonClick?.();\n }}\n icon={unReadMessageCount === 0}\n >\n <Icon name='caret-down' />\n {unReadMessageCount > 0 && <>&nbsp; {t('new_messages')}</>}\n </Button>\n )}\n <RepeatingView\n as={StyledMessageList}\n container={{ direction: 'column' }}\n ref={conversationRef}\n rows={messages}\n onScroll={debounce(onMessageListScroll, 100)}\n {...restProps}\n >\n {(item: RepeatingViewRow) => {\n const { id, type, ...messageListItemRestProps } = item as MessageListItemProps;\n if (type === 'message') {\n return <Message key={id} {...(messageListItemRestProps as MessageProps)} />;\n }\n\n if (type === 'system') {\n const extraProps: Record<string, string> = {};\n if (id === NewMessageSeparatorId) {\n extraProps['data-new-message-separator'] = NewMessageSeparatorId;\n }\n return (\n <SystemMessage\n key={id}\n {...(messageListItemRestProps as SystemMessageProps)}\n {...extraProps}\n />\n );\n }\n if (type === 'typing') {\n return (\n <TypeIndicator key={id} {...(messageListItemRestProps as TypeIndicatorProps)} />\n );\n }\n }}\n </RepeatingView>\n </Flex>\n {isScrolledToLatest() && <ScrollToLatest scrollContainerRef={conversationRef} />}\n </>\n );\n }\n);\n\nexport default MessageList;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RepeatingView.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/RepeatingView.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,iBAAiB,EAA+B,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG9F,OAAO,EAML,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5B,kCAAkC;IAClC,QAAQ,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,SAAS,CAAC;IAC/C,gBAAgB;IAChB,IAAI,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC1B,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AAC,EAAE,MAAM,IAAI,CAAC;IACtB,mDAAmD;IACnD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,uBAAuB;IACvB,eAAe,CAAC,EAAE,eAAe,GAAG,eAAe,CAAC;CACrD;AACD,eAAO,MAAM,uBAAuB,wGAOlC,CAAC;AAGH,eAAO,MAAM,qBAAqB,wGAKjC,CAAC;AAEF,eAAO,MAAM,mBAAmB,yGAE/B,CAAC;AAEF,eAAO,MAAM,eAAe,yGAM3B,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAwDvE,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,4 +1,5 @@
1
- import React, { forwardRef } from 'react';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
2
3
  import styled, { css } from 'styled-components';
3
4
  import { Flex, Progress, useItemIntersection, useConsolidatedRef, defaultThemeProp } from '@pega/cosmos-react-core';
4
5
  export const StyledRepeatingViewItem = styled.li(({ theme }) => {
@@ -30,22 +31,17 @@ const RepeatingView = forwardRef((props, ref) => {
30
31
  const { children: renderer, offset = -1, loadMore, loading: isLoading = false, rows = [], emptyView, scrollDirection = 'top-to-bottom', ...restProps } = props;
31
32
  const listRef = useConsolidatedRef(ref);
32
33
  useItemIntersection(listRef, offset, () => {
33
- loadMore === null || loadMore === void 0 ? void 0 : loadMore();
34
+ loadMore?.();
34
35
  });
35
- return (React.createElement(Flex, { container: {
36
+ return (_jsxs(Flex, { container: {
36
37
  alignItems: 'center',
37
38
  justify: 'center'
38
- }, tabindex: 0, as: StyledRepeatingView, ...restProps },
39
- React.createElement(Flex, { ...restProps, container: {
40
- direction: scrollDirection === 'top-to-bottom' ? 'column' : 'column-reverse'
41
- }, as: StyledRepeatingViewUL, ref: listRef },
42
- rows.map(row => {
43
- const { ariaLabel, ...rowRestProps } = row;
44
- return (React.createElement(StyledRepeatingViewItem, { "aria-label": ariaLabel, tabIndex: 0, key: row.id }, renderer(rowRestProps)));
45
- }),
46
- isLoading && (React.createElement(StyledRepeatingViewItem, { key: 'loader' },
47
- React.createElement(Progress, { placement: 'inline' })))),
48
- !isLoading && rows.length === 0 && emptyView && (React.createElement(StyledEmptyView, null, emptyView))));
39
+ }, tabindex: 0, as: StyledRepeatingView, ...restProps, children: [_jsxs(Flex, { ...restProps, container: {
40
+ direction: scrollDirection === 'top-to-bottom' ? 'column' : 'column-reverse'
41
+ }, as: StyledRepeatingViewUL, ref: listRef, children: [rows.map(row => {
42
+ const { ariaLabel, ...rowRestProps } = row;
43
+ return (_jsx(StyledRepeatingViewItem, { "aria-label": ariaLabel, tabIndex: 0, children: renderer(rowRestProps) }, row.id));
44
+ }), isLoading && (_jsx(StyledRepeatingViewItem, { children: _jsx(Progress, { placement: 'inline' }, void 0) }, 'loader'))] }, void 0), !isLoading && rows.length === 0 && emptyView && (_jsx(StyledEmptyView, { children: emptyView }, void 0))] }, void 0));
49
45
  });
50
46
  export default RepeatingView;
51
47
  //# sourceMappingURL=RepeatingView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RepeatingView.js","sourceRoot":"","sources":["../../../src/components/Chat/RepeatingView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAsC,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC9F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAyBjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC7D,OAAO,GAAG,CAAA;;;oBAGQ,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;;GAExC,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,uBAAuB,CAAC,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,oBAAC,uBAAuB,kBAAa,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,IACrE,QAAQ,CAAC,YAAY,CAAC,CACC,CAC3B,CAAC;YACJ,CAAC,CAAC;YACD,SAAS,IAAI,CACZ,oBAAC,uBAAuB,IAAC,GAAG,EAAC,QAAQ;gBACnC,oBAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,CACP,CAC3B,CACI;QACN,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,IAAI,CAC/C,oBAAC,eAAe,QAAE,SAAS,CAAmB,CAC/C,CACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import React, { FunctionComponent, PropsWithoutRef, forwardRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Progress,\n useItemIntersection,\n useConsolidatedRef,\n defaultThemeProp,\n ForwardProps\n} from '@pega/cosmos-react-core';\n\nexport interface RepeatingViewRow {\n id: string | number;\n ariaLabel?: string;\n}\n\nexport interface RepeatingViewProps {\n /** ref to the list element */\n ref?: Ref<HTMLUListElement>;\n /** Callback to render the view */\n children: (row: RepeatingViewRow) => ReactNode;\n /** Data rows */\n rows?: RepeatingViewRow[];\n /** Indicates if the data is being currently loading */\n loading?: boolean;\n /** Offset of the row item that need to trigger the load more callback */\n offset?: number;\n /** Callback to fetch more rows */\n loadMore?: () => void;\n /** UI that needs to be shown when list is empty */\n emptyView?: ReactNode;\n /** Scroll direction */\n scrollDirection?: 'top-to-bottom' | 'bottom-to-top';\n}\nexport const StyledRepeatingViewItem = styled.li(({ theme }) => {\n return css`\n outline: none;\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n});\nStyledRepeatingViewItem.defaultProps = defaultThemeProp;\n\nexport const StyledRepeatingViewUL = styled.ul`\n list-style-type: none;\n overflow-y: auto;\n height: 100%;\n width: 100%;\n`;\n\nexport const StyledRepeatingView = styled.div`\n position: relative;\n`;\n\nexport const StyledEmptyView = styled.div`\n position: absolute;\n bottom: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1;\n`;\n\nconst RepeatingView: FunctionComponent<RepeatingViewProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<RepeatingViewProps>, ref: RepeatingViewProps['ref']) => {\n const {\n children: renderer,\n offset = -1,\n loadMore,\n loading: isLoading = false,\n rows = [],\n emptyView,\n scrollDirection = 'top-to-bottom',\n ...restProps\n } = props;\n\n const listRef = useConsolidatedRef(ref);\n useItemIntersection(listRef, offset, () => {\n loadMore?.();\n });\n\n return (\n <Flex\n container={{\n alignItems: 'center',\n justify: 'center'\n }}\n tabindex={0}\n as={StyledRepeatingView}\n {...restProps}\n >\n <Flex\n {...restProps}\n container={{\n direction: scrollDirection === 'top-to-bottom' ? 'column' : 'column-reverse'\n }}\n as={StyledRepeatingViewUL}\n ref={listRef}\n >\n {rows.map(row => {\n const { ariaLabel, ...rowRestProps } = row;\n return (\n <StyledRepeatingViewItem aria-label={ariaLabel} tabIndex={0} key={row.id}>\n {renderer(rowRestProps)}\n </StyledRepeatingViewItem>\n );\n })}\n {isLoading && (\n <StyledRepeatingViewItem key='loader'>\n <Progress placement='inline' />\n </StyledRepeatingViewItem>\n )}\n </Flex>\n {!isLoading && rows.length === 0 && emptyView && (\n <StyledEmptyView>{emptyView}</StyledEmptyView>\n )}\n </Flex>\n );\n }\n);\n\nexport default RepeatingView;\n"]}
1
+ {"version":3,"file":"RepeatingView.js","sourceRoot":"","sources":["../../../src/components/Chat/RepeatingView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsC,UAAU,EAAkB,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,E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AC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB;iBAC7E,EACD,EAAE,EAAE,qBAAqB,EACzB,GAAG,EAAE,OAAO,aAEX,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;wBACd,MAAM,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,GAAG,GAAG,CAAC;wBAC3C,OAAO,CACL,KAAC,uBAAuB,kBAAa,SAAS,EAAE,QAAQ,EAAE,CAAC,YACxD,QAAQ,CAAC,YAAY,CAAC,IADyC,GAAG,CAAC,EAAE,CAE9C,CAC3B,CAAC;oBACJ,CAAC,CAAC,EACD,SAAS,IAAI,CACZ,KAAC,uBAAuB,cACtB,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,WAAG,IADJ,QAAQ,CAEX,CAC3B,YACI,EACN,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,IAAI,CAC/C,KAAC,eAAe,cAAE,SAAS,WAAmB,CAC/C,YACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FunctionComponent, PropsWithoutRef, forwardRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Progress,\n useItemIntersection,\n useConsolidatedRef,\n defaultThemeProp,\n ForwardProps\n} from '@pega/cosmos-react-core';\n\nexport interface RepeatingViewRow {\n id: string | number;\n ariaLabel?: string;\n}\n\nexport interface RepeatingViewProps {\n /** ref to the list element */\n ref?: Ref<HTMLUListElement>;\n /** Callback to render the view */\n children: (row: RepeatingViewRow) => ReactNode;\n /** Data rows */\n rows?: RepeatingViewRow[];\n /** Indicates if the data is being currently loading */\n loading?: boolean;\n /** Offset of the row item that need to trigger the load more callback */\n offset?: number;\n /** Callback to fetch more rows */\n loadMore?: () => void;\n /** UI that needs to be shown when list is empty */\n emptyView?: ReactNode;\n /** Scroll direction */\n scrollDirection?: 'top-to-bottom' | 'bottom-to-top';\n}\nexport const StyledRepeatingViewItem = styled.li(({ theme }) => {\n return css`\n outline: none;\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n `;\n});\nStyledRepeatingViewItem.defaultProps = defaultThemeProp;\n\nexport const StyledRepeatingViewUL = styled.ul`\n list-style-type: none;\n overflow-y: auto;\n height: 100%;\n width: 100%;\n`;\n\nexport const StyledRepeatingView = styled.div`\n position: relative;\n`;\n\nexport const StyledEmptyView = styled.div`\n position: absolute;\n bottom: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1;\n`;\n\nconst RepeatingView: FunctionComponent<RepeatingViewProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<RepeatingViewProps>, ref: RepeatingViewProps['ref']) => {\n const {\n children: renderer,\n offset = -1,\n loadMore,\n loading: isLoading = false,\n rows = [],\n emptyView,\n scrollDirection = 'top-to-bottom',\n ...restProps\n } = props;\n\n const listRef = useConsolidatedRef(ref);\n useItemIntersection(listRef, offset, () => {\n loadMore?.();\n });\n\n return (\n <Flex\n container={{\n alignItems: 'center',\n justify: 'center'\n }}\n tabindex={0}\n as={StyledRepeatingView}\n {...restProps}\n >\n <Flex\n {...restProps}\n container={{\n direction: scrollDirection === 'top-to-bottom' ? 'column' : 'column-reverse'\n }}\n as={StyledRepeatingViewUL}\n ref={listRef}\n >\n {rows.map(row => {\n const { ariaLabel, ...rowRestProps } = row;\n return (\n <StyledRepeatingViewItem aria-label={ariaLabel} tabIndex={0} key={row.id}>\n {renderer(rowRestProps)}\n </StyledRepeatingViewItem>\n );\n })}\n {isLoading && (\n <StyledRepeatingViewItem key='loader'>\n <Progress placement='inline' />\n </StyledRepeatingViewItem>\n )}\n </Flex>\n {!isLoading && rows.length === 0 && emptyView && (\n <StyledEmptyView>{emptyView}</StyledEmptyView>\n )}\n </Flex>\n );\n }\n);\n\nexport default RepeatingView;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SuggestedReplyPicker.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/SuggestedReplyPicker.tsx"],"names":[],"mappings":"AAAA,OAAc,EAEZ,iBAAiB,EAEjB,GAAG,EAGJ,MAAM,OAAO,CAAC;AAGf,OAAO,EAOL,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,0BAA0B,yGAAe,CAAC;AACvD,eAAO,MAAM,2BAA2B,yGAAe,CAAC;AACxD,eAAO,MAAM,wBAAwB,yGAAe,CAAC;AAsBrD,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACxC,yBAAyB;IACzB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,wBAAwB;IACxB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,IAAI,CAAC;IACnD,qDAAqD;IACrD,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,QAAA,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,yBAAyB,GAAG,YAAY,CAuHnF,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"SuggestedReplyPicker.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/SuggestedReplyPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAmB,GAAG,EAAuB,MAAM,OAAO,CAAC;AAGjG,OAAO,EAQL,YAAY,EACb,MAAM,yBAAyB,CAAC;AAOjC,eAAO,MAAM,0BAA0B,yGAAe,CAAC;AACvD,eAAO,MAAM,2BAA2B,yGAAe,CAAC;AACxD,eAAO,MAAM,wBAAwB,yGAAe,CAAC;AAsBrD,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,EA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