@pega/cosmos-react-social 2.0.0-dev.2.1 → 2.0.0-dev.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Chat/Chat.d.ts.map +1 -1
- package/lib/components/Chat/Chat.js +9 -16
- package/lib/components/Chat/Chat.js.map +1 -1
- 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/ChatBody.d.ts.map +1 -1
- package/lib/components/Chat/ChatBody.js +4 -3
- package/lib/components/Chat/ChatBody.js.map +1 -1
- package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
- package/lib/components/Chat/ChatComposer.js +36 -51
- package/lib/components/Chat/ChatComposer.js.map +1 -1
- package/lib/components/Chat/ChatHeader.d.ts.map +1 -1
- package/lib/components/Chat/ChatHeader.js +10 -13
- package/lib/components/Chat/ChatHeader.js.map +1 -1
- package/lib/components/Chat/ChatTranscript.d.ts.map +1 -1
- package/lib/components/Chat/ChatTranscript.js +15 -16
- package/lib/components/Chat/ChatTranscript.js.map +1 -1
- package/lib/components/Chat/Message.d.ts.map +1 -1
- package/lib/components/Chat/Message.js +41 -59
- package/lib/components/Chat/Message.js.map +1 -1
- package/lib/components/Chat/Message.styles.js +2 -2
- package/lib/components/Chat/Message.styles.js.map +1 -1
- package/lib/components/Chat/MessageList.d.ts.map +1 -1
- package/lib/components/Chat/MessageList.js +36 -41
- package/lib/components/Chat/MessageList.js.map +1 -1
- package/lib/components/Chat/RepeatingView.d.ts.map +1 -1
- package/lib/components/Chat/RepeatingView.js +10 -14
- package/lib/components/Chat/RepeatingView.js.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.js +46 -54
- package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
- package/lib/components/Chat/SystemMessage.d.ts.map +1 -1
- package/lib/components/Chat/SystemMessage.js +4 -6
- package/lib/components/Chat/SystemMessage.js.map +1 -1
- package/lib/components/Chat/TranscriptMessage.d.ts.map +1 -1
- package/lib/components/Chat/TranscriptMessage.js +7 -13
- package/lib/components/Chat/TranscriptMessage.js.map +1 -1
- package/lib/components/Chat/TypeIndicator.d.ts.map +1 -1
- package/lib/components/Chat/TypeIndicator.js +3 -2
- package/lib/components/Chat/TypeIndicator.js.map +1 -1
- package/lib/components/Email/Email.d.ts.map +1 -1
- package/lib/components/Email/Email.js +102 -129
- package/lib/components/Email/Email.js.map +1 -1
- package/lib/components/Email/Email.styles.d.ts +7 -1
- package/lib/components/Email/Email.styles.d.ts.map +1 -1
- package/lib/components/Email/Email.styles.js +73 -4
- package/lib/components/Email/Email.styles.js.map +1 -1
- package/lib/components/Email/Email.types.d.ts +124 -62
- 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/EmailComposer.d.ts +4 -6
- package/lib/components/Email/EmailComposer.d.ts.map +1 -1
- package/lib/components/Email/EmailComposer.js +155 -73
- package/lib/components/Email/EmailComposer.js.map +1 -1
- package/lib/components/Email/EmailConversation.d.ts +7 -4
- package/lib/components/Email/EmailConversation.d.ts.map +1 -1
- package/lib/components/Email/EmailConversation.js +132 -76
- package/lib/components/Email/EmailConversation.js.map +1 -1
- package/lib/components/Email/EmailEntity.d.ts +6 -0
- package/lib/components/Email/EmailEntity.d.ts.map +1 -0
- package/lib/components/Email/EmailEntity.js +19 -0
- package/lib/components/Email/EmailEntity.js.map +1 -0
- package/lib/components/Email/EmailSelector.d.ts +14 -0
- package/lib/components/Email/EmailSelector.d.ts.map +1 -0
- package/lib/components/Email/EmailSelector.js +62 -0
- package/lib/components/Email/EmailSelector.js.map +1 -0
- package/lib/components/Email/EmailShell.d.ts.map +1 -1
- package/lib/components/Email/EmailShell.js +23 -31
- package/lib/components/Email/EmailShell.js.map +1 -1
- package/lib/components/Email/EmailSummaryItem.d.ts +10 -0
- package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -0
- package/lib/components/Email/EmailSummaryItem.js +93 -0
- package/lib/components/Email/EmailSummaryItem.js.map +1 -0
- package/lib/components/Email/EmailSummaryList.d.ts +6 -0
- package/lib/components/Email/EmailSummaryList.d.ts.map +1 -0
- package/lib/components/Email/EmailSummaryList.js +115 -0
- package/lib/components/Email/EmailSummaryList.js.map +1 -0
- package/lib/components/Feed/Feed.context.d.ts +16 -6
- package/lib/components/Feed/Feed.context.d.ts.map +1 -1
- package/lib/components/Feed/Feed.context.js +1 -0
- package/lib/components/Feed/Feed.context.js.map +1 -1
- package/lib/components/Feed/Feed.d.ts +13 -17
- package/lib/components/Feed/Feed.d.ts.map +1 -1
- package/lib/components/Feed/Feed.js +20 -31
- package/lib/components/Feed/Feed.js.map +1 -1
- package/lib/components/Feed/FeedAttachments.d.ts.map +1 -1
- package/lib/components/Feed/FeedAttachments.js +7 -6
- package/lib/components/Feed/FeedAttachments.js.map +1 -1
- package/lib/components/Feed/FeedButton.d.ts.map +1 -1
- package/lib/components/Feed/FeedButton.js.map +1 -1
- package/lib/components/Feed/FeedContent.d.ts.map +1 -1
- package/lib/components/Feed/FeedContent.js +12 -6
- package/lib/components/Feed/FeedContent.js.map +1 -1
- package/lib/components/Feed/FeedModalList.d.ts +15 -0
- package/lib/components/Feed/FeedModalList.d.ts.map +1 -0
- package/lib/components/Feed/FeedModalList.js +49 -0
- package/lib/components/Feed/FeedModalList.js.map +1 -0
- package/lib/components/Feed/FeedNewPost.d.ts +2 -1
- package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPost.js +44 -44
- package/lib/components/Feed/FeedNewPost.js.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.js +47 -79
- package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
- package/lib/components/Feed/FeedPost.d.ts +34 -12
- package/lib/components/Feed/FeedPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedPost.js +165 -101
- package/lib/components/Feed/FeedPost.js.map +1 -1
- package/lib/components/Feed/FeedReply.d.ts +31 -13
- package/lib/components/Feed/FeedReply.d.ts.map +1 -1
- package/lib/components/Feed/FeedReply.js +123 -39
- package/lib/components/Feed/FeedReply.js.map +1 -1
- package/lib/components/Feed/FeedReplyInput.d.ts +6 -6
- package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
- package/lib/components/Feed/FeedReplyInput.js +43 -46
- package/lib/components/Feed/FeedReplyInput.js.map +1 -1
- package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
- package/lib/components/Feed/FeedRichText.js +81 -19
- package/lib/components/Feed/FeedRichText.js.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.d.ts +6 -4
- package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.js +23 -17
- package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
- package/lib/components/MentionButton/MentionButton.d.ts +10 -4
- package/lib/components/MentionButton/MentionButton.d.ts.map +1 -1
- package/lib/components/MentionButton/MentionButton.js +34 -18
- package/lib/components/MentionButton/MentionButton.js.map +1 -1
- package/package.json +15 -16
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef, useContext, useMemo } from 'react';
|
|
2
3
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import { Avatar, Button, Count, Card, CardContent, CardHeader, Flex, Icon, MenuButton, SummaryItem, Text, defaultThemeProp, useElement,
|
|
4
|
+
import { Avatar, Button, Count, Card, CardContent, CardHeader, Flex, Icon, registerIcon, MenuButton, SummaryItem, Text, defaultThemeProp, useElement, useI18n, Progress, useOuterEvent, MetaList, Tooltip, ModalManagerContext, StyledVisual, useConfiguration } from '@pega/cosmos-react-core';
|
|
5
|
+
import { StyledRichTextEditor } from '@pega/cosmos-react-rte';
|
|
4
6
|
import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
|
|
7
|
+
import * as arrowMicroDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/arrow-micro-down.icon';
|
|
8
|
+
import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
|
|
9
|
+
import { formatListToLocaleString } from '@pega/cosmos-react-core/lib/utils/utils';
|
|
5
10
|
import FeedButton from './FeedButton';
|
|
6
11
|
import FeedAttachments from './FeedAttachments';
|
|
7
|
-
import {
|
|
12
|
+
import { StyledFeedReplyContainer } from './FeedReply';
|
|
8
13
|
import FeedContent from './FeedContent';
|
|
9
14
|
import FeedReplyInput from './FeedReplyInput';
|
|
10
|
-
import { FeedReplyContext } from './Feed.context';
|
|
15
|
+
import { FeedContext, FeedReplyContext } from './Feed.context';
|
|
16
|
+
import FeedRichText from './FeedRichText';
|
|
17
|
+
import FeedModalList from './FeedModalList';
|
|
18
|
+
registerIcon(arrowMicroDownIcon, caretLeftIcon);
|
|
11
19
|
const defaultProps = {
|
|
12
20
|
info: {
|
|
13
21
|
avatarSrc: '',
|
|
@@ -18,127 +26,183 @@ const defaultProps = {
|
|
|
18
26
|
}
|
|
19
27
|
};
|
|
20
28
|
export const StyledFeedPost = styled.div(({ theme }) => css `
|
|
21
|
-
${
|
|
22
|
-
margin-
|
|
29
|
+
${StyledFeedReplyContainer}:not(:last-child) {
|
|
30
|
+
margin-block-end: calc(2 * ${theme.base.spacing});
|
|
23
31
|
}
|
|
24
32
|
`);
|
|
25
33
|
StyledFeedPost.defaultProps = defaultThemeProp;
|
|
34
|
+
export const StyledPostEdit = styled.div(({ theme }) => css `
|
|
35
|
+
${StyledRichTextEditor} {
|
|
36
|
+
padding: calc(0.5 * ${theme.base.spacing});
|
|
37
|
+
}
|
|
38
|
+
`);
|
|
39
|
+
StyledPostEdit.defaultProps = defaultThemeProp;
|
|
26
40
|
export const StyledReplies = styled.div(({ theme }) => css `
|
|
27
41
|
border-top: 0.0625rem solid ${theme.base.palette['border-line']};
|
|
28
42
|
padding: calc(1.25 * ${theme.base.spacing}) calc(2 * ${theme.base.spacing});
|
|
29
43
|
`);
|
|
30
44
|
StyledReplies.defaultProps = defaultThemeProp;
|
|
31
|
-
export const
|
|
32
|
-
|
|
45
|
+
export const StyledPostFooter = styled.div(({ theme }) => css `
|
|
46
|
+
margin-block-start: ${theme.base.spacing};
|
|
33
47
|
`);
|
|
34
|
-
|
|
35
|
-
export const StyledActions = styled.div(props => {
|
|
36
|
-
const { spacing } = props.theme.base;
|
|
37
|
-
return css `
|
|
38
|
-
margin-top: ${spacing};
|
|
39
|
-
`;
|
|
40
|
-
});
|
|
41
|
-
StyledActions.defaultProps = defaultThemeProp;
|
|
48
|
+
StyledPostFooter.defaultProps = defaultThemeProp;
|
|
42
49
|
const FullWidthSummaryItem = styled.div `
|
|
43
50
|
width: 100%;
|
|
51
|
+
|
|
52
|
+
${StyledVisual} {
|
|
53
|
+
align-self: start;
|
|
54
|
+
}
|
|
44
55
|
`;
|
|
45
56
|
const FeedPost = (props) => {
|
|
46
|
-
const { id, info, interactionInfo, maxContentHeight = Infinity, onMouseEnter, onMouseLeave, onCommentClick, onLikeClick, onUserClick, onShowMoreClick, newReplyField, menuItems, replies = [], replyInput, replyInputShown, replyCount, repliesLoading, onShowLessReplies, onShowMoreReplies, ...restProps } = props;
|
|
47
|
-
const { avatarSrc, fullname, username, timeElapsed, content, postType = 'public', recipients, attachments, liked, icon, postContext } = info;
|
|
48
|
-
const { likeLabel, likeCount, commentLabel, interactionsEnabled = true } = interactionInfo;
|
|
57
|
+
const { id, info, interactionInfo, maxContentHeight = Infinity, onMouseEnter, onMouseLeave, onCommentClick, onLikeClick, onLikeCountInteraction, onLoadMoreLikes, onRecipientInteraction, onLoadMoreRecipients, onUserClick, onShowMoreClick, newReplyField, menuItems, onEditSubmit, edited = false, replies = [], replyInput, replyInputShown, replyCount, repliesLoading, onShowLessReplies, onShowMoreReplies, ...restProps } = props;
|
|
58
|
+
const { avatarSrc, fullname, username, timeElapsed, content, postType = 'public', recipients = [], recipientsCount = 0, attachments, liked, icon, postContext, userStatus } = info;
|
|
59
|
+
const { likeLabel, likes = [], likeCount = 0, commentLabel, interactionsEnabled = true } = interactionInfo;
|
|
60
|
+
const loggedInUser = useContext(FeedContext).userInfo;
|
|
61
|
+
const t = useI18n();
|
|
62
|
+
const { locale } = useConfiguration();
|
|
63
|
+
const [countEl, setCountEl] = useElement();
|
|
64
|
+
const rteRef = useRef();
|
|
65
|
+
const [editMode, setEditMode] = useState(false);
|
|
66
|
+
const editTextAreaRef = useRef(null);
|
|
67
|
+
const [emptyEditText, setEmptyEditText] = useState(false);
|
|
68
|
+
const [postModified, setPostModified] = useState(false);
|
|
49
69
|
const [replyInputOpen, setReplyInputOpen] = useState(false);
|
|
50
|
-
const [mountRecipientsPopover, setMountRecipientsPopover] = useState(false);
|
|
51
|
-
const [postTypeEl, setPostTypeEl] = useElement();
|
|
52
70
|
const [replyInputRef, setReplyInputRef] = useState(null);
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
const { create } = useContext(ModalManagerContext);
|
|
72
|
+
const likesModalRef = useRef();
|
|
73
|
+
const recipientsModalRef = useRef();
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
likesModalRef.current?.update({
|
|
76
|
+
count: likeCount,
|
|
77
|
+
heading: likeLabel,
|
|
78
|
+
listItems: likes,
|
|
79
|
+
onLoadMore: onLoadMoreLikes
|
|
80
|
+
});
|
|
81
|
+
}, [likeCount, likeLabel, likes, onLoadMoreLikes]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (recipients.length) {
|
|
84
|
+
recipientsModalRef.current?.update({
|
|
85
|
+
count: recipientsCount,
|
|
86
|
+
heading: t('feed_recipients'),
|
|
87
|
+
listItems: recipients,
|
|
88
|
+
onLoadMore: onLoadMoreRecipients
|
|
89
|
+
});
|
|
58
90
|
}
|
|
59
|
-
};
|
|
60
|
-
useOuterEvent('mousedown', [
|
|
61
|
-
|
|
91
|
+
}, [recipientsCount, recipients, onLoadMoreRecipients]);
|
|
92
|
+
useOuterEvent('mousedown', [editTextAreaRef], () => {
|
|
93
|
+
if (emptyEditText)
|
|
94
|
+
setEditMode(false);
|
|
62
95
|
});
|
|
63
96
|
useEffect(() => {
|
|
64
|
-
var _a;
|
|
65
97
|
if ((replyInputOpen || replyInputShown) && replyInputRef) {
|
|
66
|
-
|
|
98
|
+
replyInputRef.current?.focus();
|
|
67
99
|
}
|
|
68
100
|
}, [replyInputOpen, replyInputShown, replyInputRef]);
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
postTypeAttributes = {
|
|
101
|
+
const userVisual = icon ? (_jsx(Icon, { name: icon }, void 0)) : (_jsx(Avatar, { name: fullname, size: 'l', imageSrc: avatarSrc, status: userStatus }, void 0));
|
|
102
|
+
const numReplies = replyCount || replies?.length;
|
|
103
|
+
const postTypeAttributes = useMemo(() => {
|
|
104
|
+
if (postType === 'private') {
|
|
105
|
+
const recipientsList = recipients.map(x => x.primary);
|
|
106
|
+
return {
|
|
76
107
|
icon: 'users-solid',
|
|
77
|
-
|
|
108
|
+
ariaLabel: `${t('feed_private_post')} t('feed_recipients')} ${formatListToLocaleString(recipientsList, t, locale, { count: recipientsCount })}`,
|
|
109
|
+
label: formatListToLocaleString(recipientsList, t, locale, {
|
|
110
|
+
count: recipientsCount,
|
|
111
|
+
separator: '\n'
|
|
112
|
+
})
|
|
78
113
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
icon: 'globe',
|
|
117
|
+
ariaLabel: t('feed_public_post'),
|
|
118
|
+
label: t('feed_public_post')
|
|
119
|
+
};
|
|
120
|
+
}, [postType, recipients, recipientsCount]);
|
|
121
|
+
const likesAttributes = useMemo(() => {
|
|
122
|
+
const likesList = likes.map(x => x.primary.toString());
|
|
123
|
+
return {
|
|
124
|
+
ariaLabel: `${t('feed_liked_by')} ${formatListToLocaleString(likesList, t, locale, {
|
|
125
|
+
count: likeCount
|
|
126
|
+
})}`,
|
|
127
|
+
label: formatListToLocaleString(likesList, t, locale, {
|
|
128
|
+
count: likeCount,
|
|
129
|
+
separator: '\n'
|
|
130
|
+
})
|
|
131
|
+
};
|
|
132
|
+
}, [likes, likeCount]);
|
|
133
|
+
const handleEdit = () => {
|
|
134
|
+
if (!emptyEditText && postModified) {
|
|
135
|
+
onEditSubmit?.({
|
|
136
|
+
postId: id,
|
|
137
|
+
value: rteRef.current?.getPlainText() || ''
|
|
138
|
+
});
|
|
139
|
+
setEditMode(false);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
return (_jsx(FeedReplyContext.Provider, { value: { onShowReplyInput: () => setReplyInputOpen(true) }, children: _jsxs(Card, { ...restProps, as: StyledFeedPost, onMouseEnter: () => {
|
|
143
|
+
onMouseEnter?.({ postId: id });
|
|
90
144
|
}, onMouseLeave: () => {
|
|
91
|
-
onMouseLeave
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
145
|
+
onMouseLeave?.({ postId: id });
|
|
146
|
+
}, children: [_jsx(CardHeader, { children: _jsx(SummaryItem, { as: FullWidthSummaryItem, visual: onUserClick ? (_jsx(BareButton, { onClick: (event) => {
|
|
147
|
+
onUserClick?.({ postId: id, username }, event);
|
|
148
|
+
}, children: userVisual }, void 0)) : (userVisual), primary: _jsxs("div", { children: [onUserClick ? (_jsx(Button, { variant: 'text', onClick: (event) => {
|
|
149
|
+
onUserClick?.({ postId: id, username }, event);
|
|
150
|
+
}, children: _jsx(Text, { variant: 'h3', children: fullname }, void 0) }, void 0)) : (_jsx(Text, { variant: 'h3', children: fullname }, void 0)), postContext && _jsxs(Text, { variant: 'primary', children: [" ", t('feed_context', [postContext])] }, void 0)] }, void 0), secondary: _jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, children: [_jsx(Button, { variant: 'text', icon: true, onClick: recipients.length
|
|
151
|
+
? () => {
|
|
152
|
+
if (recipientsCount > 10) {
|
|
153
|
+
recipientsModalRef.current = create(FeedModalList, {
|
|
154
|
+
count: recipientsCount,
|
|
155
|
+
heading: t('feed_recipients'),
|
|
156
|
+
listItems: recipients,
|
|
157
|
+
onLoadMore: onLoadMoreRecipients
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
: onRecipientInteraction, onFocus: onRecipientInteraction, onMouseOver: onRecipientInteraction, "aria-label": postTypeAttributes.ariaLabel, label: postTypeAttributes.label, children: _jsx(Icon, { name: postTypeAttributes.icon }, void 0) }, void 0), _jsx(MetaList, { items: edited ? [timeElapsed, t('edited')] : [timeElapsed] }, void 0)] }, void 0), actions: menuItems ? (_jsx(MenuButton, { text: 'More', menu: {
|
|
162
|
+
items: onEditSubmit &&
|
|
163
|
+
typeof content === 'string' &&
|
|
164
|
+
username === loggedInUser.username
|
|
165
|
+
? menuItems.concat([
|
|
166
|
+
{
|
|
167
|
+
primary: t('edit'),
|
|
168
|
+
id: 'edit',
|
|
169
|
+
onClick: () => setEditMode(true)
|
|
170
|
+
}
|
|
171
|
+
])
|
|
172
|
+
: menuItems
|
|
173
|
+
}, icon: 'more', iconOnly: true, variant: 'simple' }, void 0)) : undefined }, void 0) }, void 0), _jsxs(CardContent, { children: [editMode ? (_jsxs(_Fragment, { children: [_jsx(StyledPostEdit, { ref: editTextAreaRef, children: _jsx(FeedRichText, { onChange: () => {
|
|
174
|
+
setEmptyEditText(rteRef.current?.getPlainText().trim() === '');
|
|
175
|
+
setPostModified(rteRef.current?.getPlainText() !== content);
|
|
176
|
+
}, autoFocus: true, onSubmit: handleEdit, defaultValue: content, ref: rteRef }, void 0) }, void 0), _jsxs(Flex, { container: { justify: 'between', pad: [2, 0, 0] }, children: [_jsx(Button, { onClick: () => setEditMode(false), "aria-label": `${t('cancel')} ${t('edit')} ${id}`, children: t('cancel') }, void 0), _jsx(Button, { variant: 'primary', disabled: emptyEditText || !postModified, onClick: handleEdit, "aria-label": `${t('update')} ${t('edit')} ${id}`, children: t('update') }, void 0)] }, void 0)] }, void 0)) : (_jsx(FeedContent, { maxContentHeight: maxContentHeight, children: content }, void 0)), _jsx(FeedAttachments, { attachments: attachments }, void 0), _jsxs(Flex, { as: StyledPostFooter, container: { justify: 'between', wrap: 'wrap', gap: 1 }, children: [interactionsEnabled ? (_jsxs(Flex, { container: { gap: 2 }, children: [_jsxs(Button, { variant: 'text', as: FeedButton, onClick: () => {
|
|
177
|
+
onCommentClick?.({ postId: id });
|
|
178
|
+
if (!replyInputOpen) {
|
|
179
|
+
setReplyInputOpen(true);
|
|
180
|
+
}
|
|
181
|
+
}, children: [_jsx(Icon, { name: 'chat' }, void 0), _jsx(Text, { children: commentLabel }, void 0), numReplies > 0 && _jsx(Count, { children: numReplies }, void 0)] }, void 0), _jsxs(Flex, { container: { gap: 0.5 }, children: [_jsxs(Button, { variant: 'text', as: FeedButton, onClick: () => onLikeClick({
|
|
182
|
+
postId: id,
|
|
183
|
+
user: {
|
|
184
|
+
id: loggedInUser.username,
|
|
185
|
+
primary: loggedInUser.fullname,
|
|
186
|
+
secondary: loggedInUser.meta ? (_jsx(MetaList, { items: loggedInUser.meta }, void 0)) : undefined,
|
|
187
|
+
visual: (_jsx(Avatar, { size: 'l', imageSrc: loggedInUser.avatarSrc, name: loggedInUser.fullname }, void 0))
|
|
188
|
+
}
|
|
189
|
+
}), emphasized: liked, children: [_jsx(Icon, { name: liked ? 'thumbs-up-solid' : 'thumbs-up' }, void 0), _jsx(Text, { children: likeLabel }, void 0)] }, void 0), likeCount > 0 && (_jsxs(_Fragment, { children: [_jsx(BareButton, { ref: setCountEl, onClick: likes.length
|
|
190
|
+
? () => {
|
|
191
|
+
if (likeCount > 10) {
|
|
192
|
+
likesModalRef.current = create(FeedModalList, {
|
|
193
|
+
count: likeCount,
|
|
194
|
+
heading: t('feed_likes'),
|
|
195
|
+
listItems: likes,
|
|
196
|
+
onLoadMore: onLoadMoreLikes
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
: onLikeCountInteraction, onFocus: onLikeCountInteraction, onMouseOver: onLikeCountInteraction, "aria-label": likesAttributes.ariaLabel, children: _jsx(Count, { children: likeCount }, void 0) }, void 0), _jsx(Tooltip, { target: countEl, showDelay: 'none', hideDelay: 'none', children: likesAttributes.label }, void 0)] }, void 0))] }, void 0)] }, void 0)) : (_jsx("div", {}, void 0)), (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]) }, void 0), _jsx("span", { children: "\u2022" }, void 0)] }, void 0)), onShowMoreReplies && replies.length < numReplies && (_jsx(Button, { variant: 'link', onClick: () => onShowMoreReplies({ postId: id }), children: t('show_more') }, void 0)), repliesLoading && _jsx(Progress, { placement: 'inline' }, void 0)] }, void 0))] }, void 0)] }, void 0), !!replies?.length && _jsx(StyledReplies, { children: replies }, void 0), replyInputShown || replyInputOpen ? (_jsx(CardContent, { children: _jsx(FeedReplyInput, { onSetInputRef: ({ ref }) => {
|
|
201
|
+
setReplyInputRef(ref);
|
|
202
|
+
}, id: id, commentLabel: replyInput.commentLabel, attachments: replyInput.attachments, placeholder: replyInput.placeholder, onFilesAdded: replyInput.onFilesAdded, onSubmit: e => {
|
|
203
|
+
setReplyInputOpen(false);
|
|
204
|
+
replyInput.onSubmit(e);
|
|
205
|
+
} }, void 0) }, void 0)) : null, onShowLessReplies && !!replies.length && (_jsxs(Flex, { container: { justify: 'center', pad: [0, 0, 1], gap: 1 }, children: [_jsx(Button, { variant: 'link', onClick: () => onShowLessReplies({ postId: id }), children: t('show_less') }, void 0), repliesLoading && _jsx(Progress, { placement: 'inline' }, void 0)] }, void 0))] }, void 0) }, void 0));
|
|
142
206
|
};
|
|
143
207
|
FeedPost.defaultProps = defaultProps;
|
|
144
208
|
export default FeedPost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedPost.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedPost.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGZ,QAAQ,EACR,SAAS,EAGT,MAAM,EACP,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,IAAI,EACJ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,WAAW,EACX,IAAI,EACJ,gBAAgB,EAEhB,UAAU,EACV,OAAO,EACP,OAAO,EACP,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E,CAAC,EAAE;gBAChE,oBAAC,MAAM,IAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IACpE,CAAC,CAAC,WAAW,CAAC,CACR;gBACR,cAAc,IAAI,oBAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,CAC7C,CACR,CACI,CACmB,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,YAAY,GAAG,YAAY,CAAC;AAErC,eAAe,QAAQ,CAAC","sourcesContent":["import React, {\n FC,\n ReactElement,\n useState,\n useEffect,\n MutableRefObject,\n MouseEvent,\n useRef\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Avatar,\n Button,\n Count,\n Card,\n CardContent,\n CardHeader,\n Flex,\n Icon,\n MenuButton,\n SummaryItem,\n Text,\n defaultThemeProp,\n ForwardProps,\n useElement,\n Popover,\n useI18n,\n Progress,\n Menu,\n useOuterEvent,\n useConsolidatedRef,\n MenuItemProps\n} from '@pega/cosmos-react-core';\nimport { RichTextEditorState } from '@pega/cosmos-react-rte';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\n\nimport FeedButton from './FeedButton';\nimport FeedAttachments, { AttachedFiles } from './FeedAttachments';\nimport { StyledFeedReply } from './FeedReply';\nimport FeedContent, { FeedContentProps } from './FeedContent';\nimport FeedReplyInput, { FeedReplyInputProps } from './FeedReplyInput';\nimport { FeedReplyContext } from './Feed.context';\n\nexport interface FeedPostProps {\n /** Unique ID for this activity */\n id: string;\n /** All of the information used to fill text portions, and avatar info */\n info: {\n avatarSrc?: string;\n fullname: string;\n username: string;\n timeElapsed: string;\n content: ReactElement | string;\n postType?: 'public' | 'private';\n recipients?: MenuItemProps[];\n attachments?: AttachedFiles[];\n liked?: boolean;\n icon?: string;\n postContext?: ReactElement | string;\n };\n maxContentHeight?: FeedContentProps['maxContentHeight'];\n /** Button labels for accessibility purposes */\n interactionInfo: {\n likeLabel: string;\n likeCount: number;\n commentLabel: string;\n /**\n * @default true\n */\n interactionsEnabled?: boolean;\n };\n /** Callback that runs when the mouse pointer hovers over the Activity. */\n onMouseEnter?: (event: { feedId: string }) => void;\n /** Callback that runs when the mouse pointer leaves the Activity. */\n onMouseLeave?: (event: { feedId: string }) => void;\n /** Callback that runs when the comment button has been clicked */\n onCommentClick?: (event: { feedId: string }) => void;\n /** Callback that runs when the like button has been clicked */\n onLikeClick: (event: { feedId: string }) => void;\n /** Callback that runs when the user name or visual button has been clicked */\n onUserClick?: (event: { feedId: string; username: string }, clickEvent?: MouseEvent) => void;\n /** MenuItems that will populate the three dot menu button */\n menuItems?: MenuItemProps[];\n /** Props that will be passed into the reply input, see FeedReplyInput for more information */\n replyInput: Pick<FeedReplyInputProps, 'onSubmit' | 'placeholder' | 'onFilesAdded'> & {\n commentLabel: FeedReplyInputProps['commentLabel'];\n attachments: FeedReplyInputProps['attachments'];\n };\n /** The default visibility for the reply input */\n replyInputShown?: boolean;\n /** An array to hold FeedReply's inside of this Activity */\n replies?: ReactElement[];\n /** A total count of all replies. */\n replyCount?: number;\n /** Callback that runs when the user clicks Show more button. */\n onShowMoreReplies?: (event: { feedId: string }) => void;\n /** Callback that runs when the user clicks Show less button. */\n onShowLessReplies?: (event: { feedId: string }) => void;\n /** A loading indicator for the replies. */\n repliesLoading?: boolean;\n}\n\nconst defaultProps: Partial<FeedPostProps> = {\n info: {\n avatarSrc: '',\n fullname: '',\n username: '',\n timeElapsed: '',\n content: ''\n }\n};\n\nexport const StyledFeedPost = styled.div(\n ({ theme }) => css`\n ${StyledFeedReply}:not(:last-child) {\n margin-bottom: calc(2 * ${theme.base.spacing});\n }\n `\n);\n\nStyledFeedPost.defaultProps = defaultThemeProp;\n\nexport const StyledReplies = styled.div(\n ({ theme }) => css`\n border-top: 0.0625rem solid ${theme.base.palette['border-line']};\n padding: calc(1.25 * ${theme.base.spacing}) calc(2 * ${theme.base.spacing});\n `\n);\n\nStyledReplies.defaultProps = defaultThemeProp;\n\nexport const StyledReplyCount = styled.div(\n ({ theme }) => css`\n padding-bottom: calc(1.25 * ${theme.base.spacing});\n `\n);\n\nStyledReplyCount.defaultProps = defaultThemeProp;\n\nexport const StyledActions = styled.div(props => {\n const { spacing } = props.theme.base;\n\n return css`\n margin-top: ${spacing};\n `;\n});\n\nStyledActions.defaultProps = defaultThemeProp;\n\nconst FullWidthSummaryItem = styled.div`\n width: 100%;\n`;\n\nconst FeedPost: FC<ForwardProps & FeedPostProps> = (props: ForwardProps & FeedPostProps) => {\n const {\n id,\n info,\n interactionInfo,\n maxContentHeight = Infinity,\n onMouseEnter,\n onMouseLeave,\n onCommentClick,\n onLikeClick,\n onUserClick,\n onShowMoreClick,\n newReplyField,\n menuItems,\n replies = [],\n replyInput,\n replyInputShown,\n replyCount,\n repliesLoading,\n onShowLessReplies,\n onShowMoreReplies,\n ...restProps\n } = props;\n const {\n avatarSrc,\n fullname,\n username,\n timeElapsed,\n content,\n postType = 'public',\n recipients,\n attachments,\n liked,\n icon,\n postContext\n } = info;\n const { likeLabel, likeCount, commentLabel, interactionsEnabled = true } = interactionInfo;\n const [replyInputOpen, setReplyInputOpen] = useState(false);\n const [mountRecipientsPopover, setMountRecipientsPopover] = useState(false);\n const [postTypeEl, setPostTypeEl] = useElement<HTMLButtonElement>();\n const [replyInputRef, setReplyInputRef] = useState<MutableRefObject<\n RichTextEditorState | undefined\n > | null>(null);\n const postTypeRef = useConsolidatedRef(setPostTypeEl);\n const popoverRef = useRef(null);\n\n const togglePopover = () => {\n if (postType === 'private') {\n setMountRecipientsPopover(curr => !curr);\n }\n };\n\n useOuterEvent('mousedown', [postTypeRef, popoverRef], () => {\n setMountRecipientsPopover(false);\n });\n\n useEffect(() => {\n if ((replyInputOpen || replyInputShown) && replyInputRef) {\n replyInputRef.current?.focus();\n }\n }, [replyInputOpen, replyInputShown, replyInputRef]);\n\n const t = useI18n();\n\n const userVisual = icon ? (\n <Icon name={icon} />\n ) : (\n <Avatar name={fullname} size='l' imageSrc={avatarSrc} />\n );\n\n const numReplies = replyCount || replies?.length;\n\n let postTypeAttributes;\n\n switch (postType) {\n case 'private':\n postTypeAttributes = {\n icon: 'users-solid',\n label: 'Private'\n };\n break;\n default:\n postTypeAttributes = {\n icon: 'globe',\n label: 'Public'\n };\n break;\n }\n\n return (\n <FeedReplyContext.Provider value={{ onShowReplyInput: () => setReplyInputOpen(true) }}>\n <Card\n {...restProps}\n as={StyledFeedPost}\n onMouseEnter={() => {\n onMouseEnter?.({ feedId: id });\n }}\n onMouseLeave={() => {\n onMouseLeave?.({ feedId: id });\n }}\n >\n <CardHeader>\n <SummaryItem\n as={FullWidthSummaryItem}\n visual={\n onUserClick ? (\n <BareButton\n onClick={(event: MouseEvent) => {\n onUserClick?.({ feedId: id, username }, event);\n }}\n >\n {userVisual}\n </BareButton>\n ) : (\n userVisual\n )\n }\n primary={\n <Flex container={{ itemGap: 0.5, alignItems: 'center' }}>\n {onUserClick ? (\n <Button\n variant='text'\n onClick={(event: MouseEvent) => {\n onUserClick?.({ feedId: id, username }, event);\n }}\n >\n <Text variant='h3'>{fullname}</Text>\n </Button>\n ) : (\n <Text variant='h3'>{fullname}</Text>\n )}\n {postContext && <Text variant='primary'>{t('feed_context', postContext)}</Text>}\n </Flex>\n }\n secondary={\n <Flex container={{ itemGap: 1, alignItems: 'center' }}>\n <Text variant='secondary'>{timeElapsed}</Text>\n <Button\n ref={postTypeRef}\n variant='simple'\n icon\n onClick={togglePopover}\n label={postTypeAttributes.label}\n >\n <Icon name={postTypeAttributes.icon} />\n </Button>\n {recipients && mountRecipientsPopover && (\n <Popover ref={popoverRef} arrow hideDelay='short' target={postTypeEl}>\n <Menu items={recipients} />\n </Popover>\n )}\n </Flex>\n }\n actions={\n menuItems ? (\n <MenuButton\n text='More'\n menu={{ items: menuItems }}\n icon='more'\n iconOnly\n variant='simple'\n />\n ) : undefined\n }\n />\n </CardHeader>\n <CardContent>\n <FeedContent maxContentHeight={maxContentHeight}>{content}</FeedContent>\n <FeedAttachments attachments={attachments} />\n {interactionsEnabled && (\n <Flex container={{ itemGap: 2 }} as={StyledActions}>\n <span>\n <Button\n variant='text'\n as={FeedButton}\n onClick={() => {\n onCommentClick?.({ feedId: id });\n if (!replyInputOpen) {\n setReplyInputOpen(true);\n }\n }}\n >\n <Icon name='chat' />\n <Text>{commentLabel}</Text>\n {numReplies > 0 && <Count>{numReplies}</Count>}\n </Button>\n </span>\n <span>\n <Button\n variant='text'\n as={FeedButton}\n onClick={() => onLikeClick({ feedId: id })}\n emphasized={liked}\n >\n <Icon name={liked ? 'thumbs-up-solid' : 'thumbs-up'} />\n <Text>{likeLabel}</Text>\n {likeCount > 0 && <Count>{likeCount}</Count>}\n </Button>\n </span>\n </Flex>\n )}\n </CardContent>\n {!!replies?.length && (\n <StyledReplies>\n {(onShowLessReplies || onShowMoreReplies) && (\n <StyledReplyCount as={Flex} container={{ itemGap: 1 }}>\n {replies.length !== numReplies && (\n <Text>{t('num_of_num', replies.length, numReplies)}</Text>\n )}\n {onShowMoreReplies && replies.length < numReplies && (\n <Button variant='link' onClick={() => onShowMoreReplies({ feedId: id })}>\n {t('show_more')}\n </Button>\n )}\n {repliesLoading && <Progress placement='inline' />}\n </StyledReplyCount>\n )}\n {replies}\n </StyledReplies>\n )}\n {replyInputShown || replyInputOpen ? (\n <CardContent>\n <FeedReplyInput\n onSetInputRef={({ ref }) => {\n setReplyInputRef(ref);\n }}\n id={id}\n commentLabel={replyInput.commentLabel}\n attachments={replyInput.attachments}\n placeholder={replyInput.placeholder}\n onFilesAdded={replyInput.onFilesAdded}\n onSubmit={e => {\n setReplyInputOpen(false);\n replyInput.onSubmit(e);\n }}\n />\n </CardContent>\n ) : null}\n {onShowLessReplies && !!replies.length && (\n <Flex container={{ justify: 'center', pad: [0, 0, 1], itemGap: 1 }}>\n <Button variant='link' onClick={() => onShowLessReplies({ feedId: id })}>\n {t('show_less')}\n </Button>\n {repliesLoading && <Progress placement='inline' />}\n </Flex>\n )}\n </Card>\n </FeedReplyContext.Provider>\n );\n};\n\nFeedPost.defaultProps = defaultProps;\n\nexport default FeedPost;\n"]}
|
|
1
|
+
{"version":3,"file":"FeedPost.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedPost.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,QAAQ,EACR,SAAS,EAGT,MAAM,EACN,UAAU,EACV,OAAO,EACR,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EAEN,MAAM,EACN,KAAK,EACL,IAAI,EACJ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,IAAI,EACJ,gBAAgB,EAEhB,UAAU,EACV,OAAO,EACP,QAAQ,EACR,aAAa,EAEb,QAAQ,EACR,OAAO,EACP,mBAAmB,EAGnB,YAAY,EACZ,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAuB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAClF,OAAO,KAAK,kBAAkB,MAAM,yEAAyE,CAAC;AAC9G,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,eAAkC,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,WAAiC,MAAM,eAAe,CAAC;AAC9D,OAAO,cAAuC,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,aAAqC,MA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ef,\n useContext,\n useMemo\n} from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Avatar,\n AvatarProps,\n Button,\n Count,\n Card,\n CardContent,\n CardHeader,\n Flex,\n Icon,\n registerIcon,\n MenuButton,\n SummaryItem,\n Text,\n defaultThemeProp,\n ForwardProps,\n useElement,\n useI18n,\n Progress,\n useOuterEvent,\n MenuItemProps,\n MetaList,\n Tooltip,\n ModalManagerContext,\n SummaryListItem,\n ModalMethods,\n StyledVisual,\n useConfiguration\n} from '@pega/cosmos-react-core';\nimport { RichTextEditorState, StyledRichTextEditor } from '@pega/cosmos-react-rte';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport * as arrowMicroDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/arrow-micro-down.icon';\nimport * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';\nimport { formatListToLocaleString } from '@pega/cosmos-react-core/lib/utils/utils';\n\nimport FeedButton from './FeedButton';\nimport FeedAttachments, { AttachedFiles } from './FeedAttachments';\nimport { StyledFeedReplyContainer } from './FeedReply';\nimport FeedContent, { FeedContentProps } from './FeedContent';\nimport FeedReplyInput, { FeedReplyInputProps } from './FeedReplyInput';\nimport { FeedContext, FeedReplyContext } from './Feed.context';\nimport FeedRichText from './FeedRichText';\nimport FeedModalList, { FeedModalListProps } from './FeedModalList';\n\nregisterIcon(arrowMicroDownIcon, caretLeftIcon);\n\nexport interface FeedPostProps {\n /** Unique ID for this activity */\n id: string;\n /** All of the information used to fill text portions, and avatar info */\n info: {\n avatarSrc?: string;\n fullname: string;\n username: string;\n timeElapsed: string;\n content: ReactElement | string;\n postType?: 'public' | 'private';\n recipients?: MenuItemProps[];\n recipientsCount?: number;\n attachments?: AttachedFiles[];\n liked?: boolean;\n icon?: string;\n postContext?: ReactElement | string;\n userStatus?: AvatarProps['status'];\n };\n maxContentHeight?: FeedContentProps['maxContentHeight'];\n /** Button labels for accessibility purposes. */\n interactionInfo: {\n likeLabel: string;\n likes?: SummaryListItem[];\n likeCount?: number;\n commentLabel: string;\n /**\n * @default true\n */\n interactionsEnabled?: boolean;\n };\n /** Callback that runs when the mouse pointer hovers over the Activity. */\n onMouseEnter?: (event: { postId: string }) => void;\n /** Callback that runs when the mouse pointer leaves the Activity. */\n onMouseLeave?: (event: { postId: string }) => void;\n /** Callback that runs when the comment button has been clicked */\n onCommentClick?: (event: { postId: string }) => void;\n /** Callback that runs when the like button has been clicked */\n onLikeClick: (event: { postId: string; user: SummaryListItem }) => void;\n /** Callback that runs when the like count on a post is hovered, focused, or clicked. */\n onLikeCountInteraction?: () => void;\n /** Callback that runs when the bottom of the extended like list Modal is reached, allowing for more likes to be loaded. */\n onLoadMoreLikes?: () => void;\n /** Callback that runs when the private recipient icon on a post is hovered, focused, or clicked. */\n onRecipientInteraction?: () => void;\n /** Callback that runs when the bottom of the extended private recipient list Modal is reached, allowing for more recipients to be loaded. */\n onLoadMoreRecipients?: () => void;\n /** Callback that runs when the user name or visual button has been clicked */\n onUserClick?: (event: { postId: string; username: string }, clickEvent?: MouseEvent) => void;\n /** MenuItems that will populate the three dot menu button */\n menuItems?: MenuItemProps[];\n /** Callback that updates the post after being edited. If undefined, the post will not be editable. */\n onEditSubmit?: (event: { postId: string; value: string }) => void;\n /**\n * Flag that indicates if a post has been previously edited.\n * @default false\n */\n edited?: boolean;\n /** Props that will be passed into the reply input, see FeedReplyInput for more information */\n replyInput: Pick<FeedReplyInputProps, 'onSubmit' | 'placeholder' | 'onFilesAdded'> & {\n commentLabel: FeedReplyInputProps['commentLabel'];\n attachments: FeedReplyInputProps['attachments'];\n };\n /** The default visibility for the reply input */\n replyInputShown?: boolean;\n /** An array to hold FeedReply's inside of this Activity */\n replies?: ReactElement[];\n /** A total count of all replies. */\n replyCount?: number;\n /** Callback that runs when the user clicks Show more button. */\n onShowMoreReplies?: (event: { postId: string }) => void;\n /** Callback that runs when the user clicks Show less button. */\n onShowLessReplies?: (event: { postId: string }) => void;\n /** A loading indicator for the replies. */\n repliesLoading?: boolean;\n}\n\nconst defaultProps: Partial<FeedPostProps> = {\n info: {\n avatarSrc: '',\n fullname: '',\n username: '',\n timeElapsed: '',\n content: ''\n }\n};\n\nexport const StyledFeedPost = styled.div(\n ({ theme }) => css`\n ${StyledFeedReplyContainer}:not(:last-child) {\n margin-block-end: calc(2 * ${theme.base.spacing});\n }\n `\n);\n\nStyledFeedPost.defaultProps = defaultThemeProp;\n\nexport const StyledPostEdit = styled.div(\n ({ theme }) => css`\n ${StyledRichTextEditor} {\n padding: calc(0.5 * ${theme.base.spacing});\n }\n `\n);\n\nStyledPostEdit.defaultProps = defaultThemeProp;\n\nexport const StyledReplies = styled.div(\n ({ theme }) => css`\n border-top: 0.0625rem solid ${theme.base.palette['border-line']};\n padding: calc(1.25 * ${theme.base.spacing}) calc(2 * ${theme.base.spacing});\n `\n);\n\nStyledReplies.defaultProps = defaultThemeProp;\n\nexport const StyledPostFooter = styled.div(\n ({ theme }) => css`\n margin-block-start: ${theme.base.spacing};\n `\n);\n\nStyledPostFooter.defaultProps = defaultThemeProp;\n\nconst FullWidthSummaryItem = styled.div`\n width: 100%;\n\n ${StyledVisual} {\n align-self: start;\n }\n`;\n\nconst FeedPost: FC<ForwardProps & FeedPostProps> = (props: ForwardProps & FeedPostProps) => {\n const {\n id,\n info,\n interactionInfo,\n maxContentHeight = Infinity,\n onMouseEnter,\n onMouseLeave,\n onCommentClick,\n onLikeClick,\n onLikeCountInteraction,\n onLoadMoreLikes,\n onRecipientInteraction,\n onLoadMoreRecipients,\n onUserClick,\n onShowMoreClick,\n newReplyField,\n menuItems,\n onEditSubmit,\n edited = false,\n replies = [],\n replyInput,\n replyInputShown,\n replyCount,\n repliesLoading,\n onShowLessReplies,\n onShowMoreReplies,\n ...restProps\n } = props;\n const {\n avatarSrc,\n fullname,\n username,\n timeElapsed,\n content,\n postType = 'public',\n recipients = [],\n recipientsCount = 0,\n attachments,\n liked,\n icon,\n postContext,\n userStatus\n } = info;\n const {\n likeLabel,\n likes = [],\n likeCount = 0,\n commentLabel,\n interactionsEnabled = true\n } = interactionInfo;\n const loggedInUser = useContext(FeedContext).userInfo;\n\n const t = useI18n();\n const { locale } = useConfiguration();\n const [countEl, setCountEl] = useElement<HTMLButtonElement>();\n const rteRef = useRef<RichTextEditorState>();\n const [editMode, setEditMode] = useState(false);\n const editTextAreaRef = useRef<HTMLDivElement>(null);\n const [emptyEditText, setEmptyEditText] = useState(false);\n const [postModified, setPostModified] = useState(false);\n const [replyInputOpen, setReplyInputOpen] = useState(false);\n const [replyInputRef, setReplyInputRef] = useState<MutableRefObject<\n RichTextEditorState | undefined\n > | null>(null);\n const { create } = useContext(ModalManagerContext);\n const likesModalRef = useRef<ModalMethods<FeedModalListProps>>();\n const recipientsModalRef = useRef<ModalMethods<FeedModalListProps>>();\n\n useEffect(() => {\n likesModalRef.current?.update({\n count: likeCount,\n heading: likeLabel,\n listItems: likes,\n onLoadMore: onLoadMoreLikes\n });\n }, [likeCount, likeLabel, likes, onLoadMoreLikes]);\n\n useEffect(() => {\n if (recipients.length) {\n recipientsModalRef.current?.update({\n count: recipientsCount,\n heading: t('feed_recipients'),\n listItems: recipients as SummaryListItem[],\n onLoadMore: onLoadMoreRecipients\n });\n }\n }, [recipientsCount, recipients, onLoadMoreRecipients]);\n\n useOuterEvent('mousedown', [editTextAreaRef], () => {\n if (emptyEditText) setEditMode(false);\n });\n\n useEffect(() => {\n if ((replyInputOpen || replyInputShown) && replyInputRef) {\n replyInputRef.current?.focus();\n }\n }, [replyInputOpen, replyInputShown, replyInputRef]);\n\n const userVisual = icon ? (\n <Icon name={icon} />\n ) : (\n <Avatar name={fullname} size='l' imageSrc={avatarSrc} status={userStatus} />\n );\n\n const numReplies = replyCount || replies?.length;\n\n const postTypeAttributes = useMemo(() => {\n if (postType === 'private') {\n const recipientsList = recipients.map(x => x.primary);\n return {\n icon: 'users-solid',\n ariaLabel: `${t('feed_private_post')} t('feed_recipients')} ${formatListToLocaleString(\n recipientsList,\n t,\n locale,\n { count: recipientsCount }\n )}`,\n label: formatListToLocaleString(recipientsList, t, locale, {\n count: recipientsCount,\n separator: '\\n'\n })\n };\n }\n\n return {\n icon: 'globe',\n ariaLabel: t('feed_public_post'),\n label: t('feed_public_post')\n };\n }, [postType, recipients, recipientsCount]);\n\n const likesAttributes = useMemo(() => {\n const likesList = likes.map(x => x.primary.toString());\n return {\n ariaLabel: `${t('feed_liked_by')} ${formatListToLocaleString(likesList, t, locale, {\n count: likeCount\n })}`,\n label: formatListToLocaleString(likesList, t, locale, {\n count: likeCount,\n separator: '\\n'\n })\n };\n }, [likes, likeCount]);\n\n const handleEdit = () => {\n if (!emptyEditText && postModified) {\n onEditSubmit?.({\n postId: id,\n value: rteRef.current?.getPlainText() || ''\n });\n setEditMode(false);\n }\n };\n\n return (\n <FeedReplyContext.Provider value={{ onShowReplyInput: () => setReplyInputOpen(true) }}>\n <Card\n {...restProps}\n as={StyledFeedPost}\n onMouseEnter={() => {\n onMouseEnter?.({ postId: id });\n }}\n onMouseLeave={() => {\n onMouseLeave?.({ postId: id });\n }}\n >\n <CardHeader>\n <SummaryItem\n as={FullWidthSummaryItem}\n visual={\n onUserClick ? (\n <BareButton\n onClick={(event: MouseEvent) => {\n onUserClick?.({ postId: 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?.({ postId: id, username }, event);\n }}\n >\n <Text variant='h3'>{fullname}</Text>\n </Button>\n ) : (\n <Text variant='h3'>{fullname}</Text>\n )}\n {postContext && <Text variant='primary'> {t('feed_context', [postContext])}</Text>}\n </div>\n }\n secondary={\n <Flex container={{ gap: 1, alignItems: 'center' }}>\n <Button\n variant='text'\n icon\n onClick={\n recipients.length\n ? () => {\n if (recipientsCount > 10) {\n recipientsModalRef.current = create(FeedModalList, {\n count: recipientsCount,\n heading: t('feed_recipients'),\n listItems: recipients as SummaryListItem[],\n onLoadMore: onLoadMoreRecipients\n });\n }\n }\n : onRecipientInteraction\n }\n onFocus={onRecipientInteraction}\n onMouseOver={onRecipientInteraction}\n aria-label={postTypeAttributes.ariaLabel}\n label={postTypeAttributes.label}\n >\n <Icon name={postTypeAttributes.icon} />\n </Button>\n <MetaList items={edited ? [timeElapsed, t('edited')] : [timeElapsed]} />\n </Flex>\n }\n actions={\n menuItems ? (\n <MenuButton\n text='More'\n menu={{\n items:\n onEditSubmit &&\n typeof content === 'string' &&\n username === loggedInUser.username\n ? menuItems.concat([\n {\n primary: t('edit'),\n id: 'edit',\n onClick: () => setEditMode(true)\n }\n ])\n : menuItems\n }}\n icon='more'\n iconOnly\n variant='simple'\n />\n ) : undefined\n }\n />\n </CardHeader>\n <CardContent>\n {editMode ? (\n <>\n <StyledPostEdit ref={editTextAreaRef}>\n <FeedRichText\n onChange={() => {\n setEmptyEditText(rteRef.current?.getPlainText().trim() === '');\n setPostModified(rteRef.current?.getPlainText() !== content);\n }}\n autoFocus\n onSubmit={handleEdit}\n defaultValue={content}\n ref={rteRef}\n />\n </StyledPostEdit>\n <Flex container={{ justify: 'between', pad: [2, 0, 0] }}>\n <Button\n onClick={() => setEditMode(false)}\n aria-label={`${t('cancel')} ${t('edit')} ${id}`}\n >\n {t('cancel')}\n </Button>\n <Button\n variant='primary'\n disabled={emptyEditText || !postModified}\n onClick={handleEdit}\n aria-label={`${t('update')} ${t('edit')} ${id}`}\n >\n {t('update')}\n </Button>\n </Flex>\n </>\n ) : (\n <FeedContent maxContentHeight={maxContentHeight}>{content}</FeedContent>\n )}\n <FeedAttachments attachments={attachments} />\n <Flex as={StyledPostFooter} container={{ justify: 'between', wrap: 'wrap', gap: 1 }}>\n {interactionsEnabled ? (\n <Flex container={{ gap: 2 }}>\n <Button\n variant='text'\n as={FeedButton}\n onClick={() => {\n onCommentClick?.({ postId: id });\n if (!replyInputOpen) {\n setReplyInputOpen(true);\n }\n }}\n >\n <Icon name='chat' />\n <Text>{commentLabel}</Text>\n {numReplies > 0 && <Count>{numReplies}</Count>}\n </Button>\n <Flex container={{ gap: 0.5 }}>\n <Button\n variant='text'\n as={FeedButton}\n onClick={() =>\n onLikeClick({\n postId: id,\n user: {\n id: loggedInUser.username,\n primary: loggedInUser.fullname,\n secondary: loggedInUser.meta ? (\n <MetaList items={loggedInUser.meta} />\n ) : undefined,\n visual: (\n <Avatar\n size='l'\n imageSrc={loggedInUser.avatarSrc}\n name={loggedInUser.fullname}\n />\n )\n }\n })\n }\n emphasized={liked}\n >\n <Icon name={liked ? 'thumbs-up-solid' : 'thumbs-up'} />\n <Text>{likeLabel}</Text>\n </Button>\n {likeCount > 0 && (\n <>\n <BareButton\n ref={setCountEl}\n onClick={\n likes.length\n ? () => {\n if (likeCount > 10) {\n likesModalRef.current = create(FeedModalList, {\n count: likeCount,\n heading: t('feed_likes'),\n listItems: likes,\n onLoadMore: onLoadMoreLikes\n });\n }\n }\n : onLikeCountInteraction\n }\n onFocus={onLikeCountInteraction}\n onMouseOver={onLikeCountInteraction}\n aria-label={likesAttributes.ariaLabel}\n >\n <Count>{likeCount}</Count>\n </BareButton>\n <Tooltip target={countEl} showDelay='none' hideDelay='none'>\n {likesAttributes.label}\n </Tooltip>\n </>\n )}\n </Flex>\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({ postId: id })}>\n {t('show_more')}\n </Button>\n )}\n {repliesLoading && <Progress placement='inline' />}\n </Flex>\n )}\n </Flex>\n </CardContent>\n {!!replies?.length && <StyledReplies>{replies}</StyledReplies>}\n {replyInputShown || replyInputOpen ? (\n <CardContent>\n <FeedReplyInput\n onSetInputRef={({ ref }) => {\n setReplyInputRef(ref);\n }}\n id={id}\n commentLabel={replyInput.commentLabel}\n attachments={replyInput.attachments}\n placeholder={replyInput.placeholder}\n onFilesAdded={replyInput.onFilesAdded}\n onSubmit={e => {\n setReplyInputOpen(false);\n replyInput.onSubmit(e);\n }}\n />\n </CardContent>\n ) : null}\n {onShowLessReplies && !!replies.length && (\n <Flex container={{ justify: 'center', pad: [0, 0, 1], gap: 1 }}>\n <Button variant='link' onClick={() => onShowLessReplies({ postId: id })}>\n {t('show_less')}\n </Button>\n {repliesLoading && <Progress placement='inline' />}\n </Flex>\n )}\n </Card>\n </FeedReplyContext.Provider>\n );\n};\n\nFeedPost.defaultProps = defaultProps;\n\nexport default FeedPost;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC, ReactElement, MouseEvent } from 'react';
|
|
2
|
-
import { ForwardProps, MenuItemProps } from '@pega/cosmos-react-core';
|
|
2
|
+
import { AvatarProps, ForwardProps, MenuItemProps, SummaryListItem } from '@pega/cosmos-react-core';
|
|
3
3
|
import { AttachedFiles } from './FeedAttachments';
|
|
4
4
|
export interface FeedReplyProps {
|
|
5
5
|
id: string;
|
|
@@ -13,9 +13,11 @@ export interface FeedReplyProps {
|
|
|
13
13
|
fullnameLabel: string;
|
|
14
14
|
liked?: boolean;
|
|
15
15
|
icon?: string;
|
|
16
|
+
userStatus?: AvatarProps['status'];
|
|
16
17
|
};
|
|
17
18
|
interactionInfo: {
|
|
18
|
-
|
|
19
|
+
likes?: SummaryListItem[];
|
|
20
|
+
likeCount?: number;
|
|
19
21
|
likeLabel: string;
|
|
20
22
|
commentLabel: string;
|
|
21
23
|
/**
|
|
@@ -28,29 +30,45 @@ export interface FeedReplyProps {
|
|
|
28
30
|
* @default Infinity
|
|
29
31
|
*/
|
|
30
32
|
maxContentHeight?: number;
|
|
33
|
+
/** A set of menu options for actions on the reply. */
|
|
31
34
|
menuItems?: MenuItemProps[];
|
|
32
|
-
|
|
35
|
+
/** Callback that updates the reply after being edited. If undefined, the reply will not be editable. */
|
|
36
|
+
onEditSubmit?: (event: {
|
|
33
37
|
replyId: string;
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
value: string;
|
|
39
|
+
}) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Flag that indicates if a reply has been previously edited.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
edited?: boolean;
|
|
45
|
+
onMouseEnter?: (event: {
|
|
46
|
+
replyId: string;
|
|
47
|
+
}) => void;
|
|
48
|
+
onMouseLeave?: (event: {
|
|
36
49
|
replyId: string;
|
|
37
|
-
})
|
|
38
|
-
onCommentClick(event: {
|
|
50
|
+
}) => void;
|
|
51
|
+
onCommentClick: (event: {
|
|
39
52
|
replyId: string;
|
|
40
53
|
username: string;
|
|
41
|
-
})
|
|
42
|
-
onLikeClick(event: {
|
|
54
|
+
}) => void;
|
|
55
|
+
onLikeClick: (event: {
|
|
43
56
|
replyId: string;
|
|
44
|
-
|
|
45
|
-
|
|
57
|
+
user: SummaryListItem;
|
|
58
|
+
}) => void;
|
|
59
|
+
/** Callback that runs when the like count on a post is hovered, focused, or clicked. */
|
|
60
|
+
onLikeCountInteraction?: () => void;
|
|
61
|
+
/** Callback that runs when the bottom of the extended like list Modal is reached, allowing for more likes to be loaded. */
|
|
62
|
+
onLoadMoreLikes?: () => void;
|
|
63
|
+
onUserClick?: (event: {
|
|
46
64
|
replyId: string;
|
|
47
65
|
username: string;
|
|
48
|
-
}, clickEvent?: MouseEvent)
|
|
66
|
+
}, clickEvent?: MouseEvent) => void;
|
|
49
67
|
}
|
|
50
68
|
export declare const StyledFeedReplyContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
51
69
|
export declare const StyledFeedReplyUser: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
|
52
70
|
export declare const StyledVisualButton: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
|
53
|
-
export declare const
|
|
71
|
+
export declare const StyledFeedReplyContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
54
72
|
declare const FeedReply: FC<ForwardProps & FeedReplyProps>;
|
|
55
73
|
export default FeedReply;
|
|
56
74
|
//# sourceMappingURL=FeedReply.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedReply.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"FeedReply.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EACF,YAAY,EAEZ,UAAU,EAKX,MAAM,OAAO,CAAC;AAGf,OAAO,EAEL,WAAW,EAQX,YAAY,EACZ,aAAa,EAMb,eAAe,EAIhB,MAAM,yBAAyB,CAAC;AASjC,OAAwB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAUnE,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE;QACJ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC;QAC/B,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;KACpC,CAAC;IACF,eAAe,EAAE;QACf,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;QAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB;;WAEG;QACH,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