@pega/cosmos-react-social 2.1.6 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/lib/components/Chat/Chat.d.ts +31 -0
  2. package/lib/components/Chat/Chat.d.ts.map +1 -0
  3. package/lib/components/Chat/Chat.js +67 -0
  4. package/lib/components/Chat/Chat.js.map +1 -0
  5. package/lib/components/Chat/Chat.types.d.ts +23 -0
  6. package/lib/components/Chat/Chat.types.d.ts.map +1 -0
  7. package/lib/components/Chat/Chat.types.js +2 -0
  8. package/lib/components/Chat/Chat.types.js.map +1 -0
  9. package/lib/components/Chat/ChatBody.d.ts +12 -0
  10. package/lib/components/Chat/ChatBody.d.ts.map +1 -0
  11. package/lib/components/Chat/ChatBody.js +18 -0
  12. package/lib/components/Chat/ChatBody.js.map +1 -0
  13. package/lib/components/Chat/ChatComposer.d.ts +51 -0
  14. package/lib/components/Chat/ChatComposer.d.ts.map +1 -0
  15. package/lib/components/Chat/ChatComposer.js +213 -0
  16. package/lib/components/Chat/ChatComposer.js.map +1 -0
  17. package/lib/components/Chat/ChatHeader.d.ts +15 -0
  18. package/lib/components/Chat/ChatHeader.d.ts.map +1 -0
  19. package/lib/components/Chat/ChatHeader.js +28 -0
  20. package/lib/components/Chat/ChatHeader.js.map +1 -0
  21. package/lib/components/Chat/ChatTranscript.d.ts +23 -0
  22. package/lib/components/Chat/ChatTranscript.d.ts.map +1 -0
  23. package/lib/components/Chat/ChatTranscript.js +45 -0
  24. package/lib/components/Chat/ChatTranscript.js.map +1 -0
  25. package/lib/components/Chat/Message.d.ts +46 -0
  26. package/lib/components/Chat/Message.d.ts.map +1 -0
  27. package/lib/components/Chat/Message.js +59 -0
  28. package/lib/components/Chat/Message.js.map +1 -0
  29. package/lib/components/Chat/Message.styles.d.ts +29 -0
  30. package/lib/components/Chat/Message.styles.d.ts.map +1 -0
  31. package/lib/components/Chat/Message.styles.js +193 -0
  32. package/lib/components/Chat/Message.styles.js.map +1 -0
  33. package/lib/components/Chat/MessageList.d.ts +35 -0
  34. package/lib/components/Chat/MessageList.d.ts.map +1 -0
  35. package/lib/components/Chat/MessageList.js +123 -0
  36. package/lib/components/Chat/MessageList.js.map +1 -0
  37. package/lib/components/Chat/RepeatingView.d.ts +31 -0
  38. package/lib/components/Chat/RepeatingView.d.ts.map +1 -0
  39. package/lib/components/Chat/RepeatingView.js +47 -0
  40. package/lib/components/Chat/RepeatingView.js.map +1 -0
  41. package/lib/components/Chat/SuggestedReplyPicker.d.ts +26 -0
  42. package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -0
  43. package/lib/components/Chat/SuggestedReplyPicker.js +78 -0
  44. package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -0
  45. package/lib/components/Chat/SystemMessage.d.ts +19 -0
  46. package/lib/components/Chat/SystemMessage.d.ts.map +1 -0
  47. package/lib/components/Chat/SystemMessage.js +40 -0
  48. package/lib/components/Chat/SystemMessage.js.map +1 -0
  49. package/lib/components/Chat/TranscriptMessage.d.ts +25 -0
  50. package/lib/components/Chat/TranscriptMessage.d.ts.map +1 -0
  51. package/lib/components/Chat/TranscriptMessage.js +47 -0
  52. package/lib/components/Chat/TranscriptMessage.js.map +1 -0
  53. package/lib/components/Chat/TypeIndicator.d.ts +13 -0
  54. package/lib/components/Chat/TypeIndicator.d.ts.map +1 -0
  55. package/lib/components/Chat/TypeIndicator.js +9 -0
  56. package/lib/components/Chat/TypeIndicator.js.map +1 -0
  57. package/lib/components/Chat/index.d.ts +14 -0
  58. package/lib/components/Chat/index.d.ts.map +1 -0
  59. package/lib/components/Chat/index.js +13 -0
  60. package/lib/components/Chat/index.js.map +1 -0
  61. package/lib/components/Email/Email.d.ts +6 -0
  62. package/lib/components/Email/Email.d.ts.map +1 -0
  63. package/lib/components/Email/Email.js +153 -0
  64. package/lib/components/Email/Email.js.map +1 -0
  65. package/lib/components/Email/Email.styles.d.ts +18 -0
  66. package/lib/components/Email/Email.styles.d.ts.map +1 -0
  67. package/lib/components/Email/Email.styles.js +131 -0
  68. package/lib/components/Email/Email.styles.js.map +1 -0
  69. package/lib/components/Email/Email.types.d.ts +237 -0
  70. package/lib/components/Email/Email.types.d.ts.map +1 -0
  71. package/lib/components/Email/Email.types.js +2 -0
  72. package/lib/components/Email/Email.types.js.map +1 -0
  73. package/lib/components/Email/EmailComposer.d.ts +9 -0
  74. package/lib/components/Email/EmailComposer.d.ts.map +1 -0
  75. package/lib/components/Email/EmailComposer.js +185 -0
  76. package/lib/components/Email/EmailComposer.js.map +1 -0
  77. package/lib/components/Email/EmailConversation.d.ts +14 -0
  78. package/lib/components/Email/EmailConversation.d.ts.map +1 -0
  79. package/lib/components/Email/EmailConversation.js +179 -0
  80. package/lib/components/Email/EmailConversation.js.map +1 -0
  81. package/lib/components/Email/EmailEntity.d.ts +6 -0
  82. package/lib/components/Email/EmailEntity.d.ts.map +1 -0
  83. package/lib/components/Email/EmailEntity.js +19 -0
  84. package/lib/components/Email/EmailEntity.js.map +1 -0
  85. package/lib/components/Email/EmailSelector.d.ts +19 -0
  86. package/lib/components/Email/EmailSelector.d.ts.map +1 -0
  87. package/lib/components/Email/EmailSelector.js +103 -0
  88. package/lib/components/Email/EmailSelector.js.map +1 -0
  89. package/lib/components/Email/EmailShell.d.ts +9 -0
  90. package/lib/components/Email/EmailShell.d.ts.map +1 -0
  91. package/lib/components/Email/EmailShell.js +56 -0
  92. package/lib/components/Email/EmailShell.js.map +1 -0
  93. package/lib/components/Email/EmailSummaryItem.d.ts +10 -0
  94. package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -0
  95. package/lib/components/Email/EmailSummaryItem.js +93 -0
  96. package/lib/components/Email/EmailSummaryItem.js.map +1 -0
  97. package/lib/components/Email/EmailSummaryList.d.ts +6 -0
  98. package/lib/components/Email/EmailSummaryList.d.ts.map +1 -0
  99. package/lib/components/Email/EmailSummaryList.js +115 -0
  100. package/lib/components/Email/EmailSummaryList.js.map +1 -0
  101. package/lib/components/Email/ViewAnalysis.d.ts +6 -0
  102. package/lib/components/Email/ViewAnalysis.d.ts.map +1 -0
  103. package/lib/components/Email/ViewAnalysis.js +20 -0
  104. package/lib/components/Email/ViewAnalysis.js.map +1 -0
  105. package/lib/components/Email/index.d.ts +9 -0
  106. package/lib/components/Email/index.d.ts.map +1 -0
  107. package/lib/components/Email/index.js +8 -0
  108. package/lib/components/Email/index.js.map +1 -0
  109. package/lib/components/Feed/Feed.context.d.ts +35 -0
  110. package/lib/components/Feed/Feed.context.d.ts.map +1 -0
  111. package/lib/components/Feed/Feed.context.js +8 -0
  112. package/lib/components/Feed/Feed.context.js.map +1 -0
  113. package/lib/components/Feed/Feed.d.ts +52 -0
  114. package/lib/components/Feed/Feed.d.ts.map +1 -0
  115. package/lib/components/Feed/Feed.js +143 -0
  116. package/lib/components/Feed/Feed.js.map +1 -0
  117. package/lib/components/Feed/FeedAnnouncer.d.ts +7 -0
  118. package/lib/components/Feed/FeedAnnouncer.d.ts.map +1 -0
  119. package/lib/components/Feed/FeedAnnouncer.js +11 -0
  120. package/lib/components/Feed/FeedAnnouncer.js.map +1 -0
  121. package/lib/components/Feed/FeedAttachments.d.ts +14 -0
  122. package/lib/components/Feed/FeedAttachments.d.ts.map +1 -0
  123. package/lib/components/Feed/FeedAttachments.js +94 -0
  124. package/lib/components/Feed/FeedAttachments.js.map +1 -0
  125. package/lib/components/Feed/FeedButton.d.ts +6 -0
  126. package/lib/components/Feed/FeedButton.d.ts.map +1 -0
  127. package/lib/components/Feed/FeedButton.js +23 -0
  128. package/lib/components/Feed/FeedButton.js.map +1 -0
  129. package/lib/components/Feed/FeedContent.d.ts +14 -0
  130. package/lib/components/Feed/FeedContent.d.ts.map +1 -0
  131. package/lib/components/Feed/FeedContent.js +39 -0
  132. package/lib/components/Feed/FeedContent.js.map +1 -0
  133. package/lib/components/Feed/FeedLikeButton.d.ts +19 -0
  134. package/lib/components/Feed/FeedLikeButton.d.ts.map +1 -0
  135. package/lib/components/Feed/FeedLikeButton.js +87 -0
  136. package/lib/components/Feed/FeedLikeButton.js.map +1 -0
  137. package/lib/components/Feed/FeedModalList.d.ts +15 -0
  138. package/lib/components/Feed/FeedModalList.d.ts.map +1 -0
  139. package/lib/components/Feed/FeedModalList.js +49 -0
  140. package/lib/components/Feed/FeedModalList.js.map +1 -0
  141. package/lib/components/Feed/FeedNewPost.d.ts +36 -0
  142. package/lib/components/Feed/FeedNewPost.d.ts.map +1 -0
  143. package/lib/components/Feed/FeedNewPost.js +108 -0
  144. package/lib/components/Feed/FeedNewPost.js.map +1 -0
  145. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +35 -0
  146. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -0
  147. package/lib/components/Feed/FeedNewPostTypeMenu.js +387 -0
  148. package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -0
  149. package/lib/components/Feed/FeedPost.d.ts +10 -0
  150. package/lib/components/Feed/FeedPost.d.ts.map +1 -0
  151. package/lib/components/Feed/FeedPost.js +185 -0
  152. package/lib/components/Feed/FeedPost.js.map +1 -0
  153. package/lib/components/Feed/FeedPost.types.d.ts +101 -0
  154. package/lib/components/Feed/FeedPost.types.d.ts.map +1 -0
  155. package/lib/components/Feed/FeedPost.types.js +2 -0
  156. package/lib/components/Feed/FeedPost.types.js.map +1 -0
  157. package/lib/components/Feed/FeedReply.d.ts +10 -0
  158. package/lib/components/Feed/FeedReply.d.ts.map +1 -0
  159. package/lib/components/Feed/FeedReply.js +131 -0
  160. package/lib/components/Feed/FeedReply.js.map +1 -0
  161. package/lib/components/Feed/FeedReply.types.d.ts +68 -0
  162. package/lib/components/Feed/FeedReply.types.d.ts.map +1 -0
  163. package/lib/components/Feed/FeedReply.types.js +2 -0
  164. package/lib/components/Feed/FeedReply.types.js.map +1 -0
  165. package/lib/components/Feed/FeedReplyInput.d.ts +32 -0
  166. package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -0
  167. package/lib/components/Feed/FeedReplyInput.js +105 -0
  168. package/lib/components/Feed/FeedReplyInput.js.map +1 -0
  169. package/lib/components/Feed/FeedRichText.d.ts +9 -0
  170. package/lib/components/Feed/FeedRichText.d.ts.map +1 -0
  171. package/lib/components/Feed/FeedRichText.js +96 -0
  172. package/lib/components/Feed/FeedRichText.js.map +1 -0
  173. package/lib/components/Feed/index.d.ts +10 -0
  174. package/lib/components/Feed/index.d.ts.map +1 -0
  175. package/lib/components/Feed/index.js +6 -0
  176. package/lib/components/Feed/index.js.map +1 -0
  177. package/lib/components/HashtagButton/HashtagButton.d.ts +16 -0
  178. package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -0
  179. package/lib/components/HashtagButton/HashtagButton.js +31 -0
  180. package/lib/components/HashtagButton/HashtagButton.js.map +1 -0
  181. package/lib/components/HashtagButton/index.d.ts +3 -0
  182. package/lib/components/HashtagButton/index.d.ts.map +1 -0
  183. package/lib/components/HashtagButton/index.js +3 -0
  184. package/lib/components/HashtagButton/index.js.map +1 -0
  185. package/lib/components/MentionButton/MentionButton.d.ts +20 -0
  186. package/lib/components/MentionButton/MentionButton.d.ts.map +1 -0
  187. package/lib/components/MentionButton/MentionButton.js +58 -0
  188. package/lib/components/MentionButton/MentionButton.js.map +1 -0
  189. package/lib/components/MentionButton/index.d.ts +3 -0
  190. package/lib/components/MentionButton/index.d.ts.map +1 -0
  191. package/lib/components/MentionButton/index.js +3 -0
  192. package/lib/components/MentionButton/index.js.map +1 -0
  193. package/lib/index.d.ts +11 -0
  194. package/lib/index.d.ts.map +1 -0
  195. package/lib/index.js +12 -0
  196. package/lib/index.js.map +1 -0
  197. package/package.json +4 -4
