@pega/cosmos-react-social 3.0.0-dev.4.2 → 3.0.0-dev.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/lib/components/Chat/Chat.js +1 -1
  2. package/lib/components/Chat/Chat.js.map +1 -1
  3. package/lib/components/Chat/ChatBody.js +1 -1
  4. package/lib/components/Chat/ChatBody.js.map +1 -1
  5. package/lib/components/Chat/ChatComposer.js +6 -6
  6. package/lib/components/Chat/ChatComposer.js.map +1 -1
  7. package/lib/components/Chat/ChatHeader.js +1 -1
  8. package/lib/components/Chat/ChatHeader.js.map +1 -1
  9. package/lib/components/Chat/ChatTranscript.js +3 -3
  10. package/lib/components/Chat/ChatTranscript.js.map +1 -1
  11. package/lib/components/Chat/Message.js +9 -9
  12. package/lib/components/Chat/Message.js.map +1 -1
  13. package/lib/components/Chat/MessageList.js +3 -3
  14. package/lib/components/Chat/MessageList.js.map +1 -1
  15. package/lib/components/Chat/RepeatingView.js +1 -1
  16. package/lib/components/Chat/RepeatingView.js.map +1 -1
  17. package/lib/components/Chat/SuggestedReplyPicker.js +6 -6
  18. package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
  19. package/lib/components/Chat/SystemMessage.js +1 -1
  20. package/lib/components/Chat/SystemMessage.js.map +1 -1
  21. package/lib/components/Chat/TranscriptMessage.js +2 -2
  22. package/lib/components/Chat/TranscriptMessage.js.map +1 -1
  23. package/lib/components/Chat/TypeIndicator.js +1 -1
  24. package/lib/components/Chat/TypeIndicator.js.map +1 -1
  25. package/lib/components/Email/ContextMenuPopover.js +2 -2
  26. package/lib/components/Email/ContextMenuPopover.js.map +1 -1
  27. package/lib/components/Email/Email.js +24 -24
  28. package/lib/components/Email/Email.js.map +1 -1
  29. package/lib/components/Email/Email.types.d.ts +1 -1
  30. package/lib/components/Email/Email.types.d.ts.map +1 -1
  31. package/lib/components/Email/Email.types.js.map +1 -1
  32. package/lib/components/Email/EmailComposer.d.ts.map +1 -1
  33. package/lib/components/Email/EmailComposer.js +40 -33
  34. package/lib/components/Email/EmailComposer.js.map +1 -1
  35. package/lib/components/Email/EmailConversation.js +4 -4
  36. package/lib/components/Email/EmailConversation.js.map +1 -1
  37. package/lib/components/Email/EmailEntity.js +2 -2
  38. package/lib/components/Email/EmailEntity.js.map +1 -1
  39. package/lib/components/Email/EmailSelector.d.ts +2 -2
  40. package/lib/components/Email/EmailSelector.d.ts.map +1 -1
  41. package/lib/components/Email/EmailSelector.js +36 -28
  42. package/lib/components/Email/EmailSelector.js.map +1 -1
  43. package/lib/components/Email/EmailShell.js +4 -4
  44. package/lib/components/Email/EmailShell.js.map +1 -1
  45. package/lib/components/Email/EmailSummaryItem.js +4 -4
  46. package/lib/components/Email/EmailSummaryItem.js.map +1 -1
  47. package/lib/components/Email/EmailSummaryList.js +5 -5
  48. package/lib/components/Email/EmailSummaryList.js.map +1 -1
  49. package/lib/components/Email/EntityList.js +2 -2
  50. package/lib/components/Email/EntityList.js.map +1 -1
  51. package/lib/components/Email/index.d.ts +1 -1
  52. package/lib/components/Email/index.d.ts.map +1 -1
  53. package/lib/components/Email/index.js.map +1 -1
  54. package/lib/components/Feed/Feed.js +4 -4
  55. package/lib/components/Feed/Feed.js.map +1 -1
  56. package/lib/components/Feed/FeedAnnouncer.js +1 -1
  57. package/lib/components/Feed/FeedAnnouncer.js.map +1 -1
  58. package/lib/components/Feed/FeedAttachments.js +3 -3
  59. package/lib/components/Feed/FeedAttachments.js.map +1 -1
  60. package/lib/components/Feed/FeedContent.js +1 -1
  61. package/lib/components/Feed/FeedContent.js.map +1 -1
  62. package/lib/components/Feed/FeedLikeButton.js +4 -4
  63. package/lib/components/Feed/FeedLikeButton.js.map +1 -1
  64. package/lib/components/Feed/FeedModalList.js +1 -1
  65. package/lib/components/Feed/FeedModalList.js.map +1 -1
  66. package/lib/components/Feed/FeedNewPost.js +4 -4
  67. package/lib/components/Feed/FeedNewPost.js.map +1 -1
  68. package/lib/components/Feed/FeedNewPostTypeMenu.js +8 -8
  69. package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
  70. package/lib/components/Feed/FeedPost.js +9 -9
  71. package/lib/components/Feed/FeedPost.js.map +1 -1
  72. package/lib/components/Feed/FeedReply.js +6 -6
  73. package/lib/components/Feed/FeedReply.js.map +1 -1
  74. package/lib/components/Feed/FeedReplyInput.js +4 -4
  75. package/lib/components/Feed/FeedReplyInput.js.map +1 -1
  76. package/lib/components/Feed/FeedRichText.js +1 -1
  77. package/lib/components/Feed/FeedRichText.js.map +1 -1
  78. package/lib/components/HashtagButton/HashtagButton.js +2 -2
  79. package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
  80. package/lib/components/MentionButton/MentionButton.js +2 -2
  81. package/lib/components/MentionButton/MentionButton.js.map +1 -1
  82. package/package.json +5 -5
@@ -61,7 +61,7 @@ const Chat = forwardRef((props, ref) => {
61
61
  direction: 'column'
62
62
  }, as: StyledUtilityMerger, children: [utility && (_jsx(Flex, { tabIndex: 0, as: StyledUtilityContainer, container: {
63
63
  direction: 'column'
64
- }, children: _jsx(StyledUtilityContent, { ref: utilityContentRef, children: utility }, void 0) }, void 0)), banner && (_jsx(Banner, { id: banner.id, variant: banner.variant, heading: banner.heading, messages: banner.messages }, void 0)), body] }, void 0), suggestedReplyPicker, footer] }, void 0));
64
+ }, children: _jsx(StyledUtilityContent, { ref: utilityContentRef, children: utility }) })), banner && (_jsx(Banner, { id: banner.id, variant: banner.variant, heading: banner.heading, messages: banner.messages })), body] }), suggestedReplyPicker, footer] }));
65
65
  });
66
66
  export default Chat;
67
67
  //# sourceMappingURL=Chat.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAIV,MAAM,EACN,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,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,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IACrC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,CACL,MAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,mBAAmB,EACvB,SAAS,EAAE;YACT,SAAS,EAAE,QAAQ;SACpB,KACG,SAAS,aAEZ,MAAM,EACP,MAAC,IAAI,IACH,SAAS,EAAE;oBACT,SAAS,EAAE,QAAQ;iBACpB,EACD,EAAE,EAAE,mBAAmB,aAEtB,OAAO,IAAI,CACV,KAAC,IAAI,IACH,QAAQ,EAAE,CAAC,EACX,EAAE,EAAE,sBAAsB,EAC1B,SAAS,EAAE;4BACT,SAAS,EAAE,QAAQ;yBACpB,YAED,KAAC,oBAAoB,IAAC,GAAG,EAAE,iBAAiB,YAAG,OAAO,WAAwB,WACzE,CACR,EAEA,MAAM,IAAI,CACT,KAAC,MAAM,IACL,EAAE,EAAE,MAAM,CAAC,EAAE,EACb,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ,WACzB,CACH,EACA,IAAI,YACA,EACN,oBAAoB,EACpB,MAAM,YACF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n ReactElement,\n FunctionComponent,\n forwardRef,\n PropsWithoutRef,\n Ref,\n ReactNode,\n useRef,\n useEffect\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Banner,\n BannerProps,\n defaultThemeProp,\n ForwardProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\nimport { StyledBanner } from '@pega/cosmos-react-core/lib/components/Banner/Banner';\n\nimport ChatBody from './ChatBody';\nimport ChatComposer from './ChatComposer';\nimport ChatHeader from './ChatHeader';\nimport SuggestedReplyPicker from './SuggestedReplyPicker';\n\nexport type ChatBannerProps = {\n /** Content */\n content: string;\n /** Name of the icon */\n icon: string;\n};\n\nexport interface ChatProps extends NoChildrenProp {\n /** ref to the element */\n ref?: Ref<HTMLElement>;\n /** Header of conversation pane */\n header: ReactElement<typeof ChatHeader>;\n /** Utility - This is used by utility container internally. It has predefined styles and visible conditionally based on utility prop is */\n utility?: ReactNode;\n /** Wrapper of message groups, system messages, type ahead */\n body: ReactElement<typeof ChatBody>;\n /** Wrapper of suggested replies */\n suggestedReplyPicker?: ReactElement<typeof SuggestedReplyPicker>;\n /** chat banner */\n banner?: BannerProps;\n /** Wrapper of conversation input, emojis, attachments */\n footer: ReactElement<typeof ChatComposer>;\n}\n\nconst StyledUtilityContainer = styled.div``;\nconst StyledUtilityMerger = styled.div``;\nconst StyledUtilityContent = styled.div``;\n\nconst StyledChatContainer = styled.section(props => {\n const {\n theme: {\n base: {\n spacing,\n shadow: { high: shadowHigh },\n palette: {\n 'primary-background': primaryBackground,\n 'secondary-background': secondaryBackground\n }\n }\n }\n } = props;\n return css`\n height: 100%;\n background: ${primaryBackground};\n width: 100%;\n ${StyledUtilityMerger} {\n min-height: 15rem;\n position: relative;\n height: 100%;\n overflow-y: hidden;\n }\n ${StyledUtilityContainer} {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 2;\n max-height: 60%;\n width: 100%;\n background-color: ${secondaryBackground};\n > ${StyledUtilityContent} {\n padding: ${spacing} 0;\n box-shadow: ${shadowHigh};\n height: auto;\n width: 100%;\n overflow-y: auto;\n background: linear-gradient(${secondaryBackground} 10%, rgba(255, 255, 255, 0)),\n linear-gradient(rgba(255, 255, 255, 0), ${secondaryBackground} 10%) 0 100%,\n radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)),\n radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) 0 100%;\n background-repeat: no-repeat;\n background-size: 100% 1rem, 100% 1rem, 100% 0.25rem, 100% 0.25rem;\n background-attachment: local, local, scroll, scroll;\n }\n }\n ${StyledBanner} {\n padding: calc(2 * ${spacing});\n margin-bottom: 0;\n flex-shrink: 0;\n }\n `;\n});\n\nStyledChatContainer.defaultProps = defaultThemeProp;\n\nconst Chat: FunctionComponent<ChatProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatProps>, ref: ChatProps['ref']) => {\n const { header, body, footer, utility, banner, suggestedReplyPicker, ...restProps } = props;\n\n const utilityContentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n utilityContentRef.current?.focus();\n }, [utility]);\n\n return (\n <Flex\n ref={ref}\n as={StyledChatContainer}\n container={{\n direction: 'column'\n }}\n {...restProps}\n >\n {header}\n <Flex\n container={{\n direction: 'column'\n }}\n as={StyledUtilityMerger}\n >\n {utility && (\n <Flex\n tabIndex={0}\n as={StyledUtilityContainer}\n container={{\n direction: 'column'\n }}\n >\n <StyledUtilityContent ref={utilityContentRef}>{utility}</StyledUtilityContent>\n </Flex>\n )}\n\n {banner && (\n <Banner\n id={banner.id}\n variant={banner.variant}\n heading={banner.heading}\n messages={banner.messages}\n />\n )}\n {body}\n </Flex>\n {suggestedReplyPicker}\n {footer}\n </Flex>\n );\n }\n);\n\nexport default Chat;\n"]}
