@pega/cosmos-react-social 8.0.0-build.9.0 → 8.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/lib/components/Autopilot/Autopilot.d.ts.map +1 -1
- package/lib/components/Autopilot/Autopilot.js +2 -2
- package/lib/components/Autopilot/Autopilot.js.map +1 -1
- package/lib/components/Chat/Chat.d.ts +3 -3
- package/lib/components/Chat/Chat.d.ts.map +1 -1
- package/lib/components/Chat/Chat.js +1 -2
- package/lib/components/Chat/Chat.js.map +1 -1
- package/lib/components/Chat/Chat.types.d.ts +3 -1
- 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/ChatBody.d.ts +2 -3
- package/lib/components/Chat/ChatBody.d.ts.map +1 -1
- package/lib/components/Chat/ChatBody.js +6 -8
- package/lib/components/Chat/ChatBody.js.map +1 -1
- package/lib/components/Chat/ChatComposer.d.ts +4 -4
- package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
- package/lib/components/Chat/ChatComposer.js +15 -25
- package/lib/components/Chat/ChatComposer.js.map +1 -1
- package/lib/components/Chat/ChatHeader.d.ts +4 -3
- package/lib/components/Chat/ChatHeader.d.ts.map +1 -1
- package/lib/components/Chat/ChatHeader.js +3 -4
- package/lib/components/Chat/ChatHeader.js.map +1 -1
- package/lib/components/Chat/ChatSettingsPanel.styles.d.ts.map +1 -1
- package/lib/components/Chat/ChatSettingsPanel.styles.js +5 -2
- package/lib/components/Chat/ChatSettingsPanel.styles.js.map +1 -1
- package/lib/components/Chat/Message.d.ts +2 -3
- package/lib/components/Chat/Message.d.ts.map +1 -1
- package/lib/components/Chat/Message.js +6 -5
- package/lib/components/Chat/Message.js.map +1 -1
- package/lib/components/Chat/Message.styles.d.ts +2 -2
- package/lib/components/Chat/Message.styles.d.ts.map +1 -1
- package/lib/components/Chat/Message.styles.js +11 -3
- package/lib/components/Chat/Message.styles.js.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.d.ts +3 -3
- package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.js +3 -3
- package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
- package/lib/components/Chat/SystemMessage.d.ts +2 -3
- package/lib/components/Chat/SystemMessage.d.ts.map +1 -1
- package/lib/components/Chat/SystemMessage.js +1 -2
- package/lib/components/Chat/SystemMessage.js.map +1 -1
- package/lib/components/Chat/TypeIndicator.d.ts +2 -3
- package/lib/components/Chat/TypeIndicator.d.ts.map +1 -1
- package/lib/components/Chat/TypeIndicator.js +1 -2
- package/lib/components/Chat/TypeIndicator.js.map +1 -1
- package/lib/components/Email/ContextMenuPopover.d.ts +1 -2
- package/lib/components/Email/ContextMenuPopover.d.ts.map +1 -1
- package/lib/components/Email/ContextMenuPopover.js.map +1 -1
- package/lib/components/Email/Email.d.ts +2 -3
- package/lib/components/Email/Email.d.ts.map +1 -1
- package/lib/components/Email/Email.js +11 -4
- package/lib/components/Email/Email.js.map +1 -1
- package/lib/components/Email/Email.styles.d.ts +4 -4
- package/lib/components/Email/Email.styles.d.ts.map +1 -1
- package/lib/components/Email/Email.styles.js +6 -3
- package/lib/components/Email/Email.styles.js.map +1 -1
- package/lib/components/Email/Email.types.d.ts +16 -17
- 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/EmailCaseView.js +1 -1
- package/lib/components/Email/EmailCaseView.js.map +1 -1
- package/lib/components/Email/EmailComposer.d.ts +3 -4
- package/lib/components/Email/EmailComposer.d.ts.map +1 -1
- package/lib/components/Email/EmailComposer.js +29 -8
- package/lib/components/Email/EmailComposer.js.map +1 -1
- package/lib/components/Email/EmailConversation.d.ts +6 -7
- package/lib/components/Email/EmailConversation.d.ts.map +1 -1
- package/lib/components/Email/EmailConversation.js +2 -2
- package/lib/components/Email/EmailConversation.js.map +1 -1
- package/lib/components/Email/EmailEntity.d.ts +2 -3
- package/lib/components/Email/EmailEntity.d.ts.map +1 -1
- package/lib/components/Email/EmailEntity.js.map +1 -1
- package/lib/components/Email/EmailSelector.d.ts +6 -2
- package/lib/components/Email/EmailSelector.d.ts.map +1 -1
- package/lib/components/Email/EmailSelector.js +25 -29
- package/lib/components/Email/EmailSelector.js.map +1 -1
- package/lib/components/Email/EmailShell.d.ts +2 -3
- package/lib/components/Email/EmailShell.d.ts.map +1 -1
- package/lib/components/Email/EmailShell.js +1 -1
- package/lib/components/Email/EmailShell.js.map +1 -1
- package/lib/components/Email/EmailSummaryItem.d.ts +3 -7
- package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -1
- package/lib/components/Email/EmailSummaryItem.js +26 -26
- package/lib/components/Email/EmailSummaryItem.js.map +1 -1
- package/lib/components/Email/EmailSummaryList.d.ts +2 -3
- package/lib/components/Email/EmailSummaryList.d.ts.map +1 -1
- package/lib/components/Email/EmailSummaryList.js +17 -9
- package/lib/components/Email/EmailSummaryList.js.map +1 -1
- package/lib/components/Email/EntityList.d.ts +1 -3
- package/lib/components/Email/EntityList.d.ts.map +1 -1
- package/lib/components/Email/EntityList.js.map +1 -1
- package/lib/components/Email/utils/EntityHighlighter.d.ts.map +1 -1
- package/lib/components/Email/utils/EntityHighlighter.js +3 -5
- package/lib/components/Email/utils/EntityHighlighter.js.map +1 -1
- package/lib/components/Feed/Feed.context.d.ts +4 -49
- package/lib/components/Feed/Feed.context.d.ts.map +1 -1
- package/lib/components/Feed/Feed.context.js +1 -5
- package/lib/components/Feed/Feed.context.js.map +1 -1
- package/lib/components/Feed/Feed.d.ts +1 -3
- package/lib/components/Feed/Feed.d.ts.map +1 -1
- package/lib/components/Feed/Feed.js +15 -23
- package/lib/components/Feed/Feed.js.map +1 -1
- package/lib/components/Feed/Feed.types.d.ts +190 -252
- package/lib/components/Feed/Feed.types.d.ts.map +1 -1
- package/lib/components/Feed/Feed.types.js.map +1 -1
- package/lib/components/Feed/FeedAttachments.d.ts +2 -3
- package/lib/components/Feed/FeedAttachments.d.ts.map +1 -1
- package/lib/components/Feed/FeedAttachments.js +12 -19
- package/lib/components/Feed/FeedAttachments.js.map +1 -1
- package/lib/components/Feed/FeedContent.d.ts +2 -3
- package/lib/components/Feed/FeedContent.d.ts.map +1 -1
- package/lib/components/Feed/FeedContent.js +5 -43
- package/lib/components/Feed/FeedContent.js.map +1 -1
- package/lib/components/Feed/FeedContentFooter.d.ts.map +1 -1
- package/lib/components/Feed/FeedContentFooter.js +2 -15
- package/lib/components/Feed/FeedContentFooter.js.map +1 -1
- package/lib/components/Feed/FeedContentHeader.d.ts.map +1 -1
- package/lib/components/Feed/FeedContentHeader.js +76 -44
- package/lib/components/Feed/FeedContentHeader.js.map +1 -1
- package/lib/components/Feed/FeedCustomEditRegion.d.ts +6 -0
- package/lib/components/Feed/FeedCustomEditRegion.d.ts.map +1 -0
- package/lib/components/Feed/FeedCustomEditRegion.js +20 -0
- package/lib/components/Feed/FeedCustomEditRegion.js.map +1 -0
- package/lib/components/Feed/FeedCustomInputRegion.d.ts +6 -0
- package/lib/components/Feed/FeedCustomInputRegion.d.ts.map +1 -0
- package/lib/components/Feed/FeedCustomInputRegion.js +38 -0
- package/lib/components/Feed/FeedCustomInputRegion.js.map +1 -0
- package/lib/components/Feed/FeedEditRegion.d.ts +1 -2
- package/lib/components/Feed/FeedEditRegion.d.ts.map +1 -1
- package/lib/components/Feed/FeedEditRegion.js +41 -14
- package/lib/components/Feed/FeedEditRegion.js.map +1 -1
- package/lib/components/Feed/FeedInputRegion.d.ts +0 -1
- package/lib/components/Feed/FeedInputRegion.d.ts.map +1 -1
- package/lib/components/Feed/FeedInputRegion.js +53 -40
- package/lib/components/Feed/FeedInputRegion.js.map +1 -1
- package/lib/components/Feed/FeedLikeButton.d.ts +2 -2
- package/lib/components/Feed/FeedLikeButton.d.ts.map +1 -1
- package/lib/components/Feed/FeedLikeButton.js +5 -5
- package/lib/components/Feed/FeedLikeButton.js.map +1 -1
- package/lib/components/Feed/FeedModalList.d.ts.map +1 -1
- package/lib/components/Feed/FeedModalList.js +6 -7
- package/lib/components/Feed/FeedModalList.js.map +1 -1
- package/lib/components/Feed/FeedNewPost.d.ts +1 -2
- package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPost.js +44 -14
- package/lib/components/Feed/FeedNewPost.js.map +1 -1
- package/lib/components/Feed/FeedPost.d.ts +2 -3
- package/lib/components/Feed/FeedPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedPost.js +50 -28
- package/lib/components/Feed/FeedPost.js.map +1 -1
- package/lib/components/Feed/FeedReply.d.ts +1 -2
- package/lib/components/Feed/FeedReply.d.ts.map +1 -1
- package/lib/components/Feed/FeedReply.js +24 -5
- package/lib/components/Feed/FeedReply.js.map +1 -1
- package/lib/components/Feed/FeedReplyInput.d.ts +1 -2
- package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
- package/lib/components/Feed/FeedReplyInput.js +4 -5
- package/lib/components/Feed/FeedReplyInput.js.map +1 -1
- package/lib/components/Feed/FeedRichText.d.ts +3 -3
- package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
- package/lib/components/Feed/FeedRichText.js +16 -8
- package/lib/components/Feed/FeedRichText.js.map +1 -1
- package/lib/components/Feed/FeedRichTextViewer.d.ts +10 -0
- package/lib/components/Feed/FeedRichTextViewer.d.ts.map +1 -0
- package/lib/components/Feed/FeedRichTextViewer.js +38 -0
- package/lib/components/Feed/FeedRichTextViewer.js.map +1 -0
- package/lib/components/Feed/FeedVisibilityControls.d.ts +4 -0
- package/lib/components/Feed/FeedVisibilityControls.d.ts.map +1 -0
- package/lib/components/Feed/FeedVisibilityControls.js +62 -0
- package/lib/components/Feed/FeedVisibilityControls.js.map +1 -0
- package/lib/components/Feed/MarkdownSyntax.d.ts +3 -0
- package/lib/components/Feed/MarkdownSyntax.d.ts.map +1 -0
- package/lib/components/Feed/MarkdownSyntax.js +66 -0
- package/lib/components/Feed/MarkdownSyntax.js.map +1 -0
- package/lib/components/Feed/index.d.ts +3 -1
- package/lib/components/Feed/index.d.ts.map +1 -1
- package/lib/components/Feed/index.js +2 -0
- package/lib/components/Feed/index.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.map +1 -1
- package/lib/components/MentionButton/MentionButton.js +2 -2
- package/lib/components/MentionButton/MentionButton.js.map +1 -1
- package/lib/components/OpenGraphPreview/OpenGraphPreview.d.ts +27 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.d.ts.map +1 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.js +39 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.js.map +1 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.styles.d.ts +13 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.styles.d.ts.map +1 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.styles.js +79 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.styles.js.map +1 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.test-ids.d.ts +3 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.test-ids.d.ts.map +1 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.test-ids.js +4 -0
- package/lib/components/OpenGraphPreview/OpenGraphPreview.test-ids.js.map +1 -0
- package/lib/components/OpenGraphPreview/index.d.ts +3 -0
- package/lib/components/OpenGraphPreview/index.d.ts.map +1 -0
- package/lib/components/OpenGraphPreview/index.js +2 -0
- package/lib/components/OpenGraphPreview/index.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +10 -10
- package/lib/components/Feed/FeedAnnouncer.d.ts +0 -6
- package/lib/components/Feed/FeedAnnouncer.d.ts.map +0 -1
- package/lib/components/Feed/FeedAnnouncer.js +0 -11
- package/lib/components/Feed/FeedAnnouncer.js.map +0 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +0 -5
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +0 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.js +0 -375
- package/lib/components/Feed/FeedNewPostTypeMenu.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autopilot.d.ts","sourceRoot":"","sources":["../../../src/components/Autopilot/Autopilot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAmB,YAAY,EAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Autopilot.d.ts","sourceRoot":"","sources":["../../../src/components/Autopilot/Autopilot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAmB,YAAY,EAAmB,MAAM,OAAO,CAAC;AAW/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC;CACjD;AAsBD,QAAA,MAAM,SAAS,EAAE,iBAAiB,CAAC,cAAc,GAAG,YAAY,CAoC9D,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;CAS3B,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef,
|
|
2
|
+
import { forwardRef, useContext, useState } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { Button, Icon, defaultThemeProp, useConsolidatedRef, useElement } from '@pega/cosmos-react-core';
|
|
4
|
+
import { Button, Icon, defaultThemeProp, useConsolidatedRef, useElement, isValidElement } from '@pega/cosmos-react-core';
|
|
5
5
|
import { FeedContext } from '../Feed/Feed.context';
|
|
6
6
|
const StyledAutopilotButton = styled(Button)(({ theme }) => {
|
|
7
7
|
return css `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autopilot.js","sourceRoot":"","sources":["../../../src/components/Autopilot/Autopilot.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"Autopilot.js","sourceRoot":"","sources":["../../../src/components/Autopilot/Autopilot.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMnD,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACzD,OAAO,GAAG,CAAA;aACC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;;;;;;;;;sCASI,KAAK,CAAC,IAAI,CAAC,OAAO;;GAErD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,UAAU,GAAG,IAAI,aAAa,EAAE,CAAC;AAEvC,MAAM,SAAS,GAAqD,UAAU,CAAC,SAAS,SAAS,CAC/F,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAmC,EAC3D,GAA2B;IAE3B,MAAM,EACJ,aAAa,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,EACxC,gBAAgB,EACjB,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAC5B,MAAM,CAAC,gBAAgB,EAAE,m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, useContext, useState } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, ReactElement, Ref, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n Icon,\n defaultThemeProp,\n useConsolidatedRef,\n useElement,\n isValidElement\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\n\nimport { FeedContext } from '../Feed/Feed.context';\n\ninterface AutopilotProps {\n children: Record<string, string> | ReactElement;\n}\n\nconst StyledAutopilotButton = styled(Button)(({ theme }) => {\n return css`\n color: ${theme.base.palette.ai};\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: none;\n text-decoration: underline;\n }\n\n svg {\n margin-inline-end: calc(0.5 * ${theme.base.spacing});\n }\n `;\n});\n\nStyledAutopilotButton.defaultProps = defaultThemeProp;\n\nconst serializer = new XMLSerializer();\n\nconst Autopilot: FunctionComponent<AutopilotProps & ForwardProps> = forwardRef(function Autopilot(\n { children, ...restProps }: PropsWithoutRef<AutopilotProps>,\n ref: Ref<HTMLButtonElement>\n) {\n const {\n autopilotInfo: { label: autopilotLabel },\n onAutopilotClick\n } = useContext(FeedContext);\n const [autopilotContent, setAutopilotContent] = useState<JSX.Element | undefined>();\n const [target, setTarget] = useElement<HTMLButtonElement>(null);\n const mentionRef = useConsolidatedRef(ref);\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n setTarget(e.currentTarget);\n const comp = onAutopilotClick?.({\n target: e.currentTarget,\n onDismiss: () => setTarget(null)\n });\n if (comp) setAutopilotContent(comp);\n };\n\n return (\n <>\n <StyledAutopilotButton\n {...restProps}\n ref={mentionRef}\n variant='link'\n onClick={handleClick}\n spellCheck={false}\n >\n <Icon name='polaris-solid' />\n {isValidElement(children) ? children : autopilotLabel}\n </StyledAutopilotButton>\n {target && autopilotContent}\n </>\n );\n});\n\nexport const AutopilotConfig = {\n type: 'autopilot',\n xmlElement: 'pega-autopilot',\n regexPattern: /(?:^|)<pega-autopilot\\/>/g,\n component: Autopilot,\n inject: () => {\n const element = document.createElementNS(null, 'pega-autopilot');\n return serializer.serializeToString(element);\n }\n};\n\nexport default Autopilot;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BannerProps,
|
|
1
|
+
import type { Ref } from 'react';
|
|
2
|
+
import type { BannerProps, ForwardRefForwardPropsComponent, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
3
3
|
import type { ChatComposerProps } from './ChatComposer';
|
|
4
4
|
import type { ChatHeaderProps } from './ChatHeader';
|
|
5
5
|
import type { SuggestedReplyPickerProps } from './SuggestedReplyPicker';
|
|
@@ -24,6 +24,6 @@ export interface ChatProps extends NoChildrenProp {
|
|
|
24
24
|
/** Wrapper of conversation input, emojis, attachments */
|
|
25
25
|
composer: ChatComposerProps;
|
|
26
26
|
}
|
|
27
|
-
declare const Chat:
|
|
27
|
+
declare const Chat: ForwardRefForwardPropsComponent<ChatProps>;
|
|
28
28
|
export default Chat;
|
|
29
29
|
//# sourceMappingURL=Chat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Chat.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Chat.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,GAAG,EAAE,MAAM,OAAO,CAAC;AAIlD,OAAO,KAAK,EACV,WAAW,EACX,+BAA+B,EAC/B,cAAc,EACf,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,SAAU,SAAQ,cAAc;IAC/C,yBAAyB;IACzB,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IACvB,kCAAkC;IAClC,MAAM,EAAE,eAAe,CAAC;IACxB,6DAA6D;IAC7D,IAAI,EAAE,aAAa,CAAC;IACpB,mCAAmC;IACnC,oBAAoB,CAAC,EAAE,yBAAyB,CAAC;IACjD,kBAAkB;IAClB,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC;IACnD,yDAAyD;IACzD,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAqED,QAAA,MAAM,IAAI,EAAE,+BAA+B,CAAC,SAAS,CA2BnD,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -59,8 +59,7 @@ const StyledChatContainer = styled.section(props => {
|
|
|
59
59
|
`;
|
|
60
60
|
});
|
|
61
61
|
StyledChatContainer.defaultProps = defaultThemeProp;
|
|
62
|
-
const Chat = forwardRef(function Chat(
|
|
63
|
-
const { header, body, composer, banner, suggestedReplyPicker, ...restProps } = props;
|
|
62
|
+
const Chat = forwardRef(function Chat({ header, body, composer, banner, suggestedReplyPicker, ...restProps }, ref) {
|
|
64
63
|
return (_jsxs(Flex, { ref: ref, as: StyledChatContainer, container: {
|
|
65
64
|
direction: 'column'
|
|
66
65
|
}, ...restProps, children: [_jsx(ChatHeader, { ...header }), banner && _jsx(Banner, { variant: banner.variant, messages: banner.messages }), _jsx(ChatBody, { ...body }), suggestedReplyPicker && _jsx(SuggestedReplyPicker, { ...suggestedReplyPicker }), _jsx(ChatComposer, { ...composer })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../src/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AA;;kBAEM,iBAAiB;;qBAEd,YAAY;MAC3B,mBAAmB;;;;;;MAMnB,sBAAsB;;;;;;;0BAOF,mBAAmB;UACnC,oBAAoB;mBACX,OAAO;sBACJ,UAAU;;;;;4BAKJ,mBAAmB;oDACK,mBAAmB;;;;;;;;;;;;MAYjE,YAAY;0BACQ,OAAO;;;;GAI9B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,mBAAmB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEpD,MAAM,IAAI,GAA+C,UAAU,CAAC,SAAS,IAAI,CAC/E,EACE,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,oBAAoB,EACpB,GAAG,SAAS,EACe,EAC7B,GAAqB;IAErB,OAAO,CACL,MAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,mBAAmB,EACvB,SAAS,EAAE;YACT,SAAS,EAAE,QAAQ;SACpB,KACG,SAAS,aAEb,KAAC,UAAU,OAAK,MAAM,GAAI,EACzB,MAAM,IAAI,KAAC,MAAM,IAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAAI,EACzE,KAAC,QAAQ,OAAK,IAAI,GAAI,EACrB,oBAAoB,IAAI,KAAC,oBAAoB,OAAK,oBAAoB,GAAI,EAC3E,KAAC,YAAY,OAAK,QAAQ,GAAI,IACzB,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef } from 'react';\nimport type { PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Flex, Banner, defaultThemeProp } from '@pega/cosmos-react-core';\nimport type {\n BannerProps,\n ForwardRefForwardPropsComponent,\n NoChildrenProp\n} from '@pega/cosmos-react-core';\nimport { StyledBanner } from '@pega/cosmos-react-core/lib/components/Banner/Banner';\n\nimport ChatBody from './ChatBody';\nimport ChatComposer from './ChatComposer';\nimport type { ChatComposerProps } from './ChatComposer';\nimport ChatHeader from './ChatHeader';\nimport type { ChatHeaderProps } from './ChatHeader';\nimport SuggestedReplyPicker from './SuggestedReplyPicker';\nimport type { SuggestedReplyPickerProps } from './SuggestedReplyPicker';\nimport type { ChatBodyProps } from './Chat.types';\n\nexport type ChatBannerProps = {\n /** Content */\n content: string;\n /** Name of the icon */\n icon: string;\n};\n\nexport interface ChatProps extends NoChildrenProp {\n /** ref to the element */\n ref?: Ref<HTMLElement>;\n /** Header of conversation pane */\n header: ChatHeaderProps;\n /** Wrapper of message groups, system messages, type ahead */\n body: ChatBodyProps;\n /** Wrapper of suggested replies */\n suggestedReplyPicker?: SuggestedReplyPickerProps;\n /** chat banner */\n banner?: Pick<BannerProps, 'variant' | 'messages'>;\n /** Wrapper of conversation input, emojis, attachments */\n composer: ChatComposerProps;\n}\n\nconst StyledUtilityContainer = styled.div``;\nconst StyledUtilityMerger = styled.div``;\nconst StyledUtilityContent = styled.div``;\n\nconst StyledChatContainer = styled.section(props => {\n const {\n theme: {\n base: {\n spacing,\n shadow: { high: shadowHigh },\n palette: {\n 'primary-background': primaryBackground,\n 'secondary-background': secondaryBackground\n },\n 'border-radius': borderRadius\n }\n }\n } = props;\n return css`\n height: 100%;\n background: ${primaryBackground};\n width: 100%;\n border-radius: ${borderRadius};\n ${StyledUtilityMerger} {\n min-height: 15rem;\n position: relative;\n height: 100%;\n overflow-y: hidden;\n }\n ${StyledUtilityContainer} {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 2;\n max-height: 60%;\n width: 100%;\n background-color: ${secondaryBackground};\n > ${StyledUtilityContent} {\n padding: ${spacing} 0;\n box-shadow: ${shadowHigh};\n height: auto;\n width: 100%;\n overflow-y: auto;\n background:\n linear-gradient(${secondaryBackground} 10%, rgba(255, 255, 255, 0)),\n linear-gradient(rgba(255, 255, 255, 0), ${secondaryBackground} 10%) 0 100%,\n radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)),\n radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) 0 100%;\n background-repeat: no-repeat;\n background-size:\n 100% 1rem,\n 100% 1rem,\n 100% 0.25rem,\n 100% 0.25rem;\n background-attachment: local, local, scroll, scroll;\n }\n }\n ${StyledBanner} {\n padding: calc(2 * ${spacing});\n margin-bottom: 0;\n flex-shrink: 0;\n }\n `;\n});\n\nStyledChatContainer.defaultProps = defaultThemeProp;\n\nconst Chat: ForwardRefForwardPropsComponent<ChatProps> = forwardRef(function Chat(\n {\n header,\n body,\n composer,\n banner,\n suggestedReplyPicker,\n ...restProps\n }: PropsWithoutRef<ChatProps>,\n ref: ChatProps['ref']\n) {\n return (\n <Flex\n ref={ref}\n as={StyledChatContainer}\n container={{\n direction: 'column'\n }}\n {...restProps}\n >\n <ChatHeader {...header} />\n {banner && <Banner variant={banner.variant} messages={banner.messages} />}\n <ChatBody {...body} />\n {suggestedReplyPicker && <SuggestedReplyPicker {...suggestedReplyPicker} />}\n <ChatComposer {...composer} />\n </Flex>\n );\n});\n\nexport default Chat;\n"]}
|
|
@@ -50,7 +50,7 @@ export type MessageHeaderProps = {
|
|
|
50
50
|
/** meta data */
|
|
51
51
|
meta?: ReactNode;
|
|
52
52
|
};
|
|
53
|
-
export interface MessageProps {
|
|
53
|
+
export interface MessageProps extends Pick<ChatBodyProps, 'renderMarkdownContent'> {
|
|
54
54
|
/** Message to be displayed */
|
|
55
55
|
message?: string;
|
|
56
56
|
/** Attachment list */
|
|
@@ -117,6 +117,8 @@ export interface ChatBodyProps {
|
|
|
117
117
|
loadMore?: () => void;
|
|
118
118
|
/** Imperative handle */
|
|
119
119
|
handle?: Ref<ChatBodyHandleValue>;
|
|
120
|
+
/** Renders markdown content. Note: Native emojis are used instead of custom EmojiSet when rendering markdown. */
|
|
121
|
+
renderMarkdownContent?: boolean;
|
|
120
122
|
/** ref to the element */
|
|
121
123
|
ref?: Ref<HTMLDivElement>;
|
|
122
124
|
}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AAC;AAEF,eAAO,MAAM,uBAAuB,YACzB,qBAAqB,KAC7B,OAAO,IAAI,0BAEb,CAAC;AAEF,eAAO,MAAM,uBAAuB,YACzB,qBAAqB,KAC7B,OAAO,IAAI,yBAEb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.types.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Chat.types.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"AAkKA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAA8B,EACG,EAAE;IACnC,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,OAA8B,EACS,EAAE;IACzC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,OAA8B,EACQ,EAAE;IACxC,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC;AACnC,CAAC,CAAC","sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { DefaultTheme } from 'styled-components';\n\nimport type {\n BaseProps,\n Action,\n NoChildrenProp,\n OmitStrict,\n LinkProps,\n AvatarProps\n} from '@pega/cosmos-react-core';\n\nexport interface AttachmentItemProps extends BaseProps {\n /** Unique Id for this attachment */\n id: string;\n /** Name of the attachment. */\n name: string;\n /**\n * A Cosmos icon name identifier to use for a attachment. Will serve as a fallback to a broken thumbnail.\n * @default 'document-doc'\n */\n icon?: string;\n /** A string to be used as an image src for a attachment thumbnail. Falls back to a provided icon or the default attachment icon. */\n thumbnail?: string;\n /** Additional information about the attachment. If progress prop is passed and its value is less than 100, this region is instead used for the upload progress indicator. */\n meta?: string;\n /** When passed, previews the attachment on click */\n onPreview?: (id: string) => void;\n /** Actions list for the attachment */\n actions?: Action[];\n /** When passed, this will render a single icon button or within a MenuButton if onDelete is defined. */\n onDelete?: (id: string) => void;\n}\n\nexport type UserAvailability = 'available' | 'unavailable' | 'temporarilyUnavailable';\n\nexport interface ChatSettingsPanelProps extends NoChildrenProp {\n status?: UserAvailability;\n label: string;\n onClick: () => void;\n}\n\nexport type ColorTheme = [\n keyof OmitStrict<DefaultTheme['base']['colors'], 'white' | 'black'>,\n 'extra-light' | 'light' | 'medium' | 'dark' | 'extra-dark'\n];\n\nexport interface MediaPageLinks {\n /** Unique id for this push link */\n id: string;\n /** Title of the content */\n title: string;\n /** Href for external links */\n href?: LinkProps['href'];\n /** Callback provided to perform on click */\n onTitleClick?: () => void;\n /** A string to be used as an image src for a thumbnail. */\n thumbnail?: AttachmentItemProps['thumbnail'];\n}\n\nexport type MessageHeaderProps = {\n /** message header content */\n content?: ReactNode;\n /** meta data */\n meta?: ReactNode;\n};\n\nexport interface MessageProps extends Pick<ChatBodyProps, 'renderMarkdownContent'> {\n /** Message to be displayed */\n message?: string;\n /** Attachment list */\n attachments?: AttachmentItemProps[];\n /** Message page push links list */\n mediaPageLinks?: MediaPageLinks[];\n /** timestamp of the message(Formatted) */\n timestamp?: string;\n /** Incoming message/ outgoing message */\n direction: 'in' | 'out';\n /** Avatar information, can be image and name */\n avatarInfo?: Pick<AvatarProps, 'name' | 'imageSrc'>;\n /** Message status */\n status?: 'delivered' | 'opened' | 'undeliverable' | 'sent';\n /** Indicates if this message is being currently typed */\n typing?: boolean;\n /** Message header */\n messageHeader?: MessageHeaderProps;\n /** Sender type */\n senderType: 'customer' | 'agent' | 'bot';\n /** Sender ID, will be helpful in deciding the colour */\n senderId: string;\n /** Number used to determine the color of agent's message */\n agentVariant?: number;\n /** ref to the message wrapper */\n ref?: Ref<HTMLLIElement>;\n}\n\nexport interface TypeIndicatorProps\n extends Pick<MessageProps, 'ref' | 'message' | 'senderId' | 'senderType' | 'agentVariant'> {\n /** Avatar information, can be image and name */\n avatarInfo: Pick<AvatarProps, 'name' | 'imageSrc'>;\n}\n\nexport interface SystemMessageProps extends Pick<MessageProps, 'ref' | 'timestamp'> {\n /** System message to be displayed */\n message: string;\n /** variant of this system message\n * @default 'secondary'\n */\n variant?: 'primary' | 'secondary';\n}\n\nexport interface ChatBodyHandleValue {\n isScrolledToLatest: () => boolean;\n scrollToLatestMessage: () => void;\n scrollToNewMessage: () => void;\n}\n\nexport interface ChatBodyProps {\n /** Transcripts */\n transcripts: {\n /** Unique id of a chat session */\n id: string;\n /** Messages in a chat session */\n messages: ChatBodyListItemProps[];\n }[];\n /** Live chat messages */\n liveChat: ChatBodyListItemProps[];\n /** Total unread messages */\n unreadMessageCount?: number;\n /** on scroll to button */\n onScrollToButtonClick?: () => void;\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 /** Imperative handle */\n handle?: Ref<ChatBodyHandleValue>;\n /** Renders markdown content. Note: Native emojis are used instead of custom EmojiSet when rendering markdown. */\n renderMarkdownContent?: boolean;\n /** ref to the element */\n ref?: Ref<HTMLDivElement>;\n}\n\ntype MessageListItemProps = OmitStrict<MessageProps, 'agentVariant' | 'typing'> & {\n type: 'message';\n id: string;\n};\n\ntype SystemMessageListItemProps = SystemMessageProps & { type: 'system'; id: string };\n\ntype TypeIndicatorListItemPops = OmitStrict<TypeIndicatorProps, 'agentVariant'> & {\n type: 'typing';\n id: string;\n};\n\nexport type ChatBodyListItemProps =\n | MessageListItemProps\n | SystemMessageListItemProps\n | TypeIndicatorListItemPops;\n\nexport const isMessageListItem = (\n message: ChatBodyListItemProps\n): message is MessageListItemProps => {\n return message.type === 'message';\n};\n\nexport const isSystemMessageListItem = (\n message: ChatBodyListItemProps\n): message is SystemMessageListItemProps => {\n return message.type === 'system';\n};\n\nexport const isTypeIndicatorListItem = (\n message: ChatBodyListItemProps\n): message is TypeIndicatorListItemPops => {\n return message.type === 'typing';\n};\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
1
|
+
import type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';
|
|
3
2
|
import type { ChatBodyProps } from './Chat.types';
|
|
4
3
|
export declare const NewMessageSeparatorId = "new-message-separator";
|
|
5
|
-
declare const ChatBody:
|
|
4
|
+
declare const ChatBody: ForwardRefForwardPropsComponent<ChatBodyProps>;
|
|
6
5
|
export default ChatBody;
|
|
7
6
|
//# sourceMappingURL=ChatBody.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBody.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatBody.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatBody.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatBody.tsx"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAI/E,OAAO,KAAK,EAGV,aAAa,EAEd,MAAM,cAAc,CAAC;AAQtB,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AA+H7D,QAAA,MAAM,QAAQ,EAAE,+BAA+B,CAAC,aAAa,CA2S3D,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
|
@@ -53,8 +53,7 @@ const StyledChatBody = styled.div(props => {
|
|
|
53
53
|
`;
|
|
54
54
|
});
|
|
55
55
|
StyledChatBody.defaultProps = defaultThemeProp;
|
|
56
|
-
const ScrollToLatest =
|
|
57
|
-
const { scrollContainerRef } = props;
|
|
56
|
+
const ScrollToLatest = ({ scrollContainerRef }) => {
|
|
58
57
|
useLayoutEffect(() => {
|
|
59
58
|
if (scrollContainerRef.current) {
|
|
60
59
|
scrollContainerRef.current.scrollTop =
|
|
@@ -63,7 +62,7 @@ const ScrollToLatest = props => {
|
|
|
63
62
|
});
|
|
64
63
|
return null;
|
|
65
64
|
};
|
|
66
|
-
const ChatMessage = ({ agentSerial, message }) => {
|
|
65
|
+
const ChatMessage = ({ agentSerial, message, renderMarkdownContent }) => {
|
|
67
66
|
const getAgentVariant = (senderId, senderType, direction = 'in') => {
|
|
68
67
|
if (agentSerial.current === null)
|
|
69
68
|
return undefined;
|
|
@@ -80,7 +79,7 @@ const ChatMessage = ({ agentSerial, message }) => {
|
|
|
80
79
|
if (isMessageListItem(message)) {
|
|
81
80
|
const { id, senderType, direction, senderId } = message;
|
|
82
81
|
const agentVariant = getAgentVariant(senderId, senderType, direction);
|
|
83
|
-
return _createElement(Message, { ...message, key: id, agentVariant: agentVariant });
|
|
82
|
+
return (_createElement(Message, { ...message, key: id, agentVariant: agentVariant, renderMarkdownContent: renderMarkdownContent }));
|
|
84
83
|
}
|
|
85
84
|
if (isSystemMessageListItem(message)) {
|
|
86
85
|
const extraProps = {};
|
|
@@ -97,8 +96,7 @@ const ChatMessage = ({ agentSerial, message }) => {
|
|
|
97
96
|
}
|
|
98
97
|
return null;
|
|
99
98
|
};
|
|
100
|
-
const ChatBody = forwardRef(function ChatBody(
|
|
101
|
-
const { transcripts, liveChat, unreadMessageCount = 0, onScrollToButtonClick, handle, loading, offset = -1, loadMore, ...restProps } = props;
|
|
99
|
+
const ChatBody = forwardRef(function ChatBody({ transcripts, liveChat, unreadMessageCount = 0, onScrollToButtonClick, handle, loading, offset = -1, loadMore, renderMarkdownContent, ...restProps }, ref) {
|
|
102
100
|
const t = useI18n();
|
|
103
101
|
const conversationRef = useRef(null);
|
|
104
102
|
const scrollRef = useRef(false);
|
|
@@ -282,8 +280,8 @@ const ChatBody = forwardRef(function ChatBody(props, ref) {
|
|
|
282
280
|
}
|
|
283
281
|
}
|
|
284
282
|
}, children: [loading && _jsx(Progress, { as: 'li', placement: 'block' }), transcripts.map(session => {
|
|
285
|
-
return (_jsx(StyledSession, { children: session.messages.map(message => (_jsx(ChatMessage, { message: message, agentSerial: agentSerial }, message.id))) }, session.id));
|
|
286
|
-
}), _jsx(StyledSession, { children: liveChat.map(message => (_jsx(ChatMessage, { message: message, agentSerial: agentSerial }, message.id))) })] }), (unreadMessageCount > 0 || displayScrollLatest) && (_jsxs(Button, { "aria-label": unreadMessageCount > 0
|
|
283
|
+
return (_jsx(StyledSession, { children: session.messages.map(message => (_jsx(ChatMessage, { message: message, agentSerial: agentSerial, renderMarkdownContent: renderMarkdownContent }, message.id))) }, session.id));
|
|
284
|
+
}), _jsx(StyledSession, { children: liveChat.map(message => (_jsx(ChatMessage, { message: message, agentSerial: agentSerial, renderMarkdownContent: renderMarkdownContent }, message.id))) })] }), (unreadMessageCount > 0 || displayScrollLatest) && (_jsxs(Button, { "aria-label": unreadMessageCount > 0
|
|
287
285
|
? t('scroll_to_unread_messages')
|
|
288
286
|
: t('scroll_to_latest_message'), onClick: () => {
|
|
289
287
|
if (unreadMessageCount > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBody.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatBody.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,MAAM,EACN,QAAQ,EACR,SAAS,EACV,MAAM,OAAO,CAAC;AAEf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,SAAS,EACT,OAAO,EACP,mBAAmB,EACnB,UAAU,EACV,aAAa,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AAEnG,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAOnG,OAAO,OAAO,MAAM,WAAW,CAAC;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B,CAAC,EACD,IAAI,EAAE,kBAAkB,KAAK,CAAC,EAC9B,GAAG,EAAE,SAAS,aAEd,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,EACzB,kBAAkB,GAAG,CAAC,IAAI,yCAAU,CAAC,CAAC,cAAc,CAAC,IAAI,IACnD,CACV,IACI,EACN,kBAAkB,EAAE,IAAI,KAAC,cAAc,IAAC,kBAAkB,EAAE,eAAe,GAAI,IAC/E,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n useEffect\n} from 'react';\nimport type { FunctionComponent, PropsWithoutRef, RefObject, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n debounce,\n defaultThemeProp,\n Flex,\n getFocusables,\n focusableSelector,\n Icon,\n Progress,\n registerIcon,\n StyledButton,\n useAfterInitialEffect,\n useArrows,\n useI18n,\n useItemIntersection,\n useLiveLog,\n useOuterEvent\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\nimport * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';\n\nimport { isMessageListItem, isSystemMessageListItem, isTypeIndicatorListItem } from './Chat.types';\nimport type {\n ChatBodyHandleValue,\n ChatBodyListItemProps,\n ChatBodyProps,\n MessageProps\n} from './Chat.types';\nimport Message from './Message';\nimport SystemMessage, { StyledSystemMessage } from './SystemMessage';\nimport TypeIndicator from './TypeIndicator';\nimport { StyledMessageContainer } from './Message.styles';\n\nregisterIcon(caretDownIcon);\n\nexport const NewMessageSeparatorId = 'new-message-separator';\n\nconst StyledMessageList = styled.ul``;\nconst StyledSession = styled.div``;\n\nconst StyledChatBody = styled.div(props => {\n const {\n theme: {\n base: {\n shadow: { high: shadowHigh, focus },\n colors: { white },\n spacing,\n palette\n }\n }\n } = props;\n return css`\n position: relative;\n overflow-y: hidden;\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\n > ${StyledMessageList} {\n overflow-y: auto;\n list-style-type: none;\n height: 100%;\n\n > ${StyledSession} {\n padding-inline: 1rem;\n :not(:last-child) {\n border-block-end: 0.0625rem solid ${palette['border-line']};\n margin-block-end: ${spacing};\n padding-block-end: ${spacing};\n }\n }\n ${StyledMessageContainer}, ${StyledSystemMessage} {\n &:focus-visible {\n box-shadow: ${focus};\n outline: none;\n }\n margin-block-end: ${spacing};\n }\n }\n `;\n});\n\nStyledChatBody.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 null;\n};\n\ninterface ChatMessageProps {\n message: ChatBodyListItemProps;\n agentSerial: RefObject<{ [agentId: string]: number }>;\n}\n\nconst ChatMessage: FunctionComponent<ChatMessageProps> = ({ agentSerial, message }) => {\n const getAgentVariant = (\n senderId: MessageProps['senderId'],\n senderType: MessageProps['senderType'],\n direction: MessageProps['direction'] = 'in'\n ) => {\n if (agentSerial.current === null) return undefined;\n if (senderType === 'agent' && direction === 'in') {\n if (agentSerial.current[senderId] !== undefined) {\n return agentSerial.current[senderId];\n }\n\n const nextIndex = Object.entries(agentSerial.current).length;\n agentSerial.current[senderId] = nextIndex;\n return nextIndex;\n }\n return undefined;\n };\n\n if (isMessageListItem(message)) {\n const { id, senderType, direction, senderId } = message;\n const agentVariant = getAgentVariant(senderId, senderType, direction);\n return <Message {...message} key={id} agentVariant={agentVariant} />;\n }\n\n if (isSystemMessageListItem(message)) {\n const extraProps: Record<string, string> = {};\n const { id } = message;\n if (id === NewMessageSeparatorId) {\n extraProps['data-new-message-separator'] = NewMessageSeparatorId;\n }\n\n return <SystemMessage {...message} key={id} {...extraProps} />;\n }\n\n if (isTypeIndicatorListItem(message)) {\n const { id, senderId, senderType } = message;\n const agentVariant = getAgentVariant(senderId, senderType);\n\n return <TypeIndicator {...message} key={id} agentVariant={agentVariant} />;\n }\n\n return null;\n};\n\nconst ChatBody: FunctionComponent<ChatBodyProps & ForwardProps> = forwardRef(function ChatBody(\n props: PropsWithoutRef<ChatBodyProps>,\n ref: ChatBodyProps['ref']\n) {\n const {\n transcripts,\n liveChat,\n unreadMessageCount = 0,\n onScrollToButtonClick,\n handle,\n loading,\n offset = -1,\n loadMore,\n ...restProps\n } = props;\n\n const t = useI18n();\n const conversationRef = useRef<HTMLUListElement>(null);\n const scrollRef = useRef(false);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const focusInMessageList = useRef(false);\n const initialMessageListFocused = useRef(false);\n const elementRef = useRef<HTMLElement | null>(null);\n const activeElementIndex = useRef(-1);\n const agentSerial = useRef<{ [agentId: string]: number }>({});\n const chatFocusableSelector = 'li[type=\"system\"],li[type=\"message\"],li[type=\"typing\"]';\n\n const [messageList, setMessageList] = useState<(HTMLLIElement | null)[]>([]);\n const [verticalNav, setVerticalNav] = useState(true);\n\n const { announcePolite } = useLiveLog();\n\n const isScrolledToLatest: ChatBodyHandleValue['isScrolledToLatest'] = 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: ChatBodyHandleValue['scrollToLatestMessage'] = useCallback(() => {\n if (conversationRef.current) {\n conversationRef.current.scrollTop = conversationRef.current.scrollHeight;\n focusInMessageList.current = true;\n messageList[messageList.length - 1]?.focus();\n activeElementIndex.current = messageList.length - 1;\n }\n }, [conversationRef.current, messageList]);\n\n const [displayScrollLatest, setDisplayScrollToLatest] = useState(false);\n\n const onMessageListScroll = useCallback(() => {\n const isScrolled = isScrolledToLatest();\n if (scrollRef.current && isScrolled) {\n scrollRef.current = false;\n if (unreadMessageCount) {\n onScrollToButtonClick?.();\n }\n }\n\n if (!scrollRef.current && !isScrolled) {\n scrollRef.current = true;\n }\n\n setDisplayScrollToLatest(!isScrolled);\n }, [isScrolledToLatest(), unreadMessageCount]);\n\n const scrollToNewMessage: ChatBodyHandleValue['scrollToNewMessage'] = useCallback(() => {\n if (conversationRef.current) {\n setDisplayScrollToLatest(false);\n const newMessageIndicatorEle = conversationRef.current.querySelector<HTMLElement>(\n '[data-new-message-separator]'\n );\n if (\n newMessageIndicatorEle &&\n newMessageIndicatorEle.nextElementSibling instanceof HTMLElement\n ) {\n conversationRef.current.scrollTop = newMessageIndicatorEle.offsetTop;\n focusInMessageList.current = true;\n newMessageIndicatorEle.nextElementSibling.focus();\n activeElementIndex.current =\n messageList.findIndex(item => item?.hasAttribute('data-new-message-separator')) + 1;\n } else {\n scrollToLatestMessage();\n }\n }\n }, [conversationRef.current, messageList]);\n\n useImperativeHandle(\n handle,\n () => ({\n isScrolledToLatest,\n scrollToLatestMessage,\n scrollToNewMessage\n }),\n [isScrolledToLatest, scrollToLatestMessage, scrollToNewMessage]\n );\n\n useItemIntersection(\n conversationRef,\n offset,\n () => {\n loadMore?.();\n },\n ':scope > div > li'\n );\n\n useEffect(() => {\n const focusableElements =\n conversationRef.current?.querySelectorAll<HTMLLIElement>(chatFocusableSelector);\n\n if (focusableElements) setMessageList(Array.from(focusableElements));\n\n if (focusableElements && initialMessageListFocused.current === false) {\n activeElementIndex.current = focusableElements.length - 1;\n }\n }, [transcripts.length, liveChat.length]);\n\n useEffect(() => {\n elementRef.current = messageList[activeElementIndex.current];\n if (verticalNav) {\n elementRef.current?.focus();\n } else {\n getFocusables(elementRef)[0]?.focus();\n }\n }, [verticalNav]);\n\n useArrows(\n conversationRef,\n {\n cycle: true,\n selector: ':scope > div > li',\n dir: 'up-down',\n allowTabFocus: true\n },\n [transcripts, liveChat]\n );\n\n useArrows(\n elementRef,\n {\n cycle: true,\n selector: `li :is(${focusableSelector})`,\n dir: 'left-right',\n allowTabFocus: true\n },\n [transcripts, liveChat, verticalNav]\n );\n\n const focusSiblingElement = (currentElement: Element, isShiftKey = false) => {\n elementRef.current = currentElement as HTMLElement;\n const focusableElements = getFocusables(elementRef);\n if (focusableElements?.length > 0) {\n focusableElements?.[isShiftKey ? focusableElements.length - 1 : 0].focus();\n } else {\n const element = isShiftKey\n ? elementRef.current?.previousElementSibling\n : elementRef.current?.nextElementSibling;\n\n if (element) focusSiblingElement(element, isShiftKey);\n }\n };\n\n useOuterEvent('mousedown', [conversationRef], () => {\n focusInMessageList.current = false;\n });\n\n useAfterInitialEffect(() => {\n if (liveChat?.length > 0) {\n const unreadMessage = liveChat[liveChat.length - 1];\n if (\n isSystemMessageListItem(unreadMessage) ||\n (isMessageListItem(unreadMessage) && unreadMessage.direction === 'in')\n ) {\n announcePolite({\n message: t('new_message'),\n type: 'alert'\n });\n }\n }\n }, [liveChat]);\n\n return (\n <>\n <Flex\n {...restProps}\n as={StyledChatBody}\n item={{\n grow: 1\n }}\n container={{\n direction: 'column'\n }}\n ref={ref}\n >\n <StyledMessageList\n ref={conversationRef}\n onScroll={debounce(onMessageListScroll, 100)}\n onFocus={() => {\n if (!focusInMessageList.current) {\n initialMessageListFocused.current = true;\n elementRef.current = messageList[activeElementIndex.current];\n elementRef.current?.focus();\n focusInMessageList.current = true;\n }\n }}\n onMouseDown={(e: MouseEvent<HTMLUListElement>) => {\n focusInMessageList.current = true;\n const liElement = (e.target as HTMLElement).closest(chatFocusableSelector);\n if (liElement) {\n activeElementIndex.current = messageList.indexOf(liElement as HTMLLIElement);\n }\n }}\n onKeyDown={e => {\n if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {\n elementRef.current = messageList[activeElementIndex.current];\n if (getFocusables(elementRef).length > 0) {\n setVerticalNav(false);\n }\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n if (e.key === 'ArrowUp') {\n activeElementIndex.current =\n activeElementIndex.current === 0\n ? messageList.length - 1\n : activeElementIndex.current - 1;\n } else {\n activeElementIndex.current =\n activeElementIndex.current === messageList.length - 1\n ? 0\n : activeElementIndex.current + 1;\n }\n setVerticalNav(true);\n } else if (e.key === 'Tab') {\n e.preventDefault();\n focusInMessageList.current = false;\n if (e.shiftKey) {\n const prevElement = conversationRef?.current?.parentElement?.previousElementSibling;\n if (prevElement) focusSiblingElement(prevElement, true);\n } else if (unreadMessageCount > 0 || displayScrollLatest) {\n buttonRef?.current?.focus();\n } else {\n const nextElement = conversationRef.current?.parentElement?.nextElementSibling;\n if (nextElement) focusSiblingElement(nextElement);\n }\n }\n }}\n >\n {loading && <Progress as='li' placement='block' />}\n {transcripts.map(session => {\n return (\n <StyledSession key={session.id}>\n {session.messages.map(message => (\n <ChatMessage message={message} agentSerial={agentSerial} key={message.id} />\n ))}\n </StyledSession>\n );\n })}\n <StyledSession>\n {liveChat.map(message => (\n <ChatMessage message={message} agentSerial={agentSerial} key={message.id} />\n ))}\n </StyledSession>\n </StyledMessageList>\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 ref={buttonRef}\n >\n <Icon name='caret-down' />\n {unreadMessageCount > 0 && <> {t('new_messages')}</>}\n </Button>\n )}\n </Flex>\n {isScrolledToLatest() && <ScrollToLatest scrollContainerRef={conversationRef} />}\n </>\n );\n});\n\nexport default ChatBody;\n"]}
|
|
1
|
+
{"version":3,"file":"ChatBody.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatBody.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,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,CAAC,EAAE,CAAC,CACvB,KAAC,WAAW,IACV,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EAExB,qBAAqB,EAAE,qBAAqB,IADvC,OAAO,CAAC,EAAE,CAEf,CACH,CAAC,GACY,IACE,EACnB,CAAC,kBAAkB,GAAG,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAClD,MAAC,MAAM,kBAEH,kBAAkB,GAAG,CAAC;4BACpB,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC;4BAChC,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,EAEnC,OAAO,EAAE,GAAG,EAAE;4BACZ,IAAI,kBAAkB,GAAG,CAAC,EAAE,CAAC;gCAC3B,kBAAkB,EAAE,CAAC;4BACvB,CAAC;iCAAM,CAAC;gCACN,qBAAqB,EAAE,CAAC;4BAC1B,CAAC;4BACD,qBAAqB,EAAE,EAAE,CAAC;wBAC5B,CAAC,EACD,IAAI,EAAE,kBAAkB,KAAK,CAAC,EAC9B,GAAG,EAAE,SAAS,aAEd,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,EACzB,kBAAkB,GAAG,CAAC,IAAI,yCAAU,CAAC,CAAC,cAAc,CAAC,IAAI,IACnD,CACV,IACI,EACN,kBAAkB,EAAE,IAAI,KAAC,cAAc,IAAC,kBAAkB,EAAE,eAAe,GAAI,IAC/E,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n useEffect\n} from 'react';\nimport type { PropsWithoutRef, RefObject, MouseEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n debounce,\n defaultThemeProp,\n Flex,\n getFocusables,\n focusableSelector,\n Icon,\n Progress,\n registerIcon,\n StyledButton,\n useAfterInitialEffect,\n useArrows,\n useI18n,\n useItemIntersection,\n useLiveLog,\n useOuterEvent\n} from '@pega/cosmos-react-core';\nimport type { ForwardRefForwardPropsComponent } from '@pega/cosmos-react-core';\nimport * as caretDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-down.icon';\n\nimport { isMessageListItem, isSystemMessageListItem, isTypeIndicatorListItem } from './Chat.types';\nimport type {\n ChatBodyHandleValue,\n ChatBodyListItemProps,\n ChatBodyProps,\n MessageProps\n} from './Chat.types';\nimport Message from './Message';\nimport SystemMessage, { StyledSystemMessage } from './SystemMessage';\nimport TypeIndicator from './TypeIndicator';\nimport { StyledMessageContainer } from './Message.styles';\n\nregisterIcon(caretDownIcon);\n\nexport const NewMessageSeparatorId = 'new-message-separator';\n\nconst StyledMessageList = styled.ul``;\nconst StyledSession = styled.div``;\n\nconst StyledChatBody = styled.div(props => {\n const {\n theme: {\n base: {\n shadow: { high: shadowHigh, focus },\n colors: { white },\n spacing,\n palette\n }\n }\n } = props;\n return css`\n position: relative;\n overflow-y: hidden;\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\n > ${StyledMessageList} {\n overflow-y: auto;\n list-style-type: none;\n height: 100%;\n\n > ${StyledSession} {\n padding-inline: 1rem;\n :not(:last-child) {\n border-block-end: 0.0625rem solid ${palette['border-line']};\n margin-block-end: ${spacing};\n padding-block-end: ${spacing};\n }\n }\n ${StyledMessageContainer}, ${StyledSystemMessage} {\n &:focus-visible {\n box-shadow: ${focus};\n outline: none;\n }\n margin-block-end: ${spacing};\n }\n }\n `;\n});\n\nStyledChatBody.defaultProps = defaultThemeProp;\n\nconst ScrollToLatest = ({\n scrollContainerRef\n}: {\n scrollContainerRef: RefObject<HTMLUListElement>;\n}) => {\n useLayoutEffect(() => {\n if (scrollContainerRef.current) {\n scrollContainerRef.current.scrollTop =\n scrollContainerRef.current.scrollHeight - scrollContainerRef.current.offsetHeight;\n }\n });\n return null;\n};\n\ninterface ChatMessageProps extends Pick<ChatBodyProps, 'renderMarkdownContent'> {\n message: ChatBodyListItemProps;\n agentSerial: RefObject<{ [agentId: string]: number }>;\n}\n\nconst ChatMessage = ({ agentSerial, message, renderMarkdownContent }: ChatMessageProps) => {\n const getAgentVariant = (\n senderId: MessageProps['senderId'],\n senderType: MessageProps['senderType'],\n direction: MessageProps['direction'] = 'in'\n ) => {\n if (agentSerial.current === null) return undefined;\n if (senderType === 'agent' && direction === 'in') {\n if (agentSerial.current[senderId] !== undefined) {\n return agentSerial.current[senderId];\n }\n\n const nextIndex = Object.entries(agentSerial.current).length;\n agentSerial.current[senderId] = nextIndex;\n return nextIndex;\n }\n return undefined;\n };\n\n if (isMessageListItem(message)) {\n const { id, senderType, direction, senderId } = message;\n const agentVariant = getAgentVariant(senderId, senderType, direction);\n return (\n <Message\n {...message}\n key={id}\n agentVariant={agentVariant}\n renderMarkdownContent={renderMarkdownContent}\n />\n );\n }\n\n if (isSystemMessageListItem(message)) {\n const extraProps: Record<string, string> = {};\n const { id } = message;\n if (id === NewMessageSeparatorId) {\n extraProps['data-new-message-separator'] = NewMessageSeparatorId;\n }\n\n return <SystemMessage {...message} key={id} {...extraProps} />;\n }\n\n if (isTypeIndicatorListItem(message)) {\n const { id, senderId, senderType } = message;\n const agentVariant = getAgentVariant(senderId, senderType);\n\n return <TypeIndicator {...message} key={id} agentVariant={agentVariant} />;\n }\n\n return null;\n};\n\nconst ChatBody: ForwardRefForwardPropsComponent<ChatBodyProps> = forwardRef(function ChatBody(\n {\n transcripts,\n liveChat,\n unreadMessageCount = 0,\n onScrollToButtonClick,\n handle,\n loading,\n offset = -1,\n loadMore,\n renderMarkdownContent,\n ...restProps\n }: PropsWithoutRef<ChatBodyProps>,\n ref: ChatBodyProps['ref']\n) {\n const t = useI18n();\n const conversationRef = useRef<HTMLUListElement>(null);\n const scrollRef = useRef(false);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const focusInMessageList = useRef(false);\n const initialMessageListFocused = useRef(false);\n const elementRef = useRef<HTMLElement | null>(null);\n const activeElementIndex = useRef(-1);\n const agentSerial = useRef<{ [agentId: string]: number }>({});\n const chatFocusableSelector = 'li[type=\"system\"],li[type=\"message\"],li[type=\"typing\"]';\n\n const [messageList, setMessageList] = useState<(HTMLLIElement | null)[]>([]);\n const [verticalNav, setVerticalNav] = useState(true);\n\n const { announcePolite } = useLiveLog();\n\n const isScrolledToLatest: ChatBodyHandleValue['isScrolledToLatest'] = 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: ChatBodyHandleValue['scrollToLatestMessage'] = useCallback(() => {\n if (conversationRef.current) {\n conversationRef.current.scrollTop = conversationRef.current.scrollHeight;\n focusInMessageList.current = true;\n messageList[messageList.length - 1]?.focus();\n activeElementIndex.current = messageList.length - 1;\n }\n }, [conversationRef.current, messageList]);\n\n const [displayScrollLatest, setDisplayScrollToLatest] = useState(false);\n\n const onMessageListScroll = useCallback(() => {\n const isScrolled = isScrolledToLatest();\n if (scrollRef.current && isScrolled) {\n scrollRef.current = false;\n if (unreadMessageCount) {\n onScrollToButtonClick?.();\n }\n }\n\n if (!scrollRef.current && !isScrolled) {\n scrollRef.current = true;\n }\n\n setDisplayScrollToLatest(!isScrolled);\n }, [isScrolledToLatest(), unreadMessageCount]);\n\n const scrollToNewMessage: ChatBodyHandleValue['scrollToNewMessage'] = useCallback(() => {\n if (conversationRef.current) {\n setDisplayScrollToLatest(false);\n const newMessageIndicatorEle = conversationRef.current.querySelector<HTMLElement>(\n '[data-new-message-separator]'\n );\n if (\n newMessageIndicatorEle &&\n newMessageIndicatorEle.nextElementSibling instanceof HTMLElement\n ) {\n conversationRef.current.scrollTop = newMessageIndicatorEle.offsetTop;\n focusInMessageList.current = true;\n newMessageIndicatorEle.nextElementSibling.focus();\n activeElementIndex.current =\n messageList.findIndex(item => item?.hasAttribute('data-new-message-separator')) + 1;\n } else {\n scrollToLatestMessage();\n }\n }\n }, [conversationRef.current, messageList]);\n\n useImperativeHandle(\n handle,\n () => ({\n isScrolledToLatest,\n scrollToLatestMessage,\n scrollToNewMessage\n }),\n [isScrolledToLatest, scrollToLatestMessage, scrollToNewMessage]\n );\n\n useItemIntersection(\n conversationRef,\n offset,\n () => {\n loadMore?.();\n },\n ':scope > div > li'\n );\n\n useEffect(() => {\n const focusableElements =\n conversationRef.current?.querySelectorAll<HTMLLIElement>(chatFocusableSelector);\n\n if (focusableElements) setMessageList(Array.from(focusableElements));\n\n if (focusableElements && initialMessageListFocused.current === false) {\n activeElementIndex.current = focusableElements.length - 1;\n }\n }, [transcripts.length, liveChat.length]);\n\n useEffect(() => {\n elementRef.current = messageList[activeElementIndex.current];\n if (verticalNav) {\n elementRef.current?.focus();\n } else {\n getFocusables(elementRef)[0]?.focus();\n }\n }, [verticalNav]);\n\n useArrows(\n conversationRef,\n {\n cycle: true,\n selector: ':scope > div > li',\n dir: 'up-down',\n allowTabFocus: true\n },\n [transcripts, liveChat]\n );\n\n useArrows(\n elementRef,\n {\n cycle: true,\n selector: `li :is(${focusableSelector})`,\n dir: 'left-right',\n allowTabFocus: true\n },\n [transcripts, liveChat, verticalNav]\n );\n\n const focusSiblingElement = (currentElement: Element, isShiftKey = false) => {\n elementRef.current = currentElement as HTMLElement;\n const focusableElements = getFocusables(elementRef);\n if (focusableElements?.length > 0) {\n focusableElements?.[isShiftKey ? focusableElements.length - 1 : 0].focus();\n } else {\n const element = isShiftKey\n ? elementRef.current?.previousElementSibling\n : elementRef.current?.nextElementSibling;\n\n if (element) focusSiblingElement(element, isShiftKey);\n }\n };\n\n useOuterEvent('mousedown', [conversationRef], () => {\n focusInMessageList.current = false;\n });\n\n useAfterInitialEffect(() => {\n if (liveChat?.length > 0) {\n const unreadMessage = liveChat[liveChat.length - 1];\n if (\n isSystemMessageListItem(unreadMessage) ||\n (isMessageListItem(unreadMessage) && unreadMessage.direction === 'in')\n ) {\n announcePolite({\n message: t('new_message'),\n type: 'alert'\n });\n }\n }\n }, [liveChat]);\n\n return (\n <>\n <Flex\n {...restProps}\n as={StyledChatBody}\n item={{\n grow: 1\n }}\n container={{\n direction: 'column'\n }}\n ref={ref}\n >\n <StyledMessageList\n ref={conversationRef}\n onScroll={debounce(onMessageListScroll, 100)}\n onFocus={() => {\n if (!focusInMessageList.current) {\n initialMessageListFocused.current = true;\n elementRef.current = messageList[activeElementIndex.current];\n elementRef.current?.focus();\n focusInMessageList.current = true;\n }\n }}\n onMouseDown={(e: MouseEvent<HTMLUListElement>) => {\n focusInMessageList.current = true;\n const liElement = (e.target as HTMLElement).closest(chatFocusableSelector);\n if (liElement) {\n activeElementIndex.current = messageList.indexOf(liElement as HTMLLIElement);\n }\n }}\n onKeyDown={e => {\n if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {\n elementRef.current = messageList[activeElementIndex.current];\n if (getFocusables(elementRef).length > 0) {\n setVerticalNav(false);\n }\n } else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {\n if (e.key === 'ArrowUp') {\n activeElementIndex.current =\n activeElementIndex.current === 0\n ? messageList.length - 1\n : activeElementIndex.current - 1;\n } else {\n activeElementIndex.current =\n activeElementIndex.current === messageList.length - 1\n ? 0\n : activeElementIndex.current + 1;\n }\n setVerticalNav(true);\n } else if (e.key === 'Tab') {\n e.preventDefault();\n focusInMessageList.current = false;\n if (e.shiftKey) {\n const prevElement = conversationRef?.current?.parentElement?.previousElementSibling;\n if (prevElement) focusSiblingElement(prevElement, true);\n } else if (unreadMessageCount > 0 || displayScrollLatest) {\n buttonRef?.current?.focus();\n } else {\n const nextElement = conversationRef.current?.parentElement?.nextElementSibling;\n if (nextElement) focusSiblingElement(nextElement);\n }\n }\n }}\n >\n {loading && <Progress as='li' placement='block' />}\n {transcripts.map(session => {\n return (\n <StyledSession key={session.id}>\n {session.messages.map(message => (\n <ChatMessage\n message={message}\n agentSerial={agentSerial}\n key={message.id}\n renderMarkdownContent={renderMarkdownContent}\n />\n ))}\n </StyledSession>\n );\n })}\n <StyledSession>\n {liveChat.map(message => (\n <ChatMessage\n message={message}\n agentSerial={agentSerial}\n key={message.id}\n renderMarkdownContent={renderMarkdownContent}\n />\n ))}\n </StyledSession>\n </StyledMessageList>\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 ref={buttonRef}\n >\n <Icon name='caret-down' />\n {unreadMessageCount > 0 && <> {t('new_messages')}</>}\n </Button>\n )}\n </Flex>\n {isScrolledToLatest() && <ScrollToLatest scrollContainerRef={conversationRef} />}\n </>\n );\n});\n\nexport default ChatBody;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Ref, PropsWithoutRef, ReactNode, RefObject, KeyboardEvent } from 'react';
|
|
2
|
+
import type { ForwardRefForwardPropsComponent, FileItemProps } from '@pega/cosmos-react-core';
|
|
3
3
|
export type SpecialKeysConfig = {
|
|
4
4
|
/** Collection of specialKeys */
|
|
5
5
|
keys: string[];
|
|
@@ -50,7 +50,7 @@ export interface ChatComposerProps {
|
|
|
50
50
|
ref?: Ref<ChatComposerImperativeHandleProps>;
|
|
51
51
|
}
|
|
52
52
|
export declare const StyledAttachmentsListContainer: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<PropsWithoutRef<import("@pega/cosmos-react-core").FileListProps> & import("react").RefAttributes<HTMLDivElement>>, import("styled-components").DefaultTheme, {}, never>;
|
|
53
|
-
export declare const StyledJoinConversation: import("styled-components").StyledComponent<
|
|
53
|
+
export declare const StyledJoinConversation: import("styled-components").StyledComponent<ForwardRefForwardPropsComponent<import("@pega/cosmos-react-core").ButtonProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
54
54
|
export interface ChatComposerImperativeHandleProps {
|
|
55
55
|
/** Function to append a message */
|
|
56
56
|
appendToMessage: (appendMessage: string, position?: 'cursor' | 'start' | 'end' | 'specialKey') => void;
|
|
@@ -58,6 +58,6 @@ export interface ChatComposerImperativeHandleProps {
|
|
|
58
58
|
chatComposerRef: RefObject<HTMLDivElement | undefined>;
|
|
59
59
|
textAreaRef: RefObject<HTMLTextAreaElement | undefined>;
|
|
60
60
|
}
|
|
61
|
-
declare const ChatComposer:
|
|
61
|
+
declare const ChatComposer: ForwardRefForwardPropsComponent<ChatComposerProps>;
|
|
62
62
|
export default ChatComposer;
|
|
63
63
|
//# sourceMappingURL=ChatComposer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,SAAS,EAAe,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAqBpG,OAAO,KAAK,EAGV,+BAA+B,EAC/B,aAAa,EACd,MAAM,yBAAyB,CAAC;AASjC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gCAAgC;IAChC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,oEAAoE;IACpE,YAAY,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5E,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0BAA0B;I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AC,CAAC;CACzD;AAED,QAAA,MAAM,YAAY,EAAE,+BAA+B,CAAC,iBAAiB,CA6TpE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useState, useEffect, useCallback, useImperativeHandle, useRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { Flex, TextArea, Button, Icon, registerIcon, Popover, EmojiPicker, hasProp, useI18n, useElement, defaultThemeProp,
|
|
4
|
+
import { Flex, TextArea, Button, Icon, registerIcon, Popover, EmojiPicker, hasProp, useI18n, useElement, defaultThemeProp, useOuterEvent, VisuallyHiddenText, AIButton, FileList, useAfterInitialEffect } from '@pega/cosmos-react-core';
|
|
5
5
|
import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
|
|
6
6
|
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
7
7
|
import * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';
|
|
8
8
|
import * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';
|
|
9
9
|
import { StyledFileList } from '@pega/cosmos-react-core/lib/components/File/FileList';
|
|
10
10
|
registerIcon(timesIcon, faceHappyIcon, paperClipIcon);
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
`);
|
|
20
|
-
});
|
|
11
|
+
const StyledAttachmentButton = styled(Button)(({ theme, maxAttachmentsReached }) => maxAttachmentsReached
|
|
12
|
+
? css `
|
|
13
|
+
opacity: ${theme.base['disabled-opacity']};
|
|
14
|
+
cursor: not-allowed;
|
|
15
|
+
`
|
|
16
|
+
: null);
|
|
17
|
+
StyledAttachmentButton.defaultProps = defaultThemeProp;
|
|
21
18
|
const StyledPreviewButton = styled(BareButton) ``;
|
|
22
19
|
const StyledDeleteButton = styled(BareButton) ``;
|
|
23
20
|
const StyledChatComposer = styled.footer(({ theme, disabled, theme: { base: { 'disabled-opacity': transparentBg, spacing } } }) => {
|
|
@@ -40,13 +37,6 @@ const StyledChatComposer = styled.footer(({ theme, disabled, theme: { base: { 'd
|
|
|
40
37
|
`}
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
${StyledAttachmentElementContainer} {
|
|
44
|
-
${disabled &&
|
|
45
|
-
css `
|
|
46
|
-
pointer-events: none;
|
|
47
|
-
`}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
40
|
${StyledPreviewButton} {
|
|
51
41
|
color: ${theme.base.palette.interactive};
|
|
52
42
|
font-weight: bold;
|
|
@@ -61,7 +51,6 @@ const StyledChatComposer = styled.footer(({ theme, disabled, theme: { base: { 'd
|
|
|
61
51
|
`;
|
|
62
52
|
});
|
|
63
53
|
StyledChatComposer.defaultProps = defaultThemeProp;
|
|
64
|
-
StyledAttachmentElementContainer.defaultProps = defaultThemeProp;
|
|
65
54
|
export const StyledAttachmentsListContainer = styled(FileList)(({ theme }) => {
|
|
66
55
|
return css `
|
|
67
56
|
max-height: 5rem;
|
|
@@ -77,8 +66,7 @@ StyledAttachmentsListContainer.defaultProps = defaultThemeProp;
|
|
|
77
66
|
export const StyledJoinConversation = styled(Button) `
|
|
78
67
|
margin: auto;
|
|
79
68
|
`;
|
|
80
|
-
const ChatComposer = forwardRef(function ChatComposer(
|
|
81
|
-
const { children, attachments = [], maxAttachments = 0, onAddAttachment, maxLength, placeholder: defaultPlaceHolder, defaultMessage = '', onSend, specialKeysConfig, disabled = false, enterKeySendsMessage = true, showEmoji, onSuggestReplyClick, disableSuggestReply = false, joinConversation, ...restProps } = props;
|
|
69
|
+
const ChatComposer = forwardRef(function ChatComposer({ children, attachments = [], maxAttachments = 0, onAddAttachment, maxLength, placeholder: defaultPlaceHolder, defaultMessage = '', onSend, specialKeysConfig, disabled = false, enterKeySendsMessage = true, showEmoji, onSuggestReplyClick, disableSuggestReply = false, joinConversation, ...restProps }, ref) {
|
|
82
70
|
const [message, setMessage] = useState(defaultMessage);
|
|
83
71
|
useEffect(() => {
|
|
84
72
|
setMessage(defaultMessage);
|
|
@@ -87,9 +75,9 @@ const ChatComposer = forwardRef(function ChatComposer(props, ref) {
|
|
|
87
75
|
const textAreaRef = useRef(null);
|
|
88
76
|
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
|
|
89
77
|
const [emojiBtnEl, setEmojiBtnEl] = useElement();
|
|
90
|
-
const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();
|
|
91
78
|
const [announcement, setAnnouncement] = useState('');
|
|
92
79
|
const lastEnteredSpecialKey = useRef(null);
|
|
80
|
+
const maxAttachmentsReached = attachments.length >= maxAttachments;
|
|
93
81
|
const appendToMessage = useCallback((appendMessage, position, selectText = true) => {
|
|
94
82
|
let selectionStart;
|
|
95
83
|
let selectionEnd;
|
|
@@ -208,9 +196,11 @@ const ChatComposer = forwardRef(function ChatComposer(props, ref) {
|
|
|
208
196
|
onCancel: undefined
|
|
209
197
|
};
|
|
210
198
|
})
|
|
211
|
-
: attachments }), _jsx(TextArea, { ref: textAreaRef, maxLength: maxLength, displayCharCount: maxLength !== undefined, hardStop: false, placeholder: defaultPlaceHolder, value: message, disabled: disabled, onKeyUp: handleSpecialKey, onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, onFocus: handleTextAreaChange, "aria-label": t('enter_message'), autoResize: false })] }), _jsxs(Flex, { container: { gap: 0.5 }, children: [showEmoji && (_jsx(Button, { ref: setEmojiBtnEl, onClick: toggleEmoji, variant: 'simple', disabled: disabled, icon: true, "aria-label": t('add_emoji'), children: _jsx(Icon, { name: 'face-happy' }) })), maxAttachments > 0 && (
|
|
212
|
-
|
|
213
|
-
|
|
199
|
+
: attachments }), _jsx(TextArea, { ref: textAreaRef, maxLength: maxLength, displayCharCount: maxLength !== undefined, hardStop: false, placeholder: defaultPlaceHolder, value: message, disabled: disabled, onKeyUp: handleSpecialKey, onKeyDown: handleEnterKeyDown, onChange: handleTextAreaChange, onFocus: handleTextAreaChange, "aria-label": t('enter_message'), autoResize: false })] }), _jsxs(Flex, { container: { gap: 0.5 }, children: [showEmoji && (_jsx(Button, { ref: setEmojiBtnEl, onClick: toggleEmoji, variant: 'simple', disabled: disabled, icon: true, "aria-label": t('add_emoji'), children: _jsx(Icon, { name: 'face-happy' }) })), maxAttachments > 0 && (_jsx("div", { children: _jsx(StyledAttachmentButton, { onClick: maxAttachmentsReached ? undefined : onAddAttachment, variant: 'simple', maxAttachmentsReached: maxAttachmentsReached, disabled: disabled, icon: true, label: maxAttachmentsReached
|
|
200
|
+
? t('email_disable_attachment', [maxAttachments])
|
|
201
|
+
: t('email_add_attachment'), "aria-label": t(maxAttachmentsReached
|
|
202
|
+
? 'email_disable_attachment'
|
|
203
|
+
: 'email_add_attachment_count', [maxAttachments]), children: _jsx(Icon, { name: 'paper-clip' }) }) })), _jsxs(Flex, { item: { grow: 1 }, container: { gap: 1 }, children: [children, onSuggestReplyClick && (_jsx(AIButton, { label: t('suggest_reply'), disabled: disabled || disableSuggestReply, onClick: onSuggestReplyClick }))] }), _jsx(Button, { variant: 'primary', disabled: disabled || (!!maxLength && message.length > maxLength), onClick: () => {
|
|
214
204
|
sendMessage(message);
|
|
215
205
|
setAnnouncement(t('message_sent'));
|
|
216
206
|
}, children: t('send') }), announcement && (_jsx(VisuallyHiddenText, { "aria-live": 'assertive', children: announcement }))] })] })) }), _jsx(Popover, { show: showEmojiPicker, target: emojiBtnEl, placement: 'top-start', modifiers: [
|