@pega/cosmos-react-social 3.0.0-dev.25.0 → 3.0.0-dev.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Chat/Chat.types.d.ts +3 -3
- package/lib/components/Chat/Chat.types.d.ts.map +1 -1
- package/lib/components/Chat/Chat.types.js.map +1 -1
- package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
- package/lib/components/Chat/ChatComposer.js +9 -15
- package/lib/components/Chat/ChatComposer.js.map +1 -1
- package/lib/components/Chat/ChatHeader.d.ts +3 -1
- package/lib/components/Chat/ChatHeader.d.ts.map +1 -1
- package/lib/components/Chat/ChatHeader.js +6 -5
- package/lib/components/Chat/ChatHeader.js.map +1 -1
- package/lib/components/Chat/Message.d.ts +1 -1
- package/lib/components/Chat/Message.d.ts.map +1 -1
- package/lib/components/Chat/Message.js +28 -30
- package/lib/components/Chat/Message.js.map +1 -1
- package/lib/components/Chat/Message.styles.d.ts +3 -1
- package/lib/components/Chat/Message.styles.d.ts.map +1 -1
- package/lib/components/Chat/Message.styles.js +37 -44
- package/lib/components/Chat/Message.styles.js.map +1 -1
- package/lib/components/Email/Email.d.ts.map +1 -1
- package/lib/components/Email/Email.js +61 -52
- package/lib/components/Email/Email.js.map +1 -1
- package/lib/components/Email/Email.styles.d.ts +22 -7
- package/lib/components/Email/Email.styles.d.ts.map +1 -1
- package/lib/components/Email/Email.styles.js +159 -19
- package/lib/components/Email/Email.styles.js.map +1 -1
- package/lib/components/Email/Email.types.d.ts +24 -12
- 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.d.ts +6 -0
- package/lib/components/Email/EmailCaseView.d.ts.map +1 -0
- package/lib/components/Email/EmailCaseView.js +36 -0
- package/lib/components/Email/EmailCaseView.js.map +1 -0
- package/lib/components/Email/EmailConversation.d.ts.map +1 -1
- package/lib/components/Email/EmailConversation.js +5 -5
- package/lib/components/Email/EmailConversation.js.map +1 -1
- package/lib/components/Email/EmailManager.d.ts.map +1 -1
- package/lib/components/Email/EmailManager.js +9 -21
- package/lib/components/Email/EmailManager.js.map +1 -1
- package/lib/components/Email/EmailShell.d.ts +0 -3
- package/lib/components/Email/EmailShell.d.ts.map +1 -1
- package/lib/components/Email/EmailShell.js +3 -25
- package/lib/components/Email/EmailShell.js.map +1 -1
- package/lib/components/Email/EntityList.d.ts.map +1 -1
- package/lib/components/Email/EntityList.js +11 -17
- package/lib/components/Email/EntityList.js.map +1 -1
- package/lib/components/Email/index.d.ts +2 -1
- package/lib/components/Email/index.d.ts.map +1 -1
- package/lib/components/Email/index.js +1 -0
- package/lib/components/Email/index.js.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.js +1 -1
- package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
- package/lib/components/MentionButton/MentionButton.js +1 -1
- package/lib/components/MentionButton/MentionButton.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseProps } from '@pega/cosmos-react-core';
|
|
1
|
+
import { BaseProps, Action } from '@pega/cosmos-react-core';
|
|
2
2
|
export interface AttachmentItemProps extends BaseProps {
|
|
3
3
|
/** Unique Id for this attachment */
|
|
4
4
|
id: string;
|
|
@@ -15,8 +15,8 @@ export interface AttachmentItemProps extends BaseProps {
|
|
|
15
15
|
meta?: string;
|
|
16
16
|
/** When passed, previews the attachment on click */
|
|
17
17
|
onPreview?: (id: string) => void;
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/** Actions list for the attachment */
|
|
19
|
+
actions?: Action[];
|
|
20
20
|
/** When passed, this will render a single icon button or within a MenuButton if onDelete is defined. */
|
|
21
21
|
onDelete?: (id: string) => void;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.types.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"Chat.types.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAE5D,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oIAAoI;IACpI,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6KAA6K;IAC7K,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wGAAwG;IACxG,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.types.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseProps } 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 /**
|
|
1
|
+
{"version":3,"file":"Chat.types.js","sourceRoot":"","sources":["../../../src/components/Chat/Chat.types.ts"],"names":[],"mappings":"","sourcesContent":["import { BaseProps, Action } 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,GAAG,EAEH,SAAS,EAOT,SAAS,EACT,aAAa,EACd,MAAM,OAAO,CAAC;AAGf,OAAO,
|
|
1
|
+
{"version":3,"file":"ChatComposer.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,GAAG,EAEH,SAAS,EAOT,SAAS,EACT,aAAa,EACd,MAAM,OAAO,CAAC;AAGf,OAAO,EAcL,YAAY,EAIb,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAInD,oBAAY,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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YAAY,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
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,
|
|
4
|
+
import { Flex, TextArea, Button, Icon, registerIcon, Popover, EmojiPicker, hasProp, useI18n, useElement, defaultThemeProp, Tooltip, useOuterEvent, calculateFontSize } 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';
|
|
@@ -20,26 +20,25 @@ const StyledAttachmentElementContainer = styled.div(({ disabled, theme }) => {
|
|
|
20
20
|
});
|
|
21
21
|
const StyledPreviewButton = styled(BareButton) ``;
|
|
22
22
|
const StyledDeleteButton = styled(BareButton) ``;
|
|
23
|
-
const StyledChatComposer = styled.footer(({ theme, disabled, theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, 'disabled-opacity': transparentBg }, components: { link: { color: linkColor } } } }) => {
|
|
23
|
+
const StyledChatComposer = styled.footer(({ theme, disabled, theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, 'disabled-opacity': transparentBg, spacing }, components: { link: { color: linkColor } } } }) => {
|
|
24
24
|
const { xxs: fontSizeXXS } = calculateFontSize(fontSize, fontScale);
|
|
25
25
|
return css `
|
|
26
|
-
padding: calc(2 * ${
|
|
26
|
+
padding: calc(2 * ${spacing});
|
|
27
27
|
background-color: ${theme.base.palette['secondary-background']};
|
|
28
28
|
textarea {
|
|
29
29
|
border-radius: ${theme.base['border-radius']};
|
|
30
|
-
height:
|
|
31
|
-
min-height: 2.4rem;
|
|
30
|
+
height: 5rem;
|
|
32
31
|
border: 0.0625rem solid ${theme.base.colors.gray['extra-light']};
|
|
33
32
|
max-width: 100%;
|
|
34
33
|
}
|
|
35
34
|
${StyledAttachmentItem} {
|
|
36
35
|
color: ${linkColor};
|
|
37
36
|
background-color: ${theme.base.palette['primary-background']};
|
|
38
|
-
padding: calc(0.5 * ${
|
|
37
|
+
padding: calc(0.5 * ${spacing});
|
|
39
38
|
border-radius: calc(0.25 * ${theme.base['border-radius']});
|
|
40
39
|
font-size: ${fontSizeXXS};
|
|
41
40
|
font-weight: bold;
|
|
42
|
-
margin-
|
|
41
|
+
margin-block-end: calc(0.5 * ${spacing});
|
|
43
42
|
opacity: ${disabled ? transparentBg : 1};
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -76,7 +75,7 @@ const ChatComposer = forwardRef((props, ref) => {
|
|
|
76
75
|
setMessage(defaultMessage);
|
|
77
76
|
}, [defaultMessage]);
|
|
78
77
|
const t = useI18n();
|
|
79
|
-
const
|
|
78
|
+
const textAreaRef = useRef(null);
|
|
80
79
|
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
|
|
81
80
|
const [emojiBtnEl, setEmojiBtnEl] = useElement();
|
|
82
81
|
const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();
|
|
@@ -132,9 +131,8 @@ const ChatComposer = forwardRef((props, ref) => {
|
|
|
132
131
|
if (onSend) {
|
|
133
132
|
onSend(newMessage);
|
|
134
133
|
setMessage('');
|
|
135
|
-
resizeTextArea();
|
|
136
134
|
}
|
|
137
|
-
}, [onSend
|
|
135
|
+
}, [onSend]);
|
|
138
136
|
const handleEnterKeyDown = useCallback((e) => {
|
|
139
137
|
if (enterKeySendsMessage && e.keyCode === 13 && !e.shiftKey) {
|
|
140
138
|
if (!maxLength || message.length <= maxLength) {
|
|
@@ -146,8 +144,7 @@ const ChatComposer = forwardRef((props, ref) => {
|
|
|
146
144
|
}, [onSend, message, maxLength]);
|
|
147
145
|
const handleTextAreaChange = useCallback((e) => {
|
|
148
146
|
setMessage(e.currentTarget.value);
|
|
149
|
-
|
|
150
|
-
}, [setMessage, resizeTextArea]);
|
|
147
|
+
}, [setMessage]);
|
|
151
148
|
const handleSpecialKey = useCallback((e) => {
|
|
152
149
|
if (!specialKeysConfig)
|
|
153
150
|
return;
|
|
@@ -175,9 +172,6 @@ const ChatComposer = forwardRef((props, ref) => {
|
|
|
175
172
|
useOuterEvent('mousedown', [emojiBtnEl, EmojiPickerRef], () => {
|
|
176
173
|
setShowEmojiPicker(false);
|
|
177
174
|
});
|
|
178
|
-
useEffect(() => {
|
|
179
|
-
resizeTextArea();
|
|
180
|
-
}, []);
|
|
181
175
|
return (_jsxs(_Fragment, { children: [_jsxs(Flex, { as: StyledChatComposer, disabled: disabled, container: {
|
|
182
176
|
direction: 'column',
|
|
183
177
|
gap: 2
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposer.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,QAAQ,EACR,SAAS,EACT,WAAW,EAEX,mBAAmB,EACnB,MAAM,EAGP,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,WAAW,EAEX,OAAO,EACP,OAAO,EACP,aAAa,EACb,UAAU,EACV,gBAAgB,EAGhB,OAAO,EACP,aAAa,EACb,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAClF,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAC1F,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AACnG,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AAInG,YAAY,C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C,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,EACN,QAAQ;oCACR,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;oCAC3C,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,EAEpD,OAAO,EAAE,GAAG,EAAE;oCACZ,WAAW,CAAC,OAAO,CAAC,CAAC;gCACvB,CAAC,YAEA,CAAC,CAAC,YAAY,CAAC,GACT,IACJ,IACF,EACP,KAAC,OAAO,IACN,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,UAAU,EAClB,SAAS,EAAC,cAAc,EACxB,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 {\n forwardRef,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n ReactNode,\n useState,\n useEffect,\n useCallback,\n ChangeEvent,\n useImperativeHandle,\n useRef,\n RefObject,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n TextArea,\n Button,\n Icon,\n registerIcon,\n Popover,\n EmojiPicker,\n EmojiPickerProps,\n hasProp,\n useI18n,\n useAutoResize,\n useElement,\n defaultThemeProp,\n PropsWithDefaults,\n ForwardProps,\n Tooltip,\n useOuterEvent,\n calculateFontSize\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nimport { AttachmentItemProps } from './Chat.types';\n\nregisterIcon(timesIcon, faceHappyIcon, paperClipIcon);\n\nexport type SpecialKeysConfig = {\n /** Collection of specialKeys */\n keys: string[];\n /** onSpecialKey is fired when a special key is typed in Textarea */\n onSpecialKey: (e: KeyboardEvent<HTMLTextAreaElement>, key: string) => void;\n};\n\nexport interface ChatComposerProps {\n /** Place holder */\n placeholder?: string;\n /** Default message to populate on load */\n defaultMessage?: string;\n /** Max character limit */\n maxLength?: number;\n /** Callback when send button is clicked */\n onSend: (message: string) => void;\n /** Enter / Return key sends message */\n enterKeySendsMessage?: boolean;\n /** Max number of attachments to be allowed in chat composer.\n * If zero is passed, add attachments icon will be hidden. same rule applies if prop is not passed.\n * If attachments added are >= maxAttachments, add attachments icon will be disabled.\n */\n maxAttachments?: number;\n /** show/hide emoji */\n showEmoji?: boolean;\n /** Attachments list */\n attachments?: AttachmentItemProps[];\n /** Callback when attachment icon is clicked */\n onAddAttachment?: () => void;\n /** Special Keys configuration */\n specialKeysConfig?: SpecialKeysConfig;\n /** Disables the composer area */\n disabled?: boolean;\n /** Children */\n children?: ReactNode;\n /** Ref to the Imperative handle */\n ref?: Ref<ChatComposerImperativeHandleProps>;\n}\n\nconst StyledAttachmentItem = styled.div``;\n\ninterface DisableAttachmentProps {\n disabled?: boolean;\n}\nconst StyledAttachmentElementContainer = styled.div<DisableAttachmentProps>(\n ({ disabled, theme }) => {\n return (\n disabled &&\n css`\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n border-radius: 50%;\n outline: none;\n }\n `\n );\n }\n);\nconst StyledPreviewButton = styled(BareButton)``;\nconst StyledDeleteButton = styled(BareButton)``;\n\nconst StyledChatComposer = styled.footer<PropsWithDefaults<ChatComposerProps, 'disabled'>>(\n ({\n theme,\n disabled,\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, 'disabled-opacity': transparentBg },\n components: {\n link: { color: linkColor }\n }\n }\n }) => {\n const { xxs: fontSizeXXS } = calculateFontSize(fontSize, fontScale);\n return css`\n padding: calc(2 * ${theme.base.spacing});\n background-color: ${theme.base.palette['secondary-background']};\n textarea {\n border-radius: ${theme.base['border-radius']};\n height: 2.4rem;\n min-height: 2.4rem;\n border: 0.0625rem solid ${theme.base.colors.gray['extra-light']};\n max-width: 100%;\n }\n ${StyledAttachmentItem} {\n color: ${linkColor};\n background-color: ${theme.base.palette['primary-background']};\n padding: calc(0.5 * ${theme.base.spacing});\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n font-size: ${fontSizeXXS};\n font-weight: bold;\n margin-bottom: calc(0.5 * ${theme.base.spacing});\n opacity: ${disabled ? transparentBg : 1};\n }\n\n ${StyledAttachmentElementContainer} {\n ${disabled &&\n css`\n pointer-events: none;\n `}\n }\n\n ${StyledPreviewButton} {\n color: ${theme.base.palette.interactive};\n font-weight: bold;\n &:hover {\n text-decoration: underline;\n }\n }\n\n ${StyledDeleteButton} {\n color: ${theme.base.palette.interactive};\n }\n `;\n }\n);\n\nStyledChatComposer.defaultProps = defaultThemeProp;\nStyledAttachmentElementContainer.defaultProps = defaultThemeProp;\n\nexport const StyledAttachmentsListContainer = styled.div`\n max-height: 4rem;\n overflow-y: auto;\n`;\n\nexport interface ChatComposerImperativeHandleProps {\n /** Function to append a message */\n appendToMessage: (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey'\n ) => void;\n /** Actual ref to Chat composer component */\n chatComposerRef: RefObject<HTMLDivElement | undefined>;\n textAreaRef: RefObject<HTMLTextAreaElement | undefined>;\n}\n\nconst ChatComposer: FunctionComponent<ChatComposerProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatComposerProps>, ref: ChatComposerProps['ref']) => {\n const {\n children,\n attachments = [],\n maxAttachments = 0,\n onAddAttachment,\n maxLength,\n placeholder: defaultPlaceHolder,\n defaultMessage = '',\n onSend,\n specialKeysConfig,\n disabled = false,\n enterKeySendsMessage = true,\n showEmoji,\n ...restProps\n } = props;\n const [message, setMessage] = useState(defaultMessage);\n useEffect(() => {\n setMessage(defaultMessage);\n }, [defaultMessage]);\n\n const t = useI18n();\n\n const [textAreaRef, resizeTextArea] = useAutoResize<HTMLTextAreaElement>(75.1);\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [emojiBtnEl, setEmojiBtnEl] = useElement();\n const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();\n\n const lastEnteredSpecialKey = useRef<string | null>(null);\n\n const appendToMessage = useCallback(\n (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey',\n selectText: boolean = true\n ) => {\n let selectionStart;\n let selectionEnd;\n if (textAreaRef.current) {\n if (position === 'start') {\n textAreaRef.current.value = appendMessage + textAreaRef.current.value;\n selectionStart = 0;\n selectionEnd = appendMessage.length;\n } else if (position === 'end') {\n const initialEnd = textAreaRef.current.value.length;\n textAreaRef.current.value += appendMessage;\n selectionStart = initialEnd;\n selectionEnd = initialEnd + appendMessage.length;\n } else if (position === 'specialKey' && lastEnteredSpecialKey.current) {\n const replaceChars = lastEnteredSpecialKey.current.length;\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(\n 0,\n textAreaRef.current.selectionStart - replaceChars\n ) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart - replaceChars;\n selectionEnd = currentSelectionStart + appendMessage.length - replaceChars;\n lastEnteredSpecialKey.current = null;\n } else {\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(0, textAreaRef.current.selectionStart) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart;\n selectionEnd = currentSelectionStart + appendMessage.length;\n }\n textAreaRef.current.selectionStart = selectText ? selectionStart : selectionEnd;\n textAreaRef.current.selectionEnd = selectionEnd;\n textAreaRef.current.focus();\n setMessage(textAreaRef.current.value);\n }\n },\n [setMessage, textAreaRef.current]\n );\n\n const chatComposerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({ appendToMessage, chatComposerRef, textAreaRef }), [\n appendToMessage,\n chatComposerRef.current,\n textAreaRef.current\n ]);\n\n const sendMessage = useCallback(\n (newMessage: string) => {\n if (onSend) {\n onSend(newMessage);\n setMessage('');\n resizeTextArea();\n }\n },\n [onSend, resizeTextArea]\n );\n\n const handleEnterKeyDown = useCallback(\n (e: KeyboardEvent) => {\n if (enterKeySendsMessage && e.keyCode === 13 && !e.shiftKey) {\n if (!maxLength || message.length <= maxLength) {\n sendMessage(message);\n }\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [onSend, message, maxLength]\n );\n\n const handleTextAreaChange = useCallback(\n (e: ChangeEvent<HTMLTextAreaElement>) => {\n setMessage(e.currentTarget.value);\n resizeTextArea();\n },\n [setMessage, resizeTextArea]\n );\n\n const handleSpecialKey = useCallback(\n (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (!specialKeysConfig) return;\n const { keys, onSpecialKey } = specialKeysConfig;\n if (specialKeysConfig && keys.length > 0) {\n const composerValue = e.currentTarget.value.substring(0, e.currentTarget.selectionStart);\n const specialKey = keys.find(key => composerValue.endsWith(key));\n if (specialKey) {\n lastEnteredSpecialKey.current = specialKey;\n onSpecialKey(e, specialKey);\n }\n }\n },\n [specialKeysConfig]\n );\n\n const toggleEmoji = () => {\n setShowEmojiPicker(!showEmojiPicker);\n };\n const onEmojiSelect: EmojiPickerProps['onSelect'] = emojiElem => {\n // Check that it is not a custom emoji\n if (hasProp(emojiElem, 'native')) {\n appendToMessage(emojiElem.native, 'cursor', false);\n }\n setShowEmojiPicker(false);\n };\n\n const EmojiPickerRef = useRef<HTMLDivElement>(null);\n\n useOuterEvent('mousedown', [emojiBtnEl, EmojiPickerRef], () => {\n setShowEmojiPicker(false);\n });\n\n useEffect(() => {\n resizeTextArea();\n }, []);\n\n return (\n <>\n <Flex\n as={StyledChatComposer}\n disabled={disabled}\n container={{\n direction: 'column',\n gap: 2\n }}\n item={{\n shrink: 0\n }}\n {...restProps}\n ref={chatComposerRef}\n >\n <Flex\n container={{\n direction: 'column',\n gap: 0.5\n }}\n >\n <Flex\n container={{\n wrap: 'wrap',\n gap: 0.5\n }}\n as={StyledAttachmentsListContainer}\n >\n {attachments.map(attachment => {\n return (\n <Flex\n key={attachment.name}\n container={{\n gap: 1,\n alignItems: 'center'\n }}\n as={StyledAttachmentItem}\n >\n <BareButton\n as={StyledPreviewButton}\n disabled={disabled}\n onClick={() => {\n attachment.onPreview?.(attachment.name);\n }}\n >\n {attachment.name}\n </BareButton>\n <BareButton\n as={StyledDeleteButton}\n disabled={disabled}\n aria-label={t('email_remove_attachment')}\n onClick={() => {\n attachment.onDelete?.(attachment.name);\n }}\n >\n <Icon name='times' />\n </BareButton>\n </Flex>\n );\n })}\n </Flex>\n <TextArea\n ref={textAreaRef}\n maxLength={maxLength}\n displayCharCount={maxLength !== undefined}\n hardStop={false}\n placeholder={defaultPlaceHolder}\n value={message}\n disabled={disabled}\n onKeyUp={handleSpecialKey}\n onKeyDown={handleEnterKeyDown}\n onChange={handleTextAreaChange}\n onFocus={handleTextAreaChange}\n aria-label={t('enter_message')}\n />\n </Flex>\n <Flex container={{ gap: 0.5 }}>\n {showEmoji && (\n <Button\n ref={setEmojiBtnEl}\n onClick={toggleEmoji}\n variant='simple'\n disabled={disabled}\n icon\n aria-label={t('add_emoji')}\n >\n <Icon name='face-happy' />\n </Button>\n )}\n {maxAttachments > 0 && (\n <StyledAttachmentElementContainer\n disabled={attachments.length >= maxAttachments}\n ref={setAttachmentsBtnEl}\n tabIndex={attachments.length >= maxAttachments ? 0 : undefined}\n role='button'\n >\n <Button\n onClick={onAddAttachment}\n variant='simple'\n disabled={!!(disabled || attachments.length >= maxAttachments)}\n icon\n aria-label={\n attachments.length >= maxAttachments\n ? t('email_disable_attachment', [maxAttachments])\n : t('email_add_attachment', [maxAttachments])\n }\n >\n <Icon name='paper-clip' />\n </Button>\n {attachments.length >= maxAttachments && (\n <Tooltip\n target={attachmentsBtnEl}\n showDelay='none'\n hideDelay='none'\n {...restProps}\n >\n {t('email_disable_attachment', [maxAttachments])}\n </Tooltip>\n )}\n </StyledAttachmentElementContainer>\n )}\n <Flex item={{ grow: 1 }}>{children}</Flex>\n <Button\n variant='primary'\n disabled={\n disabled ||\n (!!maxLength && message.length > maxLength) ||\n (message.length === 0 && attachments.length === 0)\n }\n onClick={() => {\n sendMessage(message);\n }}\n >\n {t('send_label')}\n </Button>\n </Flex>\n </Flex>\n <Popover\n show={showEmojiPicker}\n target={emojiBtnEl}\n placement='bottom-start'\n modifiers={[\n {\n name: 'flip',\n enabled: true\n }\n ]}\n >\n <EmojiPicker ref={EmojiPickerRef} onSelect={onEmojiSelect} />\n </Popover>\n </>\n );\n }\n);\n\nexport default ChatComposer;\n"]}
|
|
1
|
+
{"version":3,"file":"ChatComposer.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatComposer.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EAKV,QAAQ,EACR,SAAS,EACT,WAAW,EAEX,mBAAmB,EACnB,MAAM,EAGP,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,WAAW,EAEX,OAAO,EACP,OAAO,EACP,UAAU,EACV,gBAAgB,EAGhB,OAAO,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S,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,EACN,QAAQ;oCACR,CAAC,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;oCAC3C,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,EAEpD,OAAO,EAAE,GAAG,EAAE;oCACZ,WAAW,CAAC,OAAO,CAAC,CAAC;gCACvB,CAAC,YAEA,CAAC,CAAC,YAAY,CAAC,GACT,IACJ,IACF,EACP,KAAC,OAAO,IACN,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,UAAU,EAClB,SAAS,EAAC,cAAc,EACxB,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 {\n forwardRef,\n FunctionComponent,\n Ref,\n PropsWithoutRef,\n ReactNode,\n useState,\n useEffect,\n useCallback,\n ChangeEvent,\n useImperativeHandle,\n useRef,\n RefObject,\n KeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Flex,\n TextArea,\n Button,\n Icon,\n registerIcon,\n Popover,\n EmojiPicker,\n EmojiPickerProps,\n hasProp,\n useI18n,\n useElement,\n defaultThemeProp,\n PropsWithDefaults,\n ForwardProps,\n Tooltip,\n useOuterEvent,\n calculateFontSize\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as faceHappyIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/face-happy.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nimport { AttachmentItemProps } from './Chat.types';\n\nregisterIcon(timesIcon, faceHappyIcon, paperClipIcon);\n\nexport type SpecialKeysConfig = {\n /** Collection of specialKeys */\n keys: string[];\n /** onSpecialKey is fired when a special key is typed in Textarea */\n onSpecialKey: (e: KeyboardEvent<HTMLTextAreaElement>, key: string) => void;\n};\n\nexport interface ChatComposerProps {\n /** Place holder */\n placeholder?: string;\n /** Default message to populate on load */\n defaultMessage?: string;\n /** Max character limit */\n maxLength?: number;\n /** Callback when send button is clicked */\n onSend: (message: string) => void;\n /** Enter / Return key sends message */\n enterKeySendsMessage?: boolean;\n /** Max number of attachments to be allowed in chat composer.\n * If zero is passed, add attachments icon will be hidden. same rule applies if prop is not passed.\n * If attachments added are >= maxAttachments, add attachments icon will be disabled.\n */\n maxAttachments?: number;\n /** show/hide emoji */\n showEmoji?: boolean;\n /** Attachments list */\n attachments?: AttachmentItemProps[];\n /** Callback when attachment icon is clicked */\n onAddAttachment?: () => void;\n /** Special Keys configuration */\n specialKeysConfig?: SpecialKeysConfig;\n /** Disables the composer area */\n disabled?: boolean;\n /** Children */\n children?: ReactNode;\n /** Ref to the Imperative handle */\n ref?: Ref<ChatComposerImperativeHandleProps>;\n}\n\nconst StyledAttachmentItem = styled.div``;\n\ninterface DisableAttachmentProps {\n disabled?: boolean;\n}\nconst StyledAttachmentElementContainer = styled.div<DisableAttachmentProps>(\n ({ disabled, theme }) => {\n return (\n disabled &&\n css`\n &:focus {\n box-shadow: ${theme.base.shadow.focus};\n border-radius: 50%;\n outline: none;\n }\n `\n );\n }\n);\nconst StyledPreviewButton = styled(BareButton)``;\nconst StyledDeleteButton = styled(BareButton)``;\n\nconst StyledChatComposer = styled.footer<PropsWithDefaults<ChatComposerProps, 'disabled'>>(\n ({\n theme,\n disabled,\n theme: {\n base: {\n 'font-size': fontSize,\n 'font-scale': fontScale,\n 'disabled-opacity': transparentBg,\n spacing\n },\n components: {\n link: { color: linkColor }\n }\n }\n }) => {\n const { xxs: fontSizeXXS } = calculateFontSize(fontSize, fontScale);\n return css`\n padding: calc(2 * ${spacing});\n background-color: ${theme.base.palette['secondary-background']};\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 color: ${linkColor};\n background-color: ${theme.base.palette['primary-background']};\n padding: calc(0.5 * ${spacing});\n border-radius: calc(0.25 * ${theme.base['border-radius']});\n font-size: ${fontSizeXXS};\n font-weight: bold;\n margin-block-end: calc(0.5 * ${spacing});\n opacity: ${disabled ? transparentBg : 1};\n }\n\n ${StyledAttachmentElementContainer} {\n ${disabled &&\n css`\n pointer-events: none;\n `}\n }\n\n ${StyledPreviewButton} {\n color: ${theme.base.palette.interactive};\n font-weight: bold;\n &:hover {\n text-decoration: underline;\n }\n }\n\n ${StyledDeleteButton} {\n color: ${theme.base.palette.interactive};\n }\n `;\n }\n);\n\nStyledChatComposer.defaultProps = defaultThemeProp;\nStyledAttachmentElementContainer.defaultProps = defaultThemeProp;\n\nexport const StyledAttachmentsListContainer = styled.div`\n max-height: 4rem;\n overflow-y: auto;\n`;\n\nexport interface ChatComposerImperativeHandleProps {\n /** Function to append a message */\n appendToMessage: (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey'\n ) => void;\n /** Actual ref to Chat composer component */\n chatComposerRef: RefObject<HTMLDivElement | undefined>;\n textAreaRef: RefObject<HTMLTextAreaElement | undefined>;\n}\n\nconst ChatComposer: FunctionComponent<ChatComposerProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatComposerProps>, ref: ChatComposerProps['ref']) => {\n const {\n children,\n attachments = [],\n maxAttachments = 0,\n onAddAttachment,\n maxLength,\n placeholder: defaultPlaceHolder,\n defaultMessage = '',\n onSend,\n specialKeysConfig,\n disabled = false,\n enterKeySendsMessage = true,\n showEmoji,\n ...restProps\n } = props;\n const [message, setMessage] = useState(defaultMessage);\n useEffect(() => {\n setMessage(defaultMessage);\n }, [defaultMessage]);\n\n const t = useI18n();\n\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n const [showEmojiPicker, setShowEmojiPicker] = useState(false);\n const [emojiBtnEl, setEmojiBtnEl] = useElement();\n const [attachmentsBtnEl, setAttachmentsBtnEl] = useElement();\n\n const lastEnteredSpecialKey = useRef<string | null>(null);\n\n const appendToMessage = useCallback(\n (\n appendMessage: string,\n position?: 'cursor' | 'start' | 'end' | 'specialKey',\n selectText: boolean = true\n ) => {\n let selectionStart;\n let selectionEnd;\n if (textAreaRef.current) {\n if (position === 'start') {\n textAreaRef.current.value = appendMessage + textAreaRef.current.value;\n selectionStart = 0;\n selectionEnd = appendMessage.length;\n } else if (position === 'end') {\n const initialEnd = textAreaRef.current.value.length;\n textAreaRef.current.value += appendMessage;\n selectionStart = initialEnd;\n selectionEnd = initialEnd + appendMessage.length;\n } else if (position === 'specialKey' && lastEnteredSpecialKey.current) {\n const replaceChars = lastEnteredSpecialKey.current.length;\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(\n 0,\n textAreaRef.current.selectionStart - replaceChars\n ) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart - replaceChars;\n selectionEnd = currentSelectionStart + appendMessage.length - replaceChars;\n lastEnteredSpecialKey.current = null;\n } else {\n const currentSelectionStart = textAreaRef.current.selectionStart;\n textAreaRef.current.value =\n textAreaRef.current.value.substring(0, textAreaRef.current.selectionStart) +\n appendMessage +\n textAreaRef.current.value.substring(\n textAreaRef.current.selectionStart,\n textAreaRef.current.value.length\n );\n selectionStart = currentSelectionStart;\n selectionEnd = currentSelectionStart + appendMessage.length;\n }\n textAreaRef.current.selectionStart = selectText ? selectionStart : selectionEnd;\n textAreaRef.current.selectionEnd = selectionEnd;\n textAreaRef.current.focus();\n setMessage(textAreaRef.current.value);\n }\n },\n [setMessage, textAreaRef.current]\n );\n\n const chatComposerRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({ appendToMessage, chatComposerRef, textAreaRef }), [\n appendToMessage,\n chatComposerRef.current,\n textAreaRef.current\n ]);\n\n const sendMessage = useCallback(\n (newMessage: string) => {\n if (onSend) {\n onSend(newMessage);\n setMessage('');\n }\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 }\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 },\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 <Flex\n container={{\n wrap: 'wrap',\n gap: 0.5\n }}\n as={StyledAttachmentsListContainer}\n >\n {attachments.map(attachment => {\n return (\n <Flex\n key={attachment.name}\n container={{\n gap: 1,\n alignItems: 'center'\n }}\n as={StyledAttachmentItem}\n >\n <BareButton\n as={StyledPreviewButton}\n disabled={disabled}\n onClick={() => {\n attachment.onPreview?.(attachment.name);\n }}\n >\n {attachment.name}\n </BareButton>\n <BareButton\n as={StyledDeleteButton}\n disabled={disabled}\n aria-label={t('email_remove_attachment')}\n onClick={() => {\n attachment.onDelete?.(attachment.name);\n }}\n >\n <Icon name='times' />\n </BareButton>\n </Flex>\n );\n })}\n </Flex>\n <TextArea\n ref={textAreaRef}\n maxLength={maxLength}\n displayCharCount={maxLength !== undefined}\n hardStop={false}\n placeholder={defaultPlaceHolder}\n value={message}\n disabled={disabled}\n onKeyUp={handleSpecialKey}\n onKeyDown={handleEnterKeyDown}\n onChange={handleTextAreaChange}\n onFocus={handleTextAreaChange}\n aria-label={t('enter_message')}\n />\n </Flex>\n <Flex container={{ gap: 0.5 }}>\n {showEmoji && (\n <Button\n ref={setEmojiBtnEl}\n onClick={toggleEmoji}\n variant='simple'\n disabled={disabled}\n icon\n aria-label={t('add_emoji')}\n >\n <Icon name='face-happy' />\n </Button>\n )}\n {maxAttachments > 0 && (\n <StyledAttachmentElementContainer\n disabled={attachments.length >= maxAttachments}\n ref={setAttachmentsBtnEl}\n tabIndex={attachments.length >= maxAttachments ? 0 : undefined}\n role='button'\n >\n <Button\n onClick={onAddAttachment}\n variant='simple'\n disabled={!!(disabled || attachments.length >= maxAttachments)}\n icon\n aria-label={\n attachments.length >= maxAttachments\n ? t('email_disable_attachment', [maxAttachments])\n : t('email_add_attachment', [maxAttachments])\n }\n >\n <Icon name='paper-clip' />\n </Button>\n {attachments.length >= maxAttachments && (\n <Tooltip\n target={attachmentsBtnEl}\n showDelay='none'\n hideDelay='none'\n {...restProps}\n >\n {t('email_disable_attachment', [maxAttachments])}\n </Tooltip>\n )}\n </StyledAttachmentElementContainer>\n )}\n <Flex item={{ grow: 1 }}>{children}</Flex>\n <Button\n variant='primary'\n disabled={\n disabled ||\n (!!maxLength && message.length > maxLength) ||\n (message.length === 0 && attachments.length === 0)\n }\n onClick={() => {\n sendMessage(message);\n }}\n >\n {t('send_label')}\n </Button>\n </Flex>\n </Flex>\n <Popover\n show={showEmojiPicker}\n target={emojiBtnEl}\n placement='bottom-start'\n modifiers={[\n {\n name: 'flip',\n enabled: true\n }\n ]}\n >\n <EmojiPicker ref={EmojiPickerRef} onSelect={onEmojiSelect} />\n </Popover>\n </>\n );\n }\n);\n\nexport default ChatComposer;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FunctionComponent, Ref, ReactNode } from 'react';
|
|
2
|
-
import { ForwardProps, NoChildrenProp } from '@pega/cosmos-react-core';
|
|
2
|
+
import { ForwardProps, NoChildrenProp, SentimentProps } from '@pega/cosmos-react-core';
|
|
3
3
|
export interface ChatHeaderProps extends NoChildrenProp {
|
|
4
4
|
/** ref to the element */
|
|
5
5
|
ref?: Ref<HTMLElement>;
|
|
@@ -9,6 +9,8 @@ export interface ChatHeaderProps extends NoChildrenProp {
|
|
|
9
9
|
icon?: string;
|
|
10
10
|
/** Primary actions: Used to show frequent user actions to be performed */
|
|
11
11
|
actions?: ReactNode;
|
|
12
|
+
/** Sentiment */
|
|
13
|
+
sentiment?: SentimentProps;
|
|
12
14
|
}
|
|
13
15
|
declare const ChatHeader: FunctionComponent<ChatHeaderProps & ForwardProps>;
|
|
14
16
|
export default ChatHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,GAAG,EAAmB,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvF,OAAO,EAKL,YAAY,EACZ,cAAc,
|
|
1
|
+
{"version":3,"file":"ChatHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/ChatHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,GAAG,EAAmB,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvF,OAAO,EAKL,YAAY,EACZ,cAAc,EACd,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACrD,yBAAyB;IACzB,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IACvB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,iGAAiG;IACjG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,gBAAgB;IAChB,SAAS,CAAC,EAAE,cAAc,CAAC;CAC5B;AAqBD,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,GAAG,YAAY,CA+BjE,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { Text, Flex, Icon, defaultThemeProp } from '@pega/cosmos-react-core';
|
|
4
|
+
import { Text, Flex, Icon, defaultThemeProp, Sentiment, calculateFontSize } from '@pega/cosmos-react-core';
|
|
5
5
|
const StyledChatPrimaryInfoContainer = styled.div ``;
|
|
6
|
-
const StyledChatHeader = styled.header(({ theme: { base: { spacing } } }) => {
|
|
6
|
+
const StyledChatHeader = styled.header(({ theme: { base: { 'font-size': fontSize, 'font-scale': fontScale, spacing } } }) => {
|
|
7
|
+
const fontSizes = calculateFontSize(fontSize, fontScale);
|
|
7
8
|
return css `
|
|
8
9
|
padding: ${spacing} calc(2 * ${spacing});
|
|
9
10
|
${StyledChatPrimaryInfoContainer} {
|
|
10
|
-
font-size:
|
|
11
|
+
font-size: ${fontSizes.l};
|
|
11
12
|
}
|
|
12
13
|
`;
|
|
13
14
|
});
|
|
14
15
|
StyledChatHeader.defaultProps = defaultThemeProp;
|
|
15
16
|
const ChatHeader = forwardRef((props, ref) => {
|
|
16
|
-
const { title, actions, icon, ...restProps } = props;
|
|
17
|
+
const { title, actions, icon, sentiment, ...restProps } = props;
|
|
17
18
|
return (_jsxs(Flex, { ref: ref, as: StyledChatHeader, container: true, item: {
|
|
18
19
|
shrink: 0
|
|
19
20
|
}, ...restProps, children: [_jsxs(Flex, { item: {
|
|
@@ -21,7 +22,7 @@ const ChatHeader = forwardRef((props, ref) => {
|
|
|
21
22
|
}, container: {
|
|
22
23
|
gap: 2,
|
|
23
24
|
alignItems: 'center'
|
|
24
|
-
}, as: StyledChatPrimaryInfoContainer, children: [icon && _jsx(Icon, { name: icon }), _jsx(Text, { variant: 'h3', children: title })] }), actions] }));
|
|
25
|
+
}, as: StyledChatPrimaryInfoContainer, children: [icon && _jsx(Icon, { name: icon }), _jsx(Text, { variant: 'h3', children: title }), sentiment && _jsx(Sentiment, { ...sentiment, labelHidden: true })] }), actions] }));
|
|
25
26
|
});
|
|
26
27
|
export default ChatHeader;
|
|
27
28
|
//# sourceMappingURL=ChatHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatHeader.js","sourceRoot":"","sources":["../../../src/components/Chat/ChatHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,O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SACV,KACG,SAAS,aAEb,MAAC,IAAI,IACH,IAAI,EAAE;oBACJ,IAAI,EAAE,CAAC;iBACR,EACD,SAAS,EAAE;oBACT,GAAG,EAAE,CAAC;oBACN,UAAU,EAAE,QAAQ;iBACrB,EACD,EAAE,EAAE,8BAA8B,aAEjC,IAAI,IAAI,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI,EAC7B,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,KAAK,GAAQ,EAChC,SAAS,IAAI,KAAC,SAAS,OAAK,SAAS,EAAE,WAAW,SAAG,IACjD,EACN,OAAO,IACH,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, PropsWithoutRef, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Text,\n Flex,\n Icon,\n defaultThemeProp,\n ForwardProps,\n NoChildrenProp,\n SentimentProps,\n Sentiment,\n calculateFontSize\n} from '@pega/cosmos-react-core';\n\nexport interface ChatHeaderProps extends NoChildrenProp {\n /** ref to the element */\n ref?: Ref<HTMLElement>;\n /** Title: Used to show username || channel || group name */\n title: string;\n /** Icon: Used to show the channel icons, pass the icon name from the cosmos library to render */\n icon?: string;\n /** Primary actions: Used to show frequent user actions to be performed */\n actions?: ReactNode;\n /** Sentiment */\n sentiment?: SentimentProps;\n}\n\nconst StyledChatPrimaryInfoContainer = styled.div``;\n\nconst StyledChatHeader = styled.header(\n ({\n theme: {\n base: { 'font-size': fontSize, 'font-scale': fontScale, spacing }\n }\n }) => {\n const fontSizes = calculateFontSize(fontSize, fontScale);\n return css`\n padding: ${spacing} calc(2 * ${spacing});\n ${StyledChatPrimaryInfoContainer} {\n font-size: ${fontSizes.l};\n }\n `;\n }\n);\nStyledChatHeader.defaultProps = defaultThemeProp;\n\nconst ChatHeader: FunctionComponent<ChatHeaderProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ChatHeaderProps>, ref: ChatHeaderProps['ref']) => {\n const { title, actions, icon, sentiment, ...restProps } = props;\n return (\n <Flex\n ref={ref}\n as={StyledChatHeader}\n container\n item={{\n shrink: 0\n }}\n {...restProps}\n >\n <Flex\n item={{\n grow: 1\n }}\n container={{\n gap: 2,\n alignItems: 'center'\n }}\n as={StyledChatPrimaryInfoContainer}\n >\n {icon && <Icon name={icon} />}\n <Text variant='h3'>{title}</Text>\n {sentiment && <Sentiment {...sentiment} labelHidden />}\n </Flex>\n {actions}\n </Flex>\n );\n }\n);\n\nexport default ChatHeader;\n"]}
|
|
@@ -35,7 +35,7 @@ export interface MessageProps {
|
|
|
35
35
|
/** Content type */
|
|
36
36
|
contentType?: 'rich-text' | 'plain-text';
|
|
37
37
|
/** Message status */
|
|
38
|
-
status?:
|
|
38
|
+
status?: 'sent' | 'delivered' | 'undelivered';
|
|
39
39
|
/** Indicates if this message is being currently typed */
|
|
40
40
|
typing?: boolean;
|
|
41
41
|
/** Message header */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAc,SAAS,EAAmB,GAAG,EAAc,MAAM,OAAO,CAAC;AAEnG,OAAO,EACL,WAAW,EAKX,SAAS,EAMT,YAAY,
|
|
1
|
+
{"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAc,SAAS,EAAmB,GAAG,EAAc,MAAM,OAAO,CAAC;AAEnG,OAAO,EACL,WAAW,EAKX,SAAS,EAMT,YAAY,EAEb,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAwBnD,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC;IAC7D,mCAAmC;IACnC,EAAE,EAAE,MA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/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import { Avatar, Flex, Icon, registerIcon, SummaryItem, Image, EmojiDisplay, useI18n } from '@pega/cosmos-react-core';
|
|
4
|
-
import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
|
|
5
|
-
import * as downloadIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/download.icon';
|
|
3
|
+
import { Avatar, Flex, Icon, registerIcon, SummaryItem, Image, EmojiDisplay, useI18n, Actions } from '@pega/cosmos-react-core';
|
|
6
4
|
import * as documentDocIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/document-doc.icon';
|
|
7
5
|
import * as chainUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chain-up.icon';
|
|
8
|
-
import { StyledMessageContainer, StyledMessageMain, StyledMessageBubble, StyledMessageBubbleContent, StyledMediaList, StyledMediaListItem, StyledMediaThumbNail, StyledSummaryItem, StyledMediaLink,
|
|
9
|
-
registerIcon(
|
|
6
|
+
import { StyledMessageContainer, StyledMessageMain, StyledMessageBubble, StyledMessageBubbleContent, StyledMediaList, StyledMediaListItem, StyledMediaThumbNail, StyledSummaryItem, StyledMediaLink, StyledMetaInfoContainer, StyledMetaInfo, StyledBlinkingDot, StyledMediaButton, StyledMessageHeader, StyledMessageHeaderContent, StyledMessageHeaderMeta, StyledUndeliveredIcon, StyledStatusInfo } from './Message.styles';
|
|
7
|
+
registerIcon(documentDocIcon, chainUpIcon);
|
|
10
8
|
const Message = forwardRef((props, ref) => {
|
|
11
9
|
const { message, direction, variant, avatarInfo, timeStamp, attachments = [], pagePushLinks = [], status, typing, messageHeader, ...restProps } = props;
|
|
12
10
|
const t = useI18n();
|
|
@@ -22,36 +20,36 @@ const Message = forwardRef((props, ref) => {
|
|
|
22
20
|
direction: direction === 'in' ? 'row' : 'row-reverse'
|
|
23
21
|
}, item: {
|
|
24
22
|
shrink: 0
|
|
25
|
-
}, hasMessage: !!message, messageDirection: direction, variant: variant, typing: typing, messageHeader: messageHeader, ...restProps, children: [avatarInfo && (_jsx(Avatar, { name: avatarInfo.name, size: 'm', shape: 'circle', imageSrc: avatarInfo.imageSrc })), _jsxs(Flex, { container: {
|
|
23
|
+
}, hasMessage: !!message, messageDirection: direction, variant: variant, typing: typing, messageHeader: messageHeader, status: status, ...restProps, children: [avatarInfo && (_jsx(Avatar, { name: avatarInfo.name, size: 'm', shape: 'circle', imageSrc: avatarInfo.imageSrc })), _jsxs(Flex, { container: {
|
|
26
24
|
direction: 'column',
|
|
27
25
|
alignItems: direction === 'in' ? 'start' : 'end',
|
|
28
26
|
justify: 'center'
|
|
29
|
-
}, as: StyledMessageMain, children: [_jsxs(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
27
|
+
}, as: StyledMessageMain, children: [_jsxs(Flex, { container: {
|
|
28
|
+
direction: direction === 'in' ? 'row' : 'row-reverse',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
gap: 0.5
|
|
31
|
+
}, children: [_jsxs(StyledMessageBubble, { children: [messageHeader && (_jsxs(Flex, { container: { gap: 0.5, justify: 'between' }, as: StyledMessageHeader, children: [_jsx(StyledMessageHeaderContent, { children: messageHeader.content }), _jsx(StyledMessageHeaderMeta, { children: messageHeader.meta })] })), message && (_jsx(StyledMessageBubbleContent, { children: _jsx(EmojiDisplay, { content: message, size: 20 }) })), (attachments.length > 0 || pagePushLinks.length > 0) && (_jsxs(StyledMediaList, { children: [attachments.map(attachment => {
|
|
32
|
+
const { id, icon, name, meta, actions = [], onPreview, thumbnail } = attachment;
|
|
33
|
+
return (_jsxs(Flex, { as: StyledMediaListItem, container: {
|
|
34
|
+
direction: 'column'
|
|
35
|
+
}, children: [thumbnail && (_jsx(Image, { as: StyledMediaThumbNail, src: thumbnail, onClick: (e) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
onPreview?.(id);
|
|
39
|
+
}, alt: name })), _jsx(SummaryItem, { as: StyledSummaryItem, primary: _jsx(StyledMediaButton, { onClick: (e) => {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
onPreview?.(id);
|
|
43
|
+
}, children: name }), secondary: meta, visual: _jsx(Icon, { name: icon || 'document-doc' }), actions: _jsx(Actions, { items: actions, iconOnly: true }) })] }, id));
|
|
44
|
+
}), pagePushLinks.map(pagePushLink => {
|
|
45
|
+
const { id, href, title, thumbnail } = pagePushLink;
|
|
46
|
+
return (_jsxs(Flex, { as: StyledMediaListItem, container: {
|
|
47
|
+
direction: 'column'
|
|
48
|
+
}, 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));
|
|
49
|
+
})] }))] }), status === 'undelivered' && message && _jsx(StyledUndeliveredIcon, { name: 'warn-solid' })] }), !typing && (_jsxs(Flex, { as: StyledMetaInfoContainer, container: {
|
|
52
50
|
justify: messageMetaJustify,
|
|
53
51
|
gap: 1.5
|
|
54
|
-
}, children: [timeStamp && _jsx(StyledMetaInfo, { children: timeStamp }), status && _jsx(
|
|
52
|
+
}, children: [timeStamp && _jsx(StyledMetaInfo, { children: timeStamp }), status && _jsx(StyledStatusInfo, { children: t(status) })] })), typing && (_jsxs(Flex, { container: {
|
|
55
53
|
gap: 0.25
|
|
56
54
|
}, children: [_jsx(StyledBlinkingDot, { delay: 0 }), _jsx(StyledBlinkingDot, { delay: 0.25 }), _jsx(StyledBlinkingDot, { delay: 0.5 })] }))] })] }));
|
|
57
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAA+C,MAAM,OAAO,CAAC;AAEnG,OAAO,EAEL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EAEZ,WAAW,EACX,KAAK,EAEL,YAAY,EACZ,OAAO,EAER,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAClF,OAAO,KAAK,YAAY,MAAM,iEAAiE,CAAC;AAChG,OAAO,KAAK,eAAe,MAAM,qEAAqE,CAAC;AACvG,OAAO,KAAK,WAAW,MAAM,iEAAiE,CAAC;AAG/F,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACvB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,CAAC,YAAY,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;AA6CzD,MAAM,OAAO,GAAmD,UAAU,CACxE,CAAC,KAAoC,EAAE,GAAwB,EAAE,EAAE;IACjE,MAAM,EACJ,OAAO,EACP,SAAS,EACT,OAAO,EACP,UAAU,EACV,SAAS,EACT,WAAW,GAAG,EAAE,EAChB,aAAa,GAAG,EAAE,EAClB,MAAM,EACN,MAAM,EACN,aAAa,EACb,GAAG,SAAS,EACb,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,IAAI,kBAAkB,GAAkC,SAAS,CAAC;IAClE,IAAI,SAAS,IAAI,CAAC,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AAG,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,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, ReactNode, PropsWithoutRef, Ref, MouseEvent } from 'react';\n\nimport {\n AvatarProps,\n Avatar,\n Flex,\n Icon,\n registerIcon,\n LinkProps,\n SummaryItem,\n Image,\n FlexContainerProps,\n EmojiDisplay,\n useI18n,\n ForwardProps\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as downloadIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/download.icon';\nimport * as documentDocIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/document-doc.icon';\nimport * as chainUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chain-up.icon';\n\nimport { AttachmentItemProps } from './Chat.types';\nimport {\n StyledMessageContainer,\n StyledMessageMain,\n StyledMessageBubble,\n StyledMessageBubbleContent,\n StyledMediaList,\n StyledMediaListItem,\n StyledMediaThumbNail,\n StyledSummaryItem,\n StyledMediaLink,\n StyledMediaDownloadButton,\n StyledMetaInfoContainer,\n StyledMetaInfo,\n StyledBlinkingDot,\n StyledMediaButton,\n StyledMessageHeader,\n StyledMessageHeaderContent,\n StyledMessageHeaderMeta\n} from './Message.styles';\n\nregisterIcon(downloadIcon, documentDocIcon, chainUpIcon);\n\nexport interface MediaPageLinks extends Pick<LinkProps, 'href'> {\n /** Unique id for this push link */\n id: string;\n /** A string to be used as an image src for a thumbnail. */\n thumbnail?: AttachmentItemProps['thumbnail'];\n /** Additional information about the linked resource. */\n title?: string;\n}\n\nexport type MessageHeaderProps = {\n /** message header content */\n content?: ReactNode;\n /** meta data */\n meta?: ReactNode;\n};\n\nexport interface MessageProps {\n /** ref to the message wrapper */\n ref?: Ref<HTMLDivElement>;\n /** Message to be displayed */\n message?: ReactNode;\n /** Attachment list */\n attachments?: AttachmentItemProps[];\n /** Message page push links list */\n pagePushLinks?: MediaPageLinks[];\n /** 3 themes supported by default to differentiate between sender, receiver and other */\n variant: 'sender' | 'receiver' | 'other';\n /** timestamp of the message(Formatted) */\n timeStamp?: string;\n /** Incoming message/ outgoing message */\n direction: 'in' | 'out';\n /** Avatar information, can be image and name */\n avatarInfo?: Pick<AvatarProps, 'name' | 'imageSrc'>;\n /** Content type */\n contentType?: 'rich-text' | 'plain-text';\n /** Message status */\n status?: string;\n /** Indicates if this message is being currently typed */\n typing?: boolean;\n /** Message header */\n messageHeader?: MessageHeaderProps;\n}\n\nconst Message: FunctionComponent<MessageProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MessageProps>, ref: MessageProps['ref']) => {\n const {\n message,\n direction,\n variant,\n avatarInfo,\n timeStamp,\n attachments = [],\n pagePushLinks = [],\n status,\n typing,\n messageHeader,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n let messageMetaJustify: FlexContainerProps['justify'] = 'between';\n if (timeStamp && !status) {\n messageMetaJustify = 'start';\n } else if (!timeStamp && status) {\n messageMetaJustify = 'end';\n }\n\n return (\n <Flex\n as={StyledMessageContainer}\n ref={ref}\n container={{\n gap: 0.5,\n direction: direction === 'in' ? 'row' : 'row-reverse'\n }}\n item={{\n shrink: 0\n }}\n hasMessage={!!message}\n messageDirection={direction}\n variant={variant}\n typing={typing}\n messageHeader={messageHeader}\n {...restProps}\n >\n {avatarInfo && (\n <Avatar name={avatarInfo.name} size='m' shape='circle' imageSrc={avatarInfo.imageSrc} />\n )}\n <Flex\n container={{\n direction: 'column',\n alignItems: direction === 'in' ? 'start' : 'end',\n justify: 'center'\n }}\n as={StyledMessageMain}\n >\n <StyledMessageBubble>\n {messageHeader && (\n <Flex container={{ gap: 0.5, justify: 'between' }} as={StyledMessageHeader}>\n <StyledMessageHeaderContent>{messageHeader.content}</StyledMessageHeaderContent>\n <StyledMessageHeaderMeta>{messageHeader.meta}</StyledMessageHeaderMeta>\n </Flex>\n )}\n {message && (\n <StyledMessageBubbleContent>\n <EmojiDisplay content={message} size={20} />\n </StyledMessageBubbleContent>\n )}\n {(attachments.length > 0 || pagePushLinks.length > 0) && (\n <StyledMediaList>\n {attachments.map(attachment => {\n const { id, icon, name, meta, onDownload, onPreview, thumbnail } = attachment;\n return (\n <Flex\n key={id}\n as={StyledMediaListItem}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image\n as={StyledMediaThumbNail}\n src={thumbnail}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n alt={name}\n />\n )}\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaButton\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n >\n {name}\n </StyledMediaButton>\n }\n secondary={meta}\n visual={<Icon name={icon || 'document-doc'} />}\n actions={\n <BareButton\n aria-label={t('download')}\n as={StyledMediaDownloadButton}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onDownload?.(id);\n }}\n >\n <Icon name='download' />\n </BareButton>\n }\n />\n </Flex>\n );\n })}\n {pagePushLinks.map(pagePushLink => {\n const { id, href, title, thumbnail } = pagePushLink;\n return (\n <Flex\n as={StyledMediaListItem}\n key={id}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image as={StyledMediaThumbNail} src={thumbnail} alt={title || href} />\n )}\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaLink\n aria-label={title}\n href={href}\n target='_blank'\n rel='noreferrer'\n >\n {href}\n </StyledMediaLink>\n }\n visual={<Icon name='chain-up' />}\n />\n </Flex>\n );\n })}\n </StyledMediaList>\n )}\n </StyledMessageBubble>\n {!typing && (\n <Flex\n as={StyledMetaInfoContainer}\n container={{\n justify: messageMetaJustify,\n gap: 1.5\n }}\n >\n {timeStamp && <StyledMetaInfo>{timeStamp}</StyledMetaInfo>}\n {status && <StyledMetaInfo>{status}</StyledMetaInfo>}\n </Flex>\n )}\n {typing && (\n <Flex\n container={{\n gap: 0.25\n }}\n >\n <StyledBlinkingDot delay={0} />\n <StyledBlinkingDot delay={0.25} />\n <StyledBlinkingDot delay={0.5} />\n </Flex>\n )}\n </Flex>\n </Flex>\n );\n }\n);\n\nexport default Message;\n"]}
|
|
1
|
+
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../src/components/Chat/Message.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAA+C,MAAM,OAAO,CAAC;AAEnG,OAAO,EAEL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EAEZ,WAAW,EACX,KAAK,EAEL,YAAY,EACZ,OAAO,EAEP,OAAO,EACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,eAAe,MAAM,qEAAqE,CAAC;AACvG,OAAO,KAAK,WAAW,MAAM,iEAAiE,CAAC;AAG/F,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;AA6C3C,MAAM,OAAO,GAAmD,UAAU,CACxE,CAAC,KAAoC,EAAE,GAAwB,EAAE,EAAE;IACjE,MAAM,EACJ,OAAO,EACP,SAAS,EACT,OAAO,EACP,UAAU,EACV,SAAS,EACT,WAAW,GAAG,EAAE,EAChB,aAAa,GAAG,EAAE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BAAuB,EAC3B,SAAS,EAAE;4BACT,OAAO,EAAE,kBAAkB;4BAC3B,GAAG,EAAE,GAAG;yBACT,aAEA,SAAS,IAAI,KAAC,cAAc,cAAE,SAAS,GAAkB,EACzD,MAAM,IAAI,KAAC,gBAAgB,cAAE,CAAC,CAAC,MAAM,CAAC,GAAoB,IACtD,CACR,EACA,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,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["import { FunctionComponent, forwardRef, ReactNode, PropsWithoutRef, Ref, MouseEvent } from 'react';\n\nimport {\n AvatarProps,\n Avatar,\n Flex,\n Icon,\n registerIcon,\n LinkProps,\n SummaryItem,\n Image,\n FlexContainerProps,\n EmojiDisplay,\n useI18n,\n ForwardProps,\n Actions\n} 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';\n\nimport { AttachmentItemProps } from './Chat.types';\nimport {\n StyledMessageContainer,\n StyledMessageMain,\n StyledMessageBubble,\n StyledMessageBubbleContent,\n StyledMediaList,\n StyledMediaListItem,\n StyledMediaThumbNail,\n StyledSummaryItem,\n StyledMediaLink,\n StyledMetaInfoContainer,\n StyledMetaInfo,\n StyledBlinkingDot,\n StyledMediaButton,\n StyledMessageHeader,\n StyledMessageHeaderContent,\n StyledMessageHeaderMeta,\n StyledUndeliveredIcon,\n StyledStatusInfo\n} from './Message.styles';\n\nregisterIcon(documentDocIcon, chainUpIcon);\n\nexport interface MediaPageLinks extends Pick<LinkProps, 'href'> {\n /** Unique id for this push link */\n id: string;\n /** A string to be used as an image src for a thumbnail. */\n thumbnail?: AttachmentItemProps['thumbnail'];\n /** Additional information about the linked resource. */\n title?: string;\n}\n\nexport type MessageHeaderProps = {\n /** message header content */\n content?: ReactNode;\n /** meta data */\n meta?: ReactNode;\n};\n\nexport interface MessageProps {\n /** ref to the message wrapper */\n ref?: Ref<HTMLDivElement>;\n /** Message to be displayed */\n message?: ReactNode;\n /** Attachment list */\n attachments?: AttachmentItemProps[];\n /** Message page push links list */\n pagePushLinks?: MediaPageLinks[];\n /** 3 themes supported by default to differentiate between sender, receiver and other */\n variant: 'sender' | 'receiver' | 'other';\n /** timestamp of the message(Formatted) */\n timeStamp?: string;\n /** Incoming message/ outgoing message */\n direction: 'in' | 'out';\n /** Avatar information, can be image and name */\n avatarInfo?: Pick<AvatarProps, 'name' | 'imageSrc'>;\n /** Content type */\n contentType?: 'rich-text' | 'plain-text';\n /** Message status */\n status?: 'sent' | 'delivered' | 'undelivered';\n /** Indicates if this message is being currently typed */\n typing?: boolean;\n /** Message header */\n messageHeader?: MessageHeaderProps;\n}\n\nconst Message: FunctionComponent<MessageProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MessageProps>, ref: MessageProps['ref']) => {\n const {\n message,\n direction,\n variant,\n avatarInfo,\n timeStamp,\n attachments = [],\n pagePushLinks = [],\n status,\n typing,\n messageHeader,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n let messageMetaJustify: FlexContainerProps['justify'] = 'between';\n if (timeStamp && !status) {\n messageMetaJustify = 'start';\n } else if (!timeStamp && status) {\n messageMetaJustify = 'end';\n }\n\n return (\n <Flex\n as={StyledMessageContainer}\n ref={ref}\n container={{\n gap: 0.5,\n direction: direction === 'in' ? 'row' : 'row-reverse'\n }}\n item={{\n shrink: 0\n }}\n hasMessage={!!message}\n messageDirection={direction}\n variant={variant}\n typing={typing}\n messageHeader={messageHeader}\n status={status}\n {...restProps}\n >\n {avatarInfo && (\n <Avatar name={avatarInfo.name} size='m' shape='circle' imageSrc={avatarInfo.imageSrc} />\n )}\n <Flex\n container={{\n direction: 'column',\n alignItems: direction === 'in' ? 'start' : 'end',\n justify: 'center'\n }}\n as={StyledMessageMain}\n >\n <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 <StyledMessageHeaderContent>{messageHeader.content}</StyledMessageHeaderContent>\n <StyledMessageHeaderMeta>{messageHeader.meta}</StyledMessageHeaderMeta>\n </Flex>\n )}\n {message && (\n <StyledMessageBubbleContent>\n <EmojiDisplay content={message} size={20} />\n </StyledMessageBubbleContent>\n )}\n {(attachments.length > 0 || pagePushLinks.length > 0) && (\n <StyledMediaList>\n {attachments.map(attachment => {\n const { id, icon, name, meta, actions = [], onPreview, thumbnail } = attachment;\n return (\n <Flex\n key={id}\n as={StyledMediaListItem}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image\n as={StyledMediaThumbNail}\n src={thumbnail}\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n alt={name}\n />\n )}\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaButton\n onClick={(e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n onPreview?.(id);\n }}\n >\n {name}\n </StyledMediaButton>\n }\n secondary={meta}\n visual={<Icon name={icon || 'document-doc'} />}\n actions={<Actions items={actions} iconOnly />}\n />\n </Flex>\n );\n })}\n {pagePushLinks.map(pagePushLink => {\n const { id, href, title, thumbnail } = pagePushLink;\n return (\n <Flex\n as={StyledMediaListItem}\n key={id}\n container={{\n direction: 'column'\n }}\n >\n {thumbnail && (\n <Image as={StyledMediaThumbNail} src={thumbnail} alt={title || href} />\n )}\n <SummaryItem\n as={StyledSummaryItem}\n primary={\n <StyledMediaLink\n aria-label={title}\n href={href}\n target='_blank'\n rel='noreferrer'\n >\n {href}\n </StyledMediaLink>\n }\n visual={<Icon name='chain-up' />}\n />\n </Flex>\n );\n })}\n </StyledMediaList>\n )}\n </StyledMessageBubble>\n {status === 'undelivered' && message && <StyledUndeliveredIcon name='warn-solid' />}\n </Flex>\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 && <StyledStatusInfo>{t(status)}</StyledStatusInfo>}\n </Flex>\n )}\n {typing && (\n <Flex\n container={{\n gap: 0.25\n }}\n >\n <StyledBlinkingDot delay={0} />\n <StyledBlinkingDot delay={0.25} />\n <StyledBlinkingDot delay={0.5} />\n </Flex>\n )}\n </Flex>\n </Flex>\n );\n }\n);\n\nexport default Message;\n"]}
|
|
@@ -4,13 +4,13 @@ export declare const StyledMediaList: import("styled-components").StyledComponen
|
|
|
4
4
|
export declare const StyledMediaListItem: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {}, never>;
|
|
5
5
|
export declare const StyledSummaryItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
6
6
|
export declare const StyledMediaThumbNail: import("styled-components").StyledComponent<"img", import("styled-components").DefaultTheme, {}, never>;
|
|
7
|
-
export declare const StyledMediaDownloadButton: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
|
8
7
|
export declare const StyledMediaLink: import("styled-components").StyledComponent<"a", import("styled-components").DefaultTheme, {}, never>;
|
|
9
8
|
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>, import("styled-components").DefaultTheme, {}, never>;
|
|
10
9
|
export declare const StyledMessageMain: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
11
10
|
export declare const StyledMessageBubble: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
12
11
|
export declare const StyledMetaInfoContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
13
12
|
export declare const StyledMetaInfo: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
13
|
+
export declare const StyledStatusInfo: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
14
14
|
export declare const StyledTypingIndicator: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
15
15
|
export declare const StyledMessageHeader: import("styled-components").StyledComponent<"header", import("styled-components").DefaultTheme, {}, never>;
|
|
16
16
|
export declare const StyledMessageHeaderContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -20,11 +20,13 @@ interface StyledMessageContainerProps {
|
|
|
20
20
|
messageDirection: 'in' | 'out' | string;
|
|
21
21
|
typing: boolean;
|
|
22
22
|
hasMessage: boolean;
|
|
23
|
+
status: string;
|
|
23
24
|
}
|
|
24
25
|
export declare const StyledMessageContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledMessageContainerProps, never>;
|
|
25
26
|
interface StyledBlinkingDotProps {
|
|
26
27
|
delay?: number;
|
|
27
28
|
}
|
|
28
29
|
export declare const StyledBlinkingDot: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledBlinkingDotProps, never>;
|
|
30
|
+
export declare const StyledUndeliveredIcon: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").IconProps & import("@pega/cosmos-react-core").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
29
31
|
export {};
|
|
30
32
|
//# sourceMappingURL=Message.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Message.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Message.styles.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Message.styles.d.ts","sourceRoot":"","sources":["../../../src/components/Chat/Message.styles.ts"],"names":[],"mappings":";AAYA,eAAO,MAAM,0BAA0B,yGAAe,CAAC;AAEvD,eAAO,MAAM,eAAe,wGAAc,CAAC;AAE3C,eAAO,MAAM,mBAAmB,wGAAc,CAAC;AAE/C,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAE9C,eAAO,MAAM,oBAAoB,yGAAe,CAAC;AAEjD,eAAO,MAAM,eAAe,uGAAa,CAAC;AAE1C,eAAO,MAAM,iBAAiB,0QAAuB,CAAC;AAEtD,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAE9C,eAAO,MAAM,mBAAmB,yGAAe,CAAC;AAEhD,eAAO,MAAM,uBAAuB,yGAAe,CAAC;AAEpD,eAAO,MAAM,cAAc,0GAAgB,CAAC;AAE5C,eAAO,MAAM,gBAAgB,0GAAgB,CAAC;AAE9C,eAAO,MAAM,qBAAqB,yGAAe,CAAC;AAElD,eAAO,MAAM,mBAAmB,4GAAkB,CAAC;AACnD,eAAO,MAAM,0BAA0B,yGAAe,CAAC;AACvD,eAAO,MAAM,uBAAuB,yGAAe,CAAC;AAEpD,UAAU,2BAA2B;IACnC,OAAO,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IACzC,gBAAgB,EAAE,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,sBAAsB,kIA0KlC,CAAC;AAEF,UAAU,sBAAsB;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iBAAiB,6HAiB5B,CAAC;AAGH,eAAO,MAAM,qBAAqB,mOAYjC,CAAC"}
|