1
+ {"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAIV,MAAM,EACN,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,MAAM,EAEN,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,sDAAsD,CAAC;AA+BpF,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAC5C,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AACzC,MAAM,oBAAoB,GA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BACpB,EACD,EAAE,EAAE,mBAAmB,aAEtB,OAAO,IAAI,CACV,KAAC,IAAI,IACH,QAAQ,EAAE,CAAC,EACX,EAAE,EAAE,sBAAsB,EAC1B,SAAS,EAAE;4BACT,SAAS,EAAE,QAAQ;yBACpB,YAED,KAAC,oBAAoB,IAAC,GAAG,EAAE,iBAAiB,YAAG,OAAO,GAAwB,GACzE,CACR,EAEA,MAAM,IAAI,CACT,KAAC,MAAM,IACL,EAAE,EAAE,MAAM,CAAC,EAAE,EACb,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,OAAO,EAAE,MAAM,CAAC,OAAO,EACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ,GACzB,CACH,EACA,IAAI,IACA,EACN,oBAAoB,EACpB,MAAM,IACF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import {\n ReactElement,\n FunctionComponent,\n forwardRef,\n PropsWithoutRef,\n Ref,\n ReactNode,\n useRef,\n useEffect\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Banner,\n BannerProps,\n defaultThemeProp,\n ForwardProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\nimport { StyledBanner } from '@pega/cosmos-react-core/lib/components/Banner/Banner';\n\nimport ChatBody from './ChatBody';\nimport ChatComposer from './ChatComposer';\nimport ChatHeader from './ChatHeader';\nimport SuggestedReplyPicker from './SuggestedReplyPicker';\n\nexport type ChatBannerProps = {\n /** Content */\n content: string;\n /** Name of the icon */\n icon: string;\n};\n\nexport interface ChatProps extends NoChildrenProp {\n /** ref to the element */\n ref?: Ref<HTMLElement>;\n /** Header of conversation pane */\n header: ReactElement<typeof ChatHeader>;\n /** Utility - This is used by utility container internally. It has predefined styles and visible conditionally based on utility prop is */\n utility?: ReactNode;\n /** Wrapper of message groups, system messages, type ahead */\n body: ReactElement<typeof ChatBody>;\n /** Wrapper of suggested replies */\n suggestedReplyPicker?: ReactElement<typeof SuggestedReplyPicker>;\n /** chat banner */\n banner?: BannerProps;\n /** Wrapper of conversation input, emojis, attachments */\n footer: ReactElement<typeof ChatComposer>;\n}\n\nconst StyledUtilityContainer = styled.div``;\nconst StyledUtilityMerger = styled.div``;\nconst StyledUtilityContent = styled.div``;\n\nconst StyledChatContainer = styled.section(props => {\n const {\n theme: {\n base: {\n spacing,\n shadow: { high: shadowHigh },\n palette: {\n 'primary-background': primaryBackground,\n 'secondary-background': secondaryBackground\n }\n }\n }\n } = props;\n return css`\n height: 100%;\n background: ${primaryBackground};\n width: 100%;\n ${StyledUtilityMerger} {\n min-height: 15rem;\n position: relative;\n height: 100%;\n overflow-y: hidden;\n }\n ${StyledUtilityContainer} {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 2;\n max-height: 60%;\n width: 100%;\n background-color: ${secondaryBackground};\n > ${StyledUtilityContent} {\n padding: ${spacing} 0;\n box-shadow: ${shadowHigh};\n height: auto;\n width: 100%;\n overflow-y: auto;\n background: linear-gradient(${secondaryBackground} 10%, rgba(255, 255, 255, 0)),\n linear-gradient(rgba(255, 255, 255, 0), ${secondaryBackground} 10%) 0 100%,\n radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)),\n radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) 0 100%;\n background-repeat: no-repeat;\n background-size: 100% 1rem, 100% 1rem, 100% 0.25rem, 100% 0.25rem;\n background-attachment: local, local, scroll, scroll;\n }\n }\n ${StyledBanner} {\n padding: calc(2 * ${spacing});\n margin-bottom: 0;\n flex-shrink: 0;\n }\n `;\n});\n\nStyledChatContainer.defaultProps = defaultThemeProp;\n\nconst Chat: FunctionComponent<ChatProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatProps>, ref: ChatProps['ref']) => {\n const { header, body, footer, utility, banner, suggestedReplyPicker, ...restProps } = props;\n\n const utilityContentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n utilityContentRef.current?.focus();\n }, [utility]);\n\n return (\n <Flex\n ref={ref}\n as={StyledChatContainer}\n container={{\n direction: 'column'\n }}\n {...restProps}\n >\n {header}\n <Flex\n container={{\n direction: 'column'\n }}\n as={StyledUtilityMerger}\n >\n {utility && (\n <Flex\n tabIndex={0}\n as={StyledUtilityContainer}\n container={{\n direction: 'column'\n }}\n >\n <StyledUtilityContent ref={utilityContentRef}>{utility}</StyledUtilityContent>\n </Flex>\n )}\n\n {banner && (\n <Banner\n id={banner.id}\n variant={banner.variant}\n heading={banner.heading}\n messages={banner.messages}\n />\n )}\n {body}\n </Flex>\n {suggestedReplyPicker}\n {footer}\n </Flex>\n );\n }\n);\n\nexport default Chat;\n"]}
@@ -12,7 +12,7 @@ const ChatBody = forwardRef((props, ref) => {
12
12
  grow: 1
13
13
  }, container: {
14
14
  direction: 'column'
15
- }, "aria-live": 'polite', ref: ref, ...restProps, children: children }, void 0));
15
+ }, "aria-live": 'polite', ref: ref, ...restProps, children: children }));
16
16
  });
17
17
  export default ChatBody;
18
18
  //# sourceMappingURL=ChatBody.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatBody.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatBody.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAsC,MAAM,OAAO,CAAC;AAC1F,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAgB,MAAM,yBAAyB,CAAC;AAW7D,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGzC,CAAC;AAEF,MAAM,QAAQ,GAAoD,UAAU,CAC1E,CAAC,KAAqC,EAAE,GAAyB,EAAE,EAAE;IACnE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAEzC,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAE,uBAAuB,EAC3B,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC;SACR,EACD,SAAS,EAAE;YACT,SAAS,EAAE,QAAQ;SACpB,eACS,QAAQ,EAClB,GAAG,EAAE,GAAG,KACJ,SAAS,YAEZ,QAAQ,WACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, PropsWithoutRef, Ref, ReactElement } from 'react';\nimport styled from 'styled-components';\n\nimport { Flex, ForwardProps } from '@pega/cosmos-react-core';\n\nimport MessageList from './MessageList';\n\nexport interface ChatBodyProps {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Message data Array */\n children: ReactElement<typeof MessageList>;\n}\n\nconst StyledChatBodyContainer = styled.div`\n position: relative;\n overflow-y: hidden;\n`;\n\nconst ChatBody: FunctionComponent<ChatBodyProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatBodyProps>, ref: ChatBodyProps['ref']) => {\n const { children, ...restProps } = props;\n\n return (\n <Flex\n as={StyledChatBodyContainer}\n item={{\n grow: 1\n }}\n container={{\n direction: 'column'\n }}\n aria-live='polite'\n ref={ref}\n {...restProps}\n >\n {children}\n </Flex>\n );\n }\n);\n\nexport default ChatBody;\n"]}
