@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.
Files changed (36) hide show
  1. package/SECURITY.md +11 -0
  2. package/lib/components/Chat/Chat.types.d.ts +7 -3
  3. package/lib/components/Chat/Chat.types.d.ts.map +1 -1
  4. package/lib/components/Chat/Chat.types.js.map +1 -1
  5. package/lib/components/Chat/ChatComposer.d.ts +7 -0
  6. package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
  7. package/lib/components/Chat/ChatComposer.js +4 -4
  8. package/lib/components/Chat/ChatComposer.js.map +1 -1
  9. package/lib/components/Chat/Message.d.ts.map +1 -1
  10. package/lib/components/Chat/Message.js +6 -4
  11. package/lib/components/Chat/Message.js.map +1 -1
  12. package/lib/components/Chat/Message.styles.d.ts +5 -2
  13. package/lib/components/Chat/Message.styles.d.ts.map +1 -1
  14. package/lib/components/Chat/Message.styles.js +21 -7
  15. package/lib/components/Chat/Message.styles.js.map +1 -1
  16. package/lib/components/Chat/SuggestedReplyPicker.d.ts +15 -4
  17. package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
  18. package/lib/components/Chat/SuggestedReplyPicker.js +76 -27
  19. package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
  20. package/lib/components/Chat/index.d.ts +1 -1
  21. package/lib/components/Chat/index.d.ts.map +1 -1
  22. package/lib/components/Chat/index.js +1 -1
  23. package/lib/components/Chat/index.js.map +1 -1
  24. package/lib/components/Email/ContextMenuPopover.d.ts.map +1 -1
  25. package/lib/components/Email/ContextMenuPopover.js +23 -15
  26. package/lib/components/Email/ContextMenuPopover.js.map +1 -1
  27. package/lib/components/Email/Email.js +1 -1
  28. package/lib/components/Email/Email.js.map +1 -1
  29. package/lib/components/Email/Email.types.d.ts +1 -1
  30. package/lib/components/Email/Email.types.d.ts.map +1 -1
  31. package/lib/components/Email/Email.types.js.map +1 -1
  32. package/lib/components/Email/EntityList.js +1 -1
  33. package/lib/components/Email/EntityList.js.map +1 -1
  34. package/lib/components/Feed/FeedRichText.js +1 -1
  35. package/lib/components/Feed/FeedRichText.js.map +1 -1
  36. package/package.json +7 -6
