@pega/cosmos-react-social 5.0.0-dev.9.2 → 6.0.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/SECURITY.md +11 -0
- package/lib/components/Chat/Chat.types.d.ts +7 -3
- package/lib/components/Chat/Chat.types.d.ts.map +1 -1
- package/lib/components/Chat/Chat.types.js.map +1 -1
- package/lib/components/Chat/ChatComposer.d.ts +7 -0
- package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
- package/lib/components/Chat/ChatComposer.js +4 -4
- package/lib/components/Chat/ChatComposer.js.map +1 -1
- package/lib/components/Chat/Message.d.ts.map +1 -1
- package/lib/components/Chat/Message.js +6 -4
- package/lib/components/Chat/Message.js.map +1 -1
- package/lib/components/Chat/Message.styles.d.ts +5 -2
- package/lib/components/Chat/Message.styles.d.ts.map +1 -1
- package/lib/components/Chat/Message.styles.js +21 -7
- package/lib/components/Chat/Message.styles.js.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.d.ts +15 -4
- package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.js +76 -27
- package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
- package/lib/components/Chat/index.d.ts +1 -1
- package/lib/components/Chat/index.d.ts.map +1 -1
- package/lib/components/Chat/index.js +1 -1
- package/lib/components/Chat/index.js.map +1 -1
- package/lib/components/Email/ContextMenuPopover.d.ts.map +1 -1
- package/lib/components/Email/ContextMenuPopover.js +23 -15
- package/lib/components/Email/ContextMenuPopover.js.map +1 -1
- package/lib/components/Email/Email.js +1 -1
- package/lib/components/Email/Email.js.map +1 -1
- package/lib/components/Email/Email.types.d.ts +1 -1
- 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/EntityList.js +1 -1
- package/lib/components/Email/EntityList.js.map +1 -1
- package/lib/components/Feed/FeedRichText.js +1 -1
- package/lib/components/Feed/FeedRichText.js.map +1 -1
- package/package.json +7 -6
|
@@ -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;AAEhD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,UAAU,EACV,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAIlF,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,eAAe,GAAG,MAAM,CAAC,CAAC,CAAA,EAAE,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA,EAAE,CAAC;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEhD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEpD,MAAM,CAAC,MAAM,cAAc,GAAG,M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;;GAGzB,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,IAAI,CAAC,CAC/C,CAAC,EACC,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EAAE,EAAE,MAAM,EAAE,EACpB,EACF,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;eACC,MAAM;KAChB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACvD,OAAO,GAAG,CAAA;;oCAEwB,KAAK,CAAC,IAAI,CAAC,OAAO;GACnD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport type { DefaultTheme } from 'styled-components';\nimport { readableColor, rgba, transparentize } from 'polished';\n\nimport {\n defaultThemeProp,\n tryCatch,\n Icon,\n StyledIcon,\n StyledText,\n calculateFontSize\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nimport type { MessageProps } from './Chat.types';\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 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 StyledStatusInfo = 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\nexport const StyledHeadsetIconBackground = styled.div``;\ninterface StyledMessageContainerProps {\n senderType: 'customer' | 'agent' | 'bot';\n direction: 'in' | 'out';\n typing: boolean;\n hasMessage: boolean;\n status: string;\n agentVariant: number;\n}\n\nexport const StyledHeadset = styled.div(({ theme }) => {\n return css`\n position: relative;\n\n ${StyledHeadsetIconBackground} {\n position: relative;\n inset-block-start: calc(-5.25 * ${theme.base.spacing});\n inset-inline-start: calc(2 * ${theme.base.spacing});\n height: 1.375rem;\n width: 1.375rem;\n background: ${theme.base.palette['primary-background']};\n border-radius: calc(\n (${theme.base['border-radius']}) * (${theme.components.button['border-radius']})\n );\n\n ${StyledIcon} {\n position: absolute;\n width: 2.875rem;\n height: 0.875rem;\n inset-inline-start: calc(-1.5 * ${theme.base.spacing});\n inset-block-start: calc(0.5 * ${theme.base.spacing});\n }\n }\n `;\n});\n\nStyledHeadset.defaultProps = defaultThemeProp;\n\nexport interface MessageBubbleColor {\n header: string;\n content: string;\n}\n\nexport const getMessageColors: (\n theme: DefaultTheme,\n direction: MessageProps['direction'],\n senderType: MessageProps['senderType'],\n agentVariant: MessageProps['agentVariant']\n) => MessageBubbleColor = (theme, direction, senderType, agentVariant = 0) => {\n const { slate, blue, purple, orange, green, black } = theme.base.colors;\n const agentMessageColors = [\n purple['extra-light'],\n orange['extra-light'],\n '#C5D1DD',\n green['extra-light'],\n '#BBEAEA'\n ];\n const outMessageColor = blue.medium;\n const customerMessageColor = '#E6EEFA';\n const botMessageColor = slate['extra-dark'];\n\n if (direction === 'in') {\n const messageColors: MessageBubbleColor = {\n header: orange.medium,\n content: ''\n };\n if (senderType === 'agent') {\n messageColors.content = agentMessageColors[agentVariant % agentMessageColors.length];\n } else if (senderType === 'bot') {\n messageColors.content = botMessageColor;\n } else if (senderType === 'customer') {\n messageColors.content = customerMessageColor;\n }\n return messageColors;\n }\n return {\n header: black,\n content: outMessageColor\n };\n};\n\nexport const StyledMessageContainer = styled.li<StyledMessageContainerProps>(\n ({\n direction,\n senderType,\n hasMessage,\n typing,\n status,\n agentVariant,\n theme,\n theme: {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n 'border-radius': borderRadius,\n spacing,\n palette: {\n 'foreground-color': foregroundColor,\n 'secondary-background': secondaryBackground,\n urgent\n },\n transparency: { 'transparent-2': foregroundAlpha }\n }\n }\n }) => {\n const { header, content } = getMessageColors(theme, direction, senderType, agentVariant);\n const metaForegroundColor = tryCatch(() => rgba(foregroundColor, foregroundAlpha));\n const statusForegroundColor = status === 'undeliverable' ? urgent : metaForegroundColor;\n const fontSizes = calculateFontSize(fontSize, fontScale);\n const contrastContentColor = readableColor(content);\n const contrastHeaderColor = readableColor(header);\n return css`\n ${direction === 'out'\n ? css`\n padding-inline-start: calc(4 * ${spacing});\n `\n : css`\n padding-inline-end: calc(4 * ${spacing});\n `}\n margin-block-end: ${typing ? spacing : '0'};\n\n :first-child {\n margin-block-start: ${spacing};\n }\n\n ${StyledMessageMain} {\n max-width: 90%;\n }\n ${StyledMessageBubble} {\n background: ${content};\n border-radius: calc(3 * ${borderRadius}) ${borderRadius} calc(3 * ${borderRadius})\n calc(3 * ${borderRadius});\n overflow: hidden;\n color: ${contrastContentColor};\n display: inline-block;\n width: auto;\n margin-block-end: calc(0.5 * ${spacing});\n\n label {\n color: inherit;\n }\n\n ${direction === 'in' &&\n css`\n border-radius: ${borderRadius} calc(3 * ${borderRadius}) calc(3 * ${borderRadius});\n `}\n\n > ${StyledMessageBubbleContent} {\n padding: ${spacing} calc(2 * ${spacing});\n word-break: break-word;\n white-space: pre-wrap;\n position: relative;\n }\n\n > ${StyledMediaList} {\n color: ${contrastContentColor};\n max-width: 100%;\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: ${spacing} calc(3 * ${spacing});\n font-size: ${fontSizes.xxs};\n margin-block-start: calc(0.5 * ${spacing});\n }\n ${StyledSummaryItem}::before {\n content: '';\n padding: ${spacing} 0;\n border-top: 0.0625rem solid ${contrastContentColor};\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 ${StyledText} {\n color: ${foregroundColor};\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: ${spacing} calc(2 * ${spacing});\n color: ${contrastHeaderColor};\n border-block-end: 0.0625rem solid ${transparentize(0.5, theme.base.colors.white)};\n }\n\n ${StyledMessageHeaderContent} {\n color: ${contrastHeaderColor};\n margin-inline-end: ${spacing};\n }\n ${StyledMessageHeaderMeta} {\n > a {\n color: ${contrastHeaderColor};\n }\n }\n\n ${StyledMediaLink}, ${StyledMediaButton} {\n color: ${contrastContentColor};\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: ${contrastContentColor};\n text-decoration: underline;\n }\n &:visited {\n color: ${contrastContentColor};\n }\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n }\n }\n\n ${StyledMetaInfoContainer} {\n width: 100%;\n padding: 0 ${spacing};\n ${StyledMetaInfo}, ${StyledStatusInfo} {\n margin-block-end: ${spacing};\n font-size: 0.7rem;\n color: ${metaForegroundColor};\n }\n ${StyledStatusInfo} {\n color: ${statusForegroundColor};\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\nexport const StyledUndeliveredIcon = styled(Icon)(\n ({\n theme: {\n base: {\n palette: { urgent }\n }\n }\n }) => {\n return css`\n color: ${urgent};\n `;\n }\n);\n\nStyledUndeliveredIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFlagIcon = styled(Icon)(({ theme }) => {\n return css`\n position: relative;\n inset-block-start: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledFlagIcon.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;AAEhD,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,IAAI,EACJ,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAIlF,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,GAA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AE,KAAK,EAAE,EAAE,EAAE;IACvD,OAAO,GAAG,CAAA;;oCAEwB,KAAK,CAAC,IAAI,CAAC,OAAO;GACnD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport type { DefaultTheme } from 'styled-components';\nimport { readableColor, rgba, transparentize } from 'polished';\n\nimport {\n defaultThemeProp,\n tryCatch,\n Icon,\n StyledIcon,\n StyledText,\n calculateFontSize,\n Link,\n StyledLink\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nimport type { MessageProps } from './Chat.types';\n\nexport const StyledMessageBubbleContent = styled.div``;\n\nexport const StyledMediaList = styled.ul``;\n\nexport const StyledMediaListItem = styled.li``;\n\nexport const StyledMediaMessage = styled.div``;\n\nexport const StyledMediaThumbNail = styled.img``;\n\nexport const StyledMediaLink = styled(Link)``;\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 StyledStatusInfo = 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\nexport const StyledHeadsetIconBackground = styled.div``;\n\nexport const StyledMediaContent = styled.div``;\n\ninterface StyledMessageContainerProps {\n senderType: 'customer' | 'agent' | 'bot';\n direction: 'in' | 'out';\n typing: boolean;\n hasMessage: boolean;\n status: string;\n agentVariant: number;\n}\n\nexport const StyledHeadset = styled.div(({ theme }) => {\n return css`\n position: relative;\n\n ${StyledHeadsetIconBackground} {\n position: relative;\n inset-block-start: calc(-5.25 * ${theme.base.spacing});\n inset-inline-start: calc(2 * ${theme.base.spacing});\n height: 1.375rem;\n width: 1.375rem;\n background: ${theme.base.palette['primary-background']};\n border-radius: calc(\n (${theme.base['border-radius']}) * (${theme.components.button['border-radius']})\n );\n\n ${StyledIcon} {\n position: absolute;\n width: 2.875rem;\n height: 0.875rem;\n inset-inline-start: calc(-1.5 * ${theme.base.spacing});\n inset-block-start: calc(0.5 * ${theme.base.spacing});\n }\n }\n `;\n});\n\nStyledHeadset.defaultProps = defaultThemeProp;\n\nexport interface MessageBubbleColor {\n header: string;\n content: string;\n}\n\nexport const getMessageColors: (\n theme: DefaultTheme,\n direction: MessageProps['direction'],\n senderType: MessageProps['senderType'],\n agentVariant: MessageProps['agentVariant']\n) => MessageBubbleColor = (theme, direction, senderType, agentVariant = 0) => {\n const { slate, blue, purple, orange, green, black } = theme.base.colors;\n const agentMessageColors = [\n purple['extra-light'],\n orange['extra-light'],\n '#C5D1DD',\n green['extra-light'],\n '#BBEAEA'\n ];\n const outMessageColor = blue.medium;\n const customerMessageColor = '#E6EEFA';\n const botMessageColor = slate['extra-dark'];\n\n if (direction === 'in') {\n const messageColors: MessageBubbleColor = {\n header: orange.medium,\n content: ''\n };\n if (senderType === 'agent') {\n messageColors.content = agentMessageColors[agentVariant % agentMessageColors.length];\n } else if (senderType === 'bot') {\n messageColors.content = botMessageColor;\n } else if (senderType === 'customer') {\n messageColors.content = customerMessageColor;\n }\n return messageColors;\n }\n return {\n header: black,\n content: outMessageColor\n };\n};\n\nexport const StyledMessageContainer = styled.li<StyledMessageContainerProps>(\n ({\n direction,\n senderType,\n hasMessage,\n typing,\n status,\n agentVariant,\n theme,\n theme: {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n 'border-radius': borderRadius,\n spacing,\n palette: {\n 'foreground-color': foregroundColor,\n 'secondary-background': secondaryBackground,\n urgent\n },\n transparency: { 'transparent-2': foregroundAlpha }\n }\n }\n }) => {\n const { header, content } = getMessageColors(theme, direction, senderType, agentVariant);\n const metaForegroundColor = tryCatch(() => rgba(foregroundColor, foregroundAlpha));\n const statusForegroundColor = status === 'undeliverable' ? urgent : metaForegroundColor;\n const fontSizes = calculateFontSize(fontSize, fontScale);\n const contrastContentColor = readableColor(content);\n const contrastHeaderColor = readableColor(header);\n return css`\n ${direction === 'out'\n ? css`\n padding-inline-start: calc(4 * ${spacing});\n `\n : css`\n padding-inline-end: calc(4 * ${spacing});\n `}\n margin-block-end: ${typing ? spacing : '0'};\n\n :first-child {\n margin-block-start: ${spacing};\n }\n\n ${StyledMessageMain} {\n max-width: 90%;\n }\n ${StyledMessageBubble} {\n background: ${content};\n border-radius: calc(3 * ${borderRadius}) ${borderRadius} calc(3 * ${borderRadius})\n calc(3 * ${borderRadius});\n overflow: hidden;\n color: ${contrastContentColor};\n display: inline-block;\n width: auto;\n margin-block-end: calc(0.5 * ${spacing});\n\n label {\n color: inherit;\n }\n\n ${direction === 'in' &&\n css`\n border-radius: ${borderRadius} calc(3 * ${borderRadius}) calc(3 * ${borderRadius});\n `}\n\n > ${StyledMessageBubbleContent} {\n padding: ${spacing} calc(2 * ${spacing});\n word-break: break-word;\n white-space: pre-wrap;\n position: relative;\n }\n\n > ${StyledMediaList} {\n color: ${contrastContentColor};\n max-width: 100%;\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 ${StyledMediaMessage} {\n padding: ${spacing} calc(3 * ${spacing});\n font-size: ${fontSizes.xxs};\n margin-block-start: calc(0.5 * ${spacing});\n }\n ${StyledMediaMessage}::before {\n content: '';\n padding: ${spacing} 0;\n border-top: 0.0625rem solid ${contrastContentColor};\n position: absolute;\n width: calc(100% - 2rem);\n left: 1rem;\n top: 0;\n }\n ${StyledMediaThumbNail} + ${StyledMediaMessage}::before {\n content: none;\n }\n svg {\n font-size: 1.6rem;\n }\n ${StyledText} {\n color: ${foregroundColor};\n }\n ${StyledLink} {\n color: ${contrastContentColor};\n }\n }\n\n ${!hasMessage &&\n css`\n > ${StyledMediaListItem}:first-child {\n > ${StyledMediaMessage}::before {\n border-top: none;\n }\n }\n `}\n }\n\n ${StyledMessageHeader} {\n padding: ${spacing} calc(2 * ${spacing});\n color: ${contrastHeaderColor};\n border-block-end: 0.0625rem solid ${transparentize(0.5, theme.base.colors.white)};\n }\n\n ${StyledMessageHeaderContent} {\n color: ${contrastHeaderColor};\n margin-inline-end: ${spacing};\n }\n ${StyledMessageHeaderMeta} {\n > a {\n color: ${contrastHeaderColor};\n }\n }\n\n ${StyledMediaLink}, ${StyledMediaButton} {\n color: ${contrastContentColor};\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\n &:hover {\n color: ${contrastContentColor};\n text-decoration: underline;\n }\n &:visited {\n color: ${contrastContentColor};\n }\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n }\n }\n }\n\n ${StyledMetaInfoContainer} {\n width: 100%;\n padding: 0 ${spacing};\n ${StyledMetaInfo}, ${StyledStatusInfo} {\n margin-block-end: ${spacing};\n font-size: 0.7rem;\n color: ${metaForegroundColor};\n }\n ${StyledStatusInfo} {\n color: ${statusForegroundColor};\n }\n }\n ${StyledTypingIndicator} {\n width: 4.5rem;\n position: relative;\n height: 2rem;\n }\n\n ${StyledMediaContent} {\n padding-block-end: calc(0.5 * ${spacing});\n\n ${StyledMediaLink}, ${StyledMediaButton} {\n word-break: break-word;\n white-space: pre-wrap;\n }\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\nexport const StyledUndeliveredIcon = styled(Icon)(\n ({\n theme: {\n base: {\n palette: { urgent }\n }\n }\n }) => {\n return css`\n color: ${urgent};\n `;\n }\n);\n\nStyledUndeliveredIcon.defaultProps = defaultThemeProp;\n\nexport const StyledFlagIcon = styled(Icon)(({ theme }) => {\n return css`\n position: relative;\n inset-block-start: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledFlagIcon.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FunctionComponent, Ref } from 'react';
|
|
2
|
-
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
2
|
+
import type { ForwardProps, OmitStrict } from '@pega/cosmos-react-core';
|
|
3
3
|
import type { ChatComposerProps } from './ChatComposer';
|
|
4
4
|
export declare const StyledSuggestedReplyHeader: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
5
5
|
export declare const StyledSuggestedReplyContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -9,14 +9,25 @@ export declare const StyledNotification: import("styled-components").StyledCompo
|
|
|
9
9
|
export declare const StyledSuggestedReplyIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@pega/cosmos-react-core").IconProps>, import("styled-components").DefaultTheme, {
|
|
10
10
|
suggestedReplyCollapsed?: boolean | undefined;
|
|
11
11
|
}, never>;
|
|
12
|
-
export interface
|
|
12
|
+
export interface SuggestedReplyItem {
|
|
13
13
|
/** Id for this suggested reply */
|
|
14
14
|
id: string;
|
|
15
15
|
/** Suggested reply message */
|
|
16
16
|
message: string;
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/** type of this suggested reply */
|
|
18
|
+
type: 'dialog' | 'genAIReply';
|
|
19
19
|
}
|
|
20
|
+
interface ReplyLoadingState extends OmitStrict<SuggestedReplyItem, 'message'> {
|
|
21
|
+
/** loading until reply is retrieved */
|
|
22
|
+
loading: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface ReplyErrorState extends SuggestedReplyItem {
|
|
25
|
+
/** If there are no suggestions from GenAI or if there is an error */
|
|
26
|
+
errorType: 'noSuggestions' | 'error';
|
|
27
|
+
}
|
|
28
|
+
export type SuggestedReply = SuggestedReplyItem | ReplyLoadingState | ReplyErrorState;
|
|
29
|
+
export declare const isReplyLoadingState: (reply: SuggestedReply) => reply is ReplyLoadingState;
|
|
30
|
+
export declare const isReplyErrorState: (reply: SuggestedReply) => reply is ReplyErrorState;
|
|
20
31
|
export interface SuggestedReplyPickerProps extends Pick<ChatComposerProps, 'onSend' | 'maxLength' | 'disabled'> {
|
|
21
32
|
/** ref to the element */
|
|
22
33
|
ref?: Ref<HTMLDivElement>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestedReplyPicker.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/SuggestedReplyPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SuggestedReplyPicker.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/SuggestedReplyPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAoBrE,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAMxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,eAAO,MAAM,0BAA0B,yGAAe,CAAC;AACvD,eAAO,MAAM,2BAA2B,yGAAe,CAAC;AACxD,eAAO,MAAM,WAAW,yGAAe,CAAC;AACxC,eAAO,MAAM,mBAAmB,yGAAe,CAAC;AACh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AgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAUD,QAAA,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,yBAAyB,GAAG,YAAY,CA8RlF,CAAC;AAEL,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useEffect } from 'react';
|
|
2
|
+
import { forwardRef, useEffect, useMemo } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { Flex, Icon, registerIcon, Button, Text, useI18n, defaultThemeProp, useLiveLog, ExpandCollapse, Alert, useDirection, EmptyState } from '@pega/cosmos-react-core';
|
|
4
|
+
import { Flex, Icon, registerIcon, Button, Text, useI18n, defaultThemeProp, useLiveLog, ExpandCollapse, Alert, useDirection, EmptyState, Progress, hasProp, ErrorState } from '@pega/cosmos-react-core';
|
|
5
5
|
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
6
6
|
import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
|
|
7
7
|
import * as caretRightIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-right.icon';
|
|
@@ -58,14 +58,27 @@ const StyledSuggestedReplyContainer = styled.div(props => {
|
|
|
58
58
|
`;
|
|
59
59
|
});
|
|
60
60
|
StyledSuggestedReplyContainer.defaultProps = defaultThemeProp;
|
|
61
|
+
export const isReplyLoadingState = (reply) => {
|
|
62
|
+
return hasProp(reply, 'loading');
|
|
63
|
+
};
|
|
64
|
+
export const isReplyErrorState = (reply) => {
|
|
65
|
+
return hasProp(reply, 'errorType');
|
|
66
|
+
};
|
|
67
|
+
const StyledReplyType = styled(Flex)(({ theme, type }) => {
|
|
68
|
+
return css `
|
|
69
|
+
color: ${type === 'dialog' ? 'inherit' : theme.base.palette.ai};
|
|
70
|
+
`;
|
|
71
|
+
});
|
|
72
|
+
StyledReplyType.defaultProps = defaultThemeProp;
|
|
61
73
|
const SuggestedReplyPicker = forwardRef(function SuggestedReplyPicker(props, ref) {
|
|
62
74
|
const { replies = [], collapsed, onExpandCollapse, showNotification, onSelect, currentReplyId, onReplyChange, onSend, maxLength = 256, disabled = false, ...restProps } = props;
|
|
63
75
|
const { announcePolite } = useLiveLog();
|
|
64
76
|
const t = useI18n();
|
|
65
77
|
const { rtl, ltr } = useDirection();
|
|
78
|
+
const currentReply = replies.find(reply => reply.id === currentReplyId);
|
|
79
|
+
const currentReplyIndex = replies.findIndex(reply => reply.id === currentReplyId);
|
|
66
80
|
// Allows suggested replies to cycle
|
|
67
81
|
const onSuggestedReplyChange = (mode) => {
|
|
68
|
-
const currentReplyIndex = replies.findIndex(reply => reply.id === currentReplyId);
|
|
69
82
|
let newReplyIndex = mode === 'prev' ? currentReplyIndex - 1 : currentReplyIndex + 1;
|
|
70
83
|
newReplyIndex = (newReplyIndex + replies.length) % replies.length;
|
|
71
84
|
onReplyChange(replies[newReplyIndex].id);
|
|
@@ -75,39 +88,72 @@ const SuggestedReplyPicker = forwardRef(function SuggestedReplyPicker(props, ref
|
|
|
75
88
|
if (!replies || replies.length === 0 || !currentReplyId) {
|
|
76
89
|
return;
|
|
77
90
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}, [currentReplyId]);
|
|
91
|
+
if (currentReply && !isReplyLoadingState(currentReply))
|
|
92
|
+
announcePolite({
|
|
93
|
+
message: `${t('suggested_replies_current_of_total', [
|
|
94
|
+
currentReplyIndex + 1,
|
|
95
|
+
replies.length
|
|
96
|
+
])},${currentReply?.message},${currentReply?.type === 'dialog' ? t('dialog') : t('pega_genAI')}`,
|
|
97
|
+
type: 'acknowledgement'
|
|
98
|
+
});
|
|
99
|
+
}, [currentReply]);
|
|
88
100
|
const onEditAnnouncement = () => {
|
|
89
101
|
announcePolite({
|
|
90
102
|
message: t('suggested_reply_copied_to_input_field'),
|
|
91
103
|
type: 'acknowledgement'
|
|
92
104
|
});
|
|
93
105
|
};
|
|
94
|
-
|
|
106
|
+
const suggestionType = useMemo(() => {
|
|
107
|
+
if (currentReply && !collapsed) {
|
|
108
|
+
let iconName = '';
|
|
109
|
+
let label;
|
|
110
|
+
if (currentReply.type === 'dialog') {
|
|
111
|
+
iconName = 'script';
|
|
112
|
+
label = t('dialog');
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
iconName = 'polaris-solid';
|
|
116
|
+
label = t('pega_genAI');
|
|
117
|
+
}
|
|
118
|
+
return (_jsxs(StyledReplyType, { container: { alignItems: 'center', pad: 1, gap: 0.5 }, type: currentReply.type, children: [_jsx(Icon, { name: iconName, size: 's' }), label] }));
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}, [currentReply, collapsed]);
|
|
122
|
+
const suggestion = useMemo(() => {
|
|
123
|
+
if (currentReply) {
|
|
124
|
+
if (isReplyLoadingState(currentReply)) {
|
|
125
|
+
return (_jsx(Progress, { placement: 'block', message: t('loading'), liveConfig: { contextualLabel: `${t('pega_genAI')} ${t('suggestion')}` } }));
|
|
126
|
+
}
|
|
127
|
+
if (isReplyErrorState(currentReply)) {
|
|
128
|
+
return (_jsx(Flex, { container: { justify: 'center' }, children: currentReply.errorType === 'noSuggestions' ? (_jsx(EmptyState, { message: currentReply.message })) : (_jsx(ErrorState, { message: currentReply.message })) }));
|
|
129
|
+
}
|
|
130
|
+
return (_jsx(Flex, { container: true, as: StyledReply, children: currentReply.message }));
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}, [currentReply]);
|
|
134
|
+
return (_jsxs(StyledSuggestedReplyContainer, { ref: ref, ...restProps, children: [_jsxs(Flex, { as: StyledSuggestedReplyHeader, container: {
|
|
95
135
|
justify: 'between',
|
|
96
136
|
alignContent: 'center'
|
|
97
|
-
}, children: _jsxs(Flex, { container: {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
137
|
+
}, children: [_jsxs(Flex, { container: {
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
gap: 1
|
|
140
|
+
}, children: [ltr && (_jsx(Button, { variant: 'simple', label: collapsed ? t('expand') : t('collapse'), "aria-label": t(collapsed ? 'expand_suggested_replies' : 'collapse_suggested_replies'), icon: true, onClick: onExpandCollapse, children: _jsx(StyledSuggestedReplyIcon, { name: 'caret-down', suggestedReplyCollapsed: collapsed }) })), _jsxs(Flex, { container: { gap: 0.5 }, children: [_jsx(Text, { variant: 'h3', children: t('suggested_replies') }), collapsed && showNotification && _jsx(Alert, { variant: 'urgent' })] }), !collapsed && replies?.length > 0 && (_jsx(Text, { variant: 'secondary', children: `- ${currentReplyIndex + 1}/${replies.length}` })), rtl && (_jsx(Button, { variant: 'simple', label: collapsed ? t('expand') : t('collapse'), "aria-label": t(collapsed ? 'expand_suggested_replies' : 'collapse_suggested_replies'), icon: true, onClick: onExpandCollapse, children: _jsx(StyledSuggestedReplyIcon, { name: 'caret-down', suggestedReplyCollapsed: collapsed }) }))] }), suggestionType] }), _jsx(ExpandCollapse, { dimension: 'height', collapsed: collapsed, nullWhenCollapsed: true, children: _jsxs(Flex, { container: {
|
|
101
141
|
direction: 'column',
|
|
102
142
|
gap: 1
|
|
103
|
-
}, as: StyledSuggestedReplyContent, children: [
|
|
143
|
+
}, as: StyledSuggestedReplyContent, children: [currentReply && replies.length ? (suggestion) : (_jsx(EmptyState, { message: t('no_suggestion') })), _jsxs(Flex, { container: {
|
|
104
144
|
justify: 'center'
|
|
105
145
|
}, as: StyledRepliesAction, children: [replies.length > 1 && (_jsx(Button, { icon: true, "aria-label": t('prev_suggested_reply'), variant: 'simple', disabled: currentReplyId === undefined || replies.length <= 1, onClick: () => {
|
|
106
146
|
onSuggestedReplyChange('prev');
|
|
107
|
-
}, children: _jsx(Icon, { name: 'caret-left' }) })), _jsx(Button, { disabled: disabled ||
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
147
|
+
}, children: _jsx(Icon, { name: 'caret-left' }) })), _jsx(Button, { disabled: disabled ||
|
|
148
|
+
currentReplyId === undefined ||
|
|
149
|
+
!replies ||
|
|
150
|
+
replies.length === 0 ||
|
|
151
|
+
(currentReply && isReplyLoadingState(currentReply) && currentReply.loading) ||
|
|
152
|
+
(currentReply && isReplyErrorState(currentReply) && !!currentReply.errorType), onClick: () => {
|
|
153
|
+
if (currentReply &&
|
|
154
|
+
!isReplyErrorState(currentReply) &&
|
|
155
|
+
!isReplyLoadingState(currentReply)) {
|
|
156
|
+
onSelect(currentReply);
|
|
111
157
|
onExpandCollapse();
|
|
112
158
|
onEditAnnouncement();
|
|
113
159
|
}
|
|
@@ -122,10 +168,13 @@ const SuggestedReplyPicker = forwardRef(function SuggestedReplyPicker(props, ref
|
|
|
122
168
|
currentReplyId === undefined ||
|
|
123
169
|
!replies ||
|
|
124
170
|
replies.length === 0 ||
|
|
125
|
-
(!!maxLength && replies.length > maxLength)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
171
|
+
(!!maxLength && replies.length > maxLength) ||
|
|
172
|
+
(currentReply && isReplyLoadingState(currentReply) && currentReply.loading) ||
|
|
173
|
+
(currentReply && isReplyErrorState(currentReply) && !!currentReply.errorType), onClick: () => {
|
|
174
|
+
if (currentReply &&
|
|
175
|
+
!isReplyErrorState(currentReply) &&
|
|
176
|
+
!isReplyLoadingState(currentReply)) {
|
|
177
|
+
onSend(currentReply.message);
|
|
129
178
|
onExpandCollapse();
|
|
130
179
|
}
|
|
131
180
|
}, "aria-label": replies.length > 0 && currentReplyId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestedReplyPicker.js","sourceRoot":"","sources":["../../../src/components/Chat/SuggestedReplyPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9C,OAAO,MAAM,EAAE,EAAE,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cAAc;wCAClC,CAAC,CAAC,CAAC,CAAC,uBAAuB,EAAE;4CACzB,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,cAAc;gDAClC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,cAAc,CAAC,GAAG,CAAC;gDAC7D,CAAC,CAAC,CAAC;4CACL,OAAO,CAAC,MAAM;yCACf,CAAC;wCACJ,CAAC,CAAC,SAAS,YAGd,CAAC,CAAC,MAAM,CAAC,GACH,EACR,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CACrB,KAAC,MAAM,IACL,IAAI,sBACQ,CAAC,CAAC,sBAAsB,CAAC,EACrC,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE;wCACZ,sBAAsB,CAAC,MAAM,CAAC,CAAC;oCACjC,CAAC,EACD,QAAQ,EAAE,cAAc,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,YAE7D,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,GAAG,GACpB,CACV,IACI,IACF,GACQ,IACa,CACjC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,eAAe,oBAAoB,CAAC","sourcesContent":["import { forwardRef, useEffect } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, Ref } 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 useLiveLog,\n ExpandCollapse,\n Alert,\n useDirection,\n EmptyState\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps } 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';\nimport { StyledAlert } from '@pega/cosmos-react-core/lib/components/Badges/Alert';\n\nimport type { ChatComposerProps } from './ChatComposer';\n\nregisterIcon(timesIcon, caretLeftIcon, caretRightIcon);\n\nexport const StyledSuggestedReplyHeader = styled.div``;\nexport const StyledSuggestedReplyContent = styled.div``;\nexport const StyledReply = styled.div``;\nexport const StyledRepliesAction = styled.div``;\nexport const StyledNotification = styled.div``;\nconst maxNumOfLines = 5;\nconst minNumOfLines = 2;\n\nexport const StyledSuggestedReplyIcon = styled(Icon)<{ suggestedReplyCollapsed?: boolean }>(\n ({ suggestedReplyCollapsed, theme }) => {\n const { rtl } = useDirection();\n const {\n base: {\n animation: {\n speed,\n timing: { ease }\n }\n }\n } = theme;\n return css`\n transition-property: transform;\n transition-duration: ${speed};\n transition-timing-function: ${ease};\n ${suggestedReplyCollapsed &&\n css`\n transform: rotateZ(${rtl ? '0deg' : '-90deg'});\n `}\n `;\n }\n);\n\nStyledSuggestedReplyIcon.defaultProps = defaultThemeProp;\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\n > ${StyledSuggestedReplyHeader} {\n padding: ${theme.base.spacing};\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n\n ${StyledAlert} {\n position: relative;\n inset-block-start: calc(-0.25 * ${theme.base.spacing});\n inset-inline-start: calc(-0.5 * ${theme.base.spacing});\n }\n\n ${StyledSuggestedReplyContent} {\n padding: calc(2 * ${theme.base.spacing});\n position: relative;\n\n > ${StyledReply} {\n overflow-y: auto;\n max-height: calc(2.5 * ${theme.base.spacing} * ${maxNumOfLines});\n min-height: calc(2.5 * ${theme.base.spacing} * ${minNumOfLines});\n }\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 extends Pick<ChatComposerProps, 'onSend' | 'maxLength' | 'disabled'> {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Suggested replies */\n replies?: SuggestedReply[];\n /** Id of the current reply */\n currentReplyId?: SuggestedReply['id'];\n /** Fired when user clicks on left or right buttons\n * @param id Id of the new reply\n */\n onReplyChange: (id: SuggestedReply['id']) => void;\n /** Current state of the panel */\n collapsed: boolean;\n /** Callback for expand or collapse click */\n onExpandCollapse: () => void;\n /** Callback for the event when a suggested reply is selected */\n onSelect: (suggestedReply: SuggestedReply) => void;\n /** Show notification on picker header */\n showNotification?: boolean;\n}\n\nconst SuggestedReplyPicker: FunctionComponent<SuggestedReplyPickerProps & ForwardProps> =\n forwardRef(function SuggestedReplyPicker(\n props: PropsWithoutRef<SuggestedReplyPickerProps>,\n ref: SuggestedReplyPickerProps['ref']\n ) {\n const {\n replies = [],\n collapsed,\n onExpandCollapse,\n showNotification,\n onSelect,\n currentReplyId,\n onReplyChange,\n onSend,\n maxLength = 256,\n disabled = false,\n ...restProps\n } = props;\n const { announcePolite } = useLiveLog();\n const t = useI18n();\n const { rtl, ltr } = useDirection();\n\n // Allows suggested replies to cycle\n const onSuggestedReplyChange = (mode: 'prev' | 'next') => {\n const currentReplyIndex = replies.findIndex(reply => reply.id === currentReplyId);\n let newReplyIndex = mode === 'prev' ? currentReplyIndex - 1 : currentReplyIndex + 1;\n newReplyIndex = (newReplyIndex + replies.length) % replies.length;\n onReplyChange(replies[newReplyIndex].id);\n };\n\n // SR announcement when current reply changes\n useEffect(() => {\n if (!replies || replies.length === 0 || !currentReplyId) {\n return;\n }\n const currentReplyIndex = replies.findIndex(reply => reply.id === currentReplyId);\n announcePolite({\n message: `${t('suggested_replies_current_of_total', [\n currentReplyIndex + 1,\n replies.length\n ])},\n ${t('confidence_percentage', [replies[currentReplyIndex]?.confidence])},${\n replies[currentReplyIndex]?.message\n }`,\n type: 'acknowledgement'\n });\n }, [currentReplyId]);\n\n const onEditAnnouncement = () => {\n announcePolite({\n message: t('suggested_reply_copied_to_input_field'),\n type: 'acknowledgement'\n });\n };\n\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 {ltr && (\n <Button\n variant='simple'\n label={collapsed ? t('expand') : t('collapse')}\n aria-label={t(\n collapsed ? 'expand_suggested_replies' : 'collapse_suggested_replies'\n )}\n icon\n onClick={onExpandCollapse}\n >\n <StyledSuggestedReplyIcon name='caret-down' suggestedReplyCollapsed={collapsed} />\n </Button>\n )}\n\n <Flex container={{ gap: 0.5 }}>\n <Text variant='h3'>{t('suggested_replies')}</Text>\n {collapsed && showNotification && <Alert variant='urgent' />}\n </Flex>\n\n {rtl && (\n <Button\n variant='simple'\n label={collapsed ? t('expand') : t('collapse')}\n aria-label={t(\n collapsed ? 'expand_suggested_replies' : 'collapse_suggested_replies'\n )}\n icon\n onClick={onExpandCollapse}\n >\n <StyledSuggestedReplyIcon name='caret-down' suggestedReplyCollapsed={collapsed} />\n </Button>\n )}\n </Flex>\n </Flex>\n <ExpandCollapse dimension='height' collapsed={collapsed} nullWhenCollapsed>\n <Flex\n container={{\n direction: 'column',\n gap: 1\n }}\n as={StyledSuggestedReplyContent}\n >\n {currentReplyId && replies.length ? (\n <Flex container as={StyledReply}>\n {replies.find(reply => reply.id === currentReplyId)?.message}\n </Flex>\n ) : (\n <EmptyState message={t('no_suggestion')} />\n )}\n <Flex\n container={{\n justify: 'center'\n }}\n as={StyledRepliesAction}\n >\n {replies.length > 1 && (\n <Button\n icon\n aria-label={t('prev_suggested_reply')}\n variant='simple'\n disabled={currentReplyId === undefined || replies.length <= 1}\n onClick={() => {\n onSuggestedReplyChange('prev');\n }}\n >\n <Icon name='caret-left' />\n </Button>\n )}\n <Button\n disabled={\n disabled || currentReplyId === undefined || !replies || replies.length === 0\n }\n onClick={() => {\n const selectedReply = replies.find(reply => reply.id === currentReplyId);\n if (selectedReply) {\n onSelect(selectedReply);\n onExpandCollapse();\n onEditAnnouncement();\n }\n }}\n aria-label={\n replies.length > 0 && currentReplyId\n ? t('edit_current_template', [\n replies.length > 0 && currentReplyId\n ? replies.findIndex(reply => reply.id === currentReplyId) + 1\n : 0,\n replies.length\n ])\n : undefined\n }\n >\n {t('edit')}\n </Button>\n <Button\n disabled={\n disabled ||\n currentReplyId === undefined ||\n !replies ||\n replies.length === 0 ||\n (!!maxLength && replies.length > maxLength)\n }\n onClick={() => {\n const selectedReply = replies.find(reply => reply.id === currentReplyId);\n if (selectedReply) {\n onSend(selectedReply.message);\n onExpandCollapse();\n }\n }}\n aria-label={\n replies.length > 0 && currentReplyId\n ? t('send_current_template', [\n replies.length > 0 && currentReplyId\n ? replies.findIndex(reply => reply.id === currentReplyId) + 1\n : 0,\n replies.length\n ])\n : undefined\n }\n >\n {t('send')}\n </Button>\n {replies.length > 1 && (\n <Button\n icon\n aria-label={t('next_suggested_reply')}\n variant='simple'\n onClick={() => {\n onSuggestedReplyChange('next');\n }}\n disabled={currentReplyId === undefined || replies.length <= 1}\n >\n <Icon name='caret-right' />\n </Button>\n )}\n </Flex>\n </Flex>\n </ExpandCollapse>\n </StyledSuggestedReplyContainer>\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,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvD,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,EAChB,UAAU,EACV,cAAc,EACd,KAAK,EACL,YAA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;wCAClC,CAAC,CAAC,CAAC,CAAC,uBAAuB,EAAE;4CACzB,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,cAAc;gDAClC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,cAAc,CAAC,GAAG,CAAC;gDAC7D,CAAC,CAAC,CAAC;4CACL,OAAO,CAAC,MAAM;yCACf,CAAC;wCACJ,CAAC,CAAC,SAAS,YAGd,CAAC,CAAC,MAAM,CAAC,GACH,EACR,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CACrB,KAAC,MAAM,IACL,IAAI,sBACQ,CAAC,CAAC,sBAAsB,CAAC,EACrC,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,GAAG,EAAE;wCACZ,sBAAsB,CAAC,MAAM,CAAC,CAAC;oCACjC,CAAC,EACD,QAAQ,EAAE,cAAc,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,YAE7D,KAAC,IAAI,IAAC,IAAI,EAAC,aAAa,GAAG,GACpB,CACV,IACI,IACF,GACQ,IACa,CACjC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,eAAe,oBAAoB,CAAC","sourcesContent":["import { forwardRef, useEffect, useMemo } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, Ref } 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 useLiveLog,\n ExpandCollapse,\n Alert,\n useDirection,\n EmptyState,\n Progress,\n hasProp,\n ErrorState\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps, OmitStrict } 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';\nimport { StyledAlert } from '@pega/cosmos-react-core/lib/components/Badges/Alert';\n\nimport type { ChatComposerProps } from './ChatComposer';\n\nregisterIcon(timesIcon, caretLeftIcon, caretRightIcon);\n\nexport const StyledSuggestedReplyHeader = styled.div``;\nexport const StyledSuggestedReplyContent = styled.div``;\nexport const StyledReply = styled.div``;\nexport const StyledRepliesAction = styled.div``;\nexport const StyledNotification = styled.div``;\nconst maxNumOfLines = 5;\nconst minNumOfLines = 2;\n\nexport const StyledSuggestedReplyIcon = styled(Icon)<{ suggestedReplyCollapsed?: boolean }>(\n ({ suggestedReplyCollapsed, theme }) => {\n const { rtl } = useDirection();\n const {\n base: {\n animation: {\n speed,\n timing: { ease }\n }\n }\n } = theme;\n return css`\n transition-property: transform;\n transition-duration: ${speed};\n transition-timing-function: ${ease};\n ${suggestedReplyCollapsed &&\n css`\n transform: rotateZ(${rtl ? '0deg' : '-90deg'});\n `}\n `;\n }\n);\n\nStyledSuggestedReplyIcon.defaultProps = defaultThemeProp;\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\n > ${StyledSuggestedReplyHeader} {\n padding: ${theme.base.spacing};\n border-bottom: 0.0625rem solid ${theme.base.palette['border-line']};\n }\n\n ${StyledAlert} {\n position: relative;\n inset-block-start: calc(-0.25 * ${theme.base.spacing});\n inset-inline-start: calc(-0.5 * ${theme.base.spacing});\n }\n\n ${StyledSuggestedReplyContent} {\n padding: calc(2 * ${theme.base.spacing});\n position: relative;\n\n > ${StyledReply} {\n overflow-y: auto;\n max-height: calc(2.5 * ${theme.base.spacing} * ${maxNumOfLines});\n min-height: calc(2.5 * ${theme.base.spacing} * ${minNumOfLines});\n }\n }\n `;\n});\n\nStyledSuggestedReplyContainer.defaultProps = defaultThemeProp;\n\nexport interface SuggestedReplyItem {\n /** Id for this suggested reply */\n id: string;\n /** Suggested reply message */\n message: string;\n /** type of this suggested reply */\n type: 'dialog' | 'genAIReply';\n}\n\ninterface ReplyLoadingState extends OmitStrict<SuggestedReplyItem, 'message'> {\n /** loading until reply is retrieved */\n loading: boolean;\n}\n\ninterface ReplyErrorState extends SuggestedReplyItem {\n /** If there are no suggestions from GenAI or if there is an error */\n errorType: 'noSuggestions' | 'error';\n}\n\nexport type SuggestedReply = SuggestedReplyItem | ReplyLoadingState | ReplyErrorState;\n\nexport const isReplyLoadingState = (reply: SuggestedReply): reply is ReplyLoadingState => {\n return hasProp(reply, 'loading');\n};\n\nexport const isReplyErrorState = (reply: SuggestedReply): reply is ReplyErrorState => {\n return hasProp(reply, 'errorType');\n};\n\nexport interface SuggestedReplyPickerProps\n extends Pick<ChatComposerProps, 'onSend' | 'maxLength' | 'disabled'> {\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n /** Suggested replies */\n replies?: SuggestedReply[];\n /** Id of the current reply */\n currentReplyId?: SuggestedReply['id'];\n /** Fired when user clicks on left or right buttons\n * @param id Id of the new reply\n */\n onReplyChange: (id: SuggestedReply['id']) => void;\n /** Current state of the panel */\n collapsed: boolean;\n /** Callback for expand or collapse click */\n onExpandCollapse: () => void;\n /** Callback for the event when a suggested reply is selected */\n onSelect: (suggestedReply: SuggestedReply) => void;\n /** Show notification on picker header */\n showNotification?: boolean;\n}\n\nconst StyledReplyType = styled(Flex)(({ theme, type }) => {\n return css`\n color: ${type === 'dialog' ? 'inherit' : theme.base.palette.ai};\n `;\n});\n\nStyledReplyType.defaultProps = defaultThemeProp;\n\nconst SuggestedReplyPicker: FunctionComponent<SuggestedReplyPickerProps & ForwardProps> =\n forwardRef(function SuggestedReplyPicker(\n props: PropsWithoutRef<SuggestedReplyPickerProps>,\n ref: SuggestedReplyPickerProps['ref']\n ) {\n const {\n replies = [],\n collapsed,\n onExpandCollapse,\n showNotification,\n onSelect,\n currentReplyId,\n onReplyChange,\n onSend,\n maxLength = 256,\n disabled = false,\n ...restProps\n } = props;\n const { announcePolite } = useLiveLog();\n const t = useI18n();\n const { rtl, ltr } = useDirection();\n\n const currentReply = replies.find(reply => reply.id === currentReplyId);\n const currentReplyIndex = replies.findIndex(reply => reply.id === currentReplyId);\n\n // Allows suggested replies to cycle\n const onSuggestedReplyChange = (mode: 'prev' | 'next') => {\n let newReplyIndex = mode === 'prev' ? currentReplyIndex - 1 : currentReplyIndex + 1;\n newReplyIndex = (newReplyIndex + replies.length) % replies.length;\n onReplyChange(replies[newReplyIndex].id);\n };\n\n // SR announcement when current reply changes\n useEffect(() => {\n if (!replies || replies.length === 0 || !currentReplyId) {\n return;\n }\n if (currentReply && !isReplyLoadingState(currentReply))\n announcePolite({\n message: `${t('suggested_replies_current_of_total', [\n currentReplyIndex + 1,\n replies.length\n ])},${currentReply?.message},${\n currentReply?.type === 'dialog' ? t('dialog') : t('pega_genAI')\n }`,\n type: 'acknowledgement'\n });\n }, [currentReply]);\n\n const onEditAnnouncement = () => {\n announcePolite({\n message: t('suggested_reply_copied_to_input_field'),\n type: 'acknowledgement'\n });\n };\n\n const suggestionType = useMemo(() => {\n if (currentReply && !collapsed) {\n let iconName = '';\n let label;\n if (currentReply.type === 'dialog') {\n iconName = 'script';\n label = t('dialog');\n } else {\n iconName = 'polaris-solid';\n label = t('pega_genAI');\n }\n\n return (\n <StyledReplyType\n container={{ alignItems: 'center', pad: 1, gap: 0.5 }}\n type={currentReply.type}\n >\n <Icon name={iconName} size='s' />\n {label}\n </StyledReplyType>\n );\n }\n\n return null;\n }, [currentReply, collapsed]);\n\n const suggestion = useMemo(() => {\n if (currentReply) {\n if (isReplyLoadingState(currentReply)) {\n return (\n <Progress\n placement='block'\n message={t('loading')}\n liveConfig={{ contextualLabel: `${t('pega_genAI')} ${t('suggestion')}` }}\n />\n );\n }\n\n if (isReplyErrorState(currentReply)) {\n return (\n <Flex container={{ justify: 'center' }}>\n {currentReply.errorType === 'noSuggestions' ? (\n <EmptyState message={currentReply.message} />\n ) : (\n <ErrorState message={currentReply.message} />\n )}\n </Flex>\n );\n }\n\n return (\n <Flex container as={StyledReply}>\n {currentReply.message}\n </Flex>\n );\n }\n\n return null;\n }, [currentReply]);\n\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 {ltr && (\n <Button\n variant='simple'\n label={collapsed ? t('expand') : t('collapse')}\n aria-label={t(\n collapsed ? 'expand_suggested_replies' : 'collapse_suggested_replies'\n )}\n icon\n onClick={onExpandCollapse}\n >\n <StyledSuggestedReplyIcon name='caret-down' suggestedReplyCollapsed={collapsed} />\n </Button>\n )}\n\n <Flex container={{ gap: 0.5 }}>\n <Text variant='h3'>{t('suggested_replies')}</Text>\n {collapsed && showNotification && <Alert variant='urgent' />}\n </Flex>\n\n {!collapsed && replies?.length > 0 && (\n <Text variant='secondary'>{`- ${currentReplyIndex + 1}/${replies.length}`}</Text>\n )}\n\n {rtl && (\n <Button\n variant='simple'\n label={collapsed ? t('expand') : t('collapse')}\n aria-label={t(\n collapsed ? 'expand_suggested_replies' : 'collapse_suggested_replies'\n )}\n icon\n onClick={onExpandCollapse}\n >\n <StyledSuggestedReplyIcon name='caret-down' suggestedReplyCollapsed={collapsed} />\n </Button>\n )}\n </Flex>\n {suggestionType}\n </Flex>\n <ExpandCollapse dimension='height' collapsed={collapsed} nullWhenCollapsed>\n <Flex\n container={{\n direction: 'column',\n gap: 1\n }}\n as={StyledSuggestedReplyContent}\n >\n {currentReply && replies.length ? (\n suggestion\n ) : (\n <EmptyState message={t('no_suggestion')} />\n )}\n <Flex\n container={{\n justify: 'center'\n }}\n as={StyledRepliesAction}\n >\n {replies.length > 1 && (\n <Button\n icon\n aria-label={t('prev_suggested_reply')}\n variant='simple'\n disabled={currentReplyId === undefined || replies.length <= 1}\n onClick={() => {\n onSuggestedReplyChange('prev');\n }}\n >\n <Icon name='caret-left' />\n </Button>\n )}\n <Button\n disabled={\n disabled ||\n currentReplyId === undefined ||\n !replies ||\n replies.length === 0 ||\n (currentReply && isReplyLoadingState(currentReply) && currentReply.loading) ||\n (currentReply && isReplyErrorState(currentReply) && !!currentReply.errorType)\n }\n onClick={() => {\n if (\n currentReply &&\n !isReplyErrorState(currentReply) &&\n !isReplyLoadingState(currentReply)\n ) {\n onSelect(currentReply);\n onExpandCollapse();\n onEditAnnouncement();\n }\n }}\n aria-label={\n replies.length > 0 && currentReplyId\n ? t('edit_current_template', [\n replies.length > 0 && currentReplyId\n ? replies.findIndex(reply => reply.id === currentReplyId) + 1\n : 0,\n replies.length\n ])\n : undefined\n }\n >\n {t('edit')}\n </Button>\n <Button\n disabled={\n disabled ||\n currentReplyId === undefined ||\n !replies ||\n replies.length === 0 ||\n (!!maxLength && replies.length > maxLength) ||\n (currentReply && isReplyLoadingState(currentReply) && currentReply.loading) ||\n (currentReply && isReplyErrorState(currentReply) && !!currentReply.errorType)\n }\n onClick={() => {\n if (\n currentReply &&\n !isReplyErrorState(currentReply) &&\n !isReplyLoadingState(currentReply)\n ) {\n onSend(currentReply.message);\n onExpandCollapse();\n }\n }}\n aria-label={\n replies.length > 0 && currentReplyId\n ? t('send_current_template', [\n replies.length > 0 && currentReplyId\n ? replies.findIndex(reply => reply.id === currentReplyId) + 1\n : 0,\n replies.length\n ])\n : undefined\n }\n >\n {t('send')}\n </Button>\n {replies.length > 1 && (\n <Button\n icon\n aria-label={t('next_suggested_reply')}\n variant='simple'\n onClick={() => {\n onSuggestedReplyChange('next');\n }}\n disabled={currentReplyId === undefined || replies.length <= 1}\n >\n <Icon name='caret-right' />\n </Button>\n )}\n </Flex>\n </Flex>\n </ExpandCollapse>\n </StyledSuggestedReplyContainer>\n );\n });\n\nexport default SuggestedReplyPicker;\n"]}
|
|
@@ -5,7 +5,7 @@ export type { ChatHeaderProps } from './ChatHeader';
|
|
|
5
5
|
export { default as ChatBody, NewMessageSeparatorId } from './ChatBody';
|
|
6
6
|
export { default as ChatComposer } from './ChatComposer';
|
|
7
7
|
export type { ChatComposerProps, ChatComposerImperativeHandleProps } from './ChatComposer';
|
|
8
|
-
export { default as SuggestedReplyPicker } from './SuggestedReplyPicker';
|
|
8
|
+
export { default as SuggestedReplyPicker, isReplyErrorState, isReplyLoadingState } from './SuggestedReplyPicker';
|
|
9
9
|
export type { SuggestedReplyPickerProps, SuggestedReply } from './SuggestedReplyPicker';
|
|
10
10
|
export type { AttachmentItemProps, ChatSettingsPanelProps, MediaPageLinks, MessageProps, MessageHeaderProps, ChatBodyProps, ChatBodyListItemProps, ChatBodyHandleValue, TypeIndicatorProps, SystemMessageProps } from './Chat.types';
|
|
11
11
|
export { default as Message } from './Message';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EACL,OAAO,IAAI,oBAAoB,EAC/B,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxF,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -2,7 +2,7 @@ export { default } from './Chat';
|
|
|
2
2
|
export { default as ChatHeader } from './ChatHeader';
|
|
3
3
|
export { default as ChatBody, NewMessageSeparatorId } from './ChatBody';
|
|
4
4
|
export { default as ChatComposer } from './ChatComposer';
|
|
5
|
-
export { default as SuggestedReplyPicker } from './SuggestedReplyPicker';
|
|
5
|
+
export { default as SuggestedReplyPicker, isReplyErrorState, isReplyLoadingState } from './SuggestedReplyPicker';
|
|
6
6
|
export { default as Message } from './Message';
|
|
7
7
|
export { default as SystemMessage } from './SystemMessage';
|
|
8
8
|
export { default as TypeIndicator } from './TypeIndicator';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EACL,OAAO,IAAI,oBAAoB,EAC/B,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAchC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export { default } from './Chat';\nexport type { ChatProps } from './Chat';\nexport { default as ChatHeader } from './ChatHeader';\nexport type { ChatHeaderProps } from './ChatHeader';\nexport { default as ChatBody, NewMessageSeparatorId } from './ChatBody';\nexport { default as ChatComposer } from './ChatComposer';\nexport type { ChatComposerProps, ChatComposerImperativeHandleProps } from './ChatComposer';\nexport {\n default as SuggestedReplyPicker,\n isReplyErrorState,\n isReplyLoadingState\n} from './SuggestedReplyPicker';\nexport type { SuggestedReplyPickerProps, SuggestedReply } from './SuggestedReplyPicker';\nexport type {\n AttachmentItemProps,\n ChatSettingsPanelProps,\n MediaPageLinks,\n MessageProps,\n MessageHeaderProps,\n ChatBodyProps,\n ChatBodyListItemProps,\n ChatBodyHandleValue,\n TypeIndicatorProps,\n SystemMessageProps\n} from './Chat.types';\nexport { default as Message } from './Message';\nexport { default as SystemMessage } from './SystemMessage';\nexport { default as TypeIndicator } from './TypeIndicator';\nexport { default as ChatSettingsPanel } from './ChatSettingsPanel';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuPopover.d.ts","sourceRoot":"","sources":["../../../src/components/Email/ContextMenuPopover.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAS5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"ContextMenuPopover.d.ts","sourceRoot":"","sources":["../../../src/components/Email/ContextMenuPopover.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAS5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,CAAC,uBAAuB,CAwFlE,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
2
|
+
import { forwardRef, useEffect, useRef } from 'react';
|
|
3
3
|
import { Popover, Menu, Text, useI18n } from '@pega/cosmos-react-core';
|
|
4
4
|
import { StyledEmailMoreInfoPopover, StyledContextMenuFieldSelector, StyledContextMenu } from './Email.styles';
|
|
5
5
|
const ContextMenuPopover = forwardRef(function ContextMenuPopover({ cursorPosition, contextMenu, targetNode, show }, ref) {
|
|
6
6
|
const t = useI18n();
|
|
7
|
-
const
|
|
8
|
-
const targetElement = targetNode instanceof Element ? targetNode : targetNode?.parentElement;
|
|
9
|
-
if (targetElement && targetElement.tagName.toLowerCase() === 'mark') {
|
|
10
|
-
selection?.removeAllRanges();
|
|
11
|
-
}
|
|
12
|
-
if (selection && !selection.toString() && targetNode) {
|
|
13
|
-
const range = document.createRange();
|
|
14
|
-
range.selectNodeContents(targetNode);
|
|
15
|
-
selection?.removeAllRanges();
|
|
16
|
-
selection.addRange(range);
|
|
17
|
-
}
|
|
7
|
+
const selectedText = useRef();
|
|
18
8
|
const { onItemClick, items } = contextMenu;
|
|
19
9
|
const onItemSelect = (contextMenuItemId, e) => {
|
|
20
10
|
e.stopPropagation();
|
|
21
11
|
const selectedcontextMenuItem = items.find(({ id }) => id === contextMenuItemId);
|
|
22
|
-
if (selectedcontextMenuItem &&
|
|
12
|
+
if (selectedcontextMenuItem && selectedText.current) {
|
|
23
13
|
onItemClick({
|
|
24
14
|
fieldName: selectedcontextMenuItem.primary,
|
|
25
|
-
fieldValue:
|
|
15
|
+
fieldValue: selectedText.current
|
|
26
16
|
});
|
|
27
17
|
}
|
|
28
18
|
};
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const selection = document.getSelection();
|
|
21
|
+
if (!selection || !targetNode)
|
|
22
|
+
return;
|
|
23
|
+
if (targetNode.tagName.toLowerCase() === 'mark') {
|
|
24
|
+
selection.removeAllRanges();
|
|
25
|
+
}
|
|
26
|
+
if (!selection.toString()) {
|
|
27
|
+
const range = document.createRange();
|
|
28
|
+
range.selectNodeContents(targetNode);
|
|
29
|
+
selection.removeAllRanges();
|
|
30
|
+
selection.addRange(range);
|
|
31
|
+
}
|
|
32
|
+
if (selection.toString()) {
|
|
33
|
+
selectedText.current = selection.toString();
|
|
34
|
+
}
|
|
35
|
+
}, [show, targetNode]);
|
|
29
36
|
const itemsToRender = items.map(item => {
|
|
30
37
|
return {
|
|
31
38
|
...item,
|
|
@@ -46,7 +53,8 @@ const ContextMenuPopover = forwardRef(function ContextMenuPopover({ cursorPositi
|
|
|
46
53
|
y,
|
|
47
54
|
toJSON: () => { }
|
|
48
55
|
};
|
|
49
|
-
}
|
|
56
|
+
},
|
|
57
|
+
contextElement: targetNode ?? undefined
|
|
50
58
|
}, 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 }) }) }));
|
|
51
59
|
});
|
|
52
60
|
export default ContextMenuPopover;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuPopover.js","sourceRoot":"","sources":["../../../src/components/Email/ContextMenuPopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ContextMenuPopover.js","sourceRoot":"","sources":["../../../src/components/Email/ContextMenuPopover.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,kBAAkB,GAA+C,UAAU,CAC/E,SAAS,kBAAkB,CACzB,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAA4C,EAC3F,GAAmC;IAEnC,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,YAAY,GAAG,MAAM,EAAU,CAAC;IAEtC,MAAM,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AAM,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;YACD,cAAc,EAAE,UAAU,IAAI,SAAS;SACxC,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 { forwardRef, useEffect, useRef } from 'react';\nimport type { FunctionComponent, MouseEvent, 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 type { ContextMenuPopoverProps } from './Email.types';\n\nconst ContextMenuPopover: FunctionComponent<ContextMenuPopoverProps> = forwardRef(\n function ContextMenuPopover(\n { cursorPosition, contextMenu, targetNode, show }: PropsWithoutRef<ContextMenuPopoverProps>,\n ref: ContextMenuPopoverProps['ref']\n ) {\n const t = useI18n();\n const selectedText = useRef<string>();\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 && selectedText.current) {\n onItemClick({\n fieldName: selectedcontextMenuItem.primary,\n fieldValue: selectedText.current\n });\n }\n };\n\n useEffect(() => {\n const selection = document.getSelection();\n\n if (!selection || !targetNode) return;\n\n if (targetNode.tagName.toLowerCase() === 'mark') {\n selection.removeAllRanges();\n }\n\n if (!selection.toString()) {\n const range = document.createRange();\n range.selectNodeContents(targetNode);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n\n if (selection.toString()) {\n selectedText.current = selection.toString();\n }\n }, [show, targetNode]);\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 contextElement: targetNode ?? undefined\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"]}
|
|
@@ -55,7 +55,7 @@ const Email = forwardRef(function Email(props, ref) {
|
|
|
55
55
|
});
|
|
56
56
|
// Handler for right click on email body
|
|
57
57
|
const onContextMenu = (e) => {
|
|
58
|
-
if (e.target instanceof
|
|
58
|
+
if (e.target instanceof Element && e.target.textContent?.trim()) {
|
|
59
59
|
setCurrentTarget({
|
|
60
60
|
targetNode: e.target,
|
|
61
61
|
cursorPosition: {
|