1
+ {"version":3,"file":"ChatBody.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatBody.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAsC,MAAM,OAAO,CAAC;AAC1F,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAgB,MAAM,yBAAyB,CAAC;AAW7D,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;;CAGzC,CAAC;AAEF,MAAM,QAAQ,GAAoD,UAAU,CAC1E,CAAC,KAAqC,EAAE,GAAyB,EAAE,EAAE;IACnE,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAEzC,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAE,uBAAuB,EAC3B,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC;SACR,EACD,SAAS,EAAE;YACT,SAAS,EAAE,QAAQ;SACpB,eACS,QAAQ,EAClB,GAAG,EAAE,GAAG,KACJ,SAAS,YAEZ,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, PropsWithoutRef, Ref, ReactElement } from 'react';\nimport styled from 'styled-components';\n\nimport { Flex, ForwardProps } from '@pega/cosmos-react-core';\n\nimport MessageList from './MessageList';\n\nexport interface ChatBodyProps {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Message data Array */\n children: ReactElement<typeof MessageList>;\n}\n\nconst StyledChatBodyContainer = styled.div`\n position: relative;\n overflow-y: hidden;\n`;\n\nconst ChatBody: FunctionComponent<ChatBodyProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatBodyProps>, ref: ChatBodyProps['ref']) => {\n const { children, ...restProps } = props;\n\n return (\n <Flex\n as={StyledChatBodyContainer}\n item={{\n grow: 1\n }}\n container={{\n direction: 'column'\n }}\n aria-live='polite'\n ref={ref}\n {...restProps}\n >\n {children}\n </Flex>\n );\n }\n);\n\nexport default ChatBody;\n"]}
@@ -195,19 +195,19 @@ const ChatComposer = forwardRef((props, ref) => {
195
195
  alignItems: 'center'
196
196
  }, as: StyledAttachmentItem, children: [_jsx(BareButton, { as: StyledPreviewButton, disabled: disabled, onClick: () => {
197
197
  attachment.onPreview?.(attachment.name);
198
- }, children: attachment.name }, void 0), _jsx(BareButton, { as: StyledDeleteButton, disabled: disabled, "aria-label": t('email_remove_attachment'), onClick: () => {
198
+ }, children: attachment.name }), _jsx(BareButton, { as: StyledDeleteButton, disabled: disabled, "aria-label": t('email_remove_attachment'), onClick: () => {
199
199
  attachment.onDelete?.(attachment.name);
200
- }, children: _jsx(Icon, { name: 'times' }, void 0) }, void 0)] }, attachment.name));
201
- }) }, void 0), _jsx(TextArea, { ref: textAreaRef, maxLength: maxLength, displayCharCount: maxLength !== undefined, hardStop: false, placeholder: defaultPlaceHolder, value: message, disabled: disabled, onKeyUp: handleSpecialKey, onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, onFocus: handleTextAreaChange, "aria-label": t('enter_message') }, void 0)] }, void 0), _jsxs(Flex, { container: { gap: 0.5 }, children: [showEmoji && (_jsx(Button, { ref: setEmojiBtnEl, onClick: toggleEmoji, variant: 'simple', disabled: disabled, icon: true, "aria-label": t('add_emoji'), children: _jsx(Icon, { name: 'face-happy' }, void 0) }, void 0)), maxAttachments > 0 && (_jsxs(StyledAttachmentElementContainer, { disabled: attachments.length >= maxAttachments, ref: setAttachmentsBtnEl, tabIndex: attachments.length >= maxAttachments ? 0 : undefined, role: 'button', children: [_jsx(Button, { onClick: onAddAttachment, variant: 'simple', disabled: !!(disabled || attachments.length >= maxAttachments), icon: true, "aria-label": attachments.length >= maxAttachments
200
+ }, children: _jsx(Icon, { name: 'times' }) })] }, attachment.name));
201
+ }) }), _jsx(TextArea, { ref: textAreaRef, maxLength: maxLength, displayCharCount: maxLength !== undefined, hardStop: false, placeholder: defaultPlaceHolder, value: message, disabled: disabled, onKeyUp: handleSpecialKey, onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, onFocus: handleTextAreaChange, "aria-label": t('enter_message') })] }), _jsxs(Flex, { container: { gap: 0.5 }, children: [showEmoji && (_jsx(Button, { ref: setEmojiBtnEl, onClick: toggleEmoji, variant: 'simple', disabled: disabled, icon: true, "aria-label": t('add_emoji'), children: _jsx(Icon, { name: 'face-happy' }) })), maxAttachments > 0 && (_jsxs(StyledAttachmentElementContainer, { disabled: attachments.length >= maxAttachments, ref: setAttachmentsBtnEl, tabIndex: attachments.length >= maxAttachments ? 0 : undefined, role: 'button', children: [_jsx(Button, { onClick: onAddAttachment, variant: 'simple', disabled: !!(disabled || attachments.length >= maxAttachments), icon: true, "aria-label": attachments.length >= maxAttachments
202
202
  ? t('email_disable_attachment', [maxAttachments])
203
- : t('email_add_attachment', [maxAttachments]), children: _jsx(Icon, { name: 'paper-clip' }, void 0) }, void 0), attachments.length >= maxAttachments && (_jsx(Tooltip, { target: attachmentsBtnEl, showDelay: 'none', hideDelay: 'none', ...restProps, children: t('email_disable_attachment', [maxAttachments]) }, void 0))] }, void 0)), _jsx(Flex, { item: { grow: 1 }, children: children }, void 0), _jsx(Button, { variant: 'primary', disabled: disabled || (!!maxLength && message.length > maxLength), onClick: () => {
203
+ : t('email_add_attachment', [maxAttachments]), children: _jsx(Icon, { name: 'paper-clip' }) }), attachments.length >= maxAttachments && (_jsx(Tooltip, { target: attachmentsBtnEl, showDelay: 'none', hideDelay: 'none', ...restProps, children: t('email_disable_attachment', [maxAttachments]) }))] })), _jsx(Flex, { item: { grow: 1 }, children: children }), _jsx(Button, { variant: 'primary', disabled: disabled || (!!maxLength && message.length > maxLength), onClick: () => {
204
204
  sendMessage(message);
205
- }, children: t('send_label') }, void 0)] }, void 0)] }, void 0), _jsx(Popover, { show: showEmojiPicker, target: emojiBtnEl, placement: 'bottom-start', modifiers: [
205
+ }, children: t('send_label') })] })] }), _jsx(Popover, { show: showEmojiPicker, target: emojiBtnEl, placement: 'bottom-start', modifiers: [
206
206
  {
207
207
  name: 'flip',
208
208
  enabled: true
209
209
  }
210
- ], children: _jsx(EmojiPicker, { ref: EmojiPickerRef, onSelect: onEmojiSelect }, void 0) }, void 0)] }, void 0));
210
+ ], children: _jsx(EmojiPicker, { ref: EmojiPickerRef, onSelect: onEmojiSelect }) })] }));
211
211
  });
212
212
  export default ChatComposer;