package/SECURITY.md ADDED
@@ -0,0 +1,11 @@
1
+ # Reporting Security Issues
2
+
3
+ Pegasystems takes security seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
4
+
5
+ To report a security issue, [email us](mailto:opensource@pega.com;security@pega.com) and include the word "SECURITY" in the subject line.
6
+
7
+ The Pega team will send a response indicating the next steps in handling your report. We may ask for additional information or guidance.
8
+
9
+ ## Learning More About Security
10
+
11
+ To learn more about securing a Pega application or our security capabilities, please see the [security article](https://community.pega.com/knowledgebase/capabilities/security) on Pega Community and the [Pega Trust Center](https://www.pega.com/products/cloud/pega-trust-center).
@@ -32,13 +32,17 @@ export type ColorTheme = [
32
32
  keyof OmitStrict<DefaultTheme['base']['colors'], 'white' | 'black'>,
33
33
  'extra-light' | 'light' | 'medium' | 'dark' | 'extra-dark'
34
34
  ];
35
- export interface MediaPageLinks extends Pick<LinkProps, 'href'> {
35
+ export interface MediaPageLinks {
36
36
  /** Unique id for this push link */
37
37
  id: string;
38
+ /** Title of the content */
39
+ title: string;
40
+ /** Href for external links */
41
+ href?: LinkProps['href'];
42
+ /** Callback provided to perform on click */
43
+ onTitleClick?: () => void;
38
44
  /** A string to be used as an image src for a thumbnail. */
39
45
  thumbnail?: AttachmentItemProps['thumbnail'];
40
- /** Additional information about the linked resource. */
41
- title?: string;
42
46
  }
43
47
  export type MessageHeaderProps = {
44
48
  /** message header content */
@@ -1 +1 @@
1
- {"version":3,"file":"Chat.types.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;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,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 extends Pick<LinkProps, 'href'> {\n /** Unique id for this push link */\n id: string;\n /** A string to be used as an image src for a thumbnail. */\n thumbnail?: AttachmentItemProps['thumbnail'];\n /** Additional information about the linked resource. */\n title?: string;\n}\n\nexport type MessageHeaderProps = {\n /** message header content */\n content?: ReactNode;\n /** meta data */\n meta?: ReactNode;\n};\n\nexport interface MessageProps {\n /** 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 /** 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
+ {"version":3,"file":"Chat.types.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"AAgKA,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 {\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 /** 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"]}
@@ -34,6 +34,13 @@ export interface ChatComposerProps {
34
34
  disabled?: boolean;
35
35
  /** Children */
36
36
  children?: ReactNode;
37
+ /** On suggest reply click */
38
+ onSuggestReplyClick?: () => void;
39
+ /**
40
+ * Disable suggest reply button
41
+ * @default false
42
+ */
43
+ disableSuggestReply?: boolean;
37
44
  /** Ref to the Imperative handle */
38
45
  ref?: Ref<ChatComposerImperativeHandleProps>;
39
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,GAAG,EAEH,SAAS,EAET,SAAS,EACT,aAAa,EACd,MAAM,OAAO,CAAC;AAqBf,OAAO,KAAK,EAGV,YAAY,EACZ,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAQjC,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,MA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MAAM,8BAA8B,yGAUzC,CAAC;AAEH,MAAM,WAAW,iCAAiC;IAChD,mCAAmC;IACnC,eAAe,EAAE,CACf,aAAa,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,YAAY,KACjD,IAAI,CAAC;IACV,4CAA4C;IAC5C,eAAe,EAAE,SAAS,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IACvD,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;CACzD;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,GAAG,YAAY,CA6TrE,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { createElement as _createElement } from "react";
3
3
  import { forwardRef, useState, useEffect, useCallback, useImperativeHandle, useRef } from 'react';
4
4
  import styled, { css } from 'styled-components';
5
- import { Flex, TextArea, Button, Icon, registerIcon, Popover, EmojiPicker, hasProp, useI18n, useElement, defaultThemeProp, Tooltip, useOuterEvent, VisuallyHiddenText, FileUploadItem, Grid } from '@pega/cosmos-react-core';
5
+ import { Flex, TextArea, Button, Icon, registerIcon, Popover, EmojiPicker, hasProp, useI18n, useElement, defaultThemeProp, Tooltip, useOuterEvent, VisuallyHiddenText, FileUploadItem, Grid, AIButton } from '@pega/cosmos-react-core';
6
6
  import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
7
7
  import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
8
8
  import * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';
@@ -75,7 +75,7 @@ export const StyledAttachmentsListContainer = styled.div(({ theme }) => {
75
75
  `;
76
76
  });
77
77
  const ChatComposer = forwardRef(function ChatComposer(props, ref) {
78
- const { children, attachments = [], maxAttachments = 0, onAddAttachment, maxLength, placeholder: defaultPlaceHolder, defaultMessage = '', onSend, specialKeysConfig, disabled = false, enterKeySendsMessage = true, showEmoji, ...restProps } = props;
78
+ const { children, attachments = [], maxAttachments = 0, onAddAttachment, maxLength, placeholder: defaultPlaceHolder, defaultMessage = '', onSend, specialKeysConfig, disabled = false, enterKeySendsMessage = true, showEmoji, onSuggestReplyClick, disableSuggestReply = false, ...restProps } = props;
79
79
  const [message, setMessage] = useState(defaultMessage);
80
80
  useEffect(() => {
81
81
  setMessage(defaultMessage);
@@ -141,7 +141,7 @@ const ChatComposer = forwardRef(function ChatComposer(props, ref) {
141
141
  }
142
142
  }, [onSend]);
143
143
  const handleEnterKeyDown = useCallback((e) => {
144
- if (enterKeySendsMessage && e.keyCode === 13 && !e.shiftKey) {
144
+ if (enterKeySendsMessage && e.key === 'Enter' && !e.shiftKey) {
145
145
  if (!maxLength || message.length <= maxLength) {
146
146
  sendMessage(message);
147
147
  setAnnouncement(t('message_sent'));
@@ -207,7 +207,7 @@ const ChatComposer = forwardRef(function ChatComposer(props, ref) {
207
207
  return (_jsx("div", { "aria-label": `${t('attachments_x_of_y', [idx + 1, attachments.length])}`, children: _jsx(StyledAttachmentItem, { ...attachment }) }, attachment.name));
208
208
  }) }), _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 && (_jsxs(StyledAttachmentElementContainer, { disabled: attachments.length >= maxAttachments, ref: setAttachmentsBtnEl, tabIndex: attachments.length >= maxAttachments ? 0 : undefined, role: 'button', children: [_jsx(Button, { onClick: onAddAttachment, variant: 'simple', disabled: !!(disabled || attachments.length >= maxAttachments), icon: true, "aria-label": attachments.length >= maxAttachments
209
209
  ? t('email_disable_attachment', [maxAttachments])
210
- : t('email_add_attachment', [maxAttachments]), children: _jsx(Icon, { name: 'paper-clip' }) }), attachments.length >= maxAttachments && (_jsx(Tooltip, { target: attachmentsBtnEl, showDelay: 'none', hideDelay: 'none', ...restProps, children: t('email_disable_attachment', [maxAttachments]) }))] })), _jsx(Flex, { item: { grow: 1 }, children: children }), _jsx(Button, { variant: 'primary', disabled: disabled || (!!maxLength && message.length > maxLength), onClick: () => {
210
+ : t('email_add_attachment', [maxAttachments]), children: _jsx(Icon, { name: 'paper-clip' }) }), attachments.length >= maxAttachments && (_jsx(Tooltip, { target: attachmentsBtnEl, showDelay: 'none', hideDelay: 'none', ...restProps, children: t('email_disable_attachment', [maxAttachments]) }))] })), _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: () => {
211
211
  sendMessage(message);
212
212
  setAnnouncement(t('message_sent'));
213
213
  }, children: t('send') }), announcement && (_jsx(VisuallyHiddenText, { "aria-live": 'assertive', children: announcement }))] })] }), _jsx(Popover, { show: showEmojiPicker, target: emojiBtnEl, placement: 'top-start', modifiers: [
@@ -1 +1 @@
1
- {"version":3,"file":"ChatComposer.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAUlG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,I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R,WAAW,CAAC,MAAM,IAAI,cAAc,IAAI,CACvC,KAAC,OAAO,IACN,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAC,MAAM,EAChB,SAAS,EAAC,MAAM,KACZ,SAAS,YAEZ,CAAC,CAAC,0BAA0B,EAAE,CAAC,cAAc,CAAC,CAAC,GACxC,CACX,IACgC,CACpC,EACD,KAAC,IAAI,IAAC,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,YAAG,QAAQ,GAAQ,EAC1C,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,QAAQ,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,EACjE,OAAO,EAAE,GAAG,EAAE;oCACZ,WAAW,CAAC,OAAO,CAAC,CAAC;oCACrB,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;gCACrC,CAAC,YAEA,CAAC,CAAC,MAAM,CAAC,GACH,EACR,YAAY,IAAI,CACf,KAAC,kBAAkB,iBAAW,WAAW,YAAE,YAAY,GAAsB,CAC9E,IACI,IACF,EACP,KAAC,OAAO,IACN,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,UAAU,EAClB,SAAS,EAAC,WAAW,EACrB,SAAS,EAAE;oBACT;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE,IAAI;qBACd;iBACF,YAED,KAAC,WAAW,IAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,GAAI,GACrD,IACT,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { forwardRef, useState, useEffect, useCallback, useImperativeHandle, useRef } from 'react';\nimport type {\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n ReactNode,\n ChangeEvent,\n RefObject,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n TextArea,\n Button,\n Icon,\n registerIcon,\n Popover,\n EmojiPicker,\n hasProp,\n useI18n,\n useElement,\n defaultThemeProp,\n Tooltip,\n useOuterEvent,\n VisuallyHiddenText,\n FileUploadItem,\n Grid\n} from '@pega/cosmos-react-core';\nimport type {\n EmojiPickerProps,\n PropsWithDefaults,\n ForwardProps,\n FileUploadItemProps\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nregisterIcon(timesIcon, faceHappyIcon, paperClipIcon);\n\nexport type SpecialKeysConfig = {\n /** Collection of specialKeys */\n keys: string[];\n /** onSpecialKey is fired when a special key is typed in Textarea */\n onSpecialKey: (e: KeyboardEvent<HTMLTextAreaElement>, key: string) => void;\n};\n\nexport interface ChatComposerProps {\n /** Place holder */\n placeholder?: string;\n /** Default message to populate on load */\n defaultMessage?: string;\n /** Max character limit */\n maxLength?: number;\n /** Callback when send button is clicked */\n onSend: (message: string) => void;\n /** Enter / Return key sends message */\n enterKeySendsMessage?: boolean;\n /** Max number of attachments to be allowed in chat composer.\n * If zero is passed, add attachments icon will be hidden. same rule applies if prop is not passed.\n * If attachments added are >= maxAttachments, add attachments icon will be disabled.\n */\n maxAttachments?: number;\n /** show/hide emoji */\n showEmoji?: boolean;\n /** Attachments list */\n attachments?: FileUploadItemProps[];\n /** Callback when attachment icon is clicked */\n onAddAttachment?: () => void;\n /** Special Keys configuration */\n specialKeysConfig?: SpecialKeysConfig;\n /** Disables the composer area */\n disabled?: boolean;\n /** Children */\n children?: ReactNode;\n /** Ref to the Imperative handle */\n ref?: Ref<ChatComposerImperativeHandleProps>;\n}\n\nconst StyledAttachmentItem = styled(FileUploadItem)``;\n\ninterface DisableAttachmentProps {\n disabled?: boolean;\n}\nconst StyledAttachmentElementContainer = styled.div<DisableAttachmentProps>(\n ({ disabled, theme }) => {\n return (\n disabled &&\n css`\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n border-radius: 50%;\n outline: none;\n }\n `\n );\n }\n);\nconst StyledPreviewButton = styled(BareButton)``;\nconst StyledDeleteButton = styled(BareButton)``;\n\nconst StyledChatComposer = styled.footer<PropsWithDefaults<ChatComposerProps, 'disabled'>>(\n ({\n theme,\n disabled,\n theme: {\n base: { 'disabled-opacity': transparentBg, spacing }\n }\n }) => {\n return css`\n padding: calc(2 * ${spacing});\n background-color: ${theme.base.palette['secondary-background']};\n border-end-start-radius: inherit;\n border-end-end-radius: inherit;\n textarea {\n border-radius: ${theme.base['border-radius']};\n height: 5rem;\n border: 0.0625rem solid ${theme.base.colors.gray['extra-light']};\n max-width: 100%;\n }\n ${StyledAttachmentItem} {\n ${disabled &&\n css`\n pointer-events: none;\n opacity: ${transparentBg};\n `}\n }\n\n ${StyledAttachmentElementContainer} {\n ${disabled &&\n css`\n pointer-events: none;\n `}\n }\n\n ${StyledPreviewButton} {\n color: ${theme.base.palette.interactive};\n font-weight: bold;\n &:hover {\n text-decoration: underline;\n }\n }\n\n ${StyledDeleteButton} {\n color: ${theme.base.palette.interactive};\n }\n `;\n }\n);\n\nStyledChatComposer.defaultProps = defaultThemeProp;\nStyledAttachmentElementContainer.defaultProps = defaultThemeProp;\n\nexport const StyledAttachmentsListContainer = styled.div(({ theme }) => {\n return css`\n max-height: 5rem;\n overflow-y: auto;\n\n &:focus-within {\n box-shadow: ${theme.base.shadow['focus-group']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n }\n `;\n});\n\nexport interface ChatComposerImperativeHandleProps {\n /** Function to append a message */\n appendToMessage: (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey'\n ) => void;\n /** Actual ref to Chat composer component */\n chatComposerRef: RefObject<HTMLDivElement | undefined>;\n textAreaRef: RefObject<HTMLTextAreaElement | undefined>;\n}\n\nconst ChatComposer: FunctionComponent<ChatComposerProps & ForwardProps> = forwardRef(\n function ChatComposer(props: PropsWithoutRef<ChatComposerProps>, ref: ChatComposerProps['ref']) {\n const {\n children,\n attachments = [],\n maxAttachments = 0,\n onAddAttachment,\n maxLength,\n placeholder: defaultPlaceHolder,\n defaultMessage = '',\n onSend,\n specialKeysConfig,\n disabled = false,\n enterKeySendsMessage = true,\n showEmoji,\n ...restProps\n } = props;\n const [message, setMessage] = useState(defaultMessage);\n useEffect(() => {\n setMessage(defaultMessage);\n }, [defaultMessage]);\n\n const t = useI18n();\n\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [emojiBtnEl, setEmojiBtnEl] = useElement();\n const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();\n const [announcement, setAnnouncement] = useState('');\n\n const lastEnteredSpecialKey = useRef<string | null>(null);\n\n const appendToMessage = useCallback(\n (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey',\n selectText: boolean = true\n ) => {\n let selectionStart;\n let selectionEnd;\n if (textAreaRef.current) {\n if (position === 'start') {\n textAreaRef.current.value = appendMessage + textAreaRef.current.value;\n selectionStart = 0;\n selectionEnd = appendMessage.length;\n } else if (position === 'end') {\n const initialEnd = textAreaRef.current.value.length;\n textAreaRef.current.value += appendMessage;\n selectionStart = initialEnd;\n selectionEnd = initialEnd + appendMessage.length;\n } else if (position === 'specialKey' && lastEnteredSpecialKey.current) {\n const replaceChars = lastEnteredSpecialKey.current.length;\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(\n 0,\n textAreaRef.current.selectionStart - replaceChars\n ) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart - replaceChars;\n selectionEnd = currentSelectionStart + appendMessage.length - replaceChars;\n lastEnteredSpecialKey.current = null;\n } else {\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(0, textAreaRef.current.selectionStart) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart;\n selectionEnd = currentSelectionStart + appendMessage.length;\n }\n textAreaRef.current.selectionStart = selectText ? selectionStart : selectionEnd;\n textAreaRef.current.selectionEnd = selectionEnd;\n textAreaRef.current.focus();\n setMessage(textAreaRef.current.value);\n }\n },\n [setMessage, textAreaRef.current]\n );\n\n const chatComposerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({ appendToMessage, chatComposerRef, textAreaRef }), [\n appendToMessage,\n chatComposerRef.current,\n textAreaRef.current\n ]);\n\n const sendMessage = useCallback(\n (newMessage: string) => {\n if (onSend) {\n onSend(newMessage);\n setMessage('');\n }\n },\n [onSend]\n );\n\n const handleEnterKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (enterKeySendsMessage && e.keyCode === 13 && !e.shiftKey) {\n if (!maxLength || message.length <= maxLength) {\n sendMessage(message);\n setAnnouncement(t('message_sent'));\n }\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [onSend, message, maxLength]\n );\n\n const handleTextAreaChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n setMessage(e.currentTarget.value);\n setAnnouncement('');\n },\n [setMessage]\n );\n\n const handleSpecialKey = useCallback(\n (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (!specialKeysConfig) return;\n const { keys, onSpecialKey } = specialKeysConfig;\n if (specialKeysConfig && keys.length > 0) {\n const composerValue = e.currentTarget.value.substring(0, e.currentTarget.selectionStart);\n const specialKey = keys.find(key => composerValue.endsWith(key));\n if (specialKey) {\n lastEnteredSpecialKey.current = specialKey;\n onSpecialKey(e, specialKey);\n }\n }\n },\n [specialKeysConfig]\n );\n\n const toggleEmoji = () => {\n setShowEmojiPicker(!showEmojiPicker);\n };\n const onEmojiSelect: EmojiPickerProps['onSelect'] = emojiElem => {\n // Check that it is not a custom emoji\n if (hasProp(emojiElem, 'native')) {\n appendToMessage(emojiElem.native, 'cursor', false);\n }\n setShowEmojiPicker(false);\n };\n\n const EmojiPickerRef = useRef<HTMLDivElement>(null);\n\n useOuterEvent('mousedown', [emojiBtnEl, EmojiPickerRef], () => {\n setShowEmojiPicker(false);\n });\n\n return (\n <>\n <Flex\n as={StyledChatComposer}\n disabled={disabled}\n container={{\n direction: 'column',\n gap: 2\n }}\n item={{\n shrink: 0\n }}\n {...restProps}\n ref={chatComposerRef}\n >\n <Flex\n container={{\n direction: 'column',\n gap: 0.5\n }}\n >\n <Grid\n container={{\n cols: 'repeat(auto-fill, minmax(12rem, 1fr))',\n gap: 1\n }}\n role='group'\n aria-label={`${t('attachments')}`}\n as={StyledAttachmentsListContainer}\n >\n {attachments.map((attachment, idx) => {\n if (disabled) {\n const attachmentProps = {\n ...attachment,\n onDelete: undefined,\n onDownload: undefined,\n onPreview: undefined,\n onEdit: undefined,\n onCancel: undefined\n };\n return <StyledAttachmentItem {...attachmentProps} key={attachmentProps.name} />;\n }\n return (\n <div\n aria-label={`${t('attachments_x_of_y', [idx + 1, attachments.length])}`}\n key={attachment.name}\n >\n <StyledAttachmentItem {...attachment} />\n </div>\n );\n })}\n </Grid>\n <TextArea\n ref={textAreaRef}\n maxLength={maxLength}\n displayCharCount={maxLength !== undefined}\n hardStop={false}\n placeholder={defaultPlaceHolder}\n value={message}\n disabled={disabled}\n onKeyUp={handleSpecialKey}\n onKeyDown={handleEnterKeyDown}\n onChange={handleTextAreaChange}\n onFocus={handleTextAreaChange}\n aria-label={t('enter_message')}\n autoResize={false}\n />\n </Flex>\n <Flex container={{ gap: 0.5 }}>\n {showEmoji && (\n <Button\n ref={setEmojiBtnEl}\n onClick={toggleEmoji}\n variant='simple'\n disabled={disabled}\n icon\n aria-label={t('add_emoji')}\n >\n <Icon name='face-happy' />\n </Button>\n )}\n {maxAttachments > 0 && (\n <StyledAttachmentElementContainer\n disabled={attachments.length >= maxAttachments}\n ref={setAttachmentsBtnEl}\n tabIndex={attachments.length >= maxAttachments ? 0 : undefined}\n role='button'\n >\n <Button\n onClick={onAddAttachment}\n variant='simple'\n disabled={!!(disabled || attachments.length >= maxAttachments)}\n icon\n aria-label={\n attachments.length >= maxAttachments\n ? t('email_disable_attachment', [maxAttachments])\n : t('email_add_attachment', [maxAttachments])\n }\n >\n <Icon name='paper-clip' />\n </Button>\n {attachments.length >= maxAttachments && (\n <Tooltip\n target={attachmentsBtnEl}\n showDelay='none'\n hideDelay='none'\n {...restProps}\n >\n {t('email_disable_attachment', [maxAttachments])}\n </Tooltip>\n )}\n </StyledAttachmentElementContainer>\n )}\n <Flex item={{ grow: 1 }}>{children}</Flex>\n <Button\n variant='primary'\n disabled={disabled || (!!maxLength && message.length > maxLength)}\n onClick={() => {\n sendMessage(message);\n setAnnouncement(t('message_sent'));\n }}\n >\n {t('send')}\n </Button>\n {announcement && (\n <VisuallyHiddenText aria-live='assertive'>{announcement}</VisuallyHiddenText>\n )}\n </Flex>\n </Flex>\n <Popover\n show={showEmojiPicker}\n target={emojiBtnEl}\n placement='top-start'\n modifiers={[\n {\n name: 'flip',\n enabled: true\n }\n ]}\n >\n <EmojiPicker ref={EmojiPickerRef} onSelect={onEmojiSelect} />\n </Popover>\n </>\n );\n }\n);\n\nexport default ChatComposer;\n"]}
1
+ {"version":3,"file":"ChatComposer.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAUlG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,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State, useEffect, useCallback, useImperativeHandle, useRef } from 'react';\nimport type {\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n ReactNode,\n ChangeEvent,\n RefObject,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n TextArea,\n Button,\n Icon,\n registerIcon,\n Popover,\n EmojiPicker,\n hasProp,\n useI18n,\n useElement,\n defaultThemeProp,\n Tooltip,\n useOuterEvent,\n VisuallyHiddenText,\n FileUploadItem,\n Grid,\n AIButton\n} from '@pega/cosmos-react-core';\nimport type {\n EmojiPickerProps,\n PropsWithDefaults,\n ForwardProps,\n FileUploadItemProps\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nregisterIcon(timesIcon, faceHappyIcon, paperClipIcon);\n\nexport type SpecialKeysConfig = {\n /** Collection of specialKeys */\n keys: string[];\n /** onSpecialKey is fired when a special key is typed in Textarea */\n onSpecialKey: (e: KeyboardEvent<HTMLTextAreaElement>, key: string) => void;\n};\n\nexport interface ChatComposerProps {\n /** Place holder */\n placeholder?: string;\n /** Default message to populate on load */\n defaultMessage?: string;\n /** Max character limit */\n maxLength?: number;\n /** Callback when send button is clicked */\n onSend: (message: string) => void;\n /** Enter / Return key sends message */\n enterKeySendsMessage?: boolean;\n /** Max number of attachments to be allowed in chat composer.\n * If zero is passed, add attachments icon will be hidden. same rule applies if prop is not passed.\n * If attachments added are >= maxAttachments, add attachments icon will be disabled.\n */\n maxAttachments?: number;\n /** show/hide emoji */\n showEmoji?: boolean;\n /** Attachments list */\n attachments?: FileUploadItemProps[];\n /** Callback when attachment icon is clicked */\n onAddAttachment?: () => void;\n /** Special Keys configuration */\n specialKeysConfig?: SpecialKeysConfig;\n /** Disables the composer area */\n disabled?: boolean;\n /** Children */\n children?: ReactNode;\n /** On suggest reply click */\n onSuggestReplyClick?: () => void;\n /**\n * Disable suggest reply button\n * @default false\n */\n disableSuggestReply?: boolean;\n /** Ref to the Imperative handle */\n ref?: Ref<ChatComposerImperativeHandleProps>;\n}\n\nconst StyledAttachmentItem = styled(FileUploadItem)``;\n\ninterface DisableAttachmentProps {\n disabled?: boolean;\n}\nconst StyledAttachmentElementContainer = styled.div<DisableAttachmentProps>(\n ({ disabled, theme }) => {\n return (\n disabled &&\n css`\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n border-radius: 50%;\n outline: none;\n }\n `\n );\n }\n);\nconst StyledPreviewButton = styled(BareButton)``;\nconst StyledDeleteButton = styled(BareButton)``;\n\nconst StyledChatComposer = styled.footer<PropsWithDefaults<ChatComposerProps, 'disabled'>>(\n ({\n theme,\n disabled,\n theme: {\n base: { 'disabled-opacity': transparentBg, spacing }\n }\n }) => {\n return css`\n padding: calc(2 * ${spacing});\n background-color: ${theme.base.palette['secondary-background']};\n border-end-start-radius: inherit;\n border-end-end-radius: inherit;\n textarea {\n border-radius: ${theme.base['border-radius']};\n height: 5rem;\n border: 0.0625rem solid ${theme.base.colors.gray['extra-light']};\n max-width: 100%;\n }\n ${StyledAttachmentItem} {\n ${disabled &&\n css`\n pointer-events: none;\n opacity: ${transparentBg};\n `}\n }\n\n ${StyledAttachmentElementContainer} {\n ${disabled &&\n css`\n pointer-events: none;\n `}\n }\n\n ${StyledPreviewButton} {\n color: ${theme.base.palette.interactive};\n font-weight: bold;\n &:hover {\n text-decoration: underline;\n }\n }\n\n ${StyledDeleteButton} {\n color: ${theme.base.palette.interactive};\n }\n `;\n }\n);\n\nStyledChatComposer.defaultProps = defaultThemeProp;\nStyledAttachmentElementContainer.defaultProps = defaultThemeProp;\n\nexport const StyledAttachmentsListContainer = styled.div(({ theme }) => {\n return css`\n max-height: 5rem;\n overflow-y: auto;\n\n &:focus-within {\n box-shadow: ${theme.base.shadow['focus-group']};\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n }\n `;\n});\n\nexport interface ChatComposerImperativeHandleProps {\n /** Function to append a message */\n appendToMessage: (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey'\n ) => void;\n /** Actual ref to Chat composer component */\n chatComposerRef: RefObject<HTMLDivElement | undefined>;\n textAreaRef: RefObject<HTMLTextAreaElement | undefined>;\n}\n\nconst ChatComposer: FunctionComponent<ChatComposerProps & ForwardProps> = forwardRef(\n function ChatComposer(props: PropsWithoutRef<ChatComposerProps>, ref: ChatComposerProps['ref']) {\n const {\n children,\n attachments = [],\n maxAttachments = 0,\n onAddAttachment,\n maxLength,\n placeholder: defaultPlaceHolder,\n defaultMessage = '',\n onSend,\n specialKeysConfig,\n disabled = false,\n enterKeySendsMessage = true,\n showEmoji,\n onSuggestReplyClick,\n disableSuggestReply = false,\n ...restProps\n } = props;\n const [message, setMessage] = useState(defaultMessage);\n useEffect(() => {\n setMessage(defaultMessage);\n }, [defaultMessage]);\n\n const t = useI18n();\n\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [emojiBtnEl, setEmojiBtnEl] = useElement();\n const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();\n const [announcement, setAnnouncement] = useState('');\n\n const lastEnteredSpecialKey = useRef<string | null>(null);\n\n const appendToMessage = useCallback(\n (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey',\n selectText: boolean = true\n ) => {\n let selectionStart;\n let selectionEnd;\n if (textAreaRef.current) {\n if (position === 'start') {\n textAreaRef.current.value = appendMessage + textAreaRef.current.value;\n selectionStart = 0;\n selectionEnd = appendMessage.length;\n } else if (position === 'end') {\n const initialEnd = textAreaRef.current.value.length;\n textAreaRef.current.value += appendMessage;\n selectionStart = initialEnd;\n selectionEnd = initialEnd + appendMessage.length;\n } else if (position === 'specialKey' && lastEnteredSpecialKey.current) {\n const replaceChars = lastEnteredSpecialKey.current.length;\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(\n 0,\n textAreaRef.current.selectionStart - replaceChars\n ) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart - replaceChars;\n selectionEnd = currentSelectionStart + appendMessage.length - replaceChars;\n lastEnteredSpecialKey.current = null;\n } else {\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(0, textAreaRef.current.selectionStart) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart;\n selectionEnd = currentSelectionStart + appendMessage.length;\n }\n textAreaRef.current.selectionStart = selectText ? selectionStart : selectionEnd;\n textAreaRef.current.selectionEnd = selectionEnd;\n textAreaRef.current.focus();\n setMessage(textAreaRef.current.value);\n }\n },\n [setMessage, textAreaRef.current]\n );\n\n const chatComposerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({ appendToMessage, chatComposerRef, textAreaRef }), [\n appendToMessage,\n chatComposerRef.current,\n textAreaRef.current\n ]);\n\n const sendMessage = useCallback(\n (newMessage: string) => {\n if (onSend) {\n onSend(newMessage);\n setMessage('');\n }\n },\n [onSend]\n );\n\n const handleEnterKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (enterKeySendsMessage && e.key === 'Enter' && !e.shiftKey) {\n if (!maxLength || message.length <= maxLength) {\n sendMessage(message);\n setAnnouncement(t('message_sent'));\n }\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [onSend, message, maxLength]\n );\n\n const handleTextAreaChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n setMessage(e.currentTarget.value);\n setAnnouncement('');\n },\n [setMessage]\n );\n\n const handleSpecialKey = useCallback(\n (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (!specialKeysConfig) return;\n const { keys, onSpecialKey } = specialKeysConfig;\n if (specialKeysConfig && keys.length > 0) {\n const composerValue = e.currentTarget.value.substring(0, e.currentTarget.selectionStart);\n const specialKey = keys.find(key => composerValue.endsWith(key));\n if (specialKey) {\n lastEnteredSpecialKey.current = specialKey;\n onSpecialKey(e, specialKey);\n }\n }\n },\n [specialKeysConfig]\n );\n\n const toggleEmoji = () => {\n setShowEmojiPicker(!showEmojiPicker);\n };\n const onEmojiSelect: EmojiPickerProps['onSelect'] = emojiElem => {\n // Check that it is not a custom emoji\n if (hasProp(emojiElem, 'native')) {\n appendToMessage(emojiElem.native, 'cursor', false);\n }\n setShowEmojiPicker(false);\n };\n\n const EmojiPickerRef = useRef<HTMLDivElement>(null);\n\n useOuterEvent('mousedown', [emojiBtnEl, EmojiPickerRef], () => {\n setShowEmojiPicker(false);\n });\n\n return (\n <>\n <Flex\n as={StyledChatComposer}\n disabled={disabled}\n container={{\n direction: 'column',\n gap: 2\n }}\n item={{\n shrink: 0\n }}\n {...restProps}\n ref={chatComposerRef}\n >\n <Flex\n container={{\n direction: 'column',\n gap: 0.5\n }}\n >\n <Grid\n container={{\n cols: 'repeat(auto-fill, minmax(12rem, 1fr))',\n gap: 1\n }}\n role='group'\n aria-label={`${t('attachments')}`}\n as={StyledAttachmentsListContainer}\n >\n {attachments.map((attachment, idx) => {\n if (disabled) {\n const attachmentProps = {\n ...attachment,\n onDelete: undefined,\n onDownload: undefined,\n onPreview: undefined,\n onEdit: undefined,\n onCancel: undefined\n };\n return <StyledAttachmentItem {...attachmentProps} key={attachmentProps.name} />;\n }\n return (\n <div\n aria-label={`${t('attachments_x_of_y', [idx + 1, attachments.length])}`}\n key={attachment.name}\n >\n <StyledAttachmentItem {...attachment} />\n </div>\n );\n })}\n </Grid>\n <TextArea\n ref={textAreaRef}\n maxLength={maxLength}\n displayCharCount={maxLength !== undefined}\n hardStop={false}\n placeholder={defaultPlaceHolder}\n value={message}\n disabled={disabled}\n onKeyUp={handleSpecialKey}\n onKeyDown={handleEnterKeyDown}\n onChange={handleTextAreaChange}\n onFocus={handleTextAreaChange}\n aria-label={t('enter_message')}\n autoResize={false}\n />\n </Flex>\n <Flex container={{ gap: 0.5 }}>\n {showEmoji && (\n <Button\n ref={setEmojiBtnEl}\n onClick={toggleEmoji}\n variant='simple'\n disabled={disabled}\n icon\n aria-label={t('add_emoji')}\n >\n <Icon name='face-happy' />\n </Button>\n )}\n {maxAttachments > 0 && (\n <StyledAttachmentElementContainer\n disabled={attachments.length >= maxAttachments}\n ref={setAttachmentsBtnEl}\n tabIndex={attachments.length >= maxAttachments ? 0 : undefined}\n role='button'\n >\n <Button\n onClick={onAddAttachment}\n variant='simple'\n disabled={!!(disabled || attachments.length >= maxAttachments)}\n icon\n aria-label={\n attachments.length >= maxAttachments\n ? t('email_disable_attachment', [maxAttachments])\n : t('email_add_attachment', [maxAttachments])\n }\n >\n <Icon name='paper-clip' />\n </Button>\n {attachments.length >= maxAttachments && (\n <Tooltip\n target={attachmentsBtnEl}\n showDelay='none'\n hideDelay='none'\n {...restProps}\n >\n {t('email_disable_attachment', [maxAttachments])}\n </Tooltip>\n )}\n </StyledAttachmentElementContainer>\n )}\n <Flex item={{ grow: 1 }} container={{ gap: 1 }}>\n {children}\n {onSuggestReplyClick && (\n <AIButton\n label={t('suggest_reply')}\n disabled={disabled || disableSuggestReply}\n onClick={onSuggestReplyClick}\n />\n )}\n </Flex>\n\n <Button\n variant='primary'\n disabled={disabled || (!!maxLength && message.length > maxLength)}\n onClick={() => {\n sendMessage(message);\n setAnnouncement(t('message_sent'));\n }}\n >\n {t('send')}\n </Button>\n {announcement && (\n <VisuallyHiddenText aria-live='assertive'>{announcement}</VisuallyHiddenText>\n )}\n </Flex>\n </Flex>\n <Popover\n show={showEmojiPicker}\n target={emojiBtnEl}\n placement='top-start'\n modifiers={[\n {\n name: 'flip',\n enabled: true\n }\n ]}\n >\n <EmojiPicker ref={EmojiPickerRef} onSelect={onEmojiSelect} />\n </Popover>\n </>\n );\n }\n);\n\nexport default ChatComposer;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAgB5E,OAAO,KAAK,EAAsB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKhF,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,cAAc,CAAC;AA2FtE,QAAA,MAAM,OAAO,EAAE,iBAAiB,CAAC,YAAY,GAAG,YAAY,CAyN1D,CAAC;AAEH,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAgB5E,OAAO,KAAK,EAAsB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKhF,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,cAAc,CAAC;AA4FtE,QAAA,MAAM,OAAO,EAAE,iBAAiB,CAAC,YAAY,GAAG,YAAY,CAsO1D,CAAC;AAEH,eAAe,OAAO,CAAC"}
@@ -5,7 +5,7 @@ import { Avatar, Flex, Icon, registerIcon, SummaryItem, Image, EmojiDisplay, use
5
5
  import * as documentDocIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/document-doc.icon';
6
6
  import * as chainUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chain-up.icon';
7
7
  import * as flagWaveSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/flag-wave-solid.icon';
8
- import { StyledMessageContainer, StyledMessageMain, StyledMessageBubble, StyledMessageBubbleContent, StyledMediaList, StyledMediaListItem, StyledMediaThumbNail, StyledSummaryItem, StyledMediaLink, StyledMetaInfoContainer, StyledMetaInfo, StyledBlinkingDot, StyledMediaButton, StyledMessageHeader, StyledMessageHeaderContent, StyledMessageHeaderMeta, StyledUndeliveredIcon, StyledStatusInfo, StyledHeadset, getMessageColors, StyledFlagIcon, StyledHeadsetIconBackground } from './Message.styles';
8
+ import { StyledMessageContainer, StyledMessageMain, StyledMessageBubble, StyledMessageBubbleContent, StyledMediaList, StyledMediaListItem, StyledMediaThumbNail, StyledMediaMessage, StyledMediaLink, StyledMetaInfoContainer, StyledMetaInfo, StyledBlinkingDot, StyledMediaButton, StyledMessageHeader, StyledMessageHeaderContent, StyledMessageHeaderMeta, StyledUndeliveredIcon, StyledStatusInfo, StyledHeadset, getMessageColors, StyledFlagIcon, StyledHeadsetIconBackground, StyledMediaContent } from './Message.styles';
9
9
  registerIcon(documentDocIcon, chainUpIcon, flagWaveSolidIcon);
10
10
  const Attachment = (props) => {
11
11
  const { id, icon, name, meta, actions = [], onPreview, thumbnail } = props;
@@ -28,7 +28,7 @@ const Attachment = (props) => {
28
28
  e.preventDefault();
29
29
  e.stopPropagation();
30
30
  onPreview?.(id);
31
- }, alt: name })), _jsx(SummaryItem, { as: StyledSummaryItem, primary: _jsx(StyledMediaButton, { onClick: (e) => {
31
+ }, alt: name })), _jsx(SummaryItem, { as: StyledMediaMessage, primary: _jsx(StyledMediaButton, { onClick: (e) => {
32
32
  e.preventDefault();
33
33
  e.stopPropagation();
34
34
  onPreview?.(id);
@@ -83,10 +83,12 @@ const Message = forwardRef(function Message(props, ref) {
83
83
  }, children: [_jsxs(StyledMessageBubble, { children: [messageHeader && (_jsxs(Flex, { container: { gap: 0.5, justify: 'between' }, as: StyledMessageHeader, children: [_jsxs(Flex, { container: { gap: 0.5 }, children: [_jsx(StyledFlagIcon, { name: 'flag-wave-solid' }), _jsx(StyledMessageHeaderContent, { children: messageHeader.content })] }), _jsx(StyledMessageHeaderMeta, { children: messageHeader.meta })] })), message && (_jsx(StyledMessageBubbleContent, { children: _jsx(EmojiDisplay, { content: message, size: 20 }) })), (attachments.length > 0 || mediaPageLinks.length > 0) && (_jsxs(StyledMediaList, { children: [attachments.map(attachment => {
84
84
  return _createElement(Attachment, { ...attachment, key: attachment.id });
85
85
  }), mediaPageLinks.map(pagePushLink => {
86
- const { id, href, title, thumbnail } = pagePushLink;
86
+ const { id, href, title, thumbnail, onTitleClick } = pagePushLink;
87
87
  return (_jsxs(Flex, { as: StyledMediaListItem, container: {
88
88
  direction: 'column'
89
- }, children: [thumbnail && (_jsx(Image, { as: StyledMediaThumbNail, src: thumbnail, alt: title || href })), _jsx(SummaryItem, { as: StyledSummaryItem, primary: _jsx(StyledMediaLink, { "aria-label": title, href: href, target: '_blank', rel: 'noreferrer', children: href }), visual: _jsx(Icon, { name: 'chain-up' }) })] }, id));
89
+ }, children: [thumbnail && _jsx(Image, { as: StyledMediaThumbNail, src: thumbnail, alt: title }), _jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, as: StyledMediaMessage, children: [_jsx(Icon, { name: 'book-open' }), _jsx(Flex, { container: true, as: StyledMediaContent, children: href ? (_jsx(StyledMediaLink, { "aria-label": title, href: href, target: '_blank', rel: 'noreferrer', children: title })) : (_jsx(_Fragment, { children: onTitleClick && (_jsx(StyledMediaButton, { variant: 'link', onClick: () => {
90
+ onTitleClick();
91
+ }, children: title })) })) })] })] }, id));
90
92
  })] }))] }), status === 'undeliverable' && message && direction === 'out' && (_jsx(StyledUndeliveredIcon, { name: 'warn-solid' }))] }), !typing && (_jsxs(Flex, { as: StyledMetaInfoContainer, container: {
91
93
  justify: messageMetaJustify,
92
94
  gap: 1.5
@@ -1 +1 @@
1
- {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG/D,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,KAAK,EACL,YAAY,EACZ,OAAO,E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,QAAQ,EACf,GAAG,EAAC,YAAY,YAEf,IAAI,GACW,EAEpB,MAAM,EAAE,KAAC,IAAI,IAAC,IAAI,EAAC,UAAU,GAAG,GAChC,KArBG,EAAE,CAsBF,CACR,CAAC;4CACJ,CAAC,CAAC,IACc,CACnB,IACmB,EAErB,MAAM,KAAK,eAAe,IAAI,OAAO,IAAI,SAAS,KAAK,KAAK,IAAI,CAC/D,KAAC,qBAAqB,IAAC,IAAI,EAAC,YAAY,GAAG,CAC5C,IACI,EAEN,CAAC,MAAM,IAAI,CACV,MAAC,IAAI,IACH,EAAE,EAAE,uBAAuB,EAC3B,SAAS,EAAE;4BACT,OAAO,EAAE,kBAAkB;4BAC3B,GAAG,EAAE,GAAG;yBACT,aAEA,SAAS,IAAI,KAAC,cAAc,cAAE,SAAS,GAAkB,EACzD,MAAM,IAAI,SAAS,KAAK,KAAK,IAAI,KAAC,gBAAgB,cAAE,CAAC,CAAC,MAAM,CAAC,GAAoB,IAC7E,CACR,EAEA,MAAM,IAAI,CACT,MAAC,IAAI,IACH,SAAS,EAAE;4BACT,GAAG,EAAE,IAAI;yBACV,aAED,KAAC,iBAAiB,IAAC,KAAK,EAAE,CAAC,GAAI,EAC/B,KAAC,iBAAiB,IAAC,KAAK,EAAE,IAAI,GAAI,EAClC,KAAC,iBAAiB,IAAC,KAAK,EAAE,GAAG,GAAI,IAC5B,CACR,IACI,IACF,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,OAAO,CAAC","sourcesContent":["import { forwardRef, useEffect, useMemo, useRef } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, MouseEvent } from 'react';\n\nimport {\n Avatar,\n Flex,\n Icon,\n registerIcon,\n SummaryItem,\n Image,\n EmojiDisplay,\n useI18n,\n Actions,\n Tooltip,\n useTheme,\n useElement\n} from '@pega/cosmos-react-core';\nimport type { FlexContainerProps, ForwardProps } from '@pega/cosmos-react-core';\nimport * as documentDocIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/document-doc.icon';\nimport * as chainUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chain-up.icon';\nimport * as flagWaveSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/flag-wave-solid.icon';\n\nimport type { MessageProps, AttachmentItemProps } from './Chat.types';\nimport {\n StyledMessageContainer,\n StyledMessageMain,\n StyledMessageBubble,\n StyledMessageBubbleContent,\n StyledMediaList,\n StyledMediaListItem,\n StyledMediaThumbNail,\n StyledSummaryItem,\n StyledMediaLink,\n StyledMetaInfoContainer,\n StyledMetaInfo,\n StyledBlinkingDot,\n StyledMediaButton,\n StyledMessageHeader,\n StyledMessageHeaderContent,\n StyledMessageHeaderMeta,\n StyledUndeliveredIcon,\n StyledStatusInfo,\n StyledHeadset,\n getMessageColors,\n StyledFlagIcon,\n StyledHeadsetIconBackground\n} from './Message.styles';\n\nregisterIcon(documentDocIcon, chainUpIcon, flagWaveSolidIcon);\n\nconst Attachment = (props: AttachmentItemProps) => {\n const { id, icon, name, meta, actions = [], onPreview, thumbnail } = props;\n const actionRef = useRef<HTMLButtonElement>(null);\n\n useEffect(() => {\n const listener = (e: KeyboardEvent) => {\n if (\n (e.target as HTMLButtonElement)?.getAttribute('aria-expanded') === 'true' &&\n ['ArrowLeft', 'ArrowRight', 'ArrowDown', 'ArrowUp'].includes(e.key)\n ) {\n e.stopPropagation();\n }\n };\n\n actionRef.current?.addEventListener('keydown', listener);\n\n return () => {\n actionRef.current?.removeEventListener('keydown', listener);\n };\n }, [actions]);\n\n return (\n <Flex\n key={id}\n as={StyledMediaListItem}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image\n as={StyledMediaThumbNail}\n src={thumbnail}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n alt={name}\n />\n )}\n\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaButton\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n >\n {name}\n </StyledMediaButton>\n }\n secondary={meta}\n visual={<Icon name={icon || 'document-doc'} />}\n actions={<Actions ref={actionRef} items={actions} iconOnly />}\n />\n </Flex>\n );\n};\n\nconst Message: FunctionComponent<MessageProps & ForwardProps> = forwardRef(function Message(\n props: PropsWithoutRef<MessageProps>,\n ref: MessageProps['ref']\n) {\n const {\n message,\n direction,\n avatarInfo,\n timestamp,\n attachments = [],\n mediaPageLinks = [],\n status,\n typing,\n messageHeader,\n senderType,\n senderId,\n agentVariant,\n ...restProps\n } = props;\n\n const t = useI18n();\n const theme = useTheme();\n const [avatarRef, setAvatarRef] = useElement();\n const { content: messageBubbleBackgroundColor } = useMemo(\n () => getMessageColors(theme, direction, senderType, agentVariant),\n [theme, direction, senderType, agentVariant]\n );\n\n let messageMetaJustify: FlexContainerProps['justify'] = 'between';\n if (timestamp && !status) {\n messageMetaJustify = 'start';\n } else if (!timestamp && status) {\n messageMetaJustify = 'end';\n }\n\n const renderAvatar = useMemo(() => {\n if (direction !== 'in' || (senderType !== 'bot' && !avatarInfo)) {\n return null;\n }\n\n if (senderType === 'agent') {\n return (\n <>\n <StyledHeadset>\n <Avatar\n name={avatarInfo!.name}\n size='m'\n shape='circle'\n imageSrc={avatarInfo!.imageSrc}\n ref={setAvatarRef}\n backgroundColor={messageBubbleBackgroundColor}\n />\n <StyledHeadsetIconBackground>\n <Icon name='headset' />\n </StyledHeadsetIconBackground>\n </StyledHeadset>\n <Tooltip target={avatarRef} showDelay='none' hideDelay='none'>\n {avatarInfo!.name}\n </Tooltip>\n </>\n );\n }\n\n return (\n <>\n <Avatar\n name={avatarInfo ? avatarInfo.name : t('bot')}\n size='m'\n shape='circle'\n icon={!avatarInfo?.imageSrc && senderType === 'bot' ? 'robot-solid' : undefined}\n imageSrc={avatarInfo?.imageSrc}\n ref={setAvatarRef}\n backgroundColor={messageBubbleBackgroundColor}\n />\n <Tooltip target={avatarRef} showDelay='none' hideDelay='none'>\n {avatarInfo ? avatarInfo.name : t('bot')}\n </Tooltip>\n </>\n );\n }, [avatarInfo, senderType, direction, avatarRef]);\n\n let ariaLabel: string | undefined;\n const sender = avatarInfo ? avatarInfo.name : senderType;\n\n ariaLabel = t('sender_replied_message', [sender, message || '']);\n if (attachments.length > 0) ariaLabel = t('chat_attachments', [ariaLabel, attachments.length]);\n if (mediaPageLinks.length > 0) ariaLabel = t('chat_links', [ariaLabel, mediaPageLinks.length]);\n if (timestamp) ariaLabel = t('chat_message_at_timestamp', [ariaLabel, timestamp]);\n if (status && direction === 'out') ariaLabel += ` ${t('chat_message_status', [status])}`;\n\n return (\n <Flex\n as={StyledMessageContainer}\n ref={ref}\n container={{\n gap: 1.5,\n direction: direction === 'in' ? 'row' : 'row-reverse'\n }}\n item={{\n shrink: 0\n }}\n hasMessage={!!message}\n direction={direction}\n senderType={senderType}\n typing={typing}\n messageHeader={messageHeader}\n status={status}\n agentVariant={agentVariant}\n aria-label={ariaLabel}\n {...restProps}\n >\n {renderAvatar}\n <Flex\n container={{\n direction: 'column',\n alignItems: direction === 'in' ? 'start' : 'end',\n justify: 'center'\n }}\n as={StyledMessageMain}\n >\n <Flex\n container={{\n direction: direction === 'in' ? 'row' : 'row-reverse',\n alignItems: 'center',\n gap: 0.5\n }}\n >\n <StyledMessageBubble>\n {messageHeader && (\n <Flex container={{ gap: 0.5, justify: 'between' }} as={StyledMessageHeader}>\n <Flex container={{ gap: 0.5 }}>\n <StyledFlagIcon name='flag-wave-solid' />\n <StyledMessageHeaderContent>{messageHeader.content}</StyledMessageHeaderContent>\n </Flex>\n\n <StyledMessageHeaderMeta>{messageHeader.meta}</StyledMessageHeaderMeta>\n </Flex>\n )}\n\n {message && (\n <StyledMessageBubbleContent>\n <EmojiDisplay content={message} size={20} />\n </StyledMessageBubbleContent>\n )}\n\n {(attachments.length > 0 || mediaPageLinks.length > 0) && (\n <StyledMediaList>\n {attachments.map(attachment => {\n return <Attachment {...attachment} key={attachment.id} />;\n })}\n\n {mediaPageLinks.map(pagePushLink => {\n const { id, href, title, thumbnail } = pagePushLink;\n return (\n <Flex\n as={StyledMediaListItem}\n key={id}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image as={StyledMediaThumbNail} src={thumbnail} alt={title || href} />\n )}\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaLink\n aria-label={title}\n href={href}\n target='_blank'\n rel='noreferrer'\n >\n {href}\n </StyledMediaLink>\n }\n visual={<Icon name='chain-up' />}\n />\n </Flex>\n );\n })}\n </StyledMediaList>\n )}\n </StyledMessageBubble>\n\n {status === 'undeliverable' && message && direction === 'out' && (\n <StyledUndeliveredIcon name='warn-solid' />\n )}\n </Flex>\n\n {!typing && (\n <Flex\n as={StyledMetaInfoContainer}\n container={{\n justify: messageMetaJustify,\n gap: 1.5\n }}\n >\n {timestamp && <StyledMetaInfo>{timestamp}</StyledMetaInfo>}\n {status && direction === 'out' && <StyledStatusInfo>{t(status)}</StyledStatusInfo>}\n </Flex>\n )}\n\n {typing && (\n <Flex\n container={{\n gap: 0.25\n }}\n >\n <StyledBlinkingDot delay={0} />\n <StyledBlinkingDot delay={0.25} />\n <StyledBlinkingDot delay={0.5} />\n </Flex>\n )}\n </Flex>\n </Flex>\n );\n});\n\nexport default Message;\n"]}
1
+ {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG/D,OAAO,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,KAAK,EACL,YAAY,EACZ,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,UAAU,EACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,eAAe,MAAM,qEAAqE,CAAC;AACvG,OAAO,KAAK,WAAW,MAAM,iEAAiE,CAAC;AAC/F,OAAO,K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,EAAE,IAAI,EACV,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,YAAY,YAEf,KAAK,GACU,CACnB,CAAC,CAAC,CAAC,CACF,4BACG,YAAY,IAAI,CACf,KAAC,iBAAiB,IAChB,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;gFACZ,YAAY,EAAE,CAAC;4EACjB,CAAC,YAEA,KAAK,GACY,CACrB,GACA,CACJ,GACI,IACF,KAlCF,EAAE,CAmCF,CACR,CAAC;4CACJ,CAAC,CAAC,IACc,CACnB,IACmB,EAErB,MAAM,KAAK,eAAe,IAAI,OAAO,IAAI,SAAS,KAAK,KAAK,IAAI,CAC/D,KAAC,qBAAqB,IAAC,IAAI,EAAC,YAAY,GAAG,CAC5C,IACI,EAEN,CAAC,MAAM,IAAI,CACV,MAAC,IAAI,IACH,EAAE,EAAE,uBAAuB,EAC3B,SAAS,EAAE;4BACT,OAAO,EAAE,kBAAkB;4BAC3B,GAAG,EAAE,GAAG;yBACT,aAEA,SAAS,IAAI,KAAC,cAAc,cAAE,SAAS,GAAkB,EACzD,MAAM,IAAI,SAAS,KAAK,KAAK,IAAI,KAAC,gBAAgB,cAAE,CAAC,CAAC,MAAM,CAAC,GAAoB,IAC7E,CACR,EAEA,MAAM,IAAI,CACT,MAAC,IAAI,IACH,SAAS,EAAE;4BACT,GAAG,EAAE,IAAI;yBACV,aAED,KAAC,iBAAiB,IAAC,KAAK,EAAE,CAAC,GAAI,EAC/B,KAAC,iBAAiB,IAAC,KAAK,EAAE,IAAI,GAAI,EAClC,KAAC,iBAAiB,IAAC,KAAK,EAAE,GAAG,GAAI,IAC5B,CACR,IACI,IACF,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,OAAO,CAAC","sourcesContent":["import { forwardRef, useEffect, useMemo, useRef } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, MouseEvent } from 'react';\n\nimport {\n Avatar,\n Flex,\n Icon,\n registerIcon,\n SummaryItem,\n Image,\n EmojiDisplay,\n useI18n,\n Actions,\n Tooltip,\n useTheme,\n useElement\n} from '@pega/cosmos-react-core';\nimport type { FlexContainerProps, ForwardProps } from '@pega/cosmos-react-core';\nimport * as documentDocIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/document-doc.icon';\nimport * as chainUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chain-up.icon';\nimport * as flagWaveSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/flag-wave-solid.icon';\n\nimport type { MessageProps, AttachmentItemProps } from './Chat.types';\nimport {\n StyledMessageContainer,\n StyledMessageMain,\n StyledMessageBubble,\n StyledMessageBubbleContent,\n StyledMediaList,\n StyledMediaListItem,\n StyledMediaThumbNail,\n StyledMediaMessage,\n StyledMediaLink,\n StyledMetaInfoContainer,\n StyledMetaInfo,\n StyledBlinkingDot,\n StyledMediaButton,\n StyledMessageHeader,\n StyledMessageHeaderContent,\n StyledMessageHeaderMeta,\n StyledUndeliveredIcon,\n StyledStatusInfo,\n StyledHeadset,\n getMessageColors,\n StyledFlagIcon,\n StyledHeadsetIconBackground,\n StyledMediaContent\n} from './Message.styles';\n\nregisterIcon(documentDocIcon, chainUpIcon, flagWaveSolidIcon);\n\nconst Attachment = (props: AttachmentItemProps) => {\n const { id, icon, name, meta, actions = [], onPreview, thumbnail } = props;\n const actionRef = useRef<HTMLButtonElement>(null);\n\n useEffect(() => {\n const listener = (e: KeyboardEvent) => {\n if (\n (e.target as HTMLButtonElement)?.getAttribute('aria-expanded') === 'true' &&\n ['ArrowLeft', 'ArrowRight', 'ArrowDown', 'ArrowUp'].includes(e.key)\n ) {\n e.stopPropagation();\n }\n };\n\n actionRef.current?.addEventListener('keydown', listener);\n\n return () => {\n actionRef.current?.removeEventListener('keydown', listener);\n };\n }, [actions]);\n\n return (\n <Flex\n key={id}\n as={StyledMediaListItem}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image\n as={StyledMediaThumbNail}\n src={thumbnail}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n alt={name}\n />\n )}\n\n <SummaryItem\n as={StyledMediaMessage}\n primary={\n <StyledMediaButton\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n >\n {name}\n </StyledMediaButton>\n }\n secondary={meta}\n visual={<Icon name={icon || 'document-doc'} />}\n actions={<Actions ref={actionRef} items={actions} iconOnly />}\n />\n </Flex>\n );\n};\n\nconst Message: FunctionComponent<MessageProps & ForwardProps> = forwardRef(function Message(\n props: PropsWithoutRef<MessageProps>,\n ref: MessageProps['ref']\n) {\n const {\n message,\n direction,\n avatarInfo,\n timestamp,\n attachments = [],\n mediaPageLinks = [],\n status,\n typing,\n messageHeader,\n senderType,\n senderId,\n agentVariant,\n ...restProps\n } = props;\n\n const t = useI18n();\n const theme = useTheme();\n const [avatarRef, setAvatarRef] = useElement();\n const { content: messageBubbleBackgroundColor } = useMemo(\n () => getMessageColors(theme, direction, senderType, agentVariant),\n [theme, direction, senderType, agentVariant]\n );\n\n let messageMetaJustify: FlexContainerProps['justify'] = 'between';\n if (timestamp && !status) {\n messageMetaJustify = 'start';\n } else if (!timestamp && status) {\n messageMetaJustify = 'end';\n }\n\n const renderAvatar = useMemo(() => {\n if (direction !== 'in' || (senderType !== 'bot' && !avatarInfo)) {\n return null;\n }\n\n if (senderType === 'agent') {\n return (\n <>\n <StyledHeadset>\n <Avatar\n name={avatarInfo!.name}\n size='m'\n shape='circle'\n imageSrc={avatarInfo!.imageSrc}\n ref={setAvatarRef}\n backgroundColor={messageBubbleBackgroundColor}\n />\n <StyledHeadsetIconBackground>\n <Icon name='headset' />\n </StyledHeadsetIconBackground>\n </StyledHeadset>\n <Tooltip target={avatarRef} showDelay='none' hideDelay='none'>\n {avatarInfo!.name}\n </Tooltip>\n </>\n );\n }\n\n return (\n <>\n <Avatar\n name={avatarInfo ? avatarInfo.name : t('bot')}\n size='m'\n shape='circle'\n icon={!avatarInfo?.imageSrc && senderType === 'bot' ? 'robot-solid' : undefined}\n imageSrc={avatarInfo?.imageSrc}\n ref={setAvatarRef}\n backgroundColor={messageBubbleBackgroundColor}\n />\n <Tooltip target={avatarRef} showDelay='none' hideDelay='none'>\n {avatarInfo ? avatarInfo.name : t('bot')}\n </Tooltip>\n </>\n );\n }, [avatarInfo, senderType, direction, avatarRef]);\n\n let ariaLabel: string | undefined;\n const sender = avatarInfo ? avatarInfo.name : senderType;\n\n ariaLabel = t('sender_replied_message', [sender, message || '']);\n if (attachments.length > 0) ariaLabel = t('chat_attachments', [ariaLabel, attachments.length]);\n if (mediaPageLinks.length > 0) ariaLabel = t('chat_links', [ariaLabel, mediaPageLinks.length]);\n if (timestamp) ariaLabel = t('chat_message_at_timestamp', [ariaLabel, timestamp]);\n if (status && direction === 'out') ariaLabel += ` ${t('chat_message_status', [status])}`;\n\n return (\n <Flex\n as={StyledMessageContainer}\n ref={ref}\n container={{\n gap: 1.5,\n direction: direction === 'in' ? 'row' : 'row-reverse'\n }}\n item={{\n shrink: 0\n }}\n hasMessage={!!message}\n direction={direction}\n senderType={senderType}\n typing={typing}\n messageHeader={messageHeader}\n status={status}\n agentVariant={agentVariant}\n aria-label={ariaLabel}\n {...restProps}\n >\n {renderAvatar}\n <Flex\n container={{\n direction: 'column',\n alignItems: direction === 'in' ? 'start' : 'end',\n justify: 'center'\n }}\n as={StyledMessageMain}\n >\n <Flex\n container={{\n direction: direction === 'in' ? 'row' : 'row-reverse',\n alignItems: 'center',\n gap: 0.5\n }}\n >\n <StyledMessageBubble>\n {messageHeader && (\n <Flex container={{ gap: 0.5, justify: 'between' }} as={StyledMessageHeader}>\n <Flex container={{ gap: 0.5 }}>\n <StyledFlagIcon name='flag-wave-solid' />\n <StyledMessageHeaderContent>{messageHeader.content}</StyledMessageHeaderContent>\n </Flex>\n\n <StyledMessageHeaderMeta>{messageHeader.meta}</StyledMessageHeaderMeta>\n </Flex>\n )}\n\n {message && (\n <StyledMessageBubbleContent>\n <EmojiDisplay content={message} size={20} />\n </StyledMessageBubbleContent>\n )}\n\n {(attachments.length > 0 || mediaPageLinks.length > 0) && (\n <StyledMediaList>\n {attachments.map(attachment => {\n return <Attachment {...attachment} key={attachment.id} />;\n })}\n\n {mediaPageLinks.map(pagePushLink => {\n const { id, href, title, thumbnail, onTitleClick } = pagePushLink;\n return (\n <Flex\n as={StyledMediaListItem}\n key={id}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && <Image as={StyledMediaThumbNail} src={thumbnail} alt={title} />}\n\n <Flex container={{ gap: 1, alignItems: 'center' }} as={StyledMediaMessage}>\n <Icon name='book-open' />\n <Flex container as={StyledMediaContent}>\n {href ? (\n <StyledMediaLink\n aria-label={title}\n href={href}\n target='_blank'\n rel='noreferrer'\n >\n {title}\n </StyledMediaLink>\n ) : (\n <>\n {onTitleClick && (\n <StyledMediaButton\n variant='link'\n onClick={() => {\n onTitleClick();\n }}\n >\n {title}\n </StyledMediaButton>\n )}\n </>\n )}\n </Flex>\n </Flex>\n </Flex>\n );\n })}\n </StyledMediaList>\n )}\n </StyledMessageBubble>\n\n {status === 'undeliverable' && message && direction === 'out' && (\n <StyledUndeliveredIcon name='warn-solid' />\n )}\n </Flex>\n\n {!typing && (\n <Flex\n as={StyledMetaInfoContainer}\n container={{\n justify: messageMetaJustify,\n gap: 1.5\n }}\n >\n {timestamp && <StyledMetaInfo>{timestamp}</StyledMetaInfo>}\n {status && direction === 'out' && <StyledStatusInfo>{t(status)}</StyledStatusInfo>}\n </Flex>\n )}\n\n {typing && (\n <Flex\n container={{\n gap: 0.25\n }}\n >\n <StyledBlinkingDot delay={0} />\n <StyledBlinkingDot delay={0.25} />\n <StyledBlinkingDot delay={0.5} />\n </Flex>\n )}\n </Flex>\n </Flex>\n );\n});\n\nexport default Message;\n"]}
@@ -4,9 +4,11 @@ import type { MessageProps } from './Chat.types';
4
4
  export declare const StyledMessageBubbleContent: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
5
5
  export declare const StyledMediaList: import("styled-components").StyledComponent<"ul", DefaultTheme, {}, never>;
6
6
  export declare const StyledMediaListItem: import("styled-components").StyledComponent<"li", DefaultTheme, {}, never>;
7
- export declare const StyledSummaryItem: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
7
+ export declare const StyledMediaMessage: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
8
8
  export declare const StyledMediaThumbNail: import("styled-components").StyledComponent<"img", DefaultTheme, {}, never>;
9
- export declare const StyledMediaLink: import("styled-components").StyledComponent<"a", DefaultTheme, {}, never>;
9
+ export declare const StyledMediaLink: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").LinkProps & import("@pega/cosmos-react-core").ForwardProps> & {
10
+ getTestIds: (testIdProp?: string | undefined) => import("@pega/cosmos-react-core").TestIdsRecord<readonly ["preview-popover", "preview", "new-tab"]>;
11
+ }, DefaultTheme, {}, never>;
10
12
  export declare const StyledMediaButton: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core/lib/components/Button/BareButton").BareButtonProps & import("@pega/cosmos-react-core").ForwardProps>, DefaultTheme, {}, never>;
11
13
  export declare const StyledMessageMain: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
12
14
  export declare const StyledMessageBubble: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
@@ -18,6 +20,7 @@ export declare const StyledMessageHeader: import("styled-components").StyledComp
18
20
  export declare const StyledMessageHeaderContent: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
19
21
  export declare const StyledMessageHeaderMeta: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
20
22
  export declare const StyledHeadsetIconBackground: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
23
+ export declare const StyledMediaContent: import("styled-components").StyledComponent<"div", DefaultTheme, {}, never>;
21
24
  interface StyledMessageContainerProps {
22
25
  senderType: 'customer' | 'agent' | 'bot';
23
26
  direction: 'in'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kB,CAAC;AACnD,eAAO,MAAM,0BAA0B,6EAAe,CAAC;AACvD,eAAO,MAAM,uBAAuB,6EAAe,CAAC;AAEpD,eAAO,MAAM,2BAA2B,6EAAe,CAAC;AAExD,eAAO,MAAM,kBAAkB,6EAAe,CAAC;AAE/C,UAAU,2BAA2B;IACnC,UAAU,EAAE,UAAU,GAAG,OAAO,GAAG,KAAK,CAAC;IACzC,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,aAAa,6EAwBxB,CAAC;AAIH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,gBAAgB,EAAE,CAC7B,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,EACpC,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,EACtC,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC,KACvC,kBA+BJ,CAAC;AAEF,eAAO,MAAM,sBAAsB,qGAgMlC,CAAC;AAEF,UAAU,sBAAsB;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iBAAiB,iGAiB5B,CAAC;AAGH,eAAO,MAAM,qBAAqB,8JAYjC,CAAC;AAIF,eAAO,MAAM,cAAc,8JAKzB,CAAC"}
@@ -1,13 +1,13 @@
1
1
  import styled, { css } from 'styled-components';
2
2
  import { readableColor, rgba, transparentize } from 'polished';
3
- import { defaultThemeProp, tryCatch, Icon, StyledIcon, StyledText, calculateFontSize } from '@pega/cosmos-react-core';
3
+ import { defaultThemeProp, tryCatch, Icon, StyledIcon, StyledText, calculateFontSize, Link, StyledLink } from '@pega/cosmos-react-core';
4
4
  import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
5
5
  export const StyledMessageBubbleContent = styled.div ``;
6
6
  export const StyledMediaList = styled.ul ``;
7
7
  export const StyledMediaListItem = styled.li ``;
8
- export const StyledSummaryItem = styled.div ``;
8
+ export const StyledMediaMessage = styled.div ``;
9
9
  export const StyledMediaThumbNail = styled.img ``;
10
- export const StyledMediaLink = styled.a ``;
10
+ export const StyledMediaLink = styled(Link) ``;
11
11
  export const StyledMediaButton = styled(BareButton) ``;
12
12
  export const StyledMessageMain = styled.div ``;
13
13
  export const StyledMessageBubble = styled.div ``;
@@ -19,6 +19,7 @@ export const StyledMessageHeader = styled.header ``;
19
19
  export const StyledMessageHeaderContent = styled.div ``;
20
20
  export const StyledMessageHeaderMeta = styled.div ``;
21
21
  export const StyledHeadsetIconBackground = styled.div ``;
22
+ export const StyledMediaContent = styled.div ``;
22
23
  export const StyledHeadset = styled.div(({ theme }) => {
23
24
  return css `
24
25
  position: relative;
@@ -140,12 +141,12 @@ export const StyledMessageContainer = styled.li(({ direction, senderType, hasMes
140
141
  object-fit: contain;
141
142
  background-color: ${secondaryBackground};
142
143
  }
143
- ${StyledSummaryItem} {
144
+ ${StyledMediaMessage} {
144
145
  padding: ${spacing} calc(3 * ${spacing});
145
146
  font-size: ${fontSizes.xxs};
146
147
  margin-block-start: calc(0.5 * ${spacing});
147
148
  }
148
- ${StyledSummaryItem}::before {
149
+ ${StyledMediaMessage}::before {
149
150
  content: '';
150
151
  padding: ${spacing} 0;
151
152
  border-top: 0.0625rem solid ${contrastContentColor};
@@ -154,7 +155,7 @@ export const StyledMessageContainer = styled.li(({ direction, senderType, hasMes
154
155
  left: 1rem;
155
156
  top: 0;
156
157
  }
157
- ${StyledMediaThumbNail} + ${StyledSummaryItem}::before {
158
+ ${StyledMediaThumbNail} + ${StyledMediaMessage}::before {
158
159
  content: none;
159
160
  }
160
161
  svg {
@@ -163,12 +164,15 @@ export const StyledMessageContainer = styled.li(({ direction, senderType, hasMes
163
164
  ${StyledText} {
164
165
  color: ${foregroundColor};
165
166
  }
167
+ ${StyledLink} {
168
+ color: ${contrastContentColor};
169
+ }
166
170
  }
167
171
 
168
172
  ${!hasMessage &&
169
173
  css `
170
174
  > ${StyledMediaListItem}:first-child {
171
- > ${StyledSummaryItem}::before {
175
+ > ${StyledMediaMessage}::before {
172
176
  border-top: none;
173
177
  }
174
178
  }
@@ -202,6 +206,7 @@ export const StyledMessageContainer = styled.li(({ direction, senderType, hasMes
202
206
  text-overflow: ellipsis;
203
207
  display: inline-block;
204
208
  max-width: 100%;
209
+
205
210
  &:hover {
206
211
  color: ${contrastContentColor};
207
212
  text-decoration: underline;
@@ -232,6 +237,15 @@ export const StyledMessageContainer = styled.li(({ direction, senderType, hasMes
232
237
  position: relative;
233
238
  height: 2rem;
234
239
  }
240
+
241
+ ${StyledMediaContent} {
242
+ padding-block-end: calc(0.5 * ${spacing});
243
+
244
+ ${StyledMediaLink}, ${StyledMediaButton} {
245
+ word-break: break-word;
246
+ white-space: pre-wrap;
247
+ }
248
+ }
235
249
  `;
236
250
  });
237
251
  StyledMessageContainer.defaultProps = defaultThemeProp;