@pega/cosmos-react-social 5.0.0-dev.4.6 → 5.0.0-dev.4.8
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/package.json +4 -4
- package/lib/components/Autopilot/Autopilot.d.ts +0 -15
- package/lib/components/Autopilot/Autopilot.d.ts.map +0 -1
- package/lib/components/Autopilot/Autopilot.js +0 -50
- package/lib/components/Autopilot/Autopilot.js.map +0 -1
- package/lib/components/Autopilot/AutopilotAvatar.d.ts +0 -8
- package/lib/components/Autopilot/AutopilotAvatar.d.ts.map +0 -1
- package/lib/components/Autopilot/AutopilotAvatar.js +0 -11
- package/lib/components/Autopilot/AutopilotAvatar.js.map +0 -1
- package/lib/components/Autopilot/AutopilotGlimpse.d.ts +0 -9
- package/lib/components/Autopilot/AutopilotGlimpse.d.ts.map +0 -1
- package/lib/components/Autopilot/AutopilotGlimpse.js +0 -24
- package/lib/components/Autopilot/AutopilotGlimpse.js.map +0 -1
- package/lib/components/Autopilot/index.d.ts +0 -4
- package/lib/components/Autopilot/index.d.ts.map +0 -1
- package/lib/components/Autopilot/index.js +0 -3
- package/lib/components/Autopilot/index.js.map +0 -1
- package/lib/components/Chat/Chat.d.ts +0 -29
- package/lib/components/Chat/Chat.d.ts.map +0 -1
- package/lib/components/Chat/Chat.js +0 -64
- package/lib/components/Chat/Chat.js.map +0 -1
- package/lib/components/Chat/Chat.types.d.ts +0 -136
- package/lib/components/Chat/Chat.types.d.ts.map +0 -1
- package/lib/components/Chat/Chat.types.js +0 -10
- package/lib/components/Chat/Chat.types.js.map +0 -1
- package/lib/components/Chat/ChatBody.d.ts +0 -7
- package/lib/components/Chat/ChatBody.d.ts.map +0 -1
- package/lib/components/Chat/ChatBody.js +0 -292
- package/lib/components/Chat/ChatBody.js.map +0 -1
- package/lib/components/Chat/ChatComposer.d.ts +0 -50
- package/lib/components/Chat/ChatComposer.d.ts.map +0 -1
- package/lib/components/Chat/ChatComposer.js +0 -221
- package/lib/components/Chat/ChatComposer.js.map +0 -1
- package/lib/components/Chat/ChatHeader.d.ts +0 -29
- package/lib/components/Chat/ChatHeader.d.ts.map +0 -1
- package/lib/components/Chat/ChatHeader.js +0 -44
- package/lib/components/Chat/ChatHeader.js.map +0 -1
- package/lib/components/Chat/ChatSettingsPanel.d.ts +0 -7
- package/lib/components/Chat/ChatSettingsPanel.d.ts.map +0 -1
- package/lib/components/Chat/ChatSettingsPanel.js +0 -15
- package/lib/components/Chat/ChatSettingsPanel.js.map +0 -1
- package/lib/components/Chat/ChatSettingsPanel.styles.d.ts +0 -16
- package/lib/components/Chat/ChatSettingsPanel.styles.d.ts.map +0 -1
- package/lib/components/Chat/ChatSettingsPanel.styles.js +0 -47
- package/lib/components/Chat/ChatSettingsPanel.styles.js.map +0 -1
- package/lib/components/Chat/Message.d.ts +0 -6
- package/lib/components/Chat/Message.d.ts.map +0 -1
- package/lib/components/Chat/Message.js +0 -98
- package/lib/components/Chat/Message.js.map +0 -1
- package/lib/components/Chat/Message.styles.d.ts +0 -43
- package/lib/components/Chat/Message.styles.d.ts.map +0 -1
- package/lib/components/Chat/Message.styles.js +0 -270
- package/lib/components/Chat/Message.styles.js.map +0 -1
- package/lib/components/Chat/SuggestedReplyPicker.d.ts +0 -42
- package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +0 -1
- package/lib/components/Chat/SuggestedReplyPicker.js +0 -143
- package/lib/components/Chat/SuggestedReplyPicker.js.map +0 -1
- package/lib/components/Chat/SystemMessage.d.ts +0 -8
- package/lib/components/Chat/SystemMessage.d.ts.map +0 -1
- package/lib/components/Chat/SystemMessage.js +0 -50
- package/lib/components/Chat/SystemMessage.js.map +0 -1
- package/lib/components/Chat/TypeIndicator.d.ts +0 -6
- package/lib/components/Chat/TypeIndicator.d.ts.map +0 -1
- package/lib/components/Chat/TypeIndicator.js +0 -12
- package/lib/components/Chat/TypeIndicator.js.map +0 -1
- package/lib/components/Chat/index.d.ts +0 -15
- package/lib/components/Chat/index.d.ts.map +0 -1
- package/lib/components/Chat/index.js +0 -10
- package/lib/components/Chat/index.js.map +0 -1
- package/lib/components/Email/ContextMenuPopover.d.ts +0 -5
- package/lib/components/Email/ContextMenuPopover.d.ts.map +0 -1
- package/lib/components/Email/ContextMenuPopover.js +0 -53
- package/lib/components/Email/ContextMenuPopover.js.map +0 -1
- package/lib/components/Email/Email.d.ts +0 -7
- package/lib/components/Email/Email.d.ts.map +0 -1
- package/lib/components/Email/Email.js +0 -244
- package/lib/components/Email/Email.js.map +0 -1
- package/lib/components/Email/Email.styles.d.ts +0 -67
- package/lib/components/Email/Email.styles.d.ts.map +0 -1
- package/lib/components/Email/Email.styles.js +0 -392
- package/lib/components/Email/Email.styles.js.map +0 -1
- package/lib/components/Email/Email.types.d.ts +0 -394
- package/lib/components/Email/Email.types.d.ts.map +0 -1
- package/lib/components/Email/Email.types.js +0 -2
- package/lib/components/Email/Email.types.js.map +0 -1
- package/lib/components/Email/EmailCaseView.d.ts +0 -6
- package/lib/components/Email/EmailCaseView.d.ts.map +0 -1
- package/lib/components/Email/EmailCaseView.js +0 -36
- package/lib/components/Email/EmailCaseView.js.map +0 -1
- package/lib/components/Email/EmailComposer.d.ts +0 -10
- package/lib/components/Email/EmailComposer.d.ts.map +0 -1
- package/lib/components/Email/EmailComposer.js +0 -255
- package/lib/components/Email/EmailComposer.js.map +0 -1
- package/lib/components/Email/EmailConversation.d.ts +0 -17
- package/lib/components/Email/EmailConversation.d.ts.map +0 -1
- package/lib/components/Email/EmailConversation.js +0 -174
- package/lib/components/Email/EmailConversation.js.map +0 -1
- package/lib/components/Email/EmailEntity.d.ts +0 -11
- package/lib/components/Email/EmailEntity.d.ts.map +0 -1
- package/lib/components/Email/EmailEntity.js +0 -51
- package/lib/components/Email/EmailEntity.js.map +0 -1
- package/lib/components/Email/EmailManager.d.ts +0 -6
- package/lib/components/Email/EmailManager.d.ts.map +0 -1
- package/lib/components/Email/EmailManager.js +0 -21
- package/lib/components/Email/EmailManager.js.map +0 -1
- package/lib/components/Email/EmailNotificationPanel.d.ts +0 -7
- package/lib/components/Email/EmailNotificationPanel.d.ts.map +0 -1
- package/lib/components/Email/EmailNotificationPanel.js +0 -15
- package/lib/components/Email/EmailNotificationPanel.js.map +0 -1
- package/lib/components/Email/EmailSelector.d.ts +0 -22
- package/lib/components/Email/EmailSelector.d.ts.map +0 -1
- package/lib/components/Email/EmailSelector.js +0 -121
- package/lib/components/Email/EmailSelector.js.map +0 -1
- package/lib/components/Email/EmailShell.d.ts +0 -6
- package/lib/components/Email/EmailShell.d.ts.map +0 -1
- package/lib/components/Email/EmailShell.js +0 -46
- package/lib/components/Email/EmailShell.js.map +0 -1
- package/lib/components/Email/EmailSummaryItem.d.ts +0 -11
- package/lib/components/Email/EmailSummaryItem.d.ts.map +0 -1
- package/lib/components/Email/EmailSummaryItem.js +0 -118
- package/lib/components/Email/EmailSummaryItem.js.map +0 -1
- package/lib/components/Email/EmailSummaryList.d.ts +0 -6
- package/lib/components/Email/EmailSummaryList.d.ts.map +0 -1
- package/lib/components/Email/EmailSummaryList.js +0 -95
- package/lib/components/Email/EmailSummaryList.js.map +0 -1
- package/lib/components/Email/EntityList.d.ts +0 -6
- package/lib/components/Email/EntityList.d.ts.map +0 -1
- package/lib/components/Email/EntityList.js +0 -74
- package/lib/components/Email/EntityList.js.map +0 -1
- package/lib/components/Email/index.d.ts +0 -13
- package/lib/components/Email/index.d.ts.map +0 -1
- package/lib/components/Email/index.js +0 -12
- package/lib/components/Email/index.js.map +0 -1
- package/lib/components/Email/utils/EntityHighlighter.d.ts +0 -10
- package/lib/components/Email/utils/EntityHighlighter.d.ts.map +0 -1
- package/lib/components/Email/utils/EntityHighlighter.js +0 -260
- package/lib/components/Email/utils/EntityHighlighter.js.map +0 -1
- package/lib/components/Feed/Feed.context.d.ts +0 -51
- package/lib/components/Feed/Feed.context.d.ts.map +0 -1
- package/lib/components/Feed/Feed.context.js +0 -10
- package/lib/components/Feed/Feed.context.js.map +0 -1
- package/lib/components/Feed/Feed.d.ts +0 -6
- package/lib/components/Feed/Feed.d.ts.map +0 -1
- package/lib/components/Feed/Feed.js +0 -149
- package/lib/components/Feed/Feed.js.map +0 -1
- package/lib/components/Feed/Feed.types.d.ts +0 -334
- package/lib/components/Feed/Feed.types.d.ts.map +0 -1
- package/lib/components/Feed/Feed.types.js +0 -2
- package/lib/components/Feed/Feed.types.js.map +0 -1
- package/lib/components/Feed/FeedAnnouncer.d.ts +0 -6
- package/lib/components/Feed/FeedAnnouncer.d.ts.map +0 -1
- package/lib/components/Feed/FeedAnnouncer.js +0 -11
- package/lib/components/Feed/FeedAnnouncer.js.map +0 -1
- package/lib/components/Feed/FeedAttachments.d.ts +0 -8
- package/lib/components/Feed/FeedAttachments.d.ts.map +0 -1
- package/lib/components/Feed/FeedAttachments.js +0 -97
- package/lib/components/Feed/FeedAttachments.js.map +0 -1
- package/lib/components/Feed/FeedButton.d.ts +0 -5
- package/lib/components/Feed/FeedButton.d.ts.map +0 -1
- package/lib/components/Feed/FeedButton.js +0 -15
- package/lib/components/Feed/FeedButton.js.map +0 -1
- package/lib/components/Feed/FeedContent.d.ts +0 -6
- package/lib/components/Feed/FeedContent.d.ts.map +0 -1
- package/lib/components/Feed/FeedContent.js +0 -46
- package/lib/components/Feed/FeedContent.js.map +0 -1
- package/lib/components/Feed/FeedContentFooter.d.ts +0 -5
- package/lib/components/Feed/FeedContentFooter.d.ts.map +0 -1
- package/lib/components/Feed/FeedContentFooter.js +0 -34
- package/lib/components/Feed/FeedContentFooter.js.map +0 -1
- package/lib/components/Feed/FeedContentHeader.d.ts +0 -5
- package/lib/components/Feed/FeedContentHeader.d.ts.map +0 -1
- package/lib/components/Feed/FeedContentHeader.js +0 -107
- package/lib/components/Feed/FeedContentHeader.js.map +0 -1
- package/lib/components/Feed/FeedEditRegion.d.ts +0 -6
- package/lib/components/Feed/FeedEditRegion.d.ts.map +0 -1
- package/lib/components/Feed/FeedEditRegion.js +0 -57
- package/lib/components/Feed/FeedEditRegion.js.map +0 -1
- package/lib/components/Feed/FeedInputRegion.d.ts +0 -8
- package/lib/components/Feed/FeedInputRegion.d.ts.map +0 -1
- package/lib/components/Feed/FeedInputRegion.js +0 -86
- package/lib/components/Feed/FeedInputRegion.js.map +0 -1
- package/lib/components/Feed/FeedLikeButton.d.ts +0 -7
- package/lib/components/Feed/FeedLikeButton.d.ts.map +0 -1
- package/lib/components/Feed/FeedLikeButton.js +0 -102
- package/lib/components/Feed/FeedLikeButton.js.map +0 -1
- package/lib/components/Feed/FeedModalList.d.ts +0 -5
- package/lib/components/Feed/FeedModalList.d.ts.map +0 -1
- package/lib/components/Feed/FeedModalList.js +0 -39
- package/lib/components/Feed/FeedModalList.js.map +0 -1
- package/lib/components/Feed/FeedNewPost.d.ts +0 -7
- package/lib/components/Feed/FeedNewPost.d.ts.map +0 -1
- package/lib/components/Feed/FeedNewPost.js +0 -30
- package/lib/components/Feed/FeedNewPost.js.map +0 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +0 -6
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +0 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.js +0 -375
- package/lib/components/Feed/FeedNewPostTypeMenu.js.map +0 -1
- package/lib/components/Feed/FeedPost.d.ts +0 -8
- package/lib/components/Feed/FeedPost.d.ts.map +0 -1
- package/lib/components/Feed/FeedPost.js +0 -85
- package/lib/components/Feed/FeedPost.js.map +0 -1
- package/lib/components/Feed/FeedReply.d.ts +0 -7
- package/lib/components/Feed/FeedReply.d.ts.map +0 -1
- package/lib/components/Feed/FeedReply.js +0 -36
- package/lib/components/Feed/FeedReply.js.map +0 -1
- package/lib/components/Feed/FeedReplyInput.d.ts +0 -7
- package/lib/components/Feed/FeedReplyInput.d.ts.map +0 -1
- package/lib/components/Feed/FeedReplyInput.js +0 -21
- package/lib/components/Feed/FeedReplyInput.js.map +0 -1
- package/lib/components/Feed/FeedRichText.d.ts +0 -6
- package/lib/components/Feed/FeedRichText.d.ts.map +0 -1
- package/lib/components/Feed/FeedRichText.js +0 -163
- package/lib/components/Feed/FeedRichText.js.map +0 -1
- package/lib/components/Feed/index.d.ts +0 -7
- package/lib/components/Feed/index.d.ts.map +0 -1
- package/lib/components/Feed/index.js +0 -6
- package/lib/components/Feed/index.js.map +0 -1
- package/lib/components/HashtagButton/HashtagButton.d.ts +0 -23
- package/lib/components/HashtagButton/HashtagButton.d.ts.map +0 -1
- package/lib/components/HashtagButton/HashtagButton.js +0 -44
- package/lib/components/HashtagButton/HashtagButton.js.map +0 -1
- package/lib/components/HashtagButton/index.d.ts +0 -3
- package/lib/components/HashtagButton/index.d.ts.map +0 -1
- package/lib/components/HashtagButton/index.js +0 -3
- package/lib/components/HashtagButton/index.js.map +0 -1
- package/lib/components/MentionButton/MentionButton.d.ts +0 -35
- package/lib/components/MentionButton/MentionButton.d.ts.map +0 -1
- package/lib/components/MentionButton/MentionButton.js +0 -94
- package/lib/components/MentionButton/MentionButton.js.map +0 -1
- package/lib/components/MentionButton/index.d.ts +0 -3
- package/lib/components/MentionButton/index.d.ts.map +0 -1
- package/lib/components/MentionButton/index.js +0 -3
- package/lib/components/MentionButton/index.js.map +0 -1
- package/lib/index.d.ts +0 -12
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -13
- package/lib/index.js.map +0 -1
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useEffect, useContext } from 'react';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
4
|
-
import { FileUploadItem, Grid, Image, defaultThemeProp, getKindFromMimeType, getMimeTypeFromFile, Flex, usePrevious, useI18n } from '@pega/cosmos-react-core';
|
|
5
|
-
import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
|
|
6
|
-
import { FeedContext } from './Feed.context';
|
|
7
|
-
export const StyledFeedAttachments = styled.ul(({ theme }) => {
|
|
8
|
-
return css `
|
|
9
|
-
overflow-x: auto;
|
|
10
|
-
|
|
11
|
-
> li {
|
|
12
|
-
background-color: ${theme.base.palette['primary-background']};
|
|
13
|
-
cursor: initial;
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
});
|
|
17
|
-
StyledFeedAttachments.defaultProps = defaultThemeProp;
|
|
18
|
-
export const StyledImagePreview = styled(BareButton)(({ theme }) => {
|
|
19
|
-
return css `
|
|
20
|
-
line-height: 0;
|
|
21
|
-
width: fit-content;
|
|
22
|
-
border-radius: calc(0.5 * ${theme.base['border-radius']});
|
|
23
|
-
|
|
24
|
-
& + & {
|
|
25
|
-
margin: 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&:focus {
|
|
29
|
-
box-shadow: ${theme.components.button['focus-shadow']};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
img {
|
|
33
|
-
border-radius: calc(0.5 * ${theme.base['border-radius']});
|
|
34
|
-
object-fit: contain;
|
|
35
|
-
max-height: 10rem;
|
|
36
|
-
max-width: 100%;
|
|
37
|
-
}
|
|
38
|
-
`;
|
|
39
|
-
});
|
|
40
|
-
StyledImagePreview.defaultProps = defaultThemeProp;
|
|
41
|
-
export const StyledAttachmentsRegion = styled.div(({ variant, readOnly, theme }) => {
|
|
42
|
-
return css `
|
|
43
|
-
margin: ${theme.base.spacing} calc(5 * ${theme.base.spacing}) 0
|
|
44
|
-
calc(${variant === 'post' ? 6 : 5} * ${theme.base.spacing});
|
|
45
|
-
|
|
46
|
-
${readOnly &&
|
|
47
|
-
css `
|
|
48
|
-
margin-block-start: ${theme.base.spacing};
|
|
49
|
-
margin-inline: 0;
|
|
50
|
-
|
|
51
|
-
div + ul {
|
|
52
|
-
margin-block-start: ${theme.base.spacing};
|
|
53
|
-
}
|
|
54
|
-
`}
|
|
55
|
-
`;
|
|
56
|
-
});
|
|
57
|
-
StyledAttachmentsRegion.defaultProps = defaultThemeProp;
|
|
58
|
-
const FeedAttachments = forwardRef(function FeedAttachments(props, ref) {
|
|
59
|
-
const { variant, attachments = [], readOnly } = props;
|
|
60
|
-
const t = useI18n();
|
|
61
|
-
const { announce } = useContext(FeedContext);
|
|
62
|
-
const prevAttachments = usePrevious(attachments) ?? [];
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (!readOnly && attachments.length !== prevAttachments?.length) {
|
|
65
|
-
const difference = attachments.length - prevAttachments.length;
|
|
66
|
-
const normalizedDifference = difference * (difference > 0 ? 1 : -1);
|
|
67
|
-
const timeoutId = announce(t(`feed_attachments_${difference > 0 ? 'added' : 'removed'}`, [normalizedDifference], {
|
|
68
|
-
count: normalizedDifference
|
|
69
|
-
}));
|
|
70
|
-
return () => clearTimeout(timeoutId);
|
|
71
|
-
}
|
|
72
|
-
}, [attachments, readOnly]);
|
|
73
|
-
if (attachments.length === 0)
|
|
74
|
-
return null;
|
|
75
|
-
const previewableFiles = [];
|
|
76
|
-
const nonPreviewableFiles = [];
|
|
77
|
-
attachments.forEach(file => {
|
|
78
|
-
const type = getKindFromMimeType(getMimeTypeFromFile(file.name) ?? '');
|
|
79
|
-
if (type === 'image' && file.thumbnail)
|
|
80
|
-
previewableFiles.push(file);
|
|
81
|
-
else
|
|
82
|
-
nonPreviewableFiles.push(file);
|
|
83
|
-
});
|
|
84
|
-
return (_jsxs(StyledAttachmentsRegion, { variant: variant, readOnly: readOnly, children: [readOnly && !!previewableFiles.length && (_jsx(Flex, { container: { gap: 1, wrap: 'wrap' }, children: previewableFiles.map(({ lastModified, name, onPreview, thumbnail }) => {
|
|
85
|
-
return (_jsx(StyledImagePreview, { onClick: () => onPreview?.(name), children: _jsx(Image, { alt: name, src: thumbnail }) }, lastModified));
|
|
86
|
-
}) })), _jsxs(Grid, { ref: ref, as: StyledFeedAttachments, container: {
|
|
87
|
-
cols: 'repeat(auto-fill, minmax(15rem, 1fr))',
|
|
88
|
-
gap: 1
|
|
89
|
-
}, children: [!readOnly &&
|
|
90
|
-
previewableFiles.map(({ lastModified, name, size, ...restProps }) => {
|
|
91
|
-
return _jsx(FileUploadItem, { name: name, size: size, ...restProps }, lastModified);
|
|
92
|
-
}), nonPreviewableFiles.map(({ lastModified, name, size, ...restProps }) => {
|
|
93
|
-
return _jsx(FileUploadItem, { name: name, size: size, ...restProps }, lastModified);
|
|
94
|
-
})] })] }));
|
|
95
|
-
});
|
|
96
|
-
export default FeedAttachments;
|
|
97
|
-
//# sourceMappingURL=FeedAttachments.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedAttachments.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedAttachments.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAmB,SAAS,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,cAAc,EACd,IAAI,EACJ,KAAK,EACL,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,IAAI,EACJ,WAAW,EACX,OAAO,EACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC3D,OAAO,GAAG,CAAA;;;;0BAIc,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;;;GAG/D,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACjE,OAAO,GAAG,CAAA;;;gCAGoB,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;;;;;;;oBAOvC,KAAK,CAAC,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AAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE;oBACrE,OAAO,CACL,KAAC,kBAAkB,IAAoB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,YACrE,KAAC,KAAK,IAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,GAAI,IADb,YAAY,CAEhB,CACtB,CAAC;gBACJ,CAAC,CAAC,GACG,CACR,EACD,MAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,qBAAqB,EACzB,SAAS,EAAE;oBACT,IAAI,EAAE,uCAAuC;oBAC7C,GAAG,EAAE,CAAC;iBACP,aAEA,CAAC,QAAQ;wBACR,gBAAgB,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE;4BAClE,OAAO,KAAC,cAAc,IAAoB,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KAAM,SAAS,IAAnD,YAAY,CAA2C,CAAC;wBACtF,CAAC,CAAC,EACH,mBAAmB,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE;wBACtE,OAAO,KAAC,cAAc,IAAoB,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KAAM,SAAS,IAAnD,YAAY,CAA2C,CAAC;oBACtF,CAAC,CAAC,IACG,IACiB,CAC3B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,eAAe,CAAC","sourcesContent":["import { FC, forwardRef, PropsWithoutRef, useEffect, useContext } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n FileUploadItem,\n Grid,\n Image,\n defaultThemeProp,\n getKindFromMimeType,\n getMimeTypeFromFile,\n Flex,\n usePrevious,\n useI18n\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nimport { FeedContext } from './Feed.context';\nimport { AttachedFiles, FeedAttachmentsProps } from './Feed.types';\n\nexport const StyledFeedAttachments = styled.ul(({ theme }) => {\n return css`\n overflow-x: auto;\n\n > li {\n background-color: ${theme.base.palette['primary-background']};\n cursor: initial;\n }\n `;\n});\n\nStyledFeedAttachments.defaultProps = defaultThemeProp;\n\nexport const StyledImagePreview = styled(BareButton)(({ theme }) => {\n return css`\n line-height: 0;\n width: fit-content;\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n\n & + & {\n margin: 0;\n }\n\n &:focus {\n box-shadow: ${theme.components.button['focus-shadow']};\n }\n\n img {\n border-radius: calc(0.5 * ${theme.base['border-radius']});\n object-fit: contain;\n max-height: 10rem;\n max-width: 100%;\n }\n `;\n});\n\nStyledImagePreview.defaultProps = defaultThemeProp;\n\nexport const StyledAttachmentsRegion = styled.div<FeedAttachmentsProps>(\n ({ variant, readOnly, theme }) => {\n return css`\n margin: ${theme.base.spacing} calc(5 * ${theme.base.spacing}) 0\n calc(${variant === 'post' ? 6 : 5} * ${theme.base.spacing});\n\n ${readOnly &&\n css`\n margin-block-start: ${theme.base.spacing};\n margin-inline: 0;\n\n div + ul {\n margin-block-start: ${theme.base.spacing};\n }\n `}\n `;\n }\n);\n\nStyledAttachmentsRegion.defaultProps = defaultThemeProp;\n\nconst FeedAttachments: FC<FeedAttachmentsProps> = forwardRef(function FeedAttachments(\n props: PropsWithoutRef<FeedAttachmentsProps>,\n ref: FeedAttachmentsProps['ref']\n) {\n const { variant, attachments = [], readOnly } = props;\n const t = useI18n();\n const { announce } = useContext(FeedContext);\n const prevAttachments = usePrevious(attachments) ?? [];\n\n useEffect(() => {\n if (!readOnly && attachments.length !== prevAttachments?.length) {\n const difference = attachments.length - prevAttachments.length;\n const normalizedDifference = difference * (difference > 0 ? 1 : -1);\n const timeoutId = announce(\n t(`feed_attachments_${difference > 0 ? 'added' : 'removed'}`, [normalizedDifference], {\n count: normalizedDifference\n })\n );\n return () => clearTimeout(timeoutId);\n }\n }, [attachments, readOnly]);\n\n if (attachments.length === 0) return null;\n\n const previewableFiles: AttachedFiles[] = [];\n const nonPreviewableFiles: AttachedFiles[] = [];\n\n attachments.forEach(file => {\n const type = getKindFromMimeType(getMimeTypeFromFile(file.name) ?? '');\n\n if (type === 'image' && file.thumbnail) previewableFiles.push(file);\n else nonPreviewableFiles.push(file);\n });\n\n return (\n <StyledAttachmentsRegion variant={variant} readOnly={readOnly}>\n {readOnly && !!previewableFiles.length && (\n <Flex container={{ gap: 1, wrap: 'wrap' }}>\n {previewableFiles.map(({ lastModified, name, onPreview, thumbnail }) => {\n return (\n <StyledImagePreview key={lastModified} onClick={() => onPreview?.(name)}>\n <Image alt={name} src={thumbnail} />\n </StyledImagePreview>\n );\n })}\n </Flex>\n )}\n <Grid\n ref={ref}\n as={StyledFeedAttachments}\n container={{\n cols: 'repeat(auto-fill, minmax(15rem, 1fr))',\n gap: 1\n }}\n >\n {!readOnly &&\n previewableFiles.map(({ lastModified, name, size, ...restProps }) => {\n return <FileUploadItem key={lastModified} name={name} size={size} {...restProps} />;\n })}\n {nonPreviewableFiles.map(({ lastModified, name, size, ...restProps }) => {\n return <FileUploadItem key={lastModified} name={name} size={size} {...restProps} />;\n })}\n </Grid>\n </StyledAttachmentsRegion>\n );\n});\n\nexport default FeedAttachments;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedButton.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU;;SAUd,CAAC;AAIH,eAAe,UAAU,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components';
|
|
2
|
-
import { defaultThemeProp } from '@pega/cosmos-react-core';
|
|
3
|
-
const FeedButton = styled.button(props => {
|
|
4
|
-
const { emphasized, theme } = props;
|
|
5
|
-
return css `
|
|
6
|
-
color: ${emphasized ? theme.base.palette.interactive : theme.base.palette['foreground-color']};
|
|
7
|
-
|
|
8
|
-
span {
|
|
9
|
-
margin-inline-start: ${theme.base.spacing};
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
});
|
|
13
|
-
FeedButton.defaultProps = defaultThemeProp;
|
|
14
|
-
export default FeedButton;
|
|
15
|
-
//# sourceMappingURL=FeedButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedButton.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAA2B,KAAK,CAAC,EAAE;IACjE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAEpC,OAAO,GAAG,CAAA;aACC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;;6BAGpE,KAAK,CAAC,IAAI,CAAC,OAAO;;GAE5C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,eAAe,UAAU,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '@pega/cosmos-react-core';\n\nconst FeedButton = styled.button<{ emphasized?: boolean }>(props => {\n const { emphasized, theme } = props;\n\n return css`\n color: ${emphasized ? theme.base.palette.interactive : theme.base.palette['foreground-color']};\n\n span {\n margin-inline-start: ${theme.base.spacing};\n }\n `;\n});\n\nFeedButton.defaultProps = defaultThemeProp;\n\nexport default FeedButton;\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { FeedContentProps } from './Feed.types';
|
|
4
|
-
declare const FeedContent: FC<FeedContentProps & ForwardProps>;
|
|
5
|
-
export default FeedContent;
|
|
6
|
-
//# sourceMappingURL=FeedContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedContent.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EAQH,MAAM,OAAO,CAAC;AAGf,OAAO,EAAgC,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQhD,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,GAAG,YAAY,CAoEnD,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useState, useMemo, useRef, useEffect, useContext } from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { Button, ExpandCollapse, Flex } from '@pega/cosmos-react-core';
|
|
5
|
-
import { RichTextViewer } from '@pega/cosmos-react-rte';
|
|
6
|
-
import { StyledEditorContainer } from '@pega/cosmos-react-rte/lib/components/RichTextEditor/RichTextEditor.styles';
|
|
7
|
-
import { FeedContext } from './Feed.context';
|
|
8
|
-
const StyledContent = styled.div `
|
|
9
|
-
${StyledEditorContainer} {
|
|
10
|
-
padding: 0;
|
|
11
|
-
}
|
|
12
|
-
`;
|
|
13
|
-
const FeedContent = forwardRef(function FeedContent({ children, maxContentHeight = Infinity, ...restProps }, ref) {
|
|
14
|
-
const { interactionRenderers, markdownMap } = useContext(FeedContext);
|
|
15
|
-
const [collapsed, setCollapsed] = useState(true);
|
|
16
|
-
const [exceedsMaxHeight, setExceedsMaxHeight] = useState(true);
|
|
17
|
-
const rtvRef = useRef(null);
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (!rtvRef.current)
|
|
20
|
-
return;
|
|
21
|
-
const observer = new ResizeObserver(entries => {
|
|
22
|
-
const exceedsHeight = entries.some(({ target, contentRect }) => {
|
|
23
|
-
if (target !== rtvRef.current)
|
|
24
|
-
return;
|
|
25
|
-
return contentRect.height > maxContentHeight;
|
|
26
|
-
});
|
|
27
|
-
setExceedsMaxHeight(exceedsHeight);
|
|
28
|
-
});
|
|
29
|
-
observer.observe(rtvRef.current);
|
|
30
|
-
return () => {
|
|
31
|
-
observer.disconnect();
|
|
32
|
-
};
|
|
33
|
-
}, [rtvRef.current, maxContentHeight]);
|
|
34
|
-
return useMemo(() => typeof children === 'string' ? (_jsxs(Flex, { as: StyledContent, ref: ref, container: { direction: 'column', gap: 1 }, children: [_jsx(ExpandCollapse, { collapsed: collapsed, min: exceedsMaxHeight ? `${maxContentHeight}px` : 'max-content', ...restProps, children: _jsx(RichTextViewer, { ref: rtvRef, content: children, type: 'markdown', interactionRenderers: interactionRenderers, markdownMap: markdownMap }) }), exceedsMaxHeight && (_jsx(Flex, { container: { justify: 'center' }, children: _jsx(Button, { variant: 'link', onClick: () => setCollapsed(current => !current), children: collapsed ? 'Show more' : 'Show less' }) }))] })) : (children), [
|
|
35
|
-
children,
|
|
36
|
-
collapsed,
|
|
37
|
-
exceedsMaxHeight,
|
|
38
|
-
interactionRenderers,
|
|
39
|
-
markdownMap,
|
|
40
|
-
maxContentHeight,
|
|
41
|
-
ref,
|
|
42
|
-
restProps
|
|
43
|
-
]);
|
|
44
|
-
});
|
|
45
|
-
export default FeedContent;
|
|
46
|
-
//# sourceMappingURL=FeedContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedContent.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EACV,QAAQ,EACR,OAAO,EACP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ACV,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC","sourcesContent":["import {\n FC,\n forwardRef,\n useState,\n useMemo,\n useRef,\n useEffect,\n PropsWithoutRef,\n useContext\n} from 'react';\nimport styled from 'styled-components';\n\nimport { Button, ExpandCollapse, Flex, ForwardProps } from '@pega/cosmos-react-core';\nimport { RichTextViewer } from '@pega/cosmos-react-rte';\nimport { StyledEditorContainer } from '@pega/cosmos-react-rte/lib/components/RichTextEditor/RichTextEditor.styles';\n\nimport { FeedContext } from './Feed.context';\nimport { FeedContentProps } from './Feed.types';\n\nconst StyledContent = styled.div`\n ${StyledEditorContainer} {\n padding: 0;\n }\n`;\n\nconst FeedContent: FC<FeedContentProps & ForwardProps> = forwardRef(function FeedContent(\n { children, maxContentHeight = Infinity, ...restProps }: PropsWithoutRef<FeedContentProps>,\n ref: FeedContentProps['ref']\n) {\n const { interactionRenderers, markdownMap } = useContext(FeedContext);\n const [collapsed, setCollapsed] = useState(true);\n const [exceedsMaxHeight, setExceedsMaxHeight] = useState(true);\n const rtvRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!rtvRef.current) return;\n\n const observer = new ResizeObserver(entries => {\n const exceedsHeight = entries.some(({ target, contentRect }) => {\n if (target !== rtvRef.current) return;\n\n return contentRect.height > maxContentHeight;\n });\n\n setExceedsMaxHeight(exceedsHeight);\n });\n\n observer.observe(rtvRef.current);\n\n return () => {\n observer.disconnect();\n };\n }, [rtvRef.current, maxContentHeight]);\n\n return useMemo(\n () =>\n typeof children === 'string' ? (\n <Flex as={StyledContent} ref={ref} container={{ direction: 'column', gap: 1 }}>\n <ExpandCollapse\n collapsed={collapsed}\n min={exceedsMaxHeight ? `${maxContentHeight}px` : 'max-content'}\n {...restProps}\n >\n <RichTextViewer\n ref={rtvRef}\n content={children}\n type='markdown'\n interactionRenderers={interactionRenderers}\n markdownMap={markdownMap}\n />\n </ExpandCollapse>\n {exceedsMaxHeight && (\n <Flex container={{ justify: 'center' }}>\n <Button variant='link' onClick={() => setCollapsed(current => !current)}>\n {collapsed ? 'Show more' : 'Show less'}\n </Button>\n </Flex>\n )}\n </Flex>\n ) : (\n children\n ),\n [\n children,\n collapsed,\n exceedsMaxHeight,\n interactionRenderers,\n markdownMap,\n maxContentHeight,\n ref,\n restProps\n ]\n );\n});\n\nexport default FeedContent;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedContentFooter.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedContentFooter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAc,MAAM,OAAO,CAAC;AAkBvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAWtD,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CAkGjD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useContext } from 'react';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
4
|
-
import { Button, Count, defaultThemeProp, Flex, Icon, Progress, Text, useI18n, useUID } from '@pega/cosmos-react-core';
|
|
5
|
-
import FeedButton from './FeedButton';
|
|
6
|
-
import FeedLikeButton from './FeedLikeButton';
|
|
7
|
-
import { FeedReplyContext } from './Feed.context';
|
|
8
|
-
const StyledFeedContentFooter = styled.div(({ theme }) => {
|
|
9
|
-
return css `
|
|
10
|
-
margin-block-start: ${theme.base.spacing};
|
|
11
|
-
margin-inline-end: calc(2 * ${theme.base.spacing});
|
|
12
|
-
`;
|
|
13
|
-
});
|
|
14
|
-
StyledFeedContentFooter.defaultProps = defaultThemeProp;
|
|
15
|
-
const FeedContentFooter = (props) => {
|
|
16
|
-
const { variant, id, username, liked, likes, likeCount, interactionsEnabled = true, likesLoading, replies = [], replyCount, repliesLoading, onCommentClick, onLikeClick, onLikeCountInteraction, onLoadMoreLikes, onShowMoreReplies, onShowLessReplies, replyInputOpen, setReplyInputOpen } = props;
|
|
17
|
-
const t = useI18n();
|
|
18
|
-
const commentCountId = useUID();
|
|
19
|
-
const { onShowReplyInput } = useContext(FeedReplyContext);
|
|
20
|
-
const numReplies = replyCount || replies.length;
|
|
21
|
-
return (_jsxs(Flex, { as: StyledFeedContentFooter, container: { justify: 'between', alignItems: 'center', wrap: 'wrap', gap: 1 }, children: [interactionsEnabled ? (_jsxs(Flex, { container: { gap: 2 }, children: [_jsxs(Flex, { container: { gap: 0.5, alignItems: 'center' }, children: [_jsx(Button, { variant: 'simple', as: FeedButton, icon: true, compact: true, onClick: () => {
|
|
22
|
-
onCommentClick?.({ id, username });
|
|
23
|
-
if (variant === 'post') {
|
|
24
|
-
if (!replyInputOpen) {
|
|
25
|
-
setReplyInputOpen?.(true);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
onShowReplyInput?.();
|
|
30
|
-
}
|
|
31
|
-
}, label: t('feed_comment_label'), "aria-describedby": variant === 'post' && numReplies > 0 ? commentCountId : undefined, children: _jsx(Icon, { name: 'chat' }) }), numReplies > 0 && (_jsx(Count, { "aria-label": t('feed_post_comments', [numReplies], { count: numReplies }), id: commentCountId, children: numReplies }))] }), _jsx(FeedLikeButton, { id: id, onLikeClick: onLikeClick, onLikeCountInteraction: onLikeCountInteraction, onLoadMoreLikes: onLoadMoreLikes, likesLoading: likesLoading, liked: liked, likes: likes, likeCount: likeCount })] })) : (_jsx("div", {})), (onShowLessReplies || onShowMoreReplies) && (_jsxs(Flex, { container: { gap: 0.5 }, children: [replies.length !== numReplies && (_jsxs(_Fragment, { children: [_jsx(Text, { children: t('showing_num_of_num', [replies.length, numReplies]) }), _jsx("span", { children: "\u2022" })] })), onShowMoreReplies && replies.length < numReplies && (_jsx(Button, { variant: 'link', onClick: () => onShowMoreReplies({ id }), children: t('show_more') })), repliesLoading && _jsx(Progress, { placement: 'inline' })] }))] }));
|
|
32
|
-
};
|
|
33
|
-
export default FeedContentFooter;
|
|
34
|
-
//# sourceMappingURL=FeedContentFooter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedContentFooter.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedContentFooter.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,MAAM,EACP,MAAM,yBAAyB,CAAC;AAEjC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACvD,OAAO,GAAG,CAAA;0BACc,KAAK,CAAC,IAAI,CAAC,OAAO;kCACV,KAAK,CAAC,IAAI,CAAC,OAAO;GACjD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,uBAAuB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAExD,MAAM,iBAAiB,GAA+B,CAAC,KAA6B,EAAE,EAAE;IACtF,MAAM,EACJ,OAAO,EACP,EAAE,EACF,QAAQ,EACR,KAAK,EACL,KAAK,EACL,SAAS,EACT,mBAAmB,GAAG,IAAI,EAC1B,YAAY,EACZ,OAAO,GAAG,EAAE,EACZ,UAAU,EACV,cAAc,EACd,cAAc,EACd,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EAClB,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,GAA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EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EACxE,EAAE,EAAE,cAAc,YAEjB,UAAU,GACL,CACT,IACI,EACP,KAAC,cAAc,IACb,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,WAAW,EACxB,sBAAsB,EAAE,sBAAsB,EAC9C,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,GACpB,IACG,CACR,CAAC,CAAC,CAAC,CACF,eAAO,CACR,EACA,CAAC,iBAAiB,IAAI,iBAAiB,CAAC,IAAI,CAC3C,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,aAC1B,OAAO,CAAC,MAAM,KAAK,UAAU,IAAI,CAChC,8BACE,KAAC,IAAI,cAAE,CAAC,CAAC,oBAAoB,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAAQ,EACpE,oCAAmB,IAClB,CACJ,EACA,iBAAiB,IAAI,OAAO,CAAC,MAAM,GAAG,UAAU,IAAI,CACnD,KAAC,MAAM,IAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,YAC5D,CAAC,CAAC,WAAW,CAAC,GACR,CACV,EACA,cAAc,IAAI,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,IAC7C,CACR,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { FC, useContext } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n Count,\n defaultThemeProp,\n Flex,\n Icon,\n Progress,\n Text,\n useI18n,\n useUID\n} from '@pega/cosmos-react-core';\n\nimport FeedButton from './FeedButton';\nimport FeedLikeButton from './FeedLikeButton';\nimport { FeedReplyContext } from './Feed.context';\nimport { FeedContentFooterProps } from './Feed.types';\n\nconst StyledFeedContentFooter = styled.div(({ theme }) => {\n return css`\n margin-block-start: ${theme.base.spacing};\n margin-inline-end: calc(2 * ${theme.base.spacing});\n `;\n});\n\nStyledFeedContentFooter.defaultProps = defaultThemeProp;\n\nconst FeedContentFooter: FC<FeedContentFooterProps> = (props: FeedContentFooterProps) => {\n const {\n variant,\n id,\n username,\n liked,\n likes,\n likeCount,\n interactionsEnabled = true,\n likesLoading,\n replies = [],\n replyCount,\n repliesLoading,\n onCommentClick,\n onLikeClick,\n onLikeCountInteraction,\n onLoadMoreLikes,\n onShowMoreReplies,\n onShowLessReplies,\n replyInputOpen,\n setReplyInputOpen\n } = props;\n\n const t = useI18n();\n const commentCountId = useUID();\n const { onShowReplyInput } = useContext(FeedReplyContext);\n\n const numReplies = replyCount || replies.length;\n\n return (\n <Flex\n as={StyledFeedContentFooter}\n container={{ justify: 'between', alignItems: 'center', wrap: 'wrap', gap: 1 }}\n >\n {interactionsEnabled ? (\n <Flex container={{ gap: 2 }}>\n <Flex container={{ gap: 0.5, alignItems: 'center' }}>\n <Button\n variant='simple'\n as={FeedButton}\n icon\n compact\n onClick={() => {\n onCommentClick?.({ id, username });\n if (variant === 'post') {\n if (!replyInputOpen) {\n setReplyInputOpen?.(true);\n }\n } else {\n onShowReplyInput?.();\n }\n }}\n label={t('feed_comment_label')}\n aria-describedby={variant === 'post' && numReplies > 0 ? commentCountId : undefined}\n >\n <Icon name='chat' />\n </Button>\n {numReplies > 0 && (\n <Count\n aria-label={t('feed_post_comments', [numReplies], { count: numReplies })}\n id={commentCountId}\n >\n {numReplies}\n </Count>\n )}\n </Flex>\n <FeedLikeButton\n id={id}\n onLikeClick={onLikeClick}\n onLikeCountInteraction={onLikeCountInteraction}\n onLoadMoreLikes={onLoadMoreLikes}\n likesLoading={likesLoading}\n liked={liked}\n likes={likes}\n likeCount={likeCount}\n />\n </Flex>\n ) : (\n <div />\n )}\n {(onShowLessReplies || onShowMoreReplies) && (\n <Flex container={{ gap: 0.5 }}>\n {replies.length !== numReplies && (\n <>\n <Text>{t('showing_num_of_num', [replies.length, numReplies])}</Text>\n <span>•</span>\n </>\n )}\n {onShowMoreReplies && replies.length < numReplies && (\n <Button variant='link' onClick={() => onShowMoreReplies({ id })}>\n {t('show_more')}\n </Button>\n )}\n {repliesLoading && <Progress placement='inline' />}\n </Flex>\n )}\n </Flex>\n );\n};\n\nexport default FeedContentFooter;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedContentHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedContentHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA6C,MAAM,OAAO,CAAC;AAgCtE,OAAO,EAAE,sBAAsB,EAAsB,MAAM,cAAc,CAAC;AAsB1E,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CA2MjD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useEffect, useRef } from 'react';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
4
|
-
import { Avatar, Button, DateTimeDisplay, defaultThemeProp, Flex, Icon, MenuButton, MetaList, StyledSecondary, SummaryItem, Text, Tooltip, useConfiguration, useElement, useI18n, useModalManager } from '@pega/cosmos-react-core';
|
|
5
|
-
import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
|
|
6
|
-
import { parseToDate } from '@pega/cosmos-react-core/lib/components/DateTime/Input/utils';
|
|
7
|
-
import { formatDateTime } from '@pega/cosmos-react-core/lib/components/DateTime/utils';
|
|
8
|
-
import { formatListToLocaleString } from '@pega/cosmos-react-core/lib/utils';
|
|
9
|
-
import AutopilotAvatar from '../Autopilot/AutopilotAvatar';
|
|
10
|
-
import { FeedContext } from './Feed.context';
|
|
11
|
-
import FeedModalList from './FeedModalList';
|
|
12
|
-
import FeedButton from './FeedButton';
|
|
13
|
-
const StyledFeedContentHeader = styled.div(({ theme }) => {
|
|
14
|
-
return css `
|
|
15
|
-
margin-block-end: ${theme.base.spacing};
|
|
16
|
-
column-gap: ${theme.base.spacing};
|
|
17
|
-
|
|
18
|
-
${StyledSecondary} {
|
|
19
|
-
${FeedButton} {
|
|
20
|
-
/* Negative margin needed to align the icon with the author name on the line above. */
|
|
21
|
-
margin-inline-start: calc(-0.75 * ${theme.base.spacing});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
});
|
|
26
|
-
StyledFeedContentHeader.defaultProps = defaultThemeProp;
|
|
27
|
-
const StyledName = styled(Text) `
|
|
28
|
-
display: inline-block;
|
|
29
|
-
`;
|
|
30
|
-
const FeedContentHeader = (props) => {
|
|
31
|
-
const { variant, id, fullname, username, postTimestamp, content, avatarSrc, icon, userStatus, postType, postContext, recipients = [], recipientsCount = 0, menuItems, edited, editTimestamp, recipientsLoading, onEditSubmit, onLoadMoreRecipients, onRecipientInteraction, onUserClick, setEditMode } = props;
|
|
32
|
-
const { enableAutopilot, userInfo: loggedInUser } = useContext(FeedContext);
|
|
33
|
-
const t = useI18n();
|
|
34
|
-
const { locale } = useConfiguration();
|
|
35
|
-
const { create } = useModalManager();
|
|
36
|
-
const recipientsModalRef = useRef();
|
|
37
|
-
const [postTimestampEl, setPostTimestampEl] = useElement();
|
|
38
|
-
const [editTimestampEl, setEditTimestampEl] = useElement();
|
|
39
|
-
const autopilotAuthor = enableAutopilot && username === 'Autopilot';
|
|
40
|
-
const timestamps = [
|
|
41
|
-
_jsxs(_Fragment, { children: [_jsx(DateTimeDisplay, { ref: setPostTimestampEl, value: postTimestamp, variant: 'relative' }), postTimestamp && (_jsx(Tooltip, { target: postTimestampEl, children: formatDateTime(parseToDate(postTimestamp), {
|
|
42
|
-
t,
|
|
43
|
-
locale,
|
|
44
|
-
format: 'short',
|
|
45
|
-
variant: 'datetime',
|
|
46
|
-
timeZone: loggedInUser.timeZone
|
|
47
|
-
}) }))] })
|
|
48
|
-
];
|
|
49
|
-
if (edited) {
|
|
50
|
-
timestamps.push(_jsxs(_Fragment, { children: [_jsx(Text, { ref: setEditTimestampEl, variant: 'secondary', children: t('edited', [_jsx(DateTimeDisplay, { value: editTimestamp, variant: 'relative' })]) }), editTimestamp && (_jsx(Tooltip, { target: editTimestampEl, children: formatDateTime(parseToDate(editTimestamp), {
|
|
51
|
-
t,
|
|
52
|
-
locale,
|
|
53
|
-
format: 'short',
|
|
54
|
-
variant: 'datetime',
|
|
55
|
-
timeZone: loggedInUser.timeZone
|
|
56
|
-
}) }))] }));
|
|
57
|
-
}
|
|
58
|
-
const userVisual = autopilotAuthor ? (_jsx(AutopilotAvatar, {})) : (_jsx(Avatar, { name: fullname, size: variant === 'post' ? 'l' : 'm', imageSrc: avatarSrc, icon: icon, status: userStatus }));
|
|
59
|
-
const recipientsList = recipients.map(x => x.primary);
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (recipients.length) {
|
|
62
|
-
recipientsModalRef.current?.update({
|
|
63
|
-
count: recipientsCount,
|
|
64
|
-
heading: t('feed_recipients'),
|
|
65
|
-
listItems: recipients,
|
|
66
|
-
onLoadMore: onLoadMoreRecipients,
|
|
67
|
-
loading: recipientsLoading
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}, [recipientsCount, recipients, onLoadMoreRecipients, recipientsLoading]);
|
|
71
|
-
return (_jsx(SummaryItem, { as: StyledFeedContentHeader, visual: onUserClick ? (_jsx(BareButton, { onClick: (event) => {
|
|
72
|
-
onUserClick?.({ id, username }, event);
|
|
73
|
-
}, children: userVisual })) : (userVisual), primary: _jsxs("div", { children: [onUserClick ? (_jsx(Button, { variant: 'text', onClick: (event) => {
|
|
74
|
-
onUserClick?.({ id, username }, event);
|
|
75
|
-
}, children: _jsx(Text, { variant: 'h3', children: autopilotAuthor ? 'Autopilot' : fullname }) })) : (_jsx(StyledName, { variant: 'h3', children: autopilotAuthor ? 'Autopilot' : fullname })), postContext && _jsxs(Text, { variant: 'primary', children: [" ", t('feed_context', [postContext])] })] }), secondary: _jsxs(Flex, { container: { gap: 0.5, alignItems: 'center' }, children: [postType === 'private' && (_jsx(Button, { variant: 'simple', as: FeedButton, icon: true, compact: true, onClick: recipients.length
|
|
76
|
-
? () => {
|
|
77
|
-
if (recipientsCount > 2) {
|
|
78
|
-
recipientsModalRef.current = create(FeedModalList, {
|
|
79
|
-
count: recipientsCount,
|
|
80
|
-
heading: t('feed_recipients'),
|
|
81
|
-
listItems: recipients,
|
|
82
|
-
onLoadMore: onLoadMoreRecipients,
|
|
83
|
-
loading: recipientsLoading
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
: onRecipientInteraction, onFocus: onRecipientInteraction, onMouseOver: onRecipientInteraction, "aria-label": `${t('feed_private_post')} ${t('feed_recipients')} ${formatListToLocaleString(recipientsList.slice(0, 2), t, locale, {
|
|
88
|
-
count: recipientsCount
|
|
89
|
-
})}`, label: `${t('feed_private_post')}:\n${formatListToLocaleString(recipientsList.slice(0, 2), t, locale, {
|
|
90
|
-
count: recipientsCount,
|
|
91
|
-
separator: '\n'
|
|
92
|
-
}) || t('feed_private_post')}`, children: _jsx(Icon, { name: 'lock-closed-solid' }) })), _jsx(MetaList, { items: timestamps })] }), actions: menuItems ? (_jsx(MenuButton, { text: t('feed_post_actions_menu'), menu: {
|
|
93
|
-
items: onEditSubmit && typeof content === 'string' && username === loggedInUser.username
|
|
94
|
-
? [
|
|
95
|
-
{
|
|
96
|
-
primary: t('edit'),
|
|
97
|
-
id: 'edit',
|
|
98
|
-
onClick: () => setEditMode(true),
|
|
99
|
-
disabled: content.includes('<pega-autopilot/>')
|
|
100
|
-
},
|
|
101
|
-
...menuItems
|
|
102
|
-
]
|
|
103
|
-
: menuItems
|
|
104
|
-
}, icon: 'more', iconOnly: true, variant: 'simple' })) : undefined }));
|
|
105
|
-
};
|
|
106
|
-
export default FeedContentHeader;
|
|
107
|
-
//# sourceMappingURL=FeedContentHeader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedContentHeader.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedContentHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,QAAQ,EAER,eAAe,EACf,WAAW,EACX,IAAI,EACJ,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,eAAe,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,6DAA6D,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,UAAU,MAAM,cAAc,CAAC;AAGtC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACvD,OAAO,GAAG,CAAA;wBACY,KAAK,CAAC,IAAI,CAAC,OAAO;kBACxB,KAAK,CAAC,IAAI,CAAC,OAAO;;MAE9B,eAAe;QACb,UAAU;;4CAE0B,KAAK,CAAC,IAAI,CAAC,OAAO;;;GAG3D,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,uBAAuB,CAAC,YAAY,GAAG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AY,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,QAAQ,KAAK,YAAY,CAAC,QAAQ;oBAC/E,CAAC,CAAC;wBACE;4BACE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;4BAClB,EAAE,EAAE,MAAM;4BACV,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;4BAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC;yBAChD;wBACD,GAAG,SAAS;qBACb;oBACH,CAAC,CAAC,SAAS;aAChB,EACD,IAAI,EAAC,MAAM,EACX,QAAQ,QACR,OAAO,EAAC,QAAQ,GAChB,CACH,CAAC,CAAC,CAAC,SAAS,GAEf,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import { FC, MouseEvent, useContext, useEffect, useRef } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Avatar,\n Button,\n DateTimeDisplay,\n defaultThemeProp,\n Flex,\n Icon,\n MenuButton,\n MetaList,\n ModalMethods,\n StyledSecondary,\n SummaryItem,\n Text,\n Tooltip,\n useConfiguration,\n useElement,\n useI18n,\n useModalManager\n} from '@pega/cosmos-react-core';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport { parseToDate } from '@pega/cosmos-react-core/lib/components/DateTime/Input/utils';\nimport { formatDateTime } from '@pega/cosmos-react-core/lib/components/DateTime/utils';\nimport { formatListToLocaleString } from '@pega/cosmos-react-core/lib/utils';\n\nimport AutopilotAvatar from '../Autopilot/AutopilotAvatar';\n\nimport { FeedContext } from './Feed.context';\nimport FeedModalList from './FeedModalList';\nimport FeedButton from './FeedButton';\nimport { FeedContentHeaderProps, FeedModalListProps } from './Feed.types';\n\nconst StyledFeedContentHeader = styled.div(({ theme }) => {\n return css`\n margin-block-end: ${theme.base.spacing};\n column-gap: ${theme.base.spacing};\n\n ${StyledSecondary} {\n ${FeedButton} {\n /* Negative margin needed to align the icon with the author name on the line above. */\n margin-inline-start: calc(-0.75 * ${theme.base.spacing});\n }\n }\n `;\n});\n\nStyledFeedContentHeader.defaultProps = defaultThemeProp;\n\nconst StyledName = styled(Text)`\n display: inline-block;\n`;\n\nconst FeedContentHeader: FC<FeedContentHeaderProps> = (props: FeedContentHeaderProps) => {\n const {\n variant,\n id,\n fullname,\n username,\n postTimestamp,\n content,\n avatarSrc,\n icon,\n userStatus,\n postType,\n postContext,\n recipients = [],\n recipientsCount = 0,\n menuItems,\n edited,\n editTimestamp,\n recipientsLoading,\n onEditSubmit,\n onLoadMoreRecipients,\n onRecipientInteraction,\n onUserClick,\n setEditMode\n } = props;\n\n const { enableAutopilot, userInfo: loggedInUser } = useContext(FeedContext);\n const t = useI18n();\n const { locale } = useConfiguration();\n const { create } = useModalManager();\n\n const recipientsModalRef = useRef<ModalMethods<FeedModalListProps>>();\n const [postTimestampEl, setPostTimestampEl] = useElement<HTMLSpanElement>();\n const [editTimestampEl, setEditTimestampEl] = useElement<HTMLSpanElement>();\n\n const autopilotAuthor = enableAutopilot && username === 'Autopilot';\n\n const timestamps = [\n <>\n <DateTimeDisplay ref={setPostTimestampEl} value={postTimestamp} variant='relative' />\n {postTimestamp && (\n <Tooltip target={postTimestampEl}>\n {formatDateTime(parseToDate(postTimestamp), {\n t,\n locale,\n format: 'short',\n variant: 'datetime',\n timeZone: loggedInUser.timeZone\n })}\n </Tooltip>\n )}\n </>\n ];\n\n if (edited) {\n timestamps.push(\n <>\n <Text ref={setEditTimestampEl} variant='secondary'>\n {t('edited', [<DateTimeDisplay value={editTimestamp} variant='relative' />])}\n </Text>\n {editTimestamp && (\n <Tooltip target={editTimestampEl}>\n {formatDateTime(parseToDate(editTimestamp), {\n t,\n locale,\n format: 'short',\n variant: 'datetime',\n timeZone: loggedInUser.timeZone\n })}\n </Tooltip>\n )}\n </>\n );\n }\n\n const userVisual = autopilotAuthor ? (\n <AutopilotAvatar />\n ) : (\n <Avatar\n name={fullname}\n size={variant === 'post' ? 'l' : 'm'}\n imageSrc={avatarSrc}\n icon={icon}\n status={userStatus}\n />\n );\n\n const recipientsList = recipients.map(x => x.primary);\n\n useEffect(() => {\n if (recipients.length) {\n recipientsModalRef.current?.update({\n count: recipientsCount,\n heading: t('feed_recipients'),\n listItems: recipients,\n onLoadMore: onLoadMoreRecipients,\n loading: recipientsLoading\n });\n }\n }, [recipientsCount, recipients, onLoadMoreRecipients, recipientsLoading]);\n\n return (\n <SummaryItem\n as={StyledFeedContentHeader}\n visual={\n onUserClick ? (\n <BareButton\n onClick={(event: MouseEvent) => {\n onUserClick?.({ id, username }, event);\n }}\n >\n {userVisual}\n </BareButton>\n ) : (\n userVisual\n )\n }\n primary={\n <div>\n {onUserClick ? (\n <Button\n variant='text'\n onClick={(event: MouseEvent) => {\n onUserClick?.({ id, username }, event);\n }}\n >\n <Text variant='h3'>{autopilotAuthor ? 'Autopilot' : fullname}</Text>\n </Button>\n ) : (\n <StyledName variant='h3'>{autopilotAuthor ? 'Autopilot' : fullname}</StyledName>\n )}\n {postContext && <Text variant='primary'> {t('feed_context', [postContext])}</Text>}\n </div>\n }\n secondary={\n <Flex container={{ gap: 0.5, alignItems: 'center' }}>\n {postType === 'private' && (\n <Button\n variant='simple'\n as={FeedButton}\n icon\n compact\n onClick={\n recipients.length\n ? () => {\n if (recipientsCount > 2) {\n recipientsModalRef.current = create(FeedModalList, {\n count: recipientsCount,\n heading: t('feed_recipients'),\n listItems: recipients,\n onLoadMore: onLoadMoreRecipients,\n loading: recipientsLoading\n });\n }\n }\n : onRecipientInteraction\n }\n onFocus={onRecipientInteraction}\n onMouseOver={onRecipientInteraction}\n aria-label={`${t('feed_private_post')} ${t(\n 'feed_recipients'\n )} ${formatListToLocaleString(recipientsList.slice(0, 2), t, locale, {\n count: recipientsCount\n })}`}\n label={`${t('feed_private_post')}:\\n${\n formatListToLocaleString(recipientsList.slice(0, 2), t, locale, {\n count: recipientsCount,\n separator: '\\n'\n }) || t('feed_private_post')\n }`}\n >\n <Icon name='lock-closed-solid' />\n </Button>\n )}\n <MetaList items={timestamps} />\n </Flex>\n }\n actions={\n menuItems ? (\n <MenuButton\n text={t('feed_post_actions_menu')}\n menu={{\n items:\n onEditSubmit && typeof content === 'string' && username === loggedInUser.username\n ? [\n {\n primary: t('edit'),\n id: 'edit',\n onClick: () => setEditMode(true),\n disabled: content.includes('<pega-autopilot/>')\n },\n ...menuItems\n ]\n : menuItems\n }}\n icon='more'\n iconOnly\n variant='simple'\n />\n ) : undefined\n }\n />\n );\n};\n\nexport default FeedContentHeader;\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { FeedEditRegionProps } from './Feed.types';
|
|
4
|
-
declare const FeedEditRegion: FC<ForwardProps & FeedEditRegionProps>;
|
|
5
|
-
export default FeedEditRegion;
|
|
6
|
-
//# sourceMappingURL=FeedEditRegion.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedEditRegion.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedEditRegion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA2C,MAAM,OAAO,CAAC;AAGpE,OAAO,EAIL,YAAY,EAIb,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAiBnD,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,YAAY,GAAG,mBAAmB,CAgF1D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
4
|
-
import { Button, defaultThemeProp, Flex, Icon, useI18n, useOuterEvent } from '@pega/cosmos-react-core';
|
|
5
|
-
import FeedRichText from './FeedRichText';
|
|
6
|
-
import { minInputHeight, StyledActions } from './FeedInputRegion';
|
|
7
|
-
import FeedButton from './FeedButton';
|
|
8
|
-
import { FeedContext } from './Feed.context';
|
|
9
|
-
const StyledInputContainer = styled.div(({ theme }) => {
|
|
10
|
-
return css `
|
|
11
|
-
width: calc(100% - (${theme.base.spacing} + ${theme.base['hit-area']['mouse-min']}));
|
|
12
|
-
|
|
13
|
-
@media (pointer: coarse) {
|
|
14
|
-
width: calc(100% - (${theme.base.spacing} + ${theme.base['hit-area']['finger-min']}));
|
|
15
|
-
}
|
|
16
|
-
`;
|
|
17
|
-
});
|
|
18
|
-
StyledInputContainer.defaultProps = defaultThemeProp;
|
|
19
|
-
const FeedEditRegion = (props) => {
|
|
20
|
-
const { variant, id, content, setEditMode, onEditSubmit, emptyEditText, setEmptyEditText } = props;
|
|
21
|
-
const t = useI18n();
|
|
22
|
-
const { setShowSearchResults } = useContext(FeedContext);
|
|
23
|
-
const rteRef = useRef();
|
|
24
|
-
const editTextAreaRef = useRef(null);
|
|
25
|
-
const [contentModified, setContentModified] = useState(false);
|
|
26
|
-
useOuterEvent('mousedown', [editTextAreaRef], () => {
|
|
27
|
-
if (emptyEditText)
|
|
28
|
-
setEditMode(false);
|
|
29
|
-
});
|
|
30
|
-
const handleEdit = () => {
|
|
31
|
-
setShowSearchResults?.(false);
|
|
32
|
-
if (!emptyEditText && contentModified) {
|
|
33
|
-
onEditSubmit?.({
|
|
34
|
-
id,
|
|
35
|
-
value: rteRef.current?.getPlainText() || ''
|
|
36
|
-
});
|
|
37
|
-
setEditMode(false);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const onKeyDown = (event) => {
|
|
41
|
-
setShowSearchResults?.(true);
|
|
42
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter')
|
|
43
|
-
handleEdit();
|
|
44
|
-
};
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (rteRef.current) {
|
|
47
|
-
rteRef.current?.focus();
|
|
48
|
-
}
|
|
49
|
-
}, [rteRef]);
|
|
50
|
-
const label = t(variant === 'post' ? 'feed_edit_post' : 'feed_edit_comment');
|
|
51
|
-
return (_jsxs(Flex, { container: { gap: 1, alignItems: 'start' }, children: [_jsx(StyledInputContainer, { ref: editTextAreaRef, children: _jsx(FeedRichText, { label: label, onChange: () => {
|
|
52
|
-
setEmptyEditText(rteRef.current?.getPlainText().trim() === '');
|
|
53
|
-
setContentModified(rteRef.current?.getPlainText() !== content);
|
|
54
|
-
}, onKeyDown: onKeyDown, height: { min: minInputHeight }, defaultValue: content, ref: rteRef }) }), _jsxs(Flex, { as: StyledActions, container: { direction: 'column', gap: 0.25 }, children: [_jsx(Button, { variant: 'simple', as: FeedButton, onClick: () => setEditMode(false), icon: true, label: t('cancel'), children: _jsx(Icon, { name: 'times' }) }), _jsx(Button, { as: FeedButton, disabled: emptyEditText || !contentModified, variant: 'simple', onClick: handleEdit, icon: true, label: t('update'), children: _jsx(Icon, { name: 'send' }) })] })] }));
|
|
55
|
-
};
|
|
56
|
-
export default FeedEditRegion;
|
|
57
|
-
//# sourceMappingURL=FeedEditRegion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedEditRegion.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedEditRegion.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,IAAI,EAEJ,IAAI,EACJ,OAAO,EACP,aAAa,EACd,MAAM,yBAAyB,CAAC;AAGjC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,UAAU,MAAM,cAAc,CAAC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E,aAAa,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,aACpE,KAAC,MAAM,IACL,OAAO,EAAC,QAAQ,EAChB,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EACjC,IAAI,QACJ,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,YAElB,KAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,GACd,EAET,KAAC,MAAM,IACL,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,aAAa,IAAI,CAAC,eAAe,EAC3C,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,UAAU,EACnB,IAAI,QACJ,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,YAElB,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,IACJ,IACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FC, useContext, useEffect, useRef, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n defaultThemeProp,\n Flex,\n ForwardProps,\n Icon,\n useI18n,\n useOuterEvent\n} from '@pega/cosmos-react-core';\nimport { RichTextEditorState } from '@pega/cosmos-react-rte';\n\nimport FeedRichText from './FeedRichText';\nimport { FeedEditRegionProps } from './Feed.types';\nimport { minInputHeight, StyledActions } from './FeedInputRegion';\nimport FeedButton from './FeedButton';\nimport { FeedContext } from './Feed.context';\n\nconst StyledInputContainer = styled.div(({ theme }) => {\n return css`\n width: calc(100% - (${theme.base.spacing} + ${theme.base['hit-area']['mouse-min']}));\n\n @media (pointer: coarse) {\n width: calc(100% - (${theme.base.spacing} + ${theme.base['hit-area']['finger-min']}));\n }\n `;\n});\n\nStyledInputContainer.defaultProps = defaultThemeProp;\n\nconst FeedEditRegion: FC<ForwardProps & FeedEditRegionProps> = (\n props: ForwardProps & FeedEditRegionProps\n) => {\n const { variant, id, content, setEditMode, onEditSubmit, emptyEditText, setEmptyEditText } =\n props;\n\n const t = useI18n();\n const { setShowSearchResults } = useContext(FeedContext);\n const rteRef = useRef<RichTextEditorState>();\n const editTextAreaRef = useRef<HTMLDivElement>(null);\n\n const [contentModified, setContentModified] = useState(false);\n\n useOuterEvent('mousedown', [editTextAreaRef], () => {\n if (emptyEditText) setEditMode(false);\n });\n\n const handleEdit = () => {\n setShowSearchResults?.(false);\n if (!emptyEditText && contentModified) {\n onEditSubmit?.({\n id,\n value: rteRef.current?.getPlainText() || ''\n });\n setEditMode(false);\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n setShowSearchResults?.(true);\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') handleEdit();\n };\n\n useEffect(() => {\n if (rteRef.current) {\n rteRef.current?.focus();\n }\n }, [rteRef]);\n\n const label = t(variant === 'post' ? 'feed_edit_post' : 'feed_edit_comment');\n\n return (\n <Flex container={{ gap: 1, alignItems: 'start' }}>\n <StyledInputContainer ref={editTextAreaRef}>\n <FeedRichText\n label={label}\n onChange={() => {\n setEmptyEditText(rteRef.current?.getPlainText().trim() === '');\n setContentModified(rteRef.current?.getPlainText() !== content);\n }}\n onKeyDown={onKeyDown}\n height={{ min: minInputHeight }}\n defaultValue={content}\n ref={rteRef}\n />\n </StyledInputContainer>\n <Flex as={StyledActions} container={{ direction: 'column', gap: 0.25 }}>\n <Button\n variant='simple'\n as={FeedButton}\n onClick={() => setEditMode(false)}\n icon\n label={t('cancel')}\n >\n <Icon name='times' />\n </Button>\n\n <Button\n as={FeedButton}\n disabled={emptyEditText || !contentModified}\n variant='simple'\n onClick={handleEdit}\n icon\n label={t('update')}\n >\n <Icon name='send' />\n </Button>\n </Flex>\n </Flex>\n );\n};\n\nexport default FeedEditRegion;\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { FeedInputRegionProps } from './Feed.types';
|
|
4
|
-
export declare const minInputHeight = "4rem";
|
|
5
|
-
export declare const StyledActions: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
6
|
-
declare const FeedInputRegion: FC<ForwardProps & FeedInputRegionProps>;
|
|
7
|
-
export default FeedInputRegion;
|
|
8
|
-
//# sourceMappingURL=FeedInputRegion.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedInputRegion.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedInputRegion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAoC,MAAM,OAAO,CAAC;AAG7D,OAAO,EAKL,YAAY,EAKb,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,eAAO,MAAM,cAAc,SAAS,CAAC;AAoBrC,eAAO,MAAM,aAAa,yGAQxB,CAAC;AAQH,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,YAAY,GAAG,oBAAoB,CAsH5D,CAAC;AAEF,eAAe,eAAe,CAAC"}
|