213
213
  //# sourceMappingURL=ChatComposer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatComposer.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,QAAQ,EACR,SAAS,EACT,WAAW,EAEX,mBAAmB,EACnB,MAAM,EAGP,MAAM,OAAO,CAAC;AACf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F,eAAe,YAAY,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n ReactNode,\n useState,\n useEffect,\n useCallback,\n ChangeEvent,\n useImperativeHandle,\n useRef,\n RefObject,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n TextArea,\n Button,\n Icon,\n registerIcon,\n Popover,\n EmojiPicker,\n EmojiPickerProps,\n hasProp,\n useI18n,\n useAutoResize,\n useElement,\n defaultThemeProp,\n PropsWithDefaults,\n ForwardProps,\n Tooltip,\n useOuterEvent,\n calculateFontSize\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nimport { AttachmentItemProps } from './Chat.types';\n\nregisterIcon(timesIcon, faceHappyIcon, paperClipIcon);\n\nexport type SpecialKeysConfig = {\n /** Collection of specialKeys */\n keys: string[];\n /** onSpecialKey is fired when a special key is typed in Textarea */\n onSpecialKey: (e: KeyboardEvent<HTMLTextAreaElement>, key: string) => void;\n};\n\nexport interface ChatComposerProps {\n /** Place holder */\n placeholder?: string;\n /** Default message to populate on load */\n defaultMessage?: string;\n /** Max character limit */\n maxLength?: number;\n /** Callback when send button is clicked */\n onSend: (message: string) => void;\n /** Enter / Return key sends message */\n enterKeySendsMessage?: boolean;\n /** Max number of attachments to be allowed in chat composer.\n * If zero is passed, add attachments icon will be hidden. same rule applies if prop is not passed.\n * If attachments added are >= maxAttachments, add attachments icon will be disabled.\n */\n maxAttachments?: number;\n /** show/hide emoji */\n showEmoji?: boolean;\n /** Attachments list */\n attachments?: AttachmentItemProps[];\n /** Callback when attachment icon is clicked */\n onAddAttachment?: () => void;\n /** Special Keys configuration */\n specialKeysConfig?: SpecialKeysConfig;\n /** Disables the composer area */\n disabled?: boolean;\n /** Children */\n children?: ReactNode;\n /** Ref to the Imperative handle */\n ref?: Ref<ChatComposerImperativeHandleProps>;\n}\n\nconst StyledAttachmentItem = styled.div``;\n\ninterface DisableAttachmentProps {\n disabled?: boolean;\n}\nconst StyledAttachmentElementContainer = styled.div<DisableAttachmentProps>(\n ({ disabled, theme }) => {\n return (\n disabled &&\n css`\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n border-radius: 50%;\n outline: none;\n }\n `\n );\n }\n);\nconst StyledPreviewButton = styled(BareButton)``;\nconst StyledDeleteButton = styled(BareButton)``;\n\nconst StyledChatComposer = styled.footer<PropsWithDefaults<ChatComposerProps, 'disabled'>>(\n ({\n theme,\n disabled,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, 'disabled-opacity': transparentBg },\n components: {\n link: { color: linkColor }\n }\n }\n }) => {\n const { xxs: fontSizeXXS } = calculateFontSize(fontSize, fontScale);\n return css`\n padding: calc(2 * ${theme.base.spacing});\n background-color: ${theme.base.palette['secondary-background']};\n textarea {\n border-radius: ${theme.base['border-radius']};\n height: 2.4rem;\n min-height: 2.4rem;\n border: 0.0625rem solid ${theme.base.colors.gray['extra-light']};\n max-width: 100%;\n }\n ${StyledAttachmentItem} {\n color: ${linkColor};\n background-color: ${theme.base.palette['primary-background']};\n padding: calc(0.5 * ${theme.base.spacing});\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n font-size: ${fontSizeXXS};\n font-weight: bold;\n margin-bottom: calc(0.5 * ${theme.base.spacing});\n opacity: ${disabled ? transparentBg : 1};\n }\n\n ${StyledAttachmentElementContainer} {\n ${disabled &&\n css`\n pointer-events: none;\n `}\n }\n\n ${StyledPreviewButton} {\n color: ${theme.base.palette.interactive};\n font-weight: bold;\n &:hover {\n text-decoration: underline;\n }\n }\n\n ${StyledDeleteButton} {\n color: ${theme.base.palette.interactive};\n }\n `;\n }\n);\n\nStyledChatComposer.defaultProps = defaultThemeProp;\nStyledAttachmentElementContainer.defaultProps = defaultThemeProp;\n\nexport const StyledAttachmentsListContainer = styled.div`\n max-height: 4rem;\n overflow-y: auto;\n`;\n\nexport interface ChatComposerImperativeHandleProps {\n /** Function to append a message */\n appendToMessage: (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey'\n ) => void;\n /** Actual ref to Chat composer component */\n chatComposerRef: RefObject<HTMLDivElement | undefined>;\n textAreaRef: RefObject<HTMLTextAreaElement | undefined>;\n}\n\nconst ChatComposer: FunctionComponent<ChatComposerProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatComposerProps>, ref: ChatComposerProps['ref']) => {\n const {\n children,\n attachments = [],\n maxAttachments = 0,\n onAddAttachment,\n maxLength,\n placeholder: defaultPlaceHolder,\n defaultMessage = '',\n onSend,\n specialKeysConfig,\n disabled = false,\n enterKeySendsMessage = true,\n showEmoji,\n ...restProps\n } = props;\n const [message, setMessage] = useState(defaultMessage);\n useEffect(() => {\n setMessage(defaultMessage);\n }, [defaultMessage]);\n\n const t = useI18n();\n\n const [textAreaRef, resizeTextArea] = useAutoResize<HTMLTextAreaElement>(75.1);\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [emojiBtnEl, setEmojiBtnEl] = useElement();\n const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();\n\n const lastEnteredSpecialKey = useRef<string | null>(null);\n\n const appendToMessage = useCallback(\n (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey',\n selectText: boolean = true\n ) => {\n let selectionStart;\n let selectionEnd;\n if (textAreaRef.current) {\n if (position === 'start') {\n textAreaRef.current.value = appendMessage + textAreaRef.current.value;\n selectionStart = 0;\n selectionEnd = appendMessage.length;\n } else if (position === 'end') {\n const initialEnd = textAreaRef.current.value.length;\n textAreaRef.current.value += appendMessage;\n selectionStart = initialEnd;\n selectionEnd = initialEnd + appendMessage.length;\n } else if (position === 'specialKey' && lastEnteredSpecialKey.current) {\n const replaceChars = lastEnteredSpecialKey.current.length;\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(\n 0,\n textAreaRef.current.selectionStart - replaceChars\n ) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart - replaceChars;\n selectionEnd = currentSelectionStart + appendMessage.length - replaceChars;\n lastEnteredSpecialKey.current = null;\n } else {\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(0, textAreaRef.current.selectionStart) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart;\n selectionEnd = currentSelectionStart + appendMessage.length;\n }\n textAreaRef.current.selectionStart = selectText ? selectionStart : selectionEnd;\n textAreaRef.current.selectionEnd = selectionEnd;\n textAreaRef.current.focus();\n setMessage(textAreaRef.current.value);\n }\n },\n [setMessage, textAreaRef.current]\n );\n\n const chatComposerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({ appendToMessage, chatComposerRef, textAreaRef }), [\n appendToMessage,\n chatComposerRef.current,\n textAreaRef.current\n ]);\n\n const sendMessage = useCallback(\n (newMessage: string) => {\n if (onSend) {\n onSend(newMessage);\n setMessage('');\n resizeTextArea();\n }\n },\n [onSend, resizeTextArea]\n );\n\n const handleEnterKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (enterKeySendsMessage && e.keyCode === 13 && !e.shiftKey) {\n if (!maxLength || message.length <= maxLength) {\n sendMessage(message);\n }\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [onSend, message, maxLength]\n );\n\n const handleTextAreaChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n setMessage(e.currentTarget.value);\n resizeTextArea();\n },\n [setMessage, resizeTextArea]\n );\n\n const handleSpecialKey = useCallback(\n (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (!specialKeysConfig) return;\n const { keys, onSpecialKey } = specialKeysConfig;\n if (specialKeysConfig && keys.length > 0) {\n const composerValue = e.currentTarget.value.substring(0, e.currentTarget.selectionStart);\n const specialKey = keys.find(key => composerValue.endsWith(key));\n if (specialKey) {\n lastEnteredSpecialKey.current = specialKey;\n onSpecialKey(e, specialKey);\n }\n }\n },\n [specialKeysConfig]\n );\n\n const toggleEmoji = () => {\n setShowEmojiPicker(!showEmojiPicker);\n };\n const onEmojiSelect: EmojiPickerProps['onSelect'] = emojiElem => {\n // Check that it is not a custom emoji\n if (hasProp(emojiElem, 'native')) {\n appendToMessage(emojiElem.native, 'cursor', false);\n }\n setShowEmojiPicker(false);\n };\n\n const EmojiPickerRef = useRef<HTMLDivElement>(null);\n\n useOuterEvent('mousedown', [emojiBtnEl, EmojiPickerRef], () => {\n setShowEmojiPicker(false);\n });\n\n useEffect(() => {\n resizeTextArea();\n }, []);\n\n return (\n <>\n <Flex\n as={StyledChatComposer}\n disabled={disabled}\n container={{\n direction: 'column',\n gap: 2\n }}\n item={{\n shrink: 0\n }}\n {...restProps}\n ref={chatComposerRef}\n >\n <Flex\n container={{\n direction: 'column',\n gap: 0.5\n }}\n >\n <Flex\n container={{\n wrap: 'wrap',\n gap: 0.5\n }}\n as={StyledAttachmentsListContainer}\n >\n {attachments.map(attachment => {\n return (\n <Flex\n key={attachment.name}\n container={{\n gap: 1,\n alignItems: 'center'\n }}\n as={StyledAttachmentItem}\n >\n <BareButton\n as={StyledPreviewButton}\n disabled={disabled}\n onClick={() => {\n attachment.onPreview?.(attachment.name);\n }}\n >\n {attachment.name}\n </BareButton>\n <BareButton\n as={StyledDeleteButton}\n disabled={disabled}\n aria-label={t('email_remove_attachment')}\n onClick={() => {\n attachment.onDelete?.(attachment.name);\n }}\n >\n <Icon name='times' />\n </BareButton>\n </Flex>\n );\n })}\n </Flex>\n <TextArea\n ref={textAreaRef}\n maxLength={maxLength}\n displayCharCount={maxLength !== undefined}\n hardStop={false}\n placeholder={defaultPlaceHolder}\n value={message}\n disabled={disabled}\n onKeyUp={handleSpecialKey}\n onKeyDown={handleEnterKeyDown}\n onChange={handleTextAreaChange}\n onFocus={handleTextAreaChange}\n aria-label={t('enter_message')}\n />\n </Flex>\n <Flex container={{ gap: 0.5 }}>\n {showEmoji && (\n <Button\n ref={setEmojiBtnEl}\n onClick={toggleEmoji}\n variant='simple'\n disabled={disabled}\n icon\n aria-label={t('add_emoji')}\n >\n <Icon name='face-happy' />\n </Button>\n )}\n {maxAttachments > 0 && (\n <StyledAttachmentElementContainer\n disabled={attachments.length >= maxAttachments}\n ref={setAttachmentsBtnEl}\n tabIndex={attachments.length >= maxAttachments ? 0 : undefined}\n role='button'\n >\n <Button\n onClick={onAddAttachment}\n variant='simple'\n disabled={!!(disabled || attachments.length >= maxAttachments)}\n icon\n aria-label={\n attachments.length >= maxAttachments\n ? t('email_disable_attachment', [maxAttachments])\n : t('email_add_attachment', [maxAttachments])\n }\n >\n <Icon name='paper-clip' />\n </Button>\n {attachments.length >= maxAttachments && (\n <Tooltip\n target={attachmentsBtnEl}\n showDelay='none'\n hideDelay='none'\n {...restProps}\n >\n {t('email_disable_attachment', [maxAttachments])}\n </Tooltip>\n )}\n </StyledAttachmentElementContainer>\n )}\n <Flex item={{ grow: 1 }}>{children}</Flex>\n <Button\n variant='primary'\n disabled={disabled || (!!maxLength && message.length > maxLength)}\n onClick={() => {\n sendMessage(message);\n }}\n >\n {t('send_label')}\n </Button>\n </Flex>\n </Flex>\n <Popover\n show={showEmojiPicker}\n target={emojiBtnEl}\n placement='bottom-start'\n modifiers={[\n {\n name: 'flip',\n enabled: true\n }\n ]}\n >\n <EmojiPicker ref={EmojiPickerRef} onSelect={onEmojiSelect} />\n </Popover>\n </>\n );\n }\n);\n\nexport default ChatComposer;\n"]}