@@ -0,0 +1,185 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState, useEffect, useRef, useContext, useMemo } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { Avatar, Button, Count, Card, CardContent, CardHeader, Flex, Icon, registerIcon, MenuButton, SummaryItem, Text, defaultThemeProp, useI18n, Progress, useOuterEvent, MetaList, ModalManagerContext, StyledVisual, useConfiguration, usePrevious } from '@pega/cosmos-react-core';
5
+ import { StyledRichTextEditor } from '@pega/cosmos-react-rte';
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';
10
+ import FeedButton from './FeedButton';
11
+ import FeedAttachments from './FeedAttachments';
12
+ import { StyledFeedReplyContainer } from './FeedReply';
13
+ import FeedContent from './FeedContent';
14
+ import FeedReplyInput from './FeedReplyInput';
15
+ import { FeedContext, FeedReplyContext } from './Feed.context';
16
+ import FeedRichText from './FeedRichText';
17
+ import FeedModalList from './FeedModalList';
18
+ import { FeedLikeButton } from './FeedLikeButton';
19
+ registerIcon(arrowMicroDownIcon, caretLeftIcon);
20
+ const defaultProps = {
21
+ info: {
22
+ avatarSrc: '',
23
+ fullname: '',
24
+ username: '',
25
+ timeElapsed: '',
26
+ content: ''
27
+ }
28
+ };
29
+ export const StyledFeedPost = styled.div(({ theme }) => css `
30
+ ${StyledFeedReplyContainer}:not(:last-child) {
31
+ margin-block-end: calc(2 * ${theme.base.spacing});
32
+ }
33
+ `);
34
+ StyledFeedPost.defaultProps = defaultThemeProp;
35
+ export const StyledPostEdit = styled.div(({ theme }) => css `
36
+ ${StyledRichTextEditor} {
37
+ padding: calc(0.5 * ${theme.base.spacing});
38
+ }
39
+ `);
40
+ StyledPostEdit.defaultProps = defaultThemeProp;
41
+ export const StyledReplies = styled.div(({ theme }) => css `
42
+ border-top: 0.0625rem solid ${theme.base.palette['border-line']};
43
+ padding: calc(1.25 * ${theme.base.spacing}) calc(2 * ${theme.base.spacing});
44
+ `);
45
+ StyledReplies.defaultProps = defaultThemeProp;
46
+ export const StyledPostFooter = styled.div(({ theme }) => css `
47
+ margin-block-start: ${theme.base.spacing};
48
+ `);
49
+ StyledPostFooter.defaultProps = defaultThemeProp;
50
+ const FullWidthSummaryItem = styled.div `
51
+ width: 100%;
52
+
53
+ ${StyledVisual} {
54
+ align-self: start;
55
+ }
56
+ `;
57
+ const FeedPost = (props) => {
58
+ 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;
59
+ const { avatarSrc, fullname, username, timeElapsed, content, postType = 'public', recipients = [], recipientsCount = 0, attachments, liked, icon, postContext, userStatus } = info;
60
+ const { commentLabel, interactionsEnabled = true } = interactionInfo;
61
+ const { announce, userInfo: loggedInUser } = useContext(FeedContext);
62
+ const t = useI18n();
63
+ const { locale } = useConfiguration();
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);
69
+ const [replyInputOpen, setReplyInputOpen] = useState(false);
70
+ const [replyInputRef, setReplyInputRef] = useState(null);
71
+ const { create } = useContext(ModalManagerContext);
72
+ const recipientsModalRef = useRef();
73
+ const prevReplies = usePrevious(replies);
74
+ const suppressNextAnnouncement = useRef(false);
75
+ useEffect(() => {
76
+ if (recipients.length) {
77
+ recipientsModalRef.current?.update({
78
+ count: recipientsCount,
79
+ heading: t('feed_recipients'),
80
+ listItems: recipients,
81
+ onLoadMore: onLoadMoreRecipients
82
+ });
83
+ }
84
+ }, [recipientsCount, recipients, onLoadMoreRecipients]);
85
+ useOuterEvent('mousedown', [editTextAreaRef], () => {
86
+ if (emptyEditText)
87
+ setEditMode(false);
88
+ });
89
+ useEffect(() => {
90
+ if ((replyInputOpen || replyInputShown) && replyInputRef) {
91
+ replyInputRef.current?.focus();
92
+ }
93
+ }, [replyInputOpen, replyInputShown, replyInputRef]);
94
+ const userVisual = icon ? (_jsx(Icon, { name: icon }, void 0)) : (_jsx(Avatar, { name: fullname, size: 'l', imageSrc: avatarSrc, status: userStatus }, void 0));
95
+ const numReplies = replyCount || replies?.length;
96
+ const postTypeAttributes = useMemo(() => {
97
+ if (postType === 'private') {
98
+ const recipientsList = recipients.map(x => x.primary);
99
+ return {
100
+ icon: 'users-solid',
101
+ ariaLabel: `${t('feed_private_post')} t('feed_recipients')} ${formatListToLocaleString(recipientsList, t, locale, { count: recipientsCount })}`,
102
+ label: formatListToLocaleString(recipientsList, t, locale, {
103
+ count: recipientsCount,
104
+ separator: '\n'
105
+ })
106
+ };
107
+ }
108
+ return {
109
+ icon: 'globe',
110
+ ariaLabel: t('feed_public_post'),
111
+ label: t('feed_public_post')
112
+ };
113
+ }, [postType, recipients, recipientsCount]);
114
+ const handleEdit = () => {
115
+ if (!emptyEditText && postModified) {
116
+ onEditSubmit?.({
117
+ postId: id,
118
+ value: rteRef.current?.getPlainText() || ''
119
+ });
120
+ setEditMode(false);
121
+ }
122
+ };
123
+ useEffect(() => {
124
+ if (prevReplies) {
125
+ const difference = prevReplies.length - replies.length;
126
+ if (difference > 0 && !suppressNextAnnouncement.current) {
127
+ announce(t('feed_reply_removed'));
128
+ }
129
+ else {
130
+ suppressNextAnnouncement.current = false;
131
+ }
132
+ }
133
+ }, [replies]);
134
+ return (_jsx(FeedReplyContext.Provider, { value: { onShowReplyInput: () => setReplyInputOpen(true) }, children: _jsxs(Card, { ...restProps, as: StyledFeedPost, onMouseEnter: () => {
135
+ onMouseEnter?.({ postId: id });
136
+ }, onMouseLeave: () => {
137
+ onMouseLeave?.({ postId: id });
138
+ }, children: [_jsx(CardHeader, { children: _jsx(SummaryItem, { as: FullWidthSummaryItem, visual: onUserClick ? (_jsx(BareButton, { onClick: (event) => {
139
+ onUserClick?.({ postId: id, username }, event);
140
+ }, children: userVisual }, void 0)) : (userVisual), primary: _jsxs("div", { children: [onUserClick ? (_jsx(Button, { variant: 'text', onClick: (event) => {
141
+ onUserClick?.({ postId: id, username }, event);
142
+ }, 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
143
+ ? () => {
144
+ if (recipientsCount > 10) {
145
+ recipientsModalRef.current = create(FeedModalList, {
146
+ count: recipientsCount,
147
+ heading: t('feed_recipients'),
148
+ listItems: recipients,
149
+ onLoadMore: onLoadMoreRecipients
150
+ });
151
+ }
152
+ }
153
+ : 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: {
154
+ items: onEditSubmit &&
155
+ typeof content === 'string' &&
156
+ username === loggedInUser.username
157
+ ? menuItems.concat([
158
+ {
159
+ primary: t('edit'),
160
+ id: 'edit',
161
+ onClick: () => setEditMode(true)
162
+ }
163
+ ])
164
+ : menuItems
165
+ }, 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: () => {
166
+ setEmptyEditText(rteRef.current?.getPlainText().trim() === '');
167
+ setPostModified(rteRef.current?.getPlainText() !== content);
168
+ }, autoFocus: true, label: t('feed_edit_post'), labelHidden: 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, readOnly: true }, 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: () => {
169
+ onCommentClick?.({ postId: id });
170
+ if (!replyInputOpen) {
171
+ setReplyInputOpen(true);
172
+ }
173
+ }, children: [_jsx(Icon, { name: 'chat' }, void 0), _jsx(Text, { children: commentLabel }, void 0), numReplies > 0 && _jsx(Count, { children: numReplies }, void 0)] }, void 0), _jsx(FeedLikeButton, { id: id, variant: 'post', onLikeClick: onLikeClick, onLikeCountInteraction: onLikeCountInteraction, onLoadMoreLikes: onLoadMoreLikes, liked: liked, showText: true, ...interactionInfo }, 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 }) => {
174
+ setReplyInputRef(ref);
175
+ }, id: id, commentLabel: replyInput.commentLabel, attachments: replyInput.attachments, placeholder: replyInput.placeholder, onFilesAdded: replyInput.onFilesAdded, onSubmit: e => {
176
+ setReplyInputOpen(false);
177
+ replyInput.onSubmit(e);
178
+ } }, 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: () => {
179
+ onShowLessReplies({ postId: id });
180
+ suppressNextAnnouncement.current = true;
181
+ }, children: t('show_less') }, void 0), repliesLoading && _jsx(Progress, { placement: 'inline' }, void 0)] }, void 0))] }, void 0) }, void 0));
182
+ };
183
+ FeedPost.defaultProps = defaultProps;
184
+ export default FeedPost;
185
+ //# sourceMappingURL=FeedPost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedPost.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedPost.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,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,EACN,MAAM,EACN,KAAK,EACL,IAAI,EACJ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,IAAI,EACJ,gBAAgB,EAEhB,OAAO,EACP,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,mBAAmB,EAGnB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAuB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OA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WAAG,YAC7C,CACR,YACI,WACmB,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,YAAY,GAAG,YAAY,CAAC;AAErC,eAAe,QAAQ,CAAC","sourcesContent":["import {\n FC,\n useState,\n useEffect,\n MutableRefObject,\n MouseEvent,\n useRef,\n useContext,\n useMemo\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 registerIcon,\n MenuButton,\n SummaryItem,\n Text,\n defaultThemeProp,\n ForwardProps,\n useI18n,\n Progress,\n useOuterEvent,\n MetaList,\n ModalManagerContext,\n SummaryListItem,\n ModalMethods,\n StyledVisual,\n useConfiguration,\n usePrevious\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 from './FeedAttachments';\nimport { StyledFeedReplyContainer } from './FeedReply';\nimport FeedContent from './FeedContent';\nimport FeedReplyInput from './FeedReplyInput';\nimport { FeedContext, FeedReplyContext } from './Feed.context';\nimport FeedRichText from './FeedRichText';\nimport FeedModalList, { FeedModalListProps } from './FeedModalList';\nimport { FeedLikeButton } from './FeedLikeButton';\nimport { FeedPostProps } from './FeedPost.types';\n\nregisterIcon(arrowMicroDownIcon, caretLeftIcon);\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 { commentLabel, interactionsEnabled = true } = interactionInfo;\n const { announce, userInfo: loggedInUser } = useContext(FeedContext);\n\n const t = useI18n();\n const { locale } = useConfiguration();\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 recipientsModalRef = useRef<ModalMethods<FeedModalListProps>>();\n const prevReplies = usePrevious(replies);\n const suppressNextAnnouncement = useRef(false);\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 handleEdit = () => {\n if (!emptyEditText && postModified) {\n onEditSubmit?.({\n postId: id,\n value: rteRef.current?.getPlainText() || ''\n });\n setEditMode(false);\n }\n };\n\n useEffect(() => {\n if (prevReplies) {\n const difference = prevReplies.length - replies.length;\n if (difference > 0 && !suppressNextAnnouncement.current) {\n announce(t('feed_reply_removed'));\n } else {\n suppressNextAnnouncement.current = false;\n }\n }\n }, [replies]);\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 label={t('feed_edit_post')}\n labelHidden\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} readOnly />\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 <FeedLikeButton\n id={id}\n variant='post'\n onLikeClick={onLikeClick}\n onLikeCountInteraction={onLikeCountInteraction}\n onLoadMoreLikes={onLoadMoreLikes}\n liked={liked}\n showText\n {...interactionInfo}\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>&bull;</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\n variant='link'\n onClick={() => {\n onShowLessReplies({ postId: id });\n suppressNextAnnouncement.current = true;\n }}\n >\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"]}
@@ -0,0 +1,101 @@
1
+ import { ReactElement, MouseEvent } from 'react';
2
+ import { AvatarProps, MenuItemProps, SummaryListItem } from '@pega/cosmos-react-core';
3
+ import { AttachedFiles } from './FeedAttachments';
4
+ import { FeedContentProps } from './FeedContent';
5
+ import { FeedReplyInputProps } from './FeedReplyInput';
6
+ export interface FeedPostProps {
7
+ /** Unique ID for this activity */
8
+ id: string;
9
+ /** All of the information used to fill text portions, and avatar info */
10
+ info: {
11
+ avatarSrc?: string;
12
+ fullname: string;
13
+ username: string;
14
+ timeElapsed: string;
15
+ content: ReactElement | string;
16
+ postType?: 'public' | 'private';
17
+ recipients?: MenuItemProps[];
18
+ recipientsCount?: number;
19
+ attachments?: AttachedFiles[];
20
+ liked?: boolean;
21
+ icon?: string;
22
+ postContext?: ReactElement | string;
23
+ userStatus?: AvatarProps['status'];
24
+ };
25
+ maxContentHeight?: FeedContentProps['maxContentHeight'];
26
+ /** Button labels for accessibility purposes. */
27
+ interactionInfo: {
28
+ likeLabel: string;
29
+ likes?: SummaryListItem[];
30
+ likeCount?: number;
31
+ commentLabel: string;
32
+ /**
33
+ * @default true
34
+ */
35
+ interactionsEnabled?: boolean;
36
+ };
37
+ /** Callback that runs when the mouse pointer hovers over the Activity. */
38
+ onMouseEnter?: (event: {
39
+ postId: string;
40
+ }) => void;
41
+ /** Callback that runs when the mouse pointer leaves the Activity. */
42
+ onMouseLeave?: (event: {
43
+ postId: string;
44
+ }) => void;
45
+ /** Callback that runs when the comment button has been clicked */
46
+ onCommentClick?: (event: {
47
+ postId: string;
48
+ }) => void;
49
+ /** Callback that runs when the like button has been clicked */
50
+ onLikeClick: (event: {
51
+ postId: string;
52
+ user: SummaryListItem;
53
+ }) => void;
54
+ /** Callback that runs when the like count on a post is hovered, focused, or clicked. */
55
+ onLikeCountInteraction?: () => void;
56
+ /** Callback that runs when the bottom of the extended like list Modal is reached, allowing for more likes to be loaded. */
57
+ onLoadMoreLikes?: () => void;
58
+ /** Callback that runs when the private recipient icon on a post is hovered, focused, or clicked. */
59
+ onRecipientInteraction?: () => void;
60
+ /** Callback that runs when the bottom of the extended private recipient list Modal is reached, allowing for more recipients to be loaded. */
61
+ onLoadMoreRecipients?: () => void;
62
+ /** Callback that runs when the user name or visual button has been clicked */
63
+ onUserClick?: (event: {
64
+ postId: string;
65
+ username: string;
66
+ }, clickEvent?: MouseEvent) => void;
67
+ /** MenuItems that will populate the three dot menu button */
68
+ menuItems?: MenuItemProps[];
69
+ /** Callback that updates the post after being edited. If undefined, the post will not be editable. */
70
+ onEditSubmit?: (event: {
71
+ postId: string;
72
+ value: string;
73
+ }) => void;
74
+ /**
75
+ * Flag that indicates if a post has been previously edited.
76
+ * @default false
77
+ */
78
+ edited?: boolean;
79
+ /** Props that will be passed into the reply input, see FeedReplyInput for more information */
80
+ replyInput: Pick<FeedReplyInputProps, 'onSubmit' | 'placeholder' | 'onFilesAdded'> & {
81
+ commentLabel: FeedReplyInputProps['commentLabel'];
82
+ attachments: FeedReplyInputProps['attachments'];
83
+ };
84
+ /** The default visibility for the reply input */
85
+ replyInputShown?: boolean;
86
+ /** An array to hold FeedReply's inside of this Activity */
87
+ replies?: ReactElement[];
88
+ /** A total count of all replies. */
89
+ replyCount?: number;
90
+ /** Callback that runs when the user clicks Show more button. */
91
+ onShowMoreReplies?: (event: {
92
+ postId: string;
93
+ }) => void;
94
+ /** Callback that runs when the user clicks Show less button. */
95
+ onShowLessReplies?: (event: {
96
+ postId: string;
97
+ }) => void;
98
+ /** A loading indicator for the replies. */
99
+ repliesLoading?: boolean;
100
+ }
101
+ //# sourceMappingURL=FeedPost.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedPost.types.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedPost.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,yEAAyE;IACzE,IAAI,EAAE;QACJ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,YAAY,GAAG,MAAM,CAAC;QAC/B,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;QAChC,UAAU,CAAC,EAAE,aAAa,EAAE,CA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ourceRoot":"","sources":["../../../src/components/Feed/FeedPost.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ReactElement, MouseEvent } from 'react';\n\nimport { AvatarProps, MenuItemProps, SummaryListItem } from '@pega/cosmos-react-core';\n\nimport { AttachedFiles } from './FeedAttachments';\nimport { FeedContentProps } from './FeedContent';\nimport { FeedReplyInputProps } from './FeedReplyInput';\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"]}
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { FeedReplyProps } from './FeedReply.types';
4
+ export declare const StyledFeedReplyContent: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
5
+ export declare const StyledFeedReplyUser: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
6
+ export declare const StyledVisualButton: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
7
+ export declare const StyledFeedReplyContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
8
+ declare const FeedReply: FC<ForwardProps & FeedReplyProps>;
9
+ export default FeedReply;
10
+ //# sourceMappingURL=FeedReply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedReply.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAuD,MAAM,OAAO,CAAC;AAGhF,OAAO,EAQL,YAAY,EAKb,MAAM,yBAAyB,CAAC;AAQjC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAYnD,eAAO,MAAM,sBAAsB,yGAQjC,CAAC;AAIH,eAAO,MAAM,mBAAmB,4GAO9B,CAAC;AAIH,eAAO,MAAM,kBAAkB,4GAE9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,yGA2BnC,CAAC;AAIH,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,YAAY,GAAG,cAAc,CAiNhD,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,131 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useContext, useState, useRef, useEffect } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { Avatar, Button, Flex, Icon, registerIcon, MenuButton, defaultThemeProp, MetaList, useI18n, useOuterEvent } from '@pega/cosmos-react-core';
5
+ import { StyledAvatar } from '@pega/cosmos-react-core/lib/components/Avatar/Avatar';
6
+ import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
7
+ import { StyledRichTextEditor } from '@pega/cosmos-react-rte';
8
+ import * as chatIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chat.icon';
9
+ import * as thumbsUpSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up-solid.icon';
10
+ import * as thumbsUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up.icon';
11
+ import FeedAttachments from './FeedAttachments';
12
+ import FeedButton from './FeedButton';
13
+ import FeedContent from './FeedContent';
14
+ import { FeedContext, FeedReplyContext } from './Feed.context';
15
+ import FeedRichText from './FeedRichText';
16
+ import { StyledFeedReply } from './FeedReplyInput';
17
+ import { FeedLikeButton } from './FeedLikeButton';
18
+ registerIcon(chatIcon, thumbsUpSolidIcon, thumbsUpIcon);
19
+ export const StyledFeedReplyContent = styled.div(props => {
20
+ const { theme } = props;
21
+ return css `
22
+ background-color: ${theme.base.palette['secondary-background']};
23
+ border-radius: calc(2 * ${theme.base['border-radius']});
24
+ padding: calc(1.5 * ${theme.base.spacing});
25
+ `;
26
+ });
27
+ StyledFeedReplyContent.defaultProps = defaultThemeProp;
28
+ export const StyledFeedReplyUser = styled.button(props => {
29
+ const { theme } = props;
30
+ return css `
31
+ font-weight: ${theme.base['font-weight']['semi-bold']};
32
+ margin-inline-end: ${theme.base.spacing};
33
+ `;
34
+ });
35
+ StyledFeedReplyUser.defaultProps = defaultThemeProp;
36
+ export const StyledVisualButton = styled.button `
37
+ height: min-content;
38
+ `;
39
+ export const StyledFeedReplyContainer = styled.div(props => {
40
+ const { theme } = props;
41
+ return css `
42
+ ${StyledAvatar} {
43
+ margin-inline-end: ${theme.base.spacing};
44
+ }
45
+
46
+ ${StyledFeedReplyContent} {
47
+ margin-bottom: calc(0.5 * ${theme.base.spacing});
48
+ }
49
+
50
+ ${StyledFeedReply} {
51
+ &:focus-within {
52
+ border-color: ${theme.base.palette.interactive};
53
+ }
54
+ }
55
+
56
+ ${StyledRichTextEditor} {
57
+ padding-top: calc(0.5 * ${theme.base.spacing});
58
+ padding-bottom: ${theme.base.spacing};
59
+
60
+ &:focus-within {
61
+ box-shadow: none;
62
+ }
63
+ }
64
+ `;
65
+ });
66
+ StyledFeedReplyContainer.defaultProps = defaultThemeProp;
67
+ const FeedReply = (props) => {
68
+ const { id, info, interactionInfo, maxContentHeight = Infinity, menuItems, onEditSubmit, edited = false, onMouseEnter, onMouseLeave, onCommentClick, onLikeClick, onLikeCountInteraction, onLoadMoreLikes, onUserClick, ...restProps } = props;
69
+ const { avatarSrc, timeElapsed, content, attachments, username, fullname, fullnameLabel, liked, icon, userStatus } = info;
70
+ const { likes = [], likeCount = 0, likeLabel, commentLabel, interactionsEnabled = true } = interactionInfo;
71
+ const loggedInUser = useContext(FeedContext).userInfo;
72
+ const t = useI18n();
73
+ const rteRef = useRef();
74
+ const [editMode, setEditMode] = useState(false);
75
+ const editTextAreaRef = useRef(null);
76
+ const [emptyEditText, setEmptyEditText] = useState(false);
77
+ const [replyModified, setReplyModified] = useState(false);
78
+ const { onShowReplyInput } = useContext(FeedReplyContext);
79
+ const likesModalRef = useRef();
80
+ useEffect(() => {
81
+ likesModalRef.current?.update({
82
+ count: likeCount,
83
+ heading: likeLabel,
84
+ listItems: likes,
85
+ onLoadMore: onLoadMoreLikes
86
+ });
87
+ }, [likeCount, likeLabel, likes, onLoadMoreLikes]);
88
+ useOuterEvent('mousedown', [editTextAreaRef], () => {
89
+ if (emptyEditText)
90
+ setEditMode(false);
91
+ });
92
+ const handleEdit = () => {
93
+ if (!emptyEditText && replyModified) {
94
+ onEditSubmit?.({
95
+ replyId: id,
96
+ value: rteRef.current?.getPlainText() || ''
97
+ });
98
+ setEditMode(false);
99
+ }
100
+ };
101
+ const userVisual = icon ? (_jsx(Icon, { name: icon }, void 0)) : (_jsx(Avatar, { name: fullname, size: 'm', imageSrc: avatarSrc, status: userStatus }, void 0));
102
+ return (_jsxs(Flex, { container: true, as: StyledFeedReplyContainer, onMouseEnter: () => {
103
+ onMouseEnter?.({ replyId: id });
104
+ }, onMouseLeave: () => {
105
+ onMouseLeave?.({ replyId: id });
106
+ }, ...restProps, children: [onUserClick ? (_jsx(BareButton, { as: StyledVisualButton, onClick: (event) => {
107
+ onUserClick?.({ replyId: id, username }, event);
108
+ }, children: userVisual }, void 0)) : (userVisual), _jsxs(Flex, { container: { direction: 'column' }, item: { grow: 1 }, children: [editMode ? (_jsxs(_Fragment, { children: [_jsx(StyledFeedReply, { children: _jsx(FeedRichText, { onChange: () => {
109
+ setEmptyEditText(rteRef.current?.getPlainText().trim() === '');
110
+ setReplyModified(rteRef.current?.getPlainText() !== content);
111
+ }, autoFocus: true, onSubmit: handleEdit, defaultValue: content, ref: rteRef }, void 0) }, void 0), _jsxs(Flex, { container: { justify: 'between', pad: [2, 0, 1] }, children: [_jsx(Button, { onClick: () => setEditMode(false), "aria-label": `${t('cancel')} ${t('edit')} ${id}`, children: t('cancel') }, void 0), _jsx(Button, { variant: 'primary', disabled: emptyEditText || !replyModified, onClick: handleEdit, "aria-label": `${t('update')} ${t('edit')} ${id}`, children: t('update') }, void 0)] }, void 0)] }, void 0)) : (_jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, item: { grow: 1 }, children: [_jsxs(Flex, { item: { grow: 1 }, as: StyledFeedReplyContent, children: [_jsxs(Flex, { container: { direction: 'column', gap: 0.5 }, children: [_jsx("div", { children: _jsx(Button, { as: StyledFeedReplyUser, variant: 'text', onClick: (event) => {
112
+ onUserClick?.({ replyId: id, username }, event);
113
+ }, "aria-label": fullnameLabel, children: fullname }, void 0) }, void 0), _jsx(FeedContent, { maxContentHeight: maxContentHeight, children: content }, void 0)] }, void 0), _jsx(FeedAttachments, { attachments: attachments, readOnly: true }, void 0)] }, void 0), menuItems ? (_jsx(MenuButton, { text: 'More', menu: {
114
+ items: onEditSubmit &&
115
+ typeof content === 'string' &&
116
+ username === loggedInUser.username
117
+ ? menuItems.concat([
118
+ {
119
+ primary: t('edit'),
120
+ id: 'edit',
121
+ onClick: () => setEditMode(true)
122
+ }
123
+ ])
124
+ : menuItems
125
+ }, icon: 'more', iconOnly: true, variant: 'simple' }, void 0)) : undefined] }, void 0)), _jsxs(Flex, { container: { alignItems: 'center', gap: 2 }, children: [interactionsEnabled && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: 'text', icon: true, as: FeedButton, onClick: () => {
126
+ onCommentClick({ replyId: id, username });
127
+ onShowReplyInput?.();
128
+ }, label: commentLabel, children: _jsx(Icon, { name: 'chat' }, void 0) }, void 0), _jsx(FeedLikeButton, { ...interactionInfo, variant: 'reply', id: id, onLikeClick: onLikeClick, onLikeCountInteraction: onLikeCountInteraction, onLoadMoreLikes: onLoadMoreLikes, liked: liked }, void 0)] }, void 0)), _jsx(MetaList, { items: edited ? [timeElapsed, t('edited')] : [timeElapsed] }, void 0)] }, void 0)] }, void 0)] }, void 0));
129
+ };
130
+ export default FeedReply;
131
+ //# sourceMappingURL=FeedReply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedReply.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAc,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,gBAAgB,EAEhB,QAAQ,EACR,OAAO,EACP,aAAa,EAEd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,sDAAsD,CAAC;AACpF,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAClF,OAAO,EAAuB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AACxF,OAAO,KAAK,iBAAiB,MAAM,wEAAwE,CAAC;AAC5G,OAAO,KAAK,YAAY,MAAM,kEAAkE,CAAC;AAGjG,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;IACvD,MAAM,EAAE,KAAK,EA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S,YACR,CACR,EAED,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAC9C,mBAAmB,IAAI,CACtB,8BACE,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,IAAI,QACJ,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,GAAG,EAAE;4CACZ,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;4CAC1C,gBAAgB,EAAE,EAAE,CAAC;wCACvB,CAAC,EACD,KAAK,EAAE,YAAY,YAEnB,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,WAAG,WACb,EACT,KAAC,cAAc,OACT,eAAe,EACnB,OAAO,EAAC,OAAO,EACf,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,WAAW,EACxB,sBAAsB,EAAE,sBAAsB,EAC9C,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE,KAAK,WACZ,YACD,CACJ,EACD,KAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,WAAI,YACnE,YACF,YACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { FC, useContext, MouseEvent, useState, useRef, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Avatar,\n Button,\n Flex,\n Icon,\n registerIcon,\n MenuButton,\n defaultThemeProp,\n ForwardProps,\n MetaList,\n useI18n,\n useOuterEvent,\n ModalMethods\n} from '@pega/cosmos-react-core';\nimport { StyledAvatar } from '@pega/cosmos-react-core/lib/components/Avatar/Avatar';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport { RichTextEditorState, StyledRichTextEditor } from '@pega/cosmos-react-rte';\nimport * as chatIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chat.icon';\nimport * as thumbsUpSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up-solid.icon';\nimport * as thumbsUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up.icon';\n\nimport { FeedReplyProps } from './FeedReply.types';\nimport FeedAttachments from './FeedAttachments';\nimport FeedButton from './FeedButton';\nimport FeedContent from './FeedContent';\nimport { FeedContext, FeedReplyContext } from './Feed.context';\nimport FeedRichText from './FeedRichText';\nimport { StyledFeedReply } from './FeedReplyInput';\nimport { FeedModalListProps } from './FeedModalList';\nimport { FeedLikeButton } from './FeedLikeButton';\n\nregisterIcon(chatIcon, thumbsUpSolidIcon, thumbsUpIcon);\n\nexport const StyledFeedReplyContent = styled.div(props => {\n const { theme } = props;\n\n return css`\n background-color: ${theme.base.palette['secondary-background']};\n border-radius: calc(2 * ${theme.base['border-radius']});\n padding: calc(1.5 * ${theme.base.spacing});\n `;\n});\n\nStyledFeedReplyContent.defaultProps = defaultThemeProp;\n\nexport const StyledFeedReplyUser = styled.button(props => {\n const { theme } = props;\n\n return css`\n font-weight: ${theme.base['font-weight']['semi-bold']};\n margin-inline-end: ${theme.base.spacing};\n `;\n});\n\nStyledFeedReplyUser.defaultProps = defaultThemeProp;\n\nexport const StyledVisualButton = styled.button`\n height: min-content;\n`;\n\nexport const StyledFeedReplyContainer = styled.div(props => {\n const { theme } = props;\n\n return css`\n ${StyledAvatar} {\n margin-inline-end: ${theme.base.spacing};\n }\n\n ${StyledFeedReplyContent} {\n margin-bottom: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledFeedReply} {\n &:focus-within {\n border-color: ${theme.base.palette.interactive};\n }\n }\n\n ${StyledRichTextEditor} {\n padding-top: calc(0.5 * ${theme.base.spacing});\n padding-bottom: ${theme.base.spacing};\n\n &:focus-within {\n box-shadow: none;\n }\n }\n `;\n});\n\nStyledFeedReplyContainer.defaultProps = defaultThemeProp;\n\nconst FeedReply: FC<ForwardProps & FeedReplyProps> = (props: ForwardProps & FeedReplyProps) => {\n const {\n id,\n info,\n interactionInfo,\n maxContentHeight = Infinity,\n menuItems,\n onEditSubmit,\n edited = false,\n onMouseEnter,\n onMouseLeave,\n onCommentClick,\n onLikeClick,\n onLikeCountInteraction,\n onLoadMoreLikes,\n onUserClick,\n ...restProps\n } = props;\n const {\n avatarSrc,\n timeElapsed,\n content,\n attachments,\n username,\n fullname,\n fullnameLabel,\n liked,\n icon,\n userStatus\n } = info;\n const {\n likes = [],\n likeCount = 0,\n likeLabel,\n commentLabel,\n interactionsEnabled = true\n } = interactionInfo;\n const loggedInUser = useContext(FeedContext).userInfo;\n\n const t = useI18n();\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 [replyModified, setReplyModified] = useState(false);\n const { onShowReplyInput } = useContext(FeedReplyContext);\n const likesModalRef = 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 useOuterEvent('mousedown', [editTextAreaRef], () => {\n if (emptyEditText) setEditMode(false);\n });\n\n const handleEdit = () => {\n if (!emptyEditText && replyModified) {\n onEditSubmit?.({\n replyId: id,\n value: rteRef.current?.getPlainText() || ''\n });\n setEditMode(false);\n }\n };\n\n const userVisual = icon ? (\n <Icon name={icon} />\n ) : (\n <Avatar name={fullname} size='m' imageSrc={avatarSrc} status={userStatus} />\n );\n\n return (\n <Flex\n container\n as={StyledFeedReplyContainer}\n onMouseEnter={() => {\n onMouseEnter?.({ replyId: id });\n }}\n onMouseLeave={() => {\n onMouseLeave?.({ replyId: id });\n }}\n {...restProps}\n >\n {onUserClick ? (\n <BareButton\n as={StyledVisualButton}\n onClick={(event: MouseEvent) => {\n onUserClick?.({ replyId: id, username }, event);\n }}\n >\n {userVisual}\n </BareButton>\n ) : (\n userVisual\n )}\n <Flex container={{ direction: 'column' }} item={{ grow: 1 }}>\n {editMode ? (\n <>\n <StyledFeedReply>\n <FeedRichText\n onChange={() => {\n setEmptyEditText(rteRef.current?.getPlainText().trim() === '');\n setReplyModified(rteRef.current?.getPlainText() !== content);\n }}\n autoFocus\n onSubmit={handleEdit}\n defaultValue={content}\n ref={rteRef}\n />\n </StyledFeedReply>\n <Flex container={{ justify: 'between', pad: [2, 0, 1] }}>\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 || !replyModified}\n onClick={handleEdit}\n aria-label={`${t('update')} ${t('edit')} ${id}`}\n >\n {t('update')}\n </Button>\n </Flex>\n </>\n ) : (\n <Flex container={{ gap: 1, alignItems: 'center' }} item={{ grow: 1 }}>\n <Flex item={{ grow: 1 }} as={StyledFeedReplyContent}>\n <Flex container={{ direction: 'column', gap: 0.5 }}>\n <div>\n <Button\n as={StyledFeedReplyUser}\n variant='text'\n onClick={(event: MouseEvent) => {\n onUserClick?.({ replyId: id, username }, event);\n }}\n aria-label={fullnameLabel}\n >\n {fullname}\n </Button>\n </div>\n <FeedContent maxContentHeight={maxContentHeight}>{content}</FeedContent>\n </Flex>\n <FeedAttachments attachments={attachments} readOnly />\n </Flex>\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 </Flex>\n )}\n\n <Flex container={{ alignItems: 'center', gap: 2 }}>\n {interactionsEnabled && (\n <>\n <Button\n variant='text'\n icon\n as={FeedButton}\n onClick={() => {\n onCommentClick({ replyId: id, username });\n onShowReplyInput?.();\n }}\n label={commentLabel}\n >\n <Icon name='chat' />\n </Button>\n <FeedLikeButton\n {...interactionInfo}\n variant='reply'\n id={id}\n onLikeClick={onLikeClick}\n onLikeCountInteraction={onLikeCountInteraction}\n onLoadMoreLikes={onLoadMoreLikes}\n liked={liked}\n />\n </>\n )}\n <MetaList items={edited ? [timeElapsed, t('edited')] : [timeElapsed]} />\n </Flex>\n </Flex>\n </Flex>\n );\n};\n\nexport default FeedReply;\n"]}