@pega/cosmos-react-social 3.0.0-dev.2.0 → 3.0.0-dev.21.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.
- package/lib/components/Chat/Chat.js +1 -1
- package/lib/components/Chat/Chat.js.map +1 -1
- package/lib/components/Chat/ChatBody.js +1 -1
- package/lib/components/Chat/ChatBody.js.map +1 -1
- package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
- package/lib/components/Chat/ChatComposer.js +6 -6
- package/lib/components/Chat/ChatComposer.js.map +1 -1
- package/lib/components/Chat/ChatHeader.d.ts.map +1 -1
- package/lib/components/Chat/ChatHeader.js +2 -3
- package/lib/components/Chat/ChatHeader.js.map +1 -1
- package/lib/components/Chat/ChatTranscript.js +3 -3
- package/lib/components/Chat/ChatTranscript.js.map +1 -1
- package/lib/components/Chat/Message.d.ts.map +1 -1
- package/lib/components/Chat/Message.js +9 -9
- package/lib/components/Chat/Message.js.map +1 -1
- package/lib/components/Chat/Message.styles.d.ts +1 -0
- package/lib/components/Chat/Message.styles.d.ts.map +1 -1
- package/lib/components/Chat/Message.styles.js +12 -3
- package/lib/components/Chat/Message.styles.js.map +1 -1
- package/lib/components/Chat/MessageList.js +3 -3
- package/lib/components/Chat/MessageList.js.map +1 -1
- package/lib/components/Chat/RepeatingView.js +1 -1
- package/lib/components/Chat/RepeatingView.js.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.js +6 -6
- package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
- package/lib/components/Chat/SystemMessage.js +3 -3
- package/lib/components/Chat/SystemMessage.js.map +1 -1
- package/lib/components/Chat/TranscriptMessage.js +2 -2
- package/lib/components/Chat/TranscriptMessage.js.map +1 -1
- package/lib/components/Chat/TypeIndicator.js +1 -1
- package/lib/components/Chat/TypeIndicator.js.map +1 -1
- package/lib/components/Email/ContextMenuPopover.d.ts +5 -0
- package/lib/components/Email/ContextMenuPopover.d.ts.map +1 -0
- package/lib/components/Email/ContextMenuPopover.js +50 -0
- package/lib/components/Email/ContextMenuPopover.js.map +1 -0
- package/lib/components/Email/Email.d.ts.map +1 -1
- package/lib/components/Email/Email.js +107 -32
- package/lib/components/Email/Email.js.map +1 -1
- package/lib/components/Email/Email.styles.d.ts +21 -2
- package/lib/components/Email/Email.styles.d.ts.map +1 -1
- package/lib/components/Email/Email.styles.js +97 -27
- package/lib/components/Email/Email.styles.js.map +1 -1
- package/lib/components/Email/Email.types.d.ts +142 -36
- package/lib/components/Email/Email.types.d.ts.map +1 -1
- package/lib/components/Email/Email.types.js.map +1 -1
- package/lib/components/Email/EmailComposer.d.ts +1 -1
- package/lib/components/Email/EmailComposer.d.ts.map +1 -1
- package/lib/components/Email/EmailComposer.js +103 -124
- package/lib/components/Email/EmailComposer.js.map +1 -1
- package/lib/components/Email/EmailConversation.d.ts.map +1 -1
- package/lib/components/Email/EmailConversation.js +12 -7
- package/lib/components/Email/EmailConversation.js.map +1 -1
- package/lib/components/Email/EmailEntity.d.ts.map +1 -1
- package/lib/components/Email/EmailEntity.js +7 -3
- package/lib/components/Email/EmailEntity.js.map +1 -1
- package/lib/components/Email/EmailManager.d.ts +6 -0
- package/lib/components/Email/EmailManager.d.ts.map +1 -0
- package/lib/components/Email/EmailManager.js +36 -0
- package/lib/components/Email/EmailManager.js.map +1 -0
- package/lib/components/Email/EmailSelector.d.ts +5 -3
- package/lib/components/Email/EmailSelector.d.ts.map +1 -1
- package/lib/components/Email/EmailSelector.js +36 -33
- package/lib/components/Email/EmailSelector.js.map +1 -1
- package/lib/components/Email/EmailShell.d.ts.map +1 -1
- package/lib/components/Email/EmailShell.js +9 -5
- package/lib/components/Email/EmailShell.js.map +1 -1
- package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -1
- package/lib/components/Email/EmailSummaryItem.js +25 -11
- package/lib/components/Email/EmailSummaryItem.js.map +1 -1
- package/lib/components/Email/EmailSummaryList.d.ts.map +1 -1
- package/lib/components/Email/EmailSummaryList.js +53 -60
- package/lib/components/Email/EmailSummaryList.js.map +1 -1
- package/lib/components/Email/EntityList.d.ts +6 -0
- package/lib/components/Email/EntityList.d.ts.map +1 -0
- package/lib/components/Email/EntityList.js +79 -0
- package/lib/components/Email/EntityList.js.map +1 -0
- package/lib/components/Email/index.d.ts +3 -2
- package/lib/components/Email/index.d.ts.map +1 -1
- package/lib/components/Email/index.js +2 -1
- package/lib/components/Email/index.js.map +1 -1
- package/lib/components/Feed/Feed.context.d.ts +5 -0
- package/lib/components/Feed/Feed.context.d.ts.map +1 -1
- package/lib/components/Feed/Feed.context.js.map +1 -1
- package/lib/components/Feed/Feed.d.ts +5 -1
- package/lib/components/Feed/Feed.d.ts.map +1 -1
- package/lib/components/Feed/Feed.js +23 -45
- package/lib/components/Feed/Feed.js.map +1 -1
- package/lib/components/Feed/FeedAnnouncer.js +1 -1
- package/lib/components/Feed/FeedAnnouncer.js.map +1 -1
- package/lib/components/Feed/FeedAttachments.js +3 -3
- package/lib/components/Feed/FeedAttachments.js.map +1 -1
- package/lib/components/Feed/FeedContent.js +1 -1
- package/lib/components/Feed/FeedContent.js.map +1 -1
- package/lib/components/Feed/FeedLikeButton.d.ts +1 -1
- package/lib/components/Feed/FeedLikeButton.d.ts.map +1 -1
- package/lib/components/Feed/FeedLikeButton.js +10 -8
- package/lib/components/Feed/FeedLikeButton.js.map +1 -1
- package/lib/components/Feed/FeedModalList.d.ts +2 -0
- package/lib/components/Feed/FeedModalList.d.ts.map +1 -1
- package/lib/components/Feed/FeedModalList.js +25 -38
- package/lib/components/Feed/FeedModalList.js.map +1 -1
- package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPost.js +4 -4
- package/lib/components/Feed/FeedNewPost.js.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.js +8 -8
- package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
- package/lib/components/Feed/FeedPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedPost.js +43 -20
- package/lib/components/Feed/FeedPost.js.map +1 -1
- package/lib/components/Feed/FeedPost.types.d.ts +8 -2
- package/lib/components/Feed/FeedPost.types.d.ts.map +1 -1
- package/lib/components/Feed/FeedPost.types.js.map +1 -1
- package/lib/components/Feed/FeedReply.d.ts.map +1 -1
- package/lib/components/Feed/FeedReply.js +35 -13
- package/lib/components/Feed/FeedReply.js.map +1 -1
- package/lib/components/Feed/FeedReply.types.d.ts +6 -2
- package/lib/components/Feed/FeedReply.types.d.ts.map +1 -1
- package/lib/components/Feed/FeedReply.types.js.map +1 -1
- package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
- package/lib/components/Feed/FeedReplyInput.js +5 -5
- package/lib/components/Feed/FeedReplyInput.js.map +1 -1
- package/lib/components/Feed/FeedRichText.d.ts +1 -1
- package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
- package/lib/components/Feed/FeedRichText.js +18 -8
- package/lib/components/Feed/FeedRichText.js.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.js +2 -2
- package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
- package/lib/components/MentionButton/MentionButton.d.ts +2 -0
- package/lib/components/MentionButton/MentionButton.d.ts.map +1 -1
- package/lib/components/MentionButton/MentionButton.js +22 -6
- package/lib/components/MentionButton/MentionButton.js.map +1 -1
- package/package.json +16 -13
- package/lib/components/Email/ViewAnalysis.d.ts +0 -6
- package/lib/components/Email/ViewAnalysis.d.ts.map +0 -1
- package/lib/components/Email/ViewAnalysis.js +0 -20
- package/lib/components/Email/ViewAnalysis.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.styles.js","sourceRoot":"","sources":["../../../src/components/Chat/Message.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE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sB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAKvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAyB,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC3F,OAAO,GAAG,CAAA;;;sBAGU,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM;;;sBAG7B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;;;mCAGxB,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK;kBAC3C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;;uBAEhC,KAAK;;;GAGzB,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { rgba as polishedRgba } from 'polished';\n\nimport { defaultThemeProp, tryCatch } from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nexport const StyledMessageBubbleContent = styled.div``;\n\nexport const StyledMediaList = styled.ul``;\n\nexport const StyledMediaListItem = styled.li``;\n\nexport const StyledSummaryItem = styled.div``;\n\nexport const StyledMediaThumbNail = styled.img``;\n\nexport const StyledMediaDownloadButton = styled.button``;\n\nexport const StyledMediaLink = styled.a``;\n\nexport const StyledMediaButton = styled(BareButton)``;\n\nexport const StyledMessageMain = styled.div``;\n\nexport const StyledMessageBubble = styled.div``;\n\nexport const StyledMetaInfoContainer = styled.div``;\n\nexport const StyledMetaInfo = styled.span``;\n\nexport const StyledTypingIndicator = styled.div``;\n\nexport const StyledMessageHeader = styled.header``;\nexport const StyledMessageHeaderContent = styled.div``;\nexport const StyledMessageHeaderMeta = styled.div``;\n\ninterface StyledMessageContainerProps {\n variant: 'sender' | 'receiver' | 'other';\n messageDirection: 'in' | 'out' | string;\n typing: boolean;\n}\n\nexport const StyledMessageContainer = styled.div<StyledMessageContainerProps>(\n ({\n messageDirection,\n variant,\n typing,\n theme,\n theme: {\n base: {\n palette: {\n 'foreground-color': foregroundColor,\n 'secondary-background': secondaryBackground\n },\n transparency: { 'transparent-2': foregroundAlpha }\n },\n components: { button }\n }\n }) => {\n const messageHeaderTheme = theme.components.chat.messageBubble[variant].header;\n const messageContentTheme = theme.components.chat.messageBubble[variant].content;\n const padding = messageDirection === 'in' ? '0 2rem 0 0' : '0 0 0 2rem';\n const metaForegroundColor = tryCatch(() => polishedRgba(foregroundColor, foregroundAlpha));\n\n return css`\n padding: ${padding};\n margin-bottom: ${typing ? '0.5rem' : '0'};\n ${StyledMessageMain} {\n max-width: 90%;\n }\n ${StyledMessageBubble} {\n max-width: 100%;\n min-width: 100%;\n background: ${messageContentTheme['background-color']};\n border-radius: calc(3 * ${theme.base['border-radius']}) ${theme.base['border-radius']}\n calc(3 * ${theme.base['border-radius']}) calc(3 * ${theme.base['border-radius']});\n overflow: hidden;\n color: ${messageContentTheme['foreground-color']};\n display: inline-block;\n width: auto;\n margin-bottom: 0.25rem;\n\n label {\n color: inherit;\n }\n\n ${messageDirection === 'in' &&\n css`\n border-radius: ${theme.base['border-radius']} calc(3 * ${theme.base['border-radius']})\n calc(3 * ${theme.base['border-radius']}) calc(3 * ${theme.base['border-radius']});\n `}\n\n > ${StyledMessageBubbleContent} {\n padding: 0.5rem 1rem;\n word-break: break-word;\n white-space: pre-wrap;\n position: relative;\n }\n\n > ${StyledMediaList} {\n color: ${messageContentTheme['foreground-color']};\n max-width: 100%;\n\n ${StyledMediaDownloadButton} {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n color: ${messageContentTheme['foreground-color']};\n width: ${button.height};\n height: ${button.height};\n border: 0.0625rem solid transparent;\n &:enabled:hover,\n &:enabled:focus {\n background: ${messageContentTheme['background-color']};\n color: ${messageContentTheme['foreground-color']};\n border: 0.0625rem solid ${messageContentTheme['foreground-color']};\n border-radius: 50%;\n }\n svg {\n width: 50%;\n height: 50%;\n }\n }\n\n > ${StyledMediaListItem} {\n position: relative;\n ${StyledMediaThumbNail} {\n max-height: 12rem;\n width: 100%;\n object-fit: contain;\n background-color: ${secondaryBackground};\n }\n ${StyledSummaryItem} {\n padding: 0.5rem 1.5rem;\n font-size: 0.75rem;\n margin-top: 0.25rem;\n }\n ${StyledSummaryItem}::before {\n content: '';\n padding: 0.5rem 0;\n border-top: 0.0625rem solid ${messageContentTheme['foreground-color']};\n position: absolute;\n width: calc(100% - 2rem);\n left: 1rem;\n top: 0;\n }\n ${StyledMediaThumbNail} + ${StyledSummaryItem}::before {\n content: none;\n }\n svg {\n font-size: 1.6rem;\n }\n }\n }\n\n ${StyledMessageHeader} {\n padding: 0.5rem 1rem;\n color: ${messageHeaderTheme['foreground-color']};\n background-color: ${messageHeaderTheme['background-color']};\n }\n\n ${StyledMessageHeaderContent} {\n color: ${messageHeaderTheme['foreground-color']};\n margin-inline-end: ${theme.base.spacing};\n }\n ${StyledMessageHeaderMeta} {\n > a {\n color: ${messageHeaderTheme['foreground-color']};\n }\n }\n\n ${StyledMediaLink}, ${StyledMediaButton} {\n color: ${messageContentTheme['foreground-color']};\n font-size: inherit;\n text-decoration: none;\n font-weight: 700;\n overflow-x: hidden;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n max-width: 100%;\n &:hover {\n color: ${messageContentTheme['foreground-color']};\n text-decoration: underline;\n }\n &:visited {\n color: ${messageContentTheme['foreground-color']};\n }\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n }\n }\n\n ${StyledMetaInfoContainer} {\n width: 100%;\n padding: 0 0.5rem;\n ${StyledMetaInfo} {\n margin-bottom: 0.5rem;\n font-size: 0.7rem;\n color: ${metaForegroundColor};\n }\n }\n ${StyledTypingIndicator} {\n width: 4.5rem;\n position: relative;\n height: 2rem;\n }\n `;\n }\n);\nStyledMessageContainer.defaultProps = defaultThemeProp;\ninterface StyledBlinkingDotProps {\n delay?: number;\n}\n\nexport const StyledBlinkingDot = styled.div<StyledBlinkingDotProps>(({ delay = 0, theme }) => {\n return css`\n @keyframes Blinking {\n 0% {\n background: ${theme.base.colors.gray.medium};\n }\n 100% {\n background: ${theme.base.colors.gray['extra-light']};\n }\n }\n animation: Blinking calc(4 * ${theme.base.animation.speed}) infinite;\n background: ${theme.base.colors.gray['extra-light']};\n border-radius: 50%;\n animation-delay: ${delay}s;\n height: 0.4rem;\n width: 0.4rem;\n `;\n});\nStyledBlinkingDot.defaultProps = defaultThemeProp;\n"]}
|
|
1
|
+
{"version":3,"file":"Message.styles.js","sourceRoot":"","sources":["../../../src/components/Chat/Message.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAElF,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEvD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAAA,EAAE,CAAC;AAE3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAA,EAAE,CAAC;AAE/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEjD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,CAAA,EAAE,CAAC;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,CAAA,EAAE,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,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from 'styled-components';\nimport { rgba } from 'polished';\n\nimport { defaultThemeProp, tryCatch } from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nexport const StyledMessageBubbleContent = styled.div``;\n\nexport const StyledMediaList = styled.ul``;\n\nexport const StyledMediaListItem = styled.li``;\n\nexport const StyledSummaryItem = styled.div``;\n\nexport const StyledMediaThumbNail = styled.img``;\n\nexport const StyledMediaDownloadButton = styled.button``;\n\nexport const StyledMediaLink = styled.a``;\n\nexport const StyledMediaButton = styled(BareButton)``;\n\nexport const StyledMessageMain = styled.div``;\n\nexport const StyledMessageBubble = styled.div``;\n\nexport const StyledMetaInfoContainer = styled.div``;\n\nexport const StyledMetaInfo = styled.span``;\n\nexport const StyledTypingIndicator = styled.div``;\n\nexport const StyledMessageHeader = styled.header``;\nexport const StyledMessageHeaderContent = styled.div``;\nexport const StyledMessageHeaderMeta = styled.div``;\n\ninterface StyledMessageContainerProps {\n variant: 'sender' | 'receiver' | 'other';\n messageDirection: 'in' | 'out' | string;\n typing: boolean;\n hasMessage: boolean;\n}\n\nexport const StyledMessageContainer = styled.div<StyledMessageContainerProps>(\n ({\n messageDirection,\n variant,\n hasMessage,\n typing,\n theme,\n theme: {\n base: {\n palette: {\n 'foreground-color': foregroundColor,\n 'secondary-background': secondaryBackground\n },\n transparency: { 'transparent-2': foregroundAlpha }\n },\n components: { button }\n }\n }) => {\n const messageHeaderTheme = theme.components.chat.messageBubble[variant].header;\n const messageContentTheme = theme.components.chat.messageBubble[variant].content;\n const padding = messageDirection === 'in' ? '0 2rem 0 0' : '0 0 0 2rem';\n const metaForegroundColor = tryCatch(() => rgba(foregroundColor, foregroundAlpha));\n\n return css`\n padding: ${padding};\n margin-bottom: ${typing ? '0.5rem' : '0'};\n ${StyledMessageMain} {\n max-width: 90%;\n }\n ${StyledMessageBubble} {\n max-width: 100%;\n min-width: 100%;\n background: ${messageContentTheme['background-color']};\n border-radius: calc(3 * ${theme.base['border-radius']}) ${theme.base['border-radius']}\n calc(3 * ${theme.base['border-radius']}) calc(3 * ${theme.base['border-radius']});\n overflow: hidden;\n color: ${messageContentTheme['foreground-color']};\n display: inline-block;\n width: auto;\n margin-bottom: 0.25rem;\n\n label {\n color: inherit;\n }\n\n ${messageDirection === 'in' &&\n css`\n border-radius: ${theme.base['border-radius']} calc(3 * ${theme.base['border-radius']})\n calc(3 * ${theme.base['border-radius']}) calc(3 * ${theme.base['border-radius']});\n `}\n\n > ${StyledMessageBubbleContent} {\n padding: 0.5rem 1rem;\n word-break: break-word;\n white-space: pre-wrap;\n position: relative;\n }\n\n > ${StyledMediaList} {\n color: ${messageContentTheme['foreground-color']};\n max-width: 100%;\n\n ${StyledMediaDownloadButton} {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n color: ${messageContentTheme['foreground-color']};\n width: ${button.height};\n height: ${button.height};\n border: 0.0625rem solid transparent;\n &:enabled:hover,\n &:enabled:focus {\n background: ${messageContentTheme['background-color']};\n color: ${messageContentTheme['foreground-color']};\n border: 0.0625rem solid ${messageContentTheme['foreground-color']};\n border-radius: 50%;\n }\n svg {\n width: 50%;\n height: 50%;\n }\n }\n\n > ${StyledMediaListItem} {\n position: relative;\n ${StyledMediaThumbNail} {\n max-height: 12rem;\n width: 100%;\n object-fit: contain;\n background-color: ${secondaryBackground};\n }\n ${StyledSummaryItem} {\n padding: 0.5rem 1.5rem;\n font-size: 0.75rem;\n margin-top: 0.25rem;\n }\n ${StyledSummaryItem}::before {\n content: '';\n padding: 0.5rem 0;\n border-top: 0.0625rem solid ${messageContentTheme['foreground-color']};\n position: absolute;\n width: calc(100% - 2rem);\n left: 1rem;\n top: 0;\n }\n ${StyledMediaThumbNail} + ${StyledSummaryItem}::before {\n content: none;\n }\n svg {\n font-size: 1.6rem;\n }\n }\n\n ${!hasMessage &&\n css`\n > ${StyledMediaListItem}:first-child {\n > ${StyledSummaryItem}::before {\n border-top: none;\n }\n }\n `}\n }\n\n ${StyledMessageHeader} {\n padding: 0.5rem 1rem;\n color: ${messageHeaderTheme['foreground-color']};\n background-color: ${messageHeaderTheme['background-color']};\n }\n\n ${StyledMessageHeaderContent} {\n color: ${messageHeaderTheme['foreground-color']};\n margin-inline-end: ${theme.base.spacing};\n }\n ${StyledMessageHeaderMeta} {\n > a {\n color: ${messageHeaderTheme['foreground-color']};\n }\n }\n\n ${StyledMediaLink}, ${StyledMediaButton} {\n color: ${messageContentTheme['foreground-color']};\n font-size: inherit;\n text-decoration: none;\n font-weight: 700;\n overflow-x: hidden;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n max-width: 100%;\n &:hover {\n color: ${messageContentTheme['foreground-color']};\n text-decoration: underline;\n }\n &:visited {\n color: ${messageContentTheme['foreground-color']};\n }\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n }\n }\n\n ${StyledMetaInfoContainer} {\n width: 100%;\n padding: 0 0.5rem;\n ${StyledMetaInfo} {\n margin-bottom: 0.5rem;\n font-size: 0.7rem;\n color: ${metaForegroundColor};\n }\n }\n ${StyledTypingIndicator} {\n width: 4.5rem;\n position: relative;\n height: 2rem;\n }\n `;\n }\n);\nStyledMessageContainer.defaultProps = defaultThemeProp;\ninterface StyledBlinkingDotProps {\n delay?: number;\n}\n\nexport const StyledBlinkingDot = styled.div<StyledBlinkingDotProps>(({ delay = 0, theme }) => {\n return css`\n @keyframes Blinking {\n 0% {\n background: ${theme.base.colors.gray.medium};\n }\n 100% {\n background: ${theme.base.colors.gray['extra-light']};\n }\n }\n animation: Blinking calc(4 * ${theme.base.animation.speed}) infinite;\n background: ${theme.base.colors.gray['extra-light']};\n border-radius: 50%;\n animation-delay: ${delay}s;\n height: 0.4rem;\n width: 0.4rem;\n `;\n});\nStyledBlinkingDot.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -48,7 +48,7 @@ const ScrollToLatest = props => {
|
|
|
48
48
|
scrollContainerRef.current.scrollHeight - scrollContainerRef.current.offsetHeight;
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
-
return _jsx(_Fragment, {}
|
|
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' }
|
|
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
|
-
} }
|
|
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,MAA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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 && <> {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":["../../../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E,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 && <> {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' }
|
|
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,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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} 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"]}
|
|
@@ -40,13 +40,13 @@ const SuggestedReplyPicker = forwardRef((props, ref) => {
|
|
|
40
40
|
}, children: [_jsxs(Flex, { container: {
|
|
41
41
|
alignItems: 'center',
|
|
42
42
|
gap: 1
|
|
43
|
-
}, children: [_jsx(Icon, { name: 'bulb-solid', as: StyledSuggestedReplyIcon }
|
|
43
|
+
}, children: [_jsx(Icon, { name: 'bulb-solid', as: StyledSuggestedReplyIcon }), currentReply && (_jsxs(_Fragment, { children: [_jsx(Text, { variant: 'h3', children: t('suggested_replies_current_of_total', [
|
|
44
44
|
replies.indexOf(currentReply) + 1,
|
|
45
45
|
replies.length
|
|
46
|
-
]) }
|
|
46
|
+
]) }), _jsx(Text, { variant: 'secondary', children: t('confidence_percentage', [currentReply.confidence]) })] }))] }), _jsx(Button, { icon: true, variant: 'simple', onClick: onDismiss, "aria-label": t('dismiss_suggested_replies'), children: _jsx(Icon, { name: 'times' }) })] }), _jsxs(Flex, { container: {
|
|
47
47
|
direction: 'column',
|
|
48
48
|
gap: 1
|
|
49
|
-
}, as: StyledSuggestedReplyContent, children: [currentReply && _jsx("div", { children: currentReply.message }
|
|
49
|
+
}, as: StyledSuggestedReplyContent, children: [currentReply && _jsx("div", { children: currentReply.message }), _jsxs(Flex, { container: {
|
|
50
50
|
justify: 'center'
|
|
51
51
|
}, children: [_jsx(Button, { icon: true, "aria-label": t('prev_suggested_reply'), variant: 'simple', disabled: currentReply === null || replies.indexOf(currentReply) === 0, onClick: () => {
|
|
52
52
|
setCurrentReply(prevCurrentReply => {
|
|
@@ -58,11 +58,11 @@ const SuggestedReplyPicker = forwardRef((props, ref) => {
|
|
|
58
58
|
}
|
|
59
59
|
return null;
|
|
60
60
|
});
|
|
61
|
-
}, children: _jsx(Icon, { name: 'caret-left' }
|
|
61
|
+
}, children: _jsx(Icon, { name: 'caret-left' }) }), _jsx(Button, { disabled: currentReply === null, onClick: () => {
|
|
62
62
|
if (currentReply) {
|
|
63
63
|
onSelect(currentReply);
|
|
64
64
|
}
|
|
65
|
-
}, children: t('use') }
|
|
65
|
+
}, children: t('use') }), _jsx(Button, { icon: true, "aria-label": t('next_suggested_reply'), variant: 'simple', disabled: currentReply === null || replies.indexOf(currentReply) === replies.length - 1, onClick: () => {
|
|
66
66
|
setCurrentReply(prevCurrentReply => {
|
|
67
67
|
if (prevCurrentReply) {
|
|
68
68
|
const prevCurrentReplyIndex = replies.indexOf(prevCurrentReply);
|
|
@@ -72,7 +72,7 @@ const SuggestedReplyPicker = forwardRef((props, ref) => {
|
|
|
72
72
|
}
|
|
73
73
|
return null;
|
|
74
74
|
});
|
|
75
|
-
}, children: _jsx(Icon, { name: 'caret-right' }
|
|
75
|
+
}, children: _jsx(Icon, { name: 'caret-right' }) })] })] })] }));
|
|
76
76
|
});
|
|
77
77
|
export default SuggestedReplyPicker;
|
|
78
78
|
//# sourceMappingURL=SuggestedReplyPicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestedReplyPicker.js","sourceRoot":"","sources":["../../../src/components/Chat/SuggestedReplyPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mB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IAAI,gBAAgB,EAAE;4CACpB,MAAM,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;4CAChE,IAAI,qBAAqB,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE;gDAC/C,OAAO,OAAO,CAAC,qBAAqB,GAAG,CAAC,CAAC,CAAC;6CAC3C;yCACF;wCACD,OAAO,IAAI,CAAC;oCACd,CAAC,CAAC,CAAC;gCACL,CAAC,YAED,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,WAAG,WACpB,YACJ,YACF,YACuB,CACjC,CAAC;AACJ,CAAC,CACF,CAAC;AAEJ,eAAe,oBAAoB,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, useEffect, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Icon,\n registerIcon,\n Button,\n Text,\n useI18n,\n defaultThemeProp,\n ForwardProps\n} from '@pega/cosmos-react-core';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';\n\nregisterIcon(timesIcon, caretLeftIcon, caretRightIcon);\n\nexport const StyledSuggestedReplyHeader = styled.div``;\nexport const StyledSuggestedReplyContent = styled.div``;\nexport const StyledSuggestedReplyIcon = styled.svg``;\n\nconst StyledSuggestedReplyContainer = styled.div(props => {\n const { theme } = props;\n return css`\n border-top: 0.0625rem solid ${theme.base.palette['border-line']};\n background-color: ${theme.base.palette['primary-background']};\n > ${StyledSuggestedReplyHeader} {\n ${StyledSuggestedReplyIcon} {\n font-size: 1.2rem;\n }\n padding: 0.5rem;\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n > ${StyledSuggestedReplyContent} {\n padding: 1rem;\n }\n `;\n});\n\nStyledSuggestedReplyContainer.defaultProps = defaultThemeProp;\n\nexport interface SuggestedReply {\n /** Id for this suggested reply */\n id: string;\n /** Suggested reply message */\n message: string;\n /** Confidence of this suggested reply */\n confidence: number;\n}\n\nexport interface SuggestedReplyPickerProps {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Suggested replies */\n replies?: SuggestedReply[];\n /** Callback for the event when a suggested reply is selected */\n onSelect: (suggestedReply: SuggestedReply) => void;\n /** Callback for the event close button is clicked */\n onDismiss: () => void;\n}\n\nconst SuggestedReplyPicker: FunctionComponent<SuggestedReplyPickerProps & ForwardProps> =\n forwardRef(\n (props: PropsWithoutRef<SuggestedReplyPickerProps>, ref: SuggestedReplyPickerProps['ref']) => {\n const { replies = [], onSelect, onDismiss, ...restProps } = props;\n const [currentReply, setCurrentReply] = useState<SuggestedReply | null>(null);\n\n useEffect(() => {\n setCurrentReply(replies.length > 0 ? replies[0] : null);\n }, [replies]);\n\n const t = useI18n();\n return (\n <StyledSuggestedReplyContainer ref={ref} {...restProps}>\n <Flex\n as={StyledSuggestedReplyHeader}\n container={{\n justify: 'between',\n alignContent: 'center'\n }}\n >\n <Flex\n container={{\n alignItems: 'center',\n gap: 1\n }}\n >\n <Icon name='bulb-solid' as={StyledSuggestedReplyIcon} />\n {currentReply && (\n <>\n <Text variant='h3'>\n {t('suggested_replies_current_of_total', [\n replies.indexOf(currentReply) + 1,\n replies.length\n ])}\n </Text>\n <Text variant='secondary'>\n {t('confidence_percentage', [currentReply.confidence])}\n </Text>\n </>\n )}\n </Flex>\n <Button\n icon\n variant='simple'\n onClick={onDismiss}\n aria-label={t('dismiss_suggested_replies')}\n >\n <Icon name='times' />\n </Button>\n </Flex>\n <Flex\n container={{\n direction: 'column',\n gap: 1\n }}\n as={StyledSuggestedReplyContent}\n >\n {currentReply && <div>{currentReply.message}</div>}\n <Flex\n container={{\n justify: 'center'\n }}\n >\n <Button\n icon\n aria-label={t('prev_suggested_reply')}\n variant='simple'\n disabled={currentReply === null || replies.indexOf(currentReply) === 0}\n onClick={() => {\n setCurrentReply(prevCurrentReply => {\n if (prevCurrentReply) {\n const prevCurrentReplyIndex = replies.indexOf(prevCurrentReply);\n if (prevCurrentReplyIndex - 1 >= 0 && replies.length > 0) {\n return replies[prevCurrentReplyIndex - 1];\n }\n }\n return null;\n });\n }}\n >\n <Icon name='caret-left' />\n </Button>\n <Button\n disabled={currentReply === null}\n onClick={() => {\n if (currentReply) {\n onSelect(currentReply);\n }\n }}\n >\n {t('use')}\n </Button>\n <Button\n icon\n aria-label={t('next_suggested_reply')}\n variant='simple'\n disabled={\n currentReply === null || replies.indexOf(currentReply) === replies.length - 1\n }\n onClick={() => {\n setCurrentReply(prevCurrentReply => {\n if (prevCurrentReply) {\n const prevCurrentReplyIndex = replies.indexOf(prevCurrentReply);\n if (prevCurrentReplyIndex + 1 <= replies.length) {\n return replies[prevCurrentReplyIndex + 1];\n }\n }\n return null;\n });\n }}\n >\n <Icon name='caret-right' />\n </Button>\n </Flex>\n </Flex>\n </StyledSuggestedReplyContainer>\n );\n }\n );\n\nexport default SuggestedReplyPicker;\n"]}
|
|
1
|
+
{"version":3,"file":"SuggestedReplyPicker.js","sourceRoot":"","sources":["../../../src/components/Chat/SuggestedReplyPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,IAAI,EACJ,OAAO,EACP,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAC1F,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AACnG,OAAO,KAAK,cAAc,MAAM,oEAAoE,CAAC;AAErG,YAAY,CAAC,SAAS,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AAEvD,M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pB,IACJ,IACF,IACuB,CACjC,CAAC;AACJ,CAAC,CACF,CAAC;AAEJ,eAAe,oBAAoB,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, useEffect, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Icon,\n registerIcon,\n Button,\n Text,\n useI18n,\n defaultThemeProp,\n ForwardProps\n} from '@pega/cosmos-react-core';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';\n\nregisterIcon(timesIcon, caretLeftIcon, caretRightIcon);\n\nexport const StyledSuggestedReplyHeader = styled.div``;\nexport const StyledSuggestedReplyContent = styled.div``;\nexport const StyledSuggestedReplyIcon = styled.svg``;\n\nconst StyledSuggestedReplyContainer = styled.div(props => {\n const { theme } = props;\n return css`\n border-top: 0.0625rem solid ${theme.base.palette['border-line']};\n background-color: ${theme.base.palette['primary-background']};\n > ${StyledSuggestedReplyHeader} {\n ${StyledSuggestedReplyIcon} {\n font-size: 1.2rem;\n }\n padding: 0.5rem;\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n > ${StyledSuggestedReplyContent} {\n padding: 1rem;\n }\n `;\n});\n\nStyledSuggestedReplyContainer.defaultProps = defaultThemeProp;\n\nexport interface SuggestedReply {\n /** Id for this suggested reply */\n id: string;\n /** Suggested reply message */\n message: string;\n /** Confidence of this suggested reply */\n confidence: number;\n}\n\nexport interface SuggestedReplyPickerProps {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Suggested replies */\n replies?: SuggestedReply[];\n /** Callback for the event when a suggested reply is selected */\n onSelect: (suggestedReply: SuggestedReply) => void;\n /** Callback for the event close button is clicked */\n onDismiss: () => void;\n}\n\nconst SuggestedReplyPicker: FunctionComponent<SuggestedReplyPickerProps & ForwardProps> =\n forwardRef(\n (props: PropsWithoutRef<SuggestedReplyPickerProps>, ref: SuggestedReplyPickerProps['ref']) => {\n const { replies = [], onSelect, onDismiss, ...restProps } = props;\n const [currentReply, setCurrentReply] = useState<SuggestedReply | null>(null);\n\n useEffect(() => {\n setCurrentReply(replies.length > 0 ? replies[0] : null);\n }, [replies]);\n\n const t = useI18n();\n return (\n <StyledSuggestedReplyContainer ref={ref} {...restProps}>\n <Flex\n as={StyledSuggestedReplyHeader}\n container={{\n justify: 'between',\n alignContent: 'center'\n }}\n >\n <Flex\n container={{\n alignItems: 'center',\n gap: 1\n }}\n >\n <Icon name='bulb-solid' as={StyledSuggestedReplyIcon} />\n {currentReply && (\n <>\n <Text variant='h3'>\n {t('suggested_replies_current_of_total', [\n replies.indexOf(currentReply) + 1,\n replies.length\n ])}\n </Text>\n <Text variant='secondary'>\n {t('confidence_percentage', [currentReply.confidence])}\n </Text>\n </>\n )}\n </Flex>\n <Button\n icon\n variant='simple'\n onClick={onDismiss}\n aria-label={t('dismiss_suggested_replies')}\n >\n <Icon name='times' />\n </Button>\n </Flex>\n <Flex\n container={{\n direction: 'column',\n gap: 1\n }}\n as={StyledSuggestedReplyContent}\n >\n {currentReply && <div>{currentReply.message}</div>}\n <Flex\n container={{\n justify: 'center'\n }}\n >\n <Button\n icon\n aria-label={t('prev_suggested_reply')}\n variant='simple'\n disabled={currentReply === null || replies.indexOf(currentReply) === 0}\n onClick={() => {\n setCurrentReply(prevCurrentReply => {\n if (prevCurrentReply) {\n const prevCurrentReplyIndex = replies.indexOf(prevCurrentReply);\n if (prevCurrentReplyIndex - 1 >= 0 && replies.length > 0) {\n return replies[prevCurrentReplyIndex - 1];\n }\n }\n return null;\n });\n }}\n >\n <Icon name='caret-left' />\n </Button>\n <Button\n disabled={currentReply === null}\n onClick={() => {\n if (currentReply) {\n onSelect(currentReply);\n }\n }}\n >\n {t('use')}\n </Button>\n <Button\n icon\n aria-label={t('next_suggested_reply')}\n variant='simple'\n disabled={\n currentReply === null || replies.indexOf(currentReply) === replies.length - 1\n }\n onClick={() => {\n setCurrentReply(prevCurrentReply => {\n if (prevCurrentReply) {\n const prevCurrentReplyIndex = replies.indexOf(prevCurrentReply);\n if (prevCurrentReplyIndex + 1 <= replies.length) {\n return replies[prevCurrentReplyIndex + 1];\n }\n }\n return null;\n });\n }}\n >\n <Icon name='caret-right' />\n </Button>\n </Flex>\n </Flex>\n </StyledSuggestedReplyContainer>\n );\n }\n );\n\nexport default SuggestedReplyPicker;\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { rgba
|
|
4
|
+
import { rgba } from 'polished';
|
|
5
5
|
import { Flex, tryCatch, defaultThemeProp } from '@pega/cosmos-react-core';
|
|
6
6
|
export const StyledSystemMessage = styled.div(({ theme: { base: { palette: { 'foreground-color': foregroundColor }, transparency: { 'transparent-3': foregroundAlpha } }, components: { chat: { messageBubble: { sender: { content: { 'background-color': primarySystemMessageColor } } } } } }, variant }) => {
|
|
7
7
|
const systemMessageForeGroundColor = variant === 'primary'
|
|
8
8
|
? primarySystemMessageColor
|
|
9
|
-
: tryCatch(() =>
|
|
9
|
+
: tryCatch(() => rgba(foregroundColor, foregroundAlpha));
|
|
10
10
|
return css `
|
|
11
11
|
color: ${systemMessageForeGroundColor};
|
|
12
12
|
font-size: 0.75rem;
|
|
@@ -34,7 +34,7 @@ const SystemMessage = forwardRef((props, ref) => {
|
|
|
34
34
|
alignItems: 'center'
|
|
35
35
|
}, item: {
|
|
36
36
|
shrink: 0
|
|
37
|
-
}, variant: variant, ...restProps, children: [timeStamp && `${timeStamp}: `, " ", message] }
|
|
37
|
+
}, variant: variant, ...restProps, children: [timeStamp && `${timeStamp}: `, " ", message] }));
|
|
38
38
|
});
|
|
39
39
|
export default SystemMessage;
|
|
40
40
|
//# sourceMappingURL=SystemMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SystemMessage.js","sourceRoot":"","sources":["../../../src/components/Chat/SystemMessage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAmC,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"SystemMessage.js","sourceRoot":"","sources":["../../../src/components/Chat/SystemMessage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAmC,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAiBjC,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAC3C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EAAE,EAAE,kBAAkB,EAAE,eAAe,EAAE,EAChD,YAAY,EAAE,EAAE,eAAe,EAAE,eAAe,EAAE,EACnD,EACD,UAAU,EAAE,EACV,IAAI,EAAE,EACJ,aAAa,EAAE,EACb,MAAM,EAAE,EACN,OAAO,EAAE,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,EAC3D,EACF,EACF,EACF,EACF,EACD,OAAO,EACR,EAAE,EAAE;IACH,MAAM,4BAA4B,GAChC,OAAO,KAAK,SAAS;QACnB,CAAC,CAAC,yBAAyB;QAC3B,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC;IAC7D,OAAO,GAAG,CAAA;eACC,4BAA4B;;;;;;;sCAOL,4BAA4B;;;;;;;;;;KAU7D,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,mBAAmB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEpD,MAAM,aAAa,GAAyD,UAAU,CACpF,CAAC,KAA0C,EAAE,GAA8B,EAAE,EAAE;IAC7E,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,WAAW,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAC1E,OAAO,CACL,MAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,mBAAmB,EACvB,SAAS,EAAE;YACT,UAAU,EAAE,QAAQ;SACrB,EACD,IAAI,EAAE;YACJ,MAAM,EAAE,CAAC;SACV,EACD,OAAO,EAAE,OAAO,KACZ,SAAS,aAEZ,SAAS,IAAI,GAAG,SAAS,IAAI,OAAG,OAAO,IACnC,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, PropsWithoutRef, ReactNode, Ref } from 'react';\nimport styled, { css } from 'styled-components';\nimport { rgba } from 'polished';\n\nimport {\n Flex,\n tryCatch,\n defaultThemeProp,\n ForwardProps,\n PropsWithDefaults\n} from '@pega/cosmos-react-core';\n\nexport interface SystemMessageProps {\n /** Ref to the container element */\n ref?: Ref<HTMLDivElement>;\n /** System message to be displayed */\n message: ReactNode;\n /** timestamp of the message(Formatted) */\n timeStamp?: string;\n /** variant of this system message\n * @default \"secondary\"\n */\n variant?: 'primary' | 'secondary';\n}\n\ntype SystemMessagePropsWithDefaults = PropsWithDefaults<SystemMessageProps, 'variant'>;\n\nexport const StyledSystemMessage = styled.div<Pick<SystemMessagePropsWithDefaults, 'variant'>>(\n ({\n theme: {\n base: {\n palette: { 'foreground-color': foregroundColor },\n transparency: { 'transparent-3': foregroundAlpha }\n },\n components: {\n chat: {\n messageBubble: {\n sender: {\n content: { 'background-color': primarySystemMessageColor }\n }\n }\n }\n }\n },\n variant\n }) => {\n const systemMessageForeGroundColor =\n variant === 'primary'\n ? primarySystemMessageColor\n : tryCatch(() => rgba(foregroundColor, foregroundAlpha));\n return css`\n color: ${systemMessageForeGroundColor};\n font-size: 0.75rem;\n padding: 0 0 0.5rem;\n ::before,\n ::after {\n display: inline-flex;\n content: '';\n border-top: 0.0625rem solid ${systemMessageForeGroundColor};\n flex-grow: 1;\n min-width: 1.5rem;\n }\n ::before {\n margin: 0 0.5rem 0 0;\n }\n ::after {\n margin: 0 0 0 0.5rem;\n }\n `;\n }\n);\n\nStyledSystemMessage.defaultProps = defaultThemeProp;\n\nconst SystemMessage: FunctionComponent<SystemMessageProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<SystemMessageProps>, ref: SystemMessageProps['ref']) => {\n const { message, timeStamp, variant = 'secondary', ...restProps } = props;\n return (\n <Flex\n ref={ref}\n as={StyledSystemMessage}\n container={{\n alignItems: 'center'\n }}\n item={{\n shrink: 0\n }}\n variant={variant}\n {...restProps}\n >\n {timeStamp && `${timeStamp}: `} {message}\n </Flex>\n );\n }\n);\n\nexport default SystemMessage;\n"]}
|
|
@@ -39,9 +39,9 @@ const TranscriptMessage = forwardRef((props, ref) => {
|
|
|
39
39
|
alignItems: 'start'
|
|
40
40
|
}, item: {
|
|
41
41
|
shrink: 0
|
|
42
|
-
}, ref: ref, as: StyledTranscriptMessage, ...restProps, children: [_jsx(Text, { as: StyledTranscriptTimeStamp, variant: 'secondary', children: timeStamp }
|
|
42
|
+
}, ref: ref, as: StyledTranscriptMessage, ...restProps, children: [_jsx(Text, { as: StyledTranscriptTimeStamp, variant: 'secondary', children: timeStamp }), avatarInfo ? (_jsx(Avatar, { name: avatarInfo.name, size: 's', shape: 'circle', imageSrc: avatarInfo.imageSrc })) : (_jsx(Icon, { as: StyledTranscriptIcon, name: iconMapping[variant] })), _jsxs(Flex, { item: {
|
|
43
43
|
grow: 1
|
|
44
|
-
}, children: [transcriptHeader && transcriptHeader.content && (_jsxs(StyledTranscriptHeader, { children: [_jsx(StyledTranscriptHeaderContent, { children: transcriptHeader.content }
|
|
44
|
+
}, children: [transcriptHeader && transcriptHeader.content && (_jsxs(StyledTranscriptHeader, { children: [_jsx(StyledTranscriptHeaderContent, { children: transcriptHeader.content }), transcriptHeader.meta] })), _jsx(EmojiDisplay, { content: message, size: 20 })] })] }));
|
|
45
45
|
});
|
|
46
46
|
export default TranscriptMessage;
|
|
47
47
|
//# sourceMappingURL=TranscriptMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranscriptMessage.js","sourceRoot":"","sources":["../../../src/components/Chat/TranscriptMessage.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,EAEJ,MAAM,EACN,YAAY,EACZ,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AAwBjC,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,aAAa;IAClB,QAAQ,EAAE,MAAM;CACjB,CAAC;AAEF,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAE1C,MAAM,yBAAyB,GAAG,MAAM,CAAC,IAAI,CAAA,EAAE,CAAC;AAEhD,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAA,EAAE,CAAC;AAE/C,MAAM,6BAA6B,GAAG,MAAM,CAAC,IAAI,CAAA,EAAE,CAAC;AAEpD,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CACxC,CAAC,EACC,KAAK,EAAE,EACL,UAAU,EAAE,EACV,IAAI,EAAE,EACJ,UAAU,EAAE,EACV,OAAO,EAAE,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,EAC1D,EACF,EACF,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;;;;QAIN,oB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AAoB,EAAE,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,GAAI,CAC/D,EACD,MAAC,IAAI,IACH,IAAI,EAAE;oBACJ,IAAI,EAAE,CAAC;iBACR,aAEA,gBAAgB,IAAI,gBAAgB,CAAC,OAAO,IAAI,CAC/C,MAAC,sBAAsB,eACrB,KAAC,6BAA6B,cAC3B,gBAAgB,CAAC,OAAO,GACK,EAC/B,gBAAgB,CAAC,IAAI,IACC,CAC1B,EACD,KAAC,YAAY,IAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAI,IACvC,IACF,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n Text,\n Icon,\n AvatarProps,\n Avatar,\n EmojiDisplay,\n defaultThemeProp,\n ForwardProps\n} from '@pega/cosmos-react-core';\n\nexport type TranscriptHeaderProps = {\n /** transcript header content */\n content?: ReactNode;\n /** meta data */\n meta?: ReactNode;\n};\n\nexport interface TranscriptMessageProps {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Timestamp */\n timeStamp: string;\n /** Transcript content */\n message: ReactNode;\n /** Variant of transcript item */\n variant: 'user' | 'bot' | 'question';\n /** Avatar information, can be image and name */\n avatarInfo?: Pick<AvatarProps, 'name' | 'imageSrc'>;\n /** Transcript header */\n transcriptHeader?: TranscriptHeaderProps;\n}\n\nconst iconMapping = {\n user: 'user-solid',\n bot: 'robot-solid',\n question: 'help'\n};\n\nconst StyledTranscriptIcon = styled.svg``;\n\nconst StyledTranscriptTimeStamp = styled.span``;\n\nconst StyledTranscriptHeader = styled.header``;\n\nconst StyledTranscriptHeaderContent = styled.span``;\n\nconst StyledTranscriptMessage = styled.div(\n ({\n theme: {\n components: {\n chat: {\n transcript: {\n message: { 'icon-foreground-color': iconForegroundColor }\n }\n }\n }\n }\n }) => {\n return css`\n width: 100%;\n line-height: 1rem;\n padding: 0 0 0.25rem;\n ${StyledTranscriptIcon} {\n color: ${iconForegroundColor};\n flex-shrink: 0;\n }\n ${StyledTranscriptTimeStamp} {\n flex-shrink: 0;\n }\n ${StyledTranscriptHeader} {\n margin-bottom: 0.25rem;\n }\n ${StyledTranscriptHeaderContent} {\n margin-right: 0.5rem;\n }\n `;\n }\n);\nStyledTranscriptMessage.defaultProps = defaultThemeProp;\n\nconst TranscriptMessage: FunctionComponent<TranscriptMessageProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<TranscriptMessageProps>, ref: TranscriptMessageProps['ref']) => {\n const { variant, transcriptHeader, message, timeStamp, avatarInfo, ...restProps } = props;\n\n return (\n <Flex\n container={{\n gap: 2,\n alignItems: 'start'\n }}\n item={{\n shrink: 0\n }}\n ref={ref}\n as={StyledTranscriptMessage}\n {...restProps}\n >\n <Text as={StyledTranscriptTimeStamp} variant='secondary'>\n {timeStamp}\n </Text>\n {avatarInfo ? (\n <Avatar name={avatarInfo.name} size='s' shape='circle' imageSrc={avatarInfo.imageSrc} />\n ) : (\n <Icon as={StyledTranscriptIcon} name={iconMapping[variant]} />\n )}\n <Flex\n item={{\n grow: 1\n }}\n >\n {transcriptHeader && transcriptHeader.content && (\n <StyledTranscriptHeader>\n <StyledTranscriptHeaderContent>\n {transcriptHeader.content}\n </StyledTranscriptHeaderContent>\n {transcriptHeader.meta}\n </StyledTranscriptHeader>\n )}\n <EmojiDisplay content={message} size={20} />\n </Flex>\n </Flex>\n );\n }\n);\n\nexport default TranscriptMessage;\n"]}
|
|
@@ -3,7 +3,7 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
import Message from './Message';
|
|
4
4
|
const TypeIndicator = forwardRef((props, ref) => {
|
|
5
5
|
const { avatarInfo, message, ...restProps } = props;
|
|
6
|
-
return (_jsx(Message, { variant: 'receiver', direction: 'in', avatarInfo: avatarInfo, typing: true, ref: ref, message: message, ...restProps }
|
|
6
|
+
return (_jsx(Message, { variant: 'receiver', direction: 'in', avatarInfo: avatarInfo, typing: true, ref: ref, message: message, ...restProps }));
|
|
7
7
|
});
|
|
8
8
|
export default TypeIndicator;
|
|
9
9
|
//# sourceMappingURL=TypeIndicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeIndicator.js","sourceRoot":"","sources":["../../../src/components/Chat/TypeIndicator.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAwB,MAAM,OAAO,CAAC;AAI5E,OAAO,OAAO,MAAM,WAAW,CAAC;AAWhC,MAAM,aAAa,GAAyD,UAAU,CACpF,CAAC,KAA0C,EAAE,GAA8B,EAAE,EAAE;IAC7E,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACpD,OAAO,CACL,KAAC,OAAO,IACN,OAAO,EAAC,UAAU,EAClB,SAAS,EAAC,IAAI,EACd,UAAU,EAAE,UAAU,EACtB,MAAM,QACN,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,OAAO,KACZ,SAAS,
|
|
1
|
+
{"version":3,"file":"TypeIndicator.js","sourceRoot":"","sources":["../../../src/components/Chat/TypeIndicator.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAwB,MAAM,OAAO,CAAC;AAI5E,OAAO,OAAO,MAAM,WAAW,CAAC;AAWhC,MAAM,aAAa,GAAyD,UAAU,CACpF,CAAC,KAA0C,EAAE,GAA8B,EAAE,EAAE;IAC7E,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACpD,OAAO,CACL,KAAC,OAAO,IACN,OAAO,EAAC,UAAU,EAClB,SAAS,EAAC,IAAI,EACd,UAAU,EAAE,UAAU,EACtB,MAAM,QACN,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,OAAO,KACZ,SAAS,GACb,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, PropsWithoutRef, Ref } from 'react';\n\nimport { AvatarProps, ForwardProps } from '@pega/cosmos-react-core';\n\nimport Message from './Message';\n\nexport interface TypeIndicatorProps {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Avatar information, can be image and name */\n avatarInfo: Pick<AvatarProps, 'name' | 'imageSrc'>;\n /** Type ahead message */\n message?: string;\n}\n\nconst TypeIndicator: FunctionComponent<TypeIndicatorProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<TypeIndicatorProps>, ref: TypeIndicatorProps['ref']) => {\n const { avatarInfo, message, ...restProps } = props;\n return (\n <Message\n variant='receiver'\n direction='in'\n avatarInfo={avatarInfo}\n typing\n ref={ref}\n message={message}\n {...restProps}\n />\n );\n }\n);\n\nexport default TypeIndicator;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenuPopover.d.ts","sourceRoot":"","sources":["../../../src/components/Email/ContextMenuPopover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA2C,MAAM,OAAO,CAAC;AASnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,uBAAuB,CAyElE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { Popover, Menu, Text, useI18n } from '@pega/cosmos-react-core';
|
|
4
|
+
import { StyledEmailMoreInfoPopover, StyledContextMenuFieldSelector, StyledContextMenu } from './Email.styles';
|
|
5
|
+
const ContextMenuPopover = forwardRef(({ cursorPosition, contextMenu, targetNode, show }, ref) => {
|
|
6
|
+
const t = useI18n();
|
|
7
|
+
const selection = document.getSelection();
|
|
8
|
+
if (selection && !selection.toString() && targetNode) {
|
|
9
|
+
const range = document.createRange();
|
|
10
|
+
range.selectNodeContents(targetNode);
|
|
11
|
+
selection?.removeAllRanges();
|
|
12
|
+
selection.addRange(range);
|
|
13
|
+
}
|
|
14
|
+
const { onItemClick, items } = contextMenu;
|
|
15
|
+
const onItemSelect = (contextMenuItemId, e) => {
|
|
16
|
+
e.stopPropagation();
|
|
17
|
+
const selectedcontextMenuItem = items.find(({ id }) => id === contextMenuItemId);
|
|
18
|
+
if (selectedcontextMenuItem && selection) {
|
|
19
|
+
onItemClick({
|
|
20
|
+
fieldName: selectedcontextMenuItem.primary,
|
|
21
|
+
fieldValue: selection.toString()
|
|
22
|
+
});
|
|
23
|
+
selection.removeAllRanges();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const itemsToRender = items.map(item => {
|
|
27
|
+
return {
|
|
28
|
+
...item,
|
|
29
|
+
visual: item.selected ? (_jsx(StyledContextMenuFieldSelector, { selected: true })) : (_jsx(StyledContextMenuFieldSelector, {}))
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
return (_jsx(Popover, { as: StyledEmailMoreInfoPopover, target: {
|
|
33
|
+
getBoundingClientRect: () => {
|
|
34
|
+
const { x, y } = cursorPosition;
|
|
35
|
+
return {
|
|
36
|
+
width: 0,
|
|
37
|
+
height: 0,
|
|
38
|
+
top: y,
|
|
39
|
+
right: x,
|
|
40
|
+
bottom: y,
|
|
41
|
+
left: x,
|
|
42
|
+
x,
|
|
43
|
+
y,
|
|
44
|
+
toJSON: () => { }
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}, show: show, placement: 'bottom', ref: ref, children: _jsx(StyledContextMenu, { children: _jsx(Menu, { ...contextMenu, header: _jsx(Text, { variant: 'h5', children: t('copy_to') }), items: itemsToRender, onItemClick: onItemSelect }) }) }));
|
|
48
|
+
});
|
|
49
|
+
export default ContextMenuPopover;
|
|
50
|
+
//# sourceMappingURL=ContextMenuPopover.js.map
|
|
@@ -0,0 +1 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S,CAAC,QAAQ,EAAE;aACjC,CAAC,CAAC;YACH,SAAS,CAAC,eAAe,EAAE,CAAC;SAC7B;IACH,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACrC,OAAO;YACL,GAAG,IAAI;YACP,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CACtB,KAAC,8BAA8B,IAAC,QAAQ,SAAG,CAC5C,CAAC,CAAC,CAAC,CACF,KAAC,8BAA8B,KAAG,CACnC;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,OAAO,IACN,EAAE,EAAE,0BAA0B,EAC9B,MAAM,EAAE;YACN,qBAAqB,EAAE,GAAG,EAAE;gBAC1B,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,cAAc,CAAC;gBAChC,OAAO;oBACL,KAAK,EAAE,CAAC;oBACR,MAAM,EAAE,CAAC;oBACT,GAAG,EAAE,CAAC;oBACN,KAAK,EAAE,CAAC;oBACR,MAAM,EAAE,CAAC;oBACT,IAAI,EAAE,CAAC;oBACP,CAAC;oBACD,CAAC;oBACD,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;iBACjB,CAAC;YACJ,CAAC;SACF,EACD,IAAI,EAAE,IAAI,EACV,SAAS,EAAC,QAAQ,EAClB,GAAG,EAAE,GAAG,YAER,KAAC,iBAAiB,cAChB,KAAC,IAAI,OACC,WAAW,EACf,MAAM,EAAE,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,CAAC,CAAC,SAAS,CAAC,GAAQ,EAChD,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,YAAY,GACzB,GACgB,GACZ,CACX,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import { FunctionComponent, MouseEvent, forwardRef, PropsWithoutRef } from 'react';\n\nimport { Popover, Menu, Text, useI18n } from '@pega/cosmos-react-core';\n\nimport {\n StyledEmailMoreInfoPopover,\n StyledContextMenuFieldSelector,\n StyledContextMenu\n} from './Email.styles';\nimport { ContextMenuPopoverProps } from './Email.types';\n\nconst ContextMenuPopover: FunctionComponent<ContextMenuPopoverProps> = forwardRef(\n (\n { cursorPosition, contextMenu, targetNode, show }: PropsWithoutRef<ContextMenuPopoverProps>,\n ref: ContextMenuPopoverProps['ref']\n ) => {\n const t = useI18n();\n const selection = document.getSelection();\n\n if (selection && !selection.toString() && targetNode) {\n const range = document.createRange();\n range.selectNodeContents(targetNode as Node);\n selection?.removeAllRanges();\n selection.addRange(range);\n }\n const { onItemClick, items } = contextMenu;\n const onItemSelect = (contextMenuItemId: string, e: MouseEvent) => {\n e.stopPropagation();\n const selectedcontextMenuItem = items.find(({ id }) => id === contextMenuItemId);\n\n if (selectedcontextMenuItem && selection) {\n onItemClick({\n fieldName: selectedcontextMenuItem.primary,\n fieldValue: selection.toString()\n });\n selection.removeAllRanges();\n }\n };\n\n const itemsToRender = items.map(item => {\n return {\n ...item,\n visual: item.selected ? (\n <StyledContextMenuFieldSelector selected />\n ) : (\n <StyledContextMenuFieldSelector />\n )\n };\n });\n\n return (\n <Popover\n as={StyledEmailMoreInfoPopover}\n target={{\n getBoundingClientRect: () => {\n const { x, y } = cursorPosition;\n return {\n width: 0,\n height: 0,\n top: y,\n right: x,\n bottom: y,\n left: x,\n x,\n y,\n toJSON: () => {}\n };\n }\n }}\n show={show}\n placement='bottom'\n ref={ref}\n >\n <StyledContextMenu>\n <Menu\n {...contextMenu}\n header={<Text variant='h5'>{t('copy_to')}</Text>}\n items={itemsToRender}\n onItemClick={onItemSelect}\n />\n </StyledContextMenu>\n </Popover>\n );\n }\n);\n\nexport default ContextMenuPopover;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Email.d.ts","sourceRoot":"","sources":["../../../src/components/Email/Email.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Email.d.ts","sourceRoot":"","sources":["../../../src/components/Email/Email.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EASlB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,YAAY,EAwBb,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAa,UAAU,EAAiC,MAAM,eAAe,CAAC;AA+CrF,QAAA,MAAM,KAAK,EAAE,iBAAiB,CAAC,UAAU,GAAG,YAAY,CAodvD,CAAC;AAEF,eAAe,KAAK,CAAC"}
|