1
+ {"version":3,"file":"ChatComposer.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],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ED,KAAC,WAAW,IAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,GAAI,GACrD,IACT,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n ReactNode,\n useState,\n useEffect,\n useCallback,\n ChangeEvent,\n useImperativeHandle,\n useRef,\n RefObject,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n TextArea,\n Button,\n Icon,\n registerIcon,\n Popover,\n EmojiPicker,\n EmojiPickerProps,\n hasProp,\n useI18n,\n useAutoResize,\n useElement,\n defaultThemeProp,\n PropsWithDefaults,\n ForwardProps,\n Tooltip,\n useOuterEvent,\n calculateFontSize\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nimport { AttachmentItemProps } from './Chat.types';\n\nregisterIcon(timesIcon, faceHappyIcon, paperClipIcon);\n\nexport type SpecialKeysConfig = {\n /** Collection of specialKeys */\n keys: string[];\n /** onSpecialKey is fired when a special key is typed in Textarea */\n onSpecialKey: (e: KeyboardEvent<HTMLTextAreaElement>, key: string) => void;\n};\n\nexport interface ChatComposerProps {\n /** Place holder */\n placeholder?: string;\n /** Default message to populate on load */\n defaultMessage?: string;\n /** Max character limit */\n maxLength?: number;\n /** Callback when send button is clicked */\n onSend: (message: string) => void;\n /** Enter / Return key sends message */\n enterKeySendsMessage?: boolean;\n /** Max number of attachments to be allowed in chat composer.\n * If zero is passed, add attachments icon will be hidden. same rule applies if prop is not passed.\n * If attachments added are >= maxAttachments, add attachments icon will be disabled.\n */\n maxAttachments?: number;\n /** show/hide emoji */\n showEmoji?: boolean;\n /** Attachments list */\n attachments?: AttachmentItemProps[];\n /** Callback when attachment icon is clicked */\n onAddAttachment?: () => void;\n /** Special Keys configuration */\n specialKeysConfig?: SpecialKeysConfig;\n /** Disables the composer area */\n disabled?: boolean;\n /** Children */\n children?: ReactNode;\n /** Ref to the Imperative handle */\n ref?: Ref<ChatComposerImperativeHandleProps>;\n}\n\nconst StyledAttachmentItem = styled.div``;\n\ninterface DisableAttachmentProps {\n disabled?: boolean;\n}\nconst StyledAttachmentElementContainer = styled.div<DisableAttachmentProps>(\n ({ disabled, theme }) => {\n return (\n disabled &&\n css`\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n border-radius: 50%;\n outline: none;\n }\n `\n );\n }\n);\nconst StyledPreviewButton = styled(BareButton)``;\nconst StyledDeleteButton = styled(BareButton)``;\n\nconst StyledChatComposer = styled.footer<PropsWithDefaults<ChatComposerProps, 'disabled'>>(\n ({\n theme,\n disabled,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, 'disabled-opacity': transparentBg },\n components: {\n link: { color: linkColor }\n }\n }\n }) => {\n const { xxs: fontSizeXXS } = calculateFontSize(fontSize, fontScale);\n return css`\n padding: calc(2 * ${theme.base.spacing});\n background-color: ${theme.base.palette['secondary-background']};\n textarea {\n border-radius: ${theme.base['border-radius']};\n height: 2.4rem;\n min-height: 2.4rem;\n border: 0.0625rem solid ${theme.base.colors.gray['extra-light']};\n max-width: 100%;\n }\n ${StyledAttachmentItem} {\n color: ${linkColor};\n background-color: ${theme.base.palette['primary-background']};\n padding: calc(0.5 * ${theme.base.spacing});\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n font-size: ${fontSizeXXS};\n font-weight: bold;\n margin-bottom: calc(0.5 * ${theme.base.spacing});\n opacity: ${disabled ? transparentBg : 1};\n }\n\n ${StyledAttachmentElementContainer} {\n ${disabled &&\n css`\n pointer-events: none;\n `}\n }\n\n ${StyledPreviewButton} {\n color: ${theme.base.palette.interactive};\n font-weight: bold;\n &:hover {\n text-decoration: underline;\n }\n }\n\n ${StyledDeleteButton} {\n color: ${theme.base.palette.interactive};\n }\n `;\n }\n);\n\nStyledChatComposer.defaultProps = defaultThemeProp;\nStyledAttachmentElementContainer.defaultProps = defaultThemeProp;\n\nexport const StyledAttachmentsListContainer = styled.div`\n max-height: 4rem;\n overflow-y: auto;\n`;\n\nexport interface ChatComposerImperativeHandleProps {\n /** Function to append a message */\n appendToMessage: (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey'\n ) => void;\n /** Actual ref to Chat composer component */\n chatComposerRef: RefObject<HTMLDivElement | undefined>;\n textAreaRef: RefObject<HTMLTextAreaElement | undefined>;\n}\n\nconst ChatComposer: FunctionComponent<ChatComposerProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatComposerProps>, ref: ChatComposerProps['ref']) => {\n const {\n children,\n attachments = [],\n maxAttachments = 0,\n onAddAttachment,\n maxLength,\n placeholder: defaultPlaceHolder,\n defaultMessage = '',\n onSend,\n specialKeysConfig,\n disabled = false,\n enterKeySendsMessage = true,\n showEmoji,\n ...restProps\n } = props;\n const [message, setMessage] = useState(defaultMessage);\n useEffect(() => {\n setMessage(defaultMessage);\n }, [defaultMessage]);\n\n const t = useI18n();\n\n const [textAreaRef, resizeTextArea] = useAutoResize<HTMLTextAreaElement>(75.1);\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [emojiBtnEl, setEmojiBtnEl] = useElement();\n const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();\n\n const lastEnteredSpecialKey = useRef<string | null>(null);\n\n const appendToMessage = useCallback(\n (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey',\n selectText: boolean = true\n ) => {\n let selectionStart;\n let selectionEnd;\n if (textAreaRef.current) {\n if (position === 'start') {\n textAreaRef.current.value = appendMessage + textAreaRef.current.value;\n selectionStart = 0;\n selectionEnd = appendMessage.length;\n } else if (position === 'end') {\n const initialEnd = textAreaRef.current.value.length;\n textAreaRef.current.value += appendMessage;\n selectionStart = initialEnd;\n selectionEnd = initialEnd + appendMessage.length;\n } else if (position === 'specialKey' && lastEnteredSpecialKey.current) {\n const replaceChars = lastEnteredSpecialKey.current.length;\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(\n 0,\n textAreaRef.current.selectionStart - replaceChars\n ) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart - replaceChars;\n selectionEnd = currentSelectionStart + appendMessage.length - replaceChars;\n lastEnteredSpecialKey.current = null;\n } else {\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(0, textAreaRef.current.selectionStart) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart;\n selectionEnd = currentSelectionStart + appendMessage.length;\n }\n textAreaRef.current.selectionStart = selectText ? selectionStart : selectionEnd;\n textAreaRef.current.selectionEnd = selectionEnd;\n textAreaRef.current.focus();\n setMessage(textAreaRef.current.value);\n }\n },\n [setMessage, textAreaRef.current]\n );\n\n const chatComposerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({ appendToMessage, chatComposerRef, textAreaRef }), [\n appendToMessage,\n chatComposerRef.current,\n textAreaRef.current\n ]);\n\n const sendMessage = useCallback(\n (newMessage: string) => {\n if (onSend) {\n onSend(newMessage);\n setMessage('');\n resizeTextArea();\n }\n },\n [onSend, resizeTextArea]\n );\n\n const handleEnterKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (enterKeySendsMessage && e.keyCode === 13 && !e.shiftKey) {\n if (!maxLength || message.length <= maxLength) {\n sendMessage(message);\n }\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [onSend, message, maxLength]\n );\n\n const handleTextAreaChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n setMessage(e.currentTarget.value);\n resizeTextArea();\n },\n [setMessage, resizeTextArea]\n );\n\n const handleSpecialKey = useCallback(\n (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (!specialKeysConfig) return;\n const { keys, onSpecialKey } = specialKeysConfig;\n if (specialKeysConfig && keys.length > 0) {\n const composerValue = e.currentTarget.value.substring(0, e.currentTarget.selectionStart);\n const specialKey = keys.find(key => composerValue.endsWith(key));\n if (specialKey) {\n lastEnteredSpecialKey.current = specialKey;\n onSpecialKey(e, specialKey);\n }\n }\n },\n [specialKeysConfig]\n );\n\n const toggleEmoji = () => {\n setShowEmojiPicker(!showEmojiPicker);\n };\n const onEmojiSelect: EmojiPickerProps['onSelect'] = emojiElem => {\n // Check that it is not a custom emoji\n if (hasProp(emojiElem, 'native')) {\n appendToMessage(emojiElem.native, 'cursor', false);\n }\n setShowEmojiPicker(false);\n };\n\n const EmojiPickerRef = useRef<HTMLDivElement>(null);\n\n useOuterEvent('mousedown', [emojiBtnEl, EmojiPickerRef], () => {\n setShowEmojiPicker(false);\n });\n\n useEffect(() => {\n resizeTextArea();\n }, []);\n\n return (\n <>\n <Flex\n as={StyledChatComposer}\n disabled={disabled}\n container={{\n direction: 'column',\n gap: 2\n }}\n item={{\n shrink: 0\n }}\n {...restProps}\n ref={chatComposerRef}\n >\n <Flex\n container={{\n direction: 'column',\n gap: 0.5\n }}\n >\n <Flex\n container={{\n wrap: 'wrap',\n gap: 0.5\n }}\n as={StyledAttachmentsListContainer}\n >\n {attachments.map(attachment => {\n return (\n <Flex\n key={attachment.name}\n container={{\n gap: 1,\n alignItems: 'center'\n }}\n as={StyledAttachmentItem}\n >\n <BareButton\n as={StyledPreviewButton}\n disabled={disabled}\n onClick={() => {\n attachment.onPreview?.(attachment.name);\n }}\n >\n {attachment.name}\n </BareButton>\n <BareButton\n as={StyledDeleteButton}\n disabled={disabled}\n aria-label={t('email_remove_attachment')}\n onClick={() => {\n attachment.onDelete?.(attachment.name);\n }}\n >\n <Icon name='times' />\n </BareButton>\n </Flex>\n );\n })}\n </Flex>\n <TextArea\n ref={textAreaRef}\n maxLength={maxLength}\n displayCharCount={maxLength !== undefined}\n hardStop={false}\n placeholder={defaultPlaceHolder}\n value={message}\n disabled={disabled}\n onKeyUp={handleSpecialKey}\n onKeyDown={handleEnterKeyDown}\n onChange={handleTextAreaChange}\n onFocus={handleTextAreaChange}\n aria-label={t('enter_message')}\n />\n </Flex>\n <Flex container={{ gap: 0.5 }}>\n {showEmoji && (\n <Button\n ref={setEmojiBtnEl}\n onClick={toggleEmoji}\n variant='simple'\n disabled={disabled}\n icon\n aria-label={t('add_emoji')}\n >\n <Icon name='face-happy' />\n </Button>\n )}\n {maxAttachments > 0 && (\n <StyledAttachmentElementContainer\n disabled={attachments.length >= maxAttachments}\n ref={setAttachmentsBtnEl}\n tabIndex={attachments.length >= maxAttachments ? 0 : undefined}\n role='button'\n >\n <Button\n onClick={onAddAttachment}\n variant='simple'\n disabled={!!(disabled || attachments.length >= maxAttachments)}\n icon\n aria-label={\n attachments.length >= maxAttachments\n ? t('email_disable_attachment', [maxAttachments])\n : t('email_add_attachment', [maxAttachments])\n }\n >\n <Icon name='paper-clip' />\n </Button>\n {attachments.length >= maxAttachments && (\n <Tooltip\n target={attachmentsBtnEl}\n showDelay='none'\n hideDelay='none'\n {...restProps}\n >\n {t('email_disable_attachment', [maxAttachments])}\n </Tooltip>\n )}\n </StyledAttachmentElementContainer>\n )}\n <Flex item={{ grow: 1 }}>{children}</Flex>\n <Button\n variant='primary'\n disabled={disabled || (!!maxLength && message.length > maxLength)}\n onClick={() => {\n sendMessage(message);\n }}\n >\n {t('send_label')}\n </Button>\n </Flex>\n </Flex>\n <Popover\n show={showEmojiPicker}\n target={emojiBtnEl}\n placement='bottom-start'\n modifiers={[\n {\n name: 'flip',\n enabled: true\n }\n ]}\n >\n <EmojiPicker ref={EmojiPickerRef} onSelect={onEmojiSelect} />\n </Popover>\n </>\n );\n }\n);\n\nexport default ChatComposer;\n"]}
@@ -22,7 +22,7 @@ const ChatHeader = forwardRef((props, ref) => {
22
22
  }, container: {
23
23
  gap: 2,
24
24
  alignItems: 'center'
25
- }, as: StyledChatPrimaryInfoContainer, children: [icon && _jsx(Icon, { name: icon }, void 0), _jsx(Text, { variant: 'h3', children: title }, void 0)] }, void 0), actions] }, void 0));
25
+ }, as: StyledChatPrimaryInfoContainer, children: [icon && _jsx(Icon, { name: icon }), _jsx(Text, { variant: 'h3', children: title })] }), actions] }));
26
26
  });
27
27
  export default ChatHeader;
28
28
  //# sourceMappingURL=ChatHeader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatHeader.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAajC,MAAM,8BAA8B,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEpD,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CACpC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,MAAM,EAAE,EAAE,IAAI,EAAE,EACjB,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;iBACG,OAAO,aAAa,OAAO;uCACL,IAAI,CAAC,KAAK;QACzC,8BAA8B;;;KAGjC,CAAC;AACJ,CAAC,CACF,CAAC;AACF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,UAAU,GAAsD,UAAU,CAC9E,CAAC,KAAuC,EAAE,GAA2B,EAAE,EAAE;IACvE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACrD,OAAO,CACL,MAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,gBAAgB,EACpB,SAAS,QACT,IAAI,EAAE;YACJ,MAAM,EAAE,CAAC;SACV,KACG,SAAS,aAEb,MAAC,IAAI,IACH,IAAI,EAAE;oBACJ,IAAI,EAAE,CAAC;iBACR,EACD,SAAS,EAAE;oBACT,GAAG,EAAE,CAAC;oBACN,UAAU,EAAE,QAAQ;iBACrB,EACD,EAAE,EAAE,8BAA8B,aAEjC,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,WAAI,EAC7B,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,KAAK,WAAQ,YAC5B,EACN,OAAO,YACH,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, PropsWithoutRef, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Text,\n Flex,\n Icon,\n defaultThemeProp,\n ForwardProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\n\nexport interface ChatHeaderProps extends NoChildrenProp {\n /** ref to the element */\n ref?: Ref<HTMLElement>;\n /** Title: Used to show username || channel || group name */\n title: string;\n /** Icon: Used to show the channel icons, pass the icon name from the cosmos library to render */\n icon?: string;\n /** Primary actions: Used to show frequent user actions to be performed */\n actions?: ReactNode;\n}\n\nconst StyledChatPrimaryInfoContainer = styled.div``;\n\nconst StyledChatHeader = styled.header(\n ({\n theme: {\n base: {\n spacing,\n colors: { gray }\n }\n }\n }) => {\n return css`\n padding: ${spacing} calc(2 * ${spacing});\n border-bottom: 0.0625rem solid ${gray.light};\n ${StyledChatPrimaryInfoContainer} {\n font-size: 1rem;\n }\n `;\n }\n);\nStyledChatHeader.defaultProps = defaultThemeProp;\n\nconst ChatHeader: FunctionComponent<ChatHeaderProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatHeaderProps>, ref: ChatHeaderProps['ref']) => {\n const { title, actions, icon, ...restProps } = props;\n return (\n <Flex\n ref={ref}\n as={StyledChatHeader}\n container\n item={{\n shrink: 0\n }}\n {...restProps}\n >\n <Flex\n item={{\n grow: 1\n }}\n container={{\n gap: 2,\n alignItems: 'center'\n }}\n as={StyledChatPrimaryInfoContainer}\n >\n {icon && <Icon name={icon} />}\n <Text variant='h3'>{title}</Text>\n </Flex>\n {actions}\n </Flex>\n );\n }\n);\n\nexport default ChatHeader;\n"]}
1
+ {"version":3,"file":"ChatHeader.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAajC,MAAM,8BAA8B,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEpD,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CACpC,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,MAAM,EAAE,EAAE,IAAI,EAAE,EACjB,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;iBACG,OAAO,aAAa,OAAO;uCACL,IAAI,CAAC,KAAK;QACzC,8BAA8B;;;KAGjC,CAAC;AACJ,CAAC,CACF,CAAC;AACF,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,UAAU,GAAsD,UAAU,CAC9E,CAAC,KAAuC,EAAE,GAA2B,EAAE,EAAE;IACvE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACrD,OAAO,CACL,MAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,gBAAgB,EACpB,SAAS,QACT,IAAI,EAAE;YACJ,MAAM,EAAE,CAAC;SACV,KACG,SAAS,aAEb,MAAC,IAAI,IACH,IAAI,EAAE;oBACJ,IAAI,EAAE,CAAC;iBACR,EACD,SAAS,EAAE;oBACT,GAAG,EAAE,CAAC;oBACN,UAAU,EAAE,QAAQ;iBACrB,EACD,EAAE,EAAE,8BAA8B,aAEjC,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI,EAC7B,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,KAAK,GAAQ,IAC5B,EACN,OAAO,IACH,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, PropsWithoutRef, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Text,\n Flex,\n Icon,\n defaultThemeProp,\n ForwardProps,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\n\nexport interface ChatHeaderProps extends NoChildrenProp {\n /** ref to the element */\n ref?: Ref<HTMLElement>;\n /** Title: Used to show username || channel || group name */\n title: string;\n /** Icon: Used to show the channel icons, pass the icon name from the cosmos library to render */\n icon?: string;\n /** Primary actions: Used to show frequent user actions to be performed */\n actions?: ReactNode;\n}\n\nconst StyledChatPrimaryInfoContainer = styled.div``;\n\nconst StyledChatHeader = styled.header(\n ({\n theme: {\n base: {\n spacing,\n colors: { gray }\n }\n }\n }) => {\n return css`\n padding: ${spacing} calc(2 * ${spacing});\n border-bottom: 0.0625rem solid ${gray.light};\n ${StyledChatPrimaryInfoContainer} {\n font-size: 1rem;\n }\n `;\n }\n);\nStyledChatHeader.defaultProps = defaultThemeProp;\n\nconst ChatHeader: FunctionComponent<ChatHeaderProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatHeaderProps>, ref: ChatHeaderProps['ref']) => {\n const { title, actions, icon, ...restProps } = props;\n return (\n <Flex\n ref={ref}\n as={StyledChatHeader}\n container\n item={{\n shrink: 0\n }}\n {...restProps}\n >\n <Flex\n item={{\n grow: 1\n }}\n container={{\n gap: 2,\n alignItems: 'center'\n }}\n as={StyledChatPrimaryInfoContainer}\n >\n {icon && <Icon name={icon} />}\n <Text variant='h3'>{title}</Text>\n </Flex>\n {actions}\n </Flex>\n );\n }\n);\n\nexport default ChatHeader;\n"]}
@@ -30,7 +30,7 @@ const ChatTranscript = forwardRef((props, ref) => {
30
30
  return (_jsxs(Flex, { ref: ref, as: StyledChatTranscriptContainer, container: {
31
31
  direction: 'column',
32
32
  gap: 0.5
33
- }, ...restProps, children: [title && (_jsx(Text, { variant: 'h4', as: StyledChatTranscriptHeading, children: title }, void 0)), _jsx(RepeatingView, { rows: transcriptItems, children: item => {
33
+ }, ...restProps, children: [title && (_jsx(Text, { variant: 'h4', as: StyledChatTranscriptHeading, children: title })), _jsx(RepeatingView, { rows: transcriptItems, children: item => {
34
34
  const { id, type, ...transcriptItemRestProps } = item;
35
35
  if (type === 'transcript') {
36
36
  return (_jsx(TranscriptMessage, { ...transcriptItemRestProps }, id));
@@ -38,8 +38,8 @@ const ChatTranscript = forwardRef((props, ref) => {
38
38
  if (type === 'system') {
39
39
  return (_jsx(SystemMessage, { ...transcriptItemRestProps }, id));
40
40
  }
41
- return _jsx(_Fragment, {}, void 0);
42
- } }, void 0)] }, void 0));
41
+ return _jsx(_Fragment, {});
42
+ } })] }));
43
43
  });
44
44
  export default ChatTranscript;
45
45
  //# sourceMappingURL=ChatTranscript.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatTranscript.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatTranscript.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAC5E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAgB,IAAI,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E,IAAI,EAAE,GAAG,uBAAuB,EAAE,GAAG,IAA0B,CAAC;oBAC5E,IAAI,IAAI,KAAK,YAAY,EAAE;wBACzB,OAAO,CACL,KAAC,iBAAiB,OAEX,uBAAkD,IADlD,EAAE,CAEP,CACH,CAAC;qBACH;oBACD,IAAI,IAAI,KAAK,QAAQ,EAAE;wBACrB,OAAO,CACL,KAAC,aAAa,OAAe,uBAA8C,IAAvD,EAAE,CAAyD,CAChF,CAAC;qBACH;oBACD,OAAO,2BAAK,CAAC;gBACf,CAAC,WACa,YACX,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Flex, defaultThemeProp, ForwardProps, Text } from '@pega/cosmos-react-core';\n\nimport RepeatingView, { RepeatingViewRow, StyledRepeatingViewItem } from './RepeatingView';\nimport TranscriptMessage, { TranscriptMessageProps } from './TranscriptMessage';\nimport SystemMessage, { SystemMessageProps, StyledSystemMessage } from './SystemMessage';\n\nexport type ChatTranscriptItem =\n | (TranscriptMessageProps & { type: 'transcript'; id: RepeatingViewRow['id'] })\n | (SystemMessageProps & { type: 'system'; id: RepeatingViewRow['id'] });\n\nexport interface ChatTranscriptProps {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Title for transcript's body */\n title?: string;\n /** Transcript messages array */\n transcript: ChatTranscriptItem[];\n}\n\nconst StyledChatTranscriptHeading = styled.h4``;\n\nconst StyledChatTranscriptContainer = styled.div(props => {\n const {\n theme: {\n base: {\n shadow: { focus: shadowFocus },\n spacing\n }\n }\n } = props;\n return css`\n width: 100%;\n outline: none;\n padding: 0 0.75rem 0.5rem;\n &:focus {\n box-shadow: ${shadowFocus};\n }\n ${StyledChatTranscriptHeading}, ${StyledRepeatingViewItem}, ${StyledSystemMessage} {\n margin: calc(0.25 * ${spacing});\n padding: calc(0.25 * ${spacing});\n }\n ${StyledSystemMessage} {\n padding: 0;\n }\n `;\n});\n\nStyledChatTranscriptContainer.defaultProps = defaultThemeProp;\n\nconst ChatTranscript: FunctionComponent<ChatTranscriptProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatTranscriptProps>, ref: ChatTranscriptProps['ref']) => {\n const { transcript: transcriptItems = [], title, ...restProps } = props;\n return (\n <Flex\n ref={ref}\n as={StyledChatTranscriptContainer}\n container={{\n direction: 'column',\n gap: 0.5\n }}\n {...restProps}\n >\n {title && (\n <Text variant='h4' as={StyledChatTranscriptHeading}>\n {title}\n </Text>\n )}\n <RepeatingView rows={transcriptItems}>\n {item => {\n const { id, type, ...transcriptItemRestProps } = item as ChatTranscriptItem;\n if (type === 'transcript') {\n return (\n <TranscriptMessage\n key={id}\n {...(transcriptItemRestProps as TranscriptMessageProps)}\n />\n );\n }\n if (type === 'system') {\n return (\n <SystemMessage key={id} {...(transcriptItemRestProps as SystemMessageProps)} />\n );\n }\n return <></>;\n }}\n </RepeatingView>\n </Flex>\n );\n }\n);\n\nexport default ChatTranscript;\n"]}
1
+ {"version":3,"file":"ChatTranscript.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatTranscript.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,MAAM,OAAO,CAAC;AAC5E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAgB,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAErF,OAAO,aAAa,EAAE,EAAoB,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,iBAA6C,MAAM,qBAAqB,CAAC;AAChF,OAAO,aAAa,EAAE,EAAsB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAezF,MAAM,2BAA2B,GAAG,MAAM,CAAC,EAAE,CAAA,EAAE,CAAC;AAEhD,MAAM,6BAA6B,GAAG,MAAM,CAAC,GAAG,CAA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,CAAC;gBACf,CAAC,GACa,IACX,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Flex, defaultThemeProp, ForwardProps, Text } from '@pega/cosmos-react-core';\n\nimport RepeatingView, { RepeatingViewRow, StyledRepeatingViewItem } from './RepeatingView';\nimport TranscriptMessage, { TranscriptMessageProps } from './TranscriptMessage';\nimport SystemMessage, { SystemMessageProps, StyledSystemMessage } from './SystemMessage';\n\nexport type ChatTranscriptItem =\n | (TranscriptMessageProps & { type: 'transcript'; id: RepeatingViewRow['id'] })\n | (SystemMessageProps & { type: 'system'; id: RepeatingViewRow['id'] });\n\nexport interface ChatTranscriptProps {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Title for transcript's body */\n title?: string;\n /** Transcript messages array */\n transcript: ChatTranscriptItem[];\n}\n\nconst StyledChatTranscriptHeading = styled.h4``;\n\nconst StyledChatTranscriptContainer = styled.div(props => {\n const {\n theme: {\n base: {\n shadow: { focus: shadowFocus },\n spacing\n }\n }\n } = props;\n return css`\n width: 100%;\n outline: none;\n padding: 0 0.75rem 0.5rem;\n &:focus {\n box-shadow: ${shadowFocus};\n }\n ${StyledChatTranscriptHeading}, ${StyledRepeatingViewItem}, ${StyledSystemMessage} {\n margin: calc(0.25 * ${spacing});\n padding: calc(0.25 * ${spacing});\n }\n ${StyledSystemMessage} {\n padding: 0;\n }\n `;\n});\n\nStyledChatTranscriptContainer.defaultProps = defaultThemeProp;\n\nconst ChatTranscript: FunctionComponent<ChatTranscriptProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatTranscriptProps>, ref: ChatTranscriptProps['ref']) => {\n const { transcript: transcriptItems = [], title, ...restProps } = props;\n return (\n <Flex\n ref={ref}\n as={StyledChatTranscriptContainer}\n container={{\n direction: 'column',\n gap: 0.5\n }}\n {...restProps}\n >\n {title && (\n <Text variant='h4' as={StyledChatTranscriptHeading}>\n {title}\n </Text>\n )}\n <RepeatingView rows={transcriptItems}>\n {item => {\n const { id, type, ...transcriptItemRestProps } = item as ChatTranscriptItem;\n if (type === 'transcript') {\n return (\n <TranscriptMessage\n key={id}\n {...(transcriptItemRestProps as TranscriptMessageProps)}\n />\n );\n }\n if (type === 'system') {\n return (\n <SystemMessage key={id} {...(transcriptItemRestProps as SystemMessageProps)} />\n );\n }\n return <></>;\n }}\n </RepeatingView>\n </Flex>\n );\n }\n);\n\nexport default ChatTranscript;\n"]}
@@ -22,11 +22,11 @@ const Message = forwardRef((props, ref) => {
22
22
  direction: direction === 'in' ? 'row' : 'row-reverse'
23
23
  }, item: {
24
24
  shrink: 0
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: {
25
+ }, messageDirection: direction, variant: variant, typing: typing, messageHeader: messageHeader, ...restProps, children: [avatarInfo && (_jsx(Avatar, { name: avatarInfo.name, size: 'm', shape: 'circle', imageSrc: avatarInfo.imageSrc })), _jsxs(Flex, { container: {
26
26
  direction: 'column',
27
27
  alignItems: direction === 'in' ? 'start' : 'end',
28
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 => {
29
+ }, as: StyledMessageMain, children: [_jsxs(StyledMessageBubble, { children: [messageHeader && (_jsxs(Flex, { container: { gap: 0.5, justify: 'between' }, as: StyledMessageHeader, children: [_jsx(StyledMessageHeaderContent, { children: messageHeader.content }), _jsx(StyledMessageHeaderMeta, { children: messageHeader.meta })] })), message && (_jsx(StyledMessageBubbleContent, { children: _jsx(EmojiDisplay, { content: message, size: 20 }) })), (attachments.length > 0 || pagePushLinks.length > 0) && (_jsxs(StyledMediaList, { children: [attachments.map(attachment => {
30
30
  const { id, icon, name, meta, onDownload, onPreview, thumbnail } = attachment;
31
31
  return (_jsxs(Flex, { as: StyledMediaListItem, container: {
32
32
  direction: 'column'
@@ -34,26 +34,26 @@ const Message = forwardRef((props, ref) => {
34
34
  e.preventDefault();
35
35
  e.stopPropagation();
36
36
  onPreview?.(id);
37
- }, alt: name }, void 0)), _jsx(SummaryItem, { as: StyledSummaryItem, primary: _jsx(StyledMediaButton, { onClick: (e) => {
37
+ }, alt: name })), _jsx(SummaryItem, { as: StyledSummaryItem, primary: _jsx(StyledMediaButton, { onClick: (e) => {
38
38
  e.preventDefault();
39
39
  e.stopPropagation();
40
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) => {
41
+ }, children: name }), secondary: meta, visual: _jsx(Icon, { name: icon || 'document-doc' }), actions: _jsx(BareButton, { "aria-label": t('download'), as: StyledMediaDownloadButton, onClick: (e) => {
42
42
  e.preventDefault();
43
43
  e.stopPropagation();
44
44
  onDownload?.(id);
45
- }, children: _jsx(Icon, { name: 'download' }, void 0) }, void 0) }, void 0)] }, id));
45
+ }, children: _jsx(Icon, { name: 'download' }) }) })] }, id));
46
46
  }), pagePushLinks.map(pagePushLink => {
47
47
  const { id, href, title, thumbnail } = pagePushLink;
48
48
  return (_jsxs(Flex, { as: StyledMediaListItem, container: {
49
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: {
50
+ }, children: [thumbnail && (_jsx(Image, { as: StyledMediaThumbNail, src: thumbnail, alt: title || href })), _jsx(SummaryItem, { as: StyledSummaryItem, primary: _jsx(StyledMediaLink, { "aria-label": title, href: href, target: '_blank', rel: 'noreferrer', children: href }), visual: _jsx(Icon, { name: 'chain-up' }) })] }, id));
51
+ })] }))] }), !typing && (_jsxs(Flex, { as: StyledMetaInfoContainer, container: {
52
52
  justify: messageMetaJustify,
53
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: {
54
+ }, children: [timeStamp && _jsx(StyledMetaInfo, { children: timeStamp }), status && _jsx(StyledMetaInfo, { children: status })] })), typing && (_jsxs(Flex, { container: {
55
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));
56
+ }, children: [_jsx(StyledBlinkingDot, { delay: 0 }), _jsx(StyledBlinkingDot, { delay: 0.25 }), _jsx(StyledBlinkingDot, { delay: 0.5 })] }))] })] }));
57
57
  });
58
58
  export default Message;
59
59
  //# sourceMappingURL=Message.js.map
@@ -1 +1 @@
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,M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unctionComponent, 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"]}
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,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AI,EAC/B,KAAC,iBAAiB,IAAC,KAAK,EAAE,IAAI,GAAI,EAClC,KAAC,iBAAiB,IAAC,KAAK,EAAE,GAAG,GAAI,IAC5B,CACR,IACI,IACF,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"]}
@@ -48,7 +48,7 @@ const ScrollToLatest = props => {
48
48
  scrollContainerRef.current.scrollHeight - scrollContainerRef.current.offsetHeight;
49
49
  }
50
50
  });
51
- return _jsx(_Fragment, {}, void 0);
51
+ return _jsx(_Fragment, {});
52
52
  };
53
53
  const MessageList = forwardRef((props, ref) => {
54
54
  const { messages, unReadMessageCount = 0, onScrollToButtonClick, ...restProps } = props;
@@ -102,7 +102,7 @@ const MessageList = forwardRef((props, ref) => {
102
102
  scrollToLatestMessage();
103
103
  }
104
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) => {
105
+ }, icon: unReadMessageCount === 0, children: [_jsx(Icon, { name: 'caret-down' }), unReadMessageCount > 0 && _jsxs(_Fragment, { children: ["\u00A0 ", t('new_messages')] })] })), _jsx(RepeatingView, { as: StyledMessageList, container: { direction: 'column' }, ref: conversationRef, rows: messages, onScroll: debounce(onMessageListScroll, 100), ...restProps, children: (item) => {
106
106
  const { id, type, ...messageListItemRestProps } = item;
107
107
  if (type === 'message') {
108
108
  return _jsx(Message, { ...messageListItemRestProps }, id);
@@ -117,7 +117,7 @@ const MessageList = forwardRef((props, ref) => {
117
117
  if (type === 'typing') {
118
118
  return (_jsx(TypeIndicator, { ...messageListItemRestProps }, id));
119
119
  }
120
- } }, void 0)] }, void 0), isScrolledToLatest() && _jsx(ScrollToLatest, { scrollContainerRef: conversationRef }, void 0)] }, void 0));
120
+ } })] }), isScrolledToLatest() && _jsx(ScrollToLatest, { scrollContainerRef: conversationRef })] }));
121
121
  });
122
122
  export default MessageList;
123
123
  //# sourceMappingURL=MessageList.js.map
@@ -1 +1 @@
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,CAAC;AAEvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAE7D,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;IACpD,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAC5B,MAAM,EAAE,EAAE,KAAK,EAAE,E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L,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
+ {"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,CAAC;AAEvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAE7D,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG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AE;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,GACa,IACX,EACN,kBAAkB,EAAE,IAAI,KAAC,cAAc,IAAC,kBAAkB,EAAE,eAAe,GAAI,IAC/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"]}
@@ -41,7 +41,7 @@ const RepeatingView = forwardRef((props, ref) => {
41
41
  }, as: StyledRepeatingViewUL, ref: listRef, children: [rows.map(row => {
42
42
  const { ariaLabel, ...rowRestProps } = row;
43
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));
44
+ }), isLoading && (_jsx(StyledRepeatingViewItem, { children: _jsx(Progress, { placement: 'inline' }) }, 'loader'))] }), !isLoading && rows.length === 0 && emptyView && (_jsx(StyledEmptyView, { children: emptyView }))] }));
45
45
  });
46
46
  export default RepeatingView;
47
47
  //# sourceMappingURL=RepeatingView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RepeatingView.js","sourceRoot":"","sources":["../../../src/components/Chat/RepeatingView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsC,UAAU,EAAkB,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O,EAAE,QAAQ;SAClB,EACD,QAAQ,EAAE,CAAC,EACX,EAAE,EAAE,mBAAmB,KACnB,SAAS,aAEb,MAAC,IAAI,OACC,SAAS,EACb,SAAS,EAAE;oBACT,SAAS,EAAE,eAAe,KAAK,eAAe,CAAC,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(\n listRef,\n offset,\n () => {\n loadMore?.();\n },\n ':scope > li'\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,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,YAAY,GAAG,gBAAgB,CAAC;AAExD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,EAAE,CAAA;;;;;CAK7C,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;CAE5C,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;CAMxC,CAAC;AAEF,MAAM,aAAa,GAAyD,UAAU,CACpF,CAAC,KAA0C,EAAE,GAA8B,EAAE,EAAE;IAC7E,MAAM,EACJ,QAAQ,EAAE,QAAQ,EAClB,MAAM,GAAG,CAAC,CAAC,EACX,QAAQ,EACR,OAAO,EAAE,SAAS,GAAG,KAAK,EAC1B,IAAI,GAAG,EAAE,EACT,SAAS,EACT,eAAe,GAAG,eAAe,EACjC,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACxC,mBAAmB,CACjB,OAAO,EACP,MAAM,EACN,GAAG,EAAE;QACH,QAAQ,EAAE,EAAE,CAAC;IACf,CAAC,EACD,aAAa,CACd,CAAC;IAEF,OAAO,CACL,MAAC,IAAI,IACH,SAAS,EAAE;YACT,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,QAAQ;SAClB,EACD,QAAQ,EAAE,CAAC,EACX,EAAE,EAAE,mBAAmB,KACnB,SAAS,aAEb,MAAC,IAAI,OACC,SAAS,EACb,SAAS,EAAE;oBACT,SAAS,EAAE,eAAe,KAAK,eAAe,CAAC,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,GAAG,IADJ,QAAQ,CAEX,CAC3B,IACI,EACN,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,IAAI,CAC/C,KAAC,eAAe,cAAE,SAAS,GAAmB,CAC/C,IACI,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(\n listRef,\n offset,\n () => {\n loadMore?.();\n },\n ':scope > li'\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"]}