@pega/cosmos-react-social 5.0.0-dev.4.8 → 5.0.0-dev.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/lib/components/Autopilot/Autopilot.d.ts +15 -0
  2. package/lib/components/Autopilot/Autopilot.d.ts.map +1 -0
  3. package/lib/components/Autopilot/Autopilot.js +50 -0
  4. package/lib/components/Autopilot/Autopilot.js.map +1 -0
  5. package/lib/components/Autopilot/AutopilotAvatar.d.ts +8 -0
  6. package/lib/components/Autopilot/AutopilotAvatar.d.ts.map +1 -0
  7. package/lib/components/Autopilot/AutopilotAvatar.js +11 -0
  8. package/lib/components/Autopilot/AutopilotAvatar.js.map +1 -0
  9. package/lib/components/Autopilot/AutopilotGlimpse.d.ts +9 -0
  10. package/lib/components/Autopilot/AutopilotGlimpse.d.ts.map +1 -0
  11. package/lib/components/Autopilot/AutopilotGlimpse.js +24 -0
  12. package/lib/components/Autopilot/AutopilotGlimpse.js.map +1 -0
  13. package/lib/components/Autopilot/index.d.ts +4 -0
  14. package/lib/components/Autopilot/index.d.ts.map +1 -0
  15. package/lib/components/Autopilot/index.js +3 -0
  16. package/lib/components/Autopilot/index.js.map +1 -0
  17. package/lib/components/Chat/Chat.d.ts +29 -0
  18. package/lib/components/Chat/Chat.d.ts.map +1 -0
  19. package/lib/components/Chat/Chat.js +64 -0
  20. package/lib/components/Chat/Chat.js.map +1 -0
  21. package/lib/components/Chat/Chat.types.d.ts +136 -0
  22. package/lib/components/Chat/Chat.types.d.ts.map +1 -0
  23. package/lib/components/Chat/Chat.types.js +10 -0
  24. package/lib/components/Chat/Chat.types.js.map +1 -0
  25. package/lib/components/Chat/ChatBody.d.ts +7 -0
  26. package/lib/components/Chat/ChatBody.d.ts.map +1 -0
  27. package/lib/components/Chat/ChatBody.js +292 -0
  28. package/lib/components/Chat/ChatBody.js.map +1 -0
  29. package/lib/components/Chat/ChatComposer.d.ts +50 -0
  30. package/lib/components/Chat/ChatComposer.d.ts.map +1 -0
  31. package/lib/components/Chat/ChatComposer.js +221 -0
  32. package/lib/components/Chat/ChatComposer.js.map +1 -0
  33. package/lib/components/Chat/ChatHeader.d.ts +29 -0
  34. package/lib/components/Chat/ChatHeader.d.ts.map +1 -0
  35. package/lib/components/Chat/ChatHeader.js +44 -0
  36. package/lib/components/Chat/ChatHeader.js.map +1 -0
  37. package/lib/components/Chat/ChatSettingsPanel.d.ts +7 -0
  38. package/lib/components/Chat/ChatSettingsPanel.d.ts.map +1 -0
  39. package/lib/components/Chat/ChatSettingsPanel.js +15 -0
  40. package/lib/components/Chat/ChatSettingsPanel.js.map +1 -0
  41. package/lib/components/Chat/ChatSettingsPanel.styles.d.ts +16 -0
  42. package/lib/components/Chat/ChatSettingsPanel.styles.d.ts.map +1 -0
  43. package/lib/components/Chat/ChatSettingsPanel.styles.js +47 -0
  44. package/lib/components/Chat/ChatSettingsPanel.styles.js.map +1 -0
  45. package/lib/components/Chat/Message.d.ts +6 -0
  46. package/lib/components/Chat/Message.d.ts.map +1 -0
  47. package/lib/components/Chat/Message.js +98 -0
  48. package/lib/components/Chat/Message.js.map +1 -0
  49. package/lib/components/Chat/Message.styles.d.ts +43 -0
  50. package/lib/components/Chat/Message.styles.d.ts.map +1 -0
  51. package/lib/components/Chat/Message.styles.js +270 -0
  52. package/lib/components/Chat/Message.styles.js.map +1 -0
  53. package/lib/components/Chat/SuggestedReplyPicker.d.ts +42 -0
  54. package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -0
  55. package/lib/components/Chat/SuggestedReplyPicker.js +143 -0
  56. package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -0
  57. package/lib/components/Chat/SystemMessage.d.ts +8 -0
  58. package/lib/components/Chat/SystemMessage.d.ts.map +1 -0
  59. package/lib/components/Chat/SystemMessage.js +50 -0
  60. package/lib/components/Chat/SystemMessage.js.map +1 -0
  61. package/lib/components/Chat/TypeIndicator.d.ts +6 -0
  62. package/lib/components/Chat/TypeIndicator.d.ts.map +1 -0
  63. package/lib/components/Chat/TypeIndicator.js +12 -0
  64. package/lib/components/Chat/TypeIndicator.js.map +1 -0
  65. package/lib/components/Chat/index.d.ts +15 -0
  66. package/lib/components/Chat/index.d.ts.map +1 -0
  67. package/lib/components/Chat/index.js +10 -0
  68. package/lib/components/Chat/index.js.map +1 -0
  69. package/lib/components/Email/ContextMenuPopover.d.ts +5 -0
  70. package/lib/components/Email/ContextMenuPopover.d.ts.map +1 -0
  71. package/lib/components/Email/ContextMenuPopover.js +53 -0
  72. package/lib/components/Email/ContextMenuPopover.js.map +1 -0
  73. package/lib/components/Email/Email.d.ts +7 -0
  74. package/lib/components/Email/Email.d.ts.map +1 -0
  75. package/lib/components/Email/Email.js +244 -0
  76. package/lib/components/Email/Email.js.map +1 -0
  77. package/lib/components/Email/Email.styles.d.ts +67 -0
  78. package/lib/components/Email/Email.styles.d.ts.map +1 -0
  79. package/lib/components/Email/Email.styles.js +392 -0
  80. package/lib/components/Email/Email.styles.js.map +1 -0
  81. package/lib/components/Email/Email.types.d.ts +394 -0
  82. package/lib/components/Email/Email.types.d.ts.map +1 -0
  83. package/lib/components/Email/Email.types.js +2 -0
  84. package/lib/components/Email/Email.types.js.map +1 -0
  85. package/lib/components/Email/EmailCaseView.d.ts +6 -0
  86. package/lib/components/Email/EmailCaseView.d.ts.map +1 -0
  87. package/lib/components/Email/EmailCaseView.js +36 -0
  88. package/lib/components/Email/EmailCaseView.js.map +1 -0
  89. package/lib/components/Email/EmailComposer.d.ts +10 -0
  90. package/lib/components/Email/EmailComposer.d.ts.map +1 -0
  91. package/lib/components/Email/EmailComposer.js +255 -0
  92. package/lib/components/Email/EmailComposer.js.map +1 -0
  93. package/lib/components/Email/EmailConversation.d.ts +17 -0
  94. package/lib/components/Email/EmailConversation.d.ts.map +1 -0
  95. package/lib/components/Email/EmailConversation.js +174 -0
  96. package/lib/components/Email/EmailConversation.js.map +1 -0
  97. package/lib/components/Email/EmailEntity.d.ts +11 -0
  98. package/lib/components/Email/EmailEntity.d.ts.map +1 -0
  99. package/lib/components/Email/EmailEntity.js +51 -0
  100. package/lib/components/Email/EmailEntity.js.map +1 -0
  101. package/lib/components/Email/EmailManager.d.ts +6 -0
  102. package/lib/components/Email/EmailManager.d.ts.map +1 -0
  103. package/lib/components/Email/EmailManager.js +21 -0
  104. package/lib/components/Email/EmailManager.js.map +1 -0
  105. package/lib/components/Email/EmailNotificationPanel.d.ts +7 -0
  106. package/lib/components/Email/EmailNotificationPanel.d.ts.map +1 -0
  107. package/lib/components/Email/EmailNotificationPanel.js +15 -0
  108. package/lib/components/Email/EmailNotificationPanel.js.map +1 -0
  109. package/lib/components/Email/EmailSelector.d.ts +22 -0
  110. package/lib/components/Email/EmailSelector.d.ts.map +1 -0
  111. package/lib/components/Email/EmailSelector.js +121 -0
  112. package/lib/components/Email/EmailSelector.js.map +1 -0
  113. package/lib/components/Email/EmailShell.d.ts +6 -0
  114. package/lib/components/Email/EmailShell.d.ts.map +1 -0
  115. package/lib/components/Email/EmailShell.js +46 -0
  116. package/lib/components/Email/EmailShell.js.map +1 -0
  117. package/lib/components/Email/EmailSummaryItem.d.ts +11 -0
  118. package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -0
  119. package/lib/components/Email/EmailSummaryItem.js +118 -0
  120. package/lib/components/Email/EmailSummaryItem.js.map +1 -0
  121. package/lib/components/Email/EmailSummaryList.d.ts +6 -0
  122. package/lib/components/Email/EmailSummaryList.d.ts.map +1 -0
  123. package/lib/components/Email/EmailSummaryList.js +95 -0
  124. package/lib/components/Email/EmailSummaryList.js.map +1 -0
  125. package/lib/components/Email/EntityList.d.ts +6 -0
  126. package/lib/components/Email/EntityList.d.ts.map +1 -0
  127. package/lib/components/Email/EntityList.js +74 -0
  128. package/lib/components/Email/EntityList.js.map +1 -0
  129. package/lib/components/Email/index.d.ts +13 -0
  130. package/lib/components/Email/index.d.ts.map +1 -0
  131. package/lib/components/Email/index.js +12 -0
  132. package/lib/components/Email/index.js.map +1 -0
  133. package/lib/components/Email/utils/EntityHighlighter.d.ts +10 -0
  134. package/lib/components/Email/utils/EntityHighlighter.d.ts.map +1 -0
  135. package/lib/components/Email/utils/EntityHighlighter.js +260 -0
  136. package/lib/components/Email/utils/EntityHighlighter.js.map +1 -0
  137. package/lib/components/Feed/Feed.context.d.ts +51 -0
  138. package/lib/components/Feed/Feed.context.d.ts.map +1 -0
  139. package/lib/components/Feed/Feed.context.js +10 -0
  140. package/lib/components/Feed/Feed.context.js.map +1 -0
  141. package/lib/components/Feed/Feed.d.ts +6 -0
  142. package/lib/components/Feed/Feed.d.ts.map +1 -0
  143. package/lib/components/Feed/Feed.js +149 -0
  144. package/lib/components/Feed/Feed.js.map +1 -0
  145. package/lib/components/Feed/Feed.types.d.ts +334 -0
  146. package/lib/components/Feed/Feed.types.d.ts.map +1 -0
  147. package/lib/components/Feed/Feed.types.js +2 -0
  148. package/lib/components/Feed/Feed.types.js.map +1 -0
  149. package/lib/components/Feed/FeedAnnouncer.d.ts +6 -0
  150. package/lib/components/Feed/FeedAnnouncer.d.ts.map +1 -0
  151. package/lib/components/Feed/FeedAnnouncer.js +11 -0
  152. package/lib/components/Feed/FeedAnnouncer.js.map +1 -0
  153. package/lib/components/Feed/FeedAttachments.d.ts +8 -0
  154. package/lib/components/Feed/FeedAttachments.d.ts.map +1 -0
  155. package/lib/components/Feed/FeedAttachments.js +97 -0
  156. package/lib/components/Feed/FeedAttachments.js.map +1 -0
  157. package/lib/components/Feed/FeedButton.d.ts +5 -0
  158. package/lib/components/Feed/FeedButton.d.ts.map +1 -0
  159. package/lib/components/Feed/FeedButton.js +15 -0
  160. package/lib/components/Feed/FeedButton.js.map +1 -0
  161. package/lib/components/Feed/FeedContent.d.ts +6 -0
  162. package/lib/components/Feed/FeedContent.d.ts.map +1 -0
  163. package/lib/components/Feed/FeedContent.js +46 -0
  164. package/lib/components/Feed/FeedContent.js.map +1 -0
  165. package/lib/components/Feed/FeedContentFooter.d.ts +5 -0
  166. package/lib/components/Feed/FeedContentFooter.d.ts.map +1 -0
  167. package/lib/components/Feed/FeedContentFooter.js +34 -0
  168. package/lib/components/Feed/FeedContentFooter.js.map +1 -0
  169. package/lib/components/Feed/FeedContentHeader.d.ts +5 -0
  170. package/lib/components/Feed/FeedContentHeader.d.ts.map +1 -0
  171. package/lib/components/Feed/FeedContentHeader.js +107 -0
  172. package/lib/components/Feed/FeedContentHeader.js.map +1 -0
  173. package/lib/components/Feed/FeedEditRegion.d.ts +6 -0
  174. package/lib/components/Feed/FeedEditRegion.d.ts.map +1 -0
  175. package/lib/components/Feed/FeedEditRegion.js +57 -0
  176. package/lib/components/Feed/FeedEditRegion.js.map +1 -0
  177. package/lib/components/Feed/FeedInputRegion.d.ts +8 -0
  178. package/lib/components/Feed/FeedInputRegion.d.ts.map +1 -0
  179. package/lib/components/Feed/FeedInputRegion.js +86 -0
  180. package/lib/components/Feed/FeedInputRegion.js.map +1 -0
  181. package/lib/components/Feed/FeedLikeButton.d.ts +7 -0
  182. package/lib/components/Feed/FeedLikeButton.d.ts.map +1 -0
  183. package/lib/components/Feed/FeedLikeButton.js +102 -0
  184. package/lib/components/Feed/FeedLikeButton.js.map +1 -0
  185. package/lib/components/Feed/FeedModalList.d.ts +5 -0
  186. package/lib/components/Feed/FeedModalList.d.ts.map +1 -0
  187. package/lib/components/Feed/FeedModalList.js +39 -0
  188. package/lib/components/Feed/FeedModalList.js.map +1 -0
  189. package/lib/components/Feed/FeedNewPost.d.ts +7 -0
  190. package/lib/components/Feed/FeedNewPost.d.ts.map +1 -0
  191. package/lib/components/Feed/FeedNewPost.js +30 -0
  192. package/lib/components/Feed/FeedNewPost.js.map +1 -0
  193. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +6 -0
  194. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -0
  195. package/lib/components/Feed/FeedNewPostTypeMenu.js +375 -0
  196. package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -0
  197. package/lib/components/Feed/FeedPost.d.ts +8 -0
  198. package/lib/components/Feed/FeedPost.d.ts.map +1 -0
  199. package/lib/components/Feed/FeedPost.js +85 -0
  200. package/lib/components/Feed/FeedPost.js.map +1 -0
  201. package/lib/components/Feed/FeedReply.d.ts +7 -0
  202. package/lib/components/Feed/FeedReply.d.ts.map +1 -0
  203. package/lib/components/Feed/FeedReply.js +36 -0
  204. package/lib/components/Feed/FeedReply.js.map +1 -0
  205. package/lib/components/Feed/FeedReplyInput.d.ts +7 -0
  206. package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -0
  207. package/lib/components/Feed/FeedReplyInput.js +21 -0
  208. package/lib/components/Feed/FeedReplyInput.js.map +1 -0
  209. package/lib/components/Feed/FeedRichText.d.ts +6 -0
  210. package/lib/components/Feed/FeedRichText.d.ts.map +1 -0
  211. package/lib/components/Feed/FeedRichText.js +163 -0
  212. package/lib/components/Feed/FeedRichText.js.map +1 -0
  213. package/lib/components/Feed/index.d.ts +7 -0
  214. package/lib/components/Feed/index.d.ts.map +1 -0
  215. package/lib/components/Feed/index.js +6 -0
  216. package/lib/components/Feed/index.js.map +1 -0
  217. package/lib/components/HashtagButton/HashtagButton.d.ts +23 -0
  218. package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -0
  219. package/lib/components/HashtagButton/HashtagButton.js +44 -0
  220. package/lib/components/HashtagButton/HashtagButton.js.map +1 -0
  221. package/lib/components/HashtagButton/index.d.ts +3 -0
  222. package/lib/components/HashtagButton/index.d.ts.map +1 -0
  223. package/lib/components/HashtagButton/index.js +3 -0
  224. package/lib/components/HashtagButton/index.js.map +1 -0
  225. package/lib/components/MentionButton/MentionButton.d.ts +35 -0
  226. package/lib/components/MentionButton/MentionButton.d.ts.map +1 -0
  227. package/lib/components/MentionButton/MentionButton.js +94 -0
  228. package/lib/components/MentionButton/MentionButton.js.map +1 -0
  229. package/lib/components/MentionButton/index.d.ts +3 -0
  230. package/lib/components/MentionButton/index.d.ts.map +1 -0
  231. package/lib/components/MentionButton/index.js +3 -0
  232. package/lib/components/MentionButton/index.js.map +1 -0
  233. package/lib/index.d.ts +12 -0
  234. package/lib/index.d.ts.map +1 -0
  235. package/lib/index.js +13 -0
  236. package/lib/index.js.map +1 -0
  237. package/package.json +4 -4
@@ -0,0 +1,86 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useContext, useState } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { Avatar, Button, defaultThemeProp, Flex, Icon, useElement, useI18n, useOuterEvent } from '@pega/cosmos-react-core';
5
+ import { FeedContext } from './Feed.context';
6
+ import FeedAttachments from './FeedAttachments';
7
+ import FeedButton from './FeedButton';
8
+ import FeedRichText from './FeedRichText';
9
+ export const minInputHeight = '4rem';
10
+ const StyledAvatar = styled(Avatar)(({ theme }) => {
11
+ return css `
12
+ margin-block-start: calc(0.5 * ${theme.base.spacing});
13
+ `;
14
+ });
15
+ StyledAvatar.defaultProps = defaultThemeProp;
16
+ const StyledTextAreaContainer = styled.div(({ theme }) => {
17
+ return css `
18
+ width: 100%;
19
+ overflow-y: hidden;
20
+ padding: 0 ${theme.base.spacing} calc(0.5 * ${theme.base.spacing}) ${theme.base.spacing};
21
+ `;
22
+ });
23
+ StyledTextAreaContainer.defaultProps = defaultThemeProp;
24
+ export const StyledActions = styled.div(({ theme }) => {
25
+ return css `
26
+ margin-block-start: calc(2.5 * ${theme.base.spacing});
27
+
28
+ ${FeedButton} + ${FeedButton} {
29
+ margin-inline-start: 0;
30
+ }
31
+ `;
32
+ });
33
+ StyledActions.defaultProps = defaultThemeProp;
34
+ const HiddenFileInput = styled.input `
35
+ display: none;
36
+ `;
37
+ const FeedInputRegion = (props) => {
38
+ const { variant, id, attachments = [], onFilesAdded, onSubmit, inputRegionEl, rteRef, selectedRecipients } = props;
39
+ const t = useI18n();
40
+ const { setShowSearchResults } = useContext(FeedContext);
41
+ const { avatarSrc, fullname, username, userStatus } = useContext(FeedContext).userInfo;
42
+ const [emptyText, setEmptyText] = useState(true);
43
+ const [attachmentEl, setAttachmentEl] = useElement();
44
+ useOuterEvent('mousedown', [inputRegionEl], () => {
45
+ if (emptyText)
46
+ rteRef.current?.clear();
47
+ });
48
+ const handleSubmit = () => {
49
+ setShowSearchResults?.(false);
50
+ if ((!emptyText || attachments.length > 0) && attachments.every(x => !x.error)) {
51
+ onSubmit({
52
+ id,
53
+ value: rteRef.current?.getPlainText() || '',
54
+ attachments: attachments || [],
55
+ username,
56
+ recipients: variant === 'post' ? selectedRecipients : undefined,
57
+ clear: () => {
58
+ rteRef.current?.clear();
59
+ }
60
+ });
61
+ }
62
+ };
63
+ const onKeyDown = (event) => {
64
+ setShowSearchResults?.(true);
65
+ if ((event.metaKey || event.ctrlKey) && event.key === 'Enter')
66
+ handleSubmit();
67
+ };
68
+ const inputLabel = t(variant === 'post' ? 'feed_new_post' : 'feed_new_comment');
69
+ const submitLabel = t(variant === 'post' ? 'feed_new_post_submit' : 'feed_new_comment_submit');
70
+ return (_jsxs(_Fragment, { children: [_jsxs(Flex, { container: { alignItems: 'start' }, children: [_jsx(StyledAvatar, { name: fullname, size: variant === 'post' ? 'l' : 'm', imageSrc: avatarSrc, status: userStatus }), _jsx(StyledTextAreaContainer, { children: _jsx(FeedRichText, { label: inputLabel, onChange: () => {
71
+ setEmptyText(rteRef.current?.getPlainText().trim() === '');
72
+ }, onKeyDown: onKeyDown, height: { min: minInputHeight }, ref: rteRef }) }), _jsxs(Flex, { as: StyledActions, container: { direction: 'column', gap: 0.25 }, children: [onFilesAdded && (_jsx(Button, { variant: 'simple', as: FeedButton, onClick: () => {
73
+ setShowSearchResults?.(false);
74
+ attachmentEl?.click();
75
+ }, icon: true, label: t('feed_attach_files'), children: _jsx(Icon, { name: 'paper-clip' }) })), _jsx(Button, { as: FeedButton, disabled: (emptyText && attachments.length === 0) || attachments.some(x => x.error), variant: 'simple', onClick: handleSubmit, icon: true, label: submitLabel, children: _jsx(Icon, { name: 'send' }) })] })] }), _jsx(HiddenFileInput, { ref: setAttachmentEl, type: 'file', multiple: true, onChange: () => {
76
+ if (attachmentEl?.files) {
77
+ onFilesAdded?.(Array.from(attachmentEl?.files));
78
+ }
79
+ },
80
+ // Must trick input to believe there is no value when activated so that the same file may be added consecutively.
81
+ onClick: (event) => {
82
+ event.target.value = '';
83
+ } }), _jsx(FeedAttachments, { variant: variant, attachments: attachments })] }));
84
+ };
85
+ export default FeedInputRegion;
86
+ //# sourceMappingURL=FeedInputRegion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedInputRegion.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedInputRegion.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,MAAM,EACN,gBAAgB,EAChB,IAAI,EAEJ,IAAI,EACJ,UAAU,EACV,OAAO,EACP,aAAa,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAG1C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AAErC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAChD,OAAO,GAAG,CAAA;qCACyB,KAAK,CAAC,IAAI,CAAC,OAAO;GACpD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,YAAY,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE7C,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACvD,OAA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M,GAAG,GACb,IACJ,IACF,EAEP,KAAC,eAAe,IACd,GAAG,EAAE,eAAe,EACpB,IAAI,EAAC,MAAM,EACX,QAAQ,QACR,QAAQ,EAAE,GAAG,EAAE;oBACb,IAAI,YAAY,EAAE,KAAK,EAAE;wBACvB,YAAY,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;qBACjD;gBACH,CAAC;gBACD,iHAAiH;gBACjH,OAAO,EAAE,CAAC,KAAiB,EAAE,EAAE;oBAC5B,KAAK,CAAC,MAA2B,CAAC,KAAK,GAAG,EAAE,CAAC;gBAChD,CAAC,GACD,EAEF,KAAC,eAAe,IAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,GAAI,IAC9D,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { FC, MouseEvent, useContext, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Avatar,\n Button,\n defaultThemeProp,\n Flex,\n ForwardProps,\n Icon,\n useElement,\n useI18n,\n useOuterEvent\n} from '@pega/cosmos-react-core';\n\nimport { FeedContext } from './Feed.context';\nimport FeedAttachments from './FeedAttachments';\nimport FeedButton from './FeedButton';\nimport FeedRichText from './FeedRichText';\nimport { FeedInputRegionProps } from './Feed.types';\n\nexport const minInputHeight = '4rem';\n\nconst StyledAvatar = styled(Avatar)(({ theme }) => {\n return css`\n margin-block-start: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledAvatar.defaultProps = defaultThemeProp;\n\nconst StyledTextAreaContainer = styled.div(({ theme }) => {\n return css`\n width: 100%;\n overflow-y: hidden;\n padding: 0 ${theme.base.spacing} calc(0.5 * ${theme.base.spacing}) ${theme.base.spacing};\n `;\n});\n\nStyledTextAreaContainer.defaultProps = defaultThemeProp;\n\nexport const StyledActions = styled.div(({ theme }) => {\n return css`\n margin-block-start: calc(2.5 * ${theme.base.spacing});\n\n ${FeedButton} + ${FeedButton} {\n margin-inline-start: 0;\n }\n `;\n});\n\nStyledActions.defaultProps = defaultThemeProp;\n\nconst HiddenFileInput = styled.input`\n display: none;\n`;\n\nconst FeedInputRegion: FC<ForwardProps & FeedInputRegionProps> = (\n props: ForwardProps & FeedInputRegionProps\n) => {\n const {\n variant,\n id,\n attachments = [],\n onFilesAdded,\n onSubmit,\n inputRegionEl,\n rteRef,\n selectedRecipients\n } = props;\n\n const t = useI18n();\n const { setShowSearchResults } = useContext(FeedContext);\n const { avatarSrc, fullname, username, userStatus } = useContext(FeedContext).userInfo;\n\n const [emptyText, setEmptyText] = useState(true);\n const [attachmentEl, setAttachmentEl] = useElement<HTMLInputElement>();\n\n useOuterEvent('mousedown', [inputRegionEl], () => {\n if (emptyText) rteRef.current?.clear();\n });\n\n const handleSubmit = () => {\n setShowSearchResults?.(false);\n if ((!emptyText || attachments.length > 0) && attachments.every(x => !x.error)) {\n onSubmit({\n id,\n value: rteRef.current?.getPlainText() || '',\n attachments: attachments || [],\n username,\n recipients: variant === 'post' ? selectedRecipients : undefined,\n clear: () => {\n rteRef.current?.clear();\n }\n });\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n setShowSearchResults?.(true);\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') handleSubmit();\n };\n\n const inputLabel = t(variant === 'post' ? 'feed_new_post' : 'feed_new_comment');\n const submitLabel = t(variant === 'post' ? 'feed_new_post_submit' : 'feed_new_comment_submit');\n\n return (\n <>\n <Flex container={{ alignItems: 'start' }}>\n <StyledAvatar\n name={fullname}\n size={variant === 'post' ? 'l' : 'm'}\n imageSrc={avatarSrc}\n status={userStatus}\n />\n\n <StyledTextAreaContainer>\n <FeedRichText\n label={inputLabel}\n onChange={() => {\n setEmptyText(rteRef.current?.getPlainText().trim() === '');\n }}\n onKeyDown={onKeyDown}\n height={{ min: minInputHeight }}\n ref={rteRef}\n />\n </StyledTextAreaContainer>\n\n <Flex as={StyledActions} container={{ direction: 'column', gap: 0.25 }}>\n {onFilesAdded && (\n <Button\n variant='simple'\n as={FeedButton}\n onClick={() => {\n setShowSearchResults?.(false);\n attachmentEl?.click();\n }}\n icon\n label={t('feed_attach_files')}\n >\n <Icon name='paper-clip' />\n </Button>\n )}\n\n <Button\n as={FeedButton}\n disabled={(emptyText && attachments.length === 0) || attachments.some(x => x.error)}\n variant='simple'\n onClick={handleSubmit}\n icon\n label={submitLabel}\n >\n <Icon name='send' />\n </Button>\n </Flex>\n </Flex>\n\n <HiddenFileInput\n ref={setAttachmentEl}\n type='file'\n multiple\n onChange={() => {\n if (attachmentEl?.files) {\n onFilesAdded?.(Array.from(attachmentEl?.files));\n }\n }}\n // Must trick input to believe there is no value when activated so that the same file may be added consecutively.\n onClick={(event: MouseEvent) => {\n (event.target as HTMLInputElement).value = '';\n }}\n />\n\n <FeedAttachments variant={variant} attachments={attachments} />\n </>\n );\n};\n\nexport default FeedInputRegion;\n"]}
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { FeedMessageBaseProps } from './Feed.types';
4
+ type FeedLikeButtonProps = Pick<FeedMessageBaseProps, 'id' | 'liked' | 'likeCount' | 'likes' | 'onLikeClick' | 'onLikeCountInteraction' | 'onLoadMoreLikes' | 'likesLoading'>;
5
+ declare const FeedLikeButton: FC<FeedLikeButtonProps & ForwardProps>;
6
+ export default FeedLikeButton;
7
+ //# sourceMappingURL=FeedLikeButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedLikeButton.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedLikeButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA0E,MAAM,OAAO,CAAC;AAGnG,OAAO,EACL,YAAY,EAeb,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,oBAAoB,EAAsB,MAAM,cAAc,CAAC;AAgCxE,KAAK,mBAAmB,GAAG,IAAI,CAC7B,oBAAoB,EAClB,IAAI,GACJ,OAAO,GACP,WAAW,GACX,OAAO,GACP,aAAa,GACb,wBAAwB,GACxB,iBAAiB,GACjB,cAAc,CACjB,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,GAAG,YAAY,CAyHzD,CAAC;AAEH,eAAe,cAAc,CAAC"}
@@ -0,0 +1,102 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useContext, useMemo, useRef, useEffect } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { Button, Icon, Avatar, Count, Tooltip, useModalManager, useI18n, useConfiguration, useElement, formatListToLocaleString, Flex, defaultThemeProp, useUID } from '@pega/cosmos-react-core';
5
+ import BareRoleButton from '@pega/cosmos-react-core/lib/components/Button/BareRoleButton';
6
+ import { FeedContext } from './Feed.context';
7
+ import FeedButton from './FeedButton';
8
+ import FeedModalList from './FeedModalList';
9
+ const InlineBareButton = styled(BareRoleButton)(({ theme }) => {
10
+ return css `
11
+ position: relative;
12
+ display: inline-block;
13
+ line-height: 1;
14
+ outline: none;
15
+ border-radius: calc(${theme.base['border-radius']} * 9999);
16
+
17
+ &:hover {
18
+ ::before {
19
+ content: '';
20
+ position: absolute;
21
+ top: calc(${theme.components.button['border-width']} * -1);
22
+ bottom: calc(${theme.components.button['border-width']} * -1);
23
+ left: calc(${theme.components.button['border-width']} * -1);
24
+ right: calc(${theme.components.button['border-width']} * -1);
25
+ border-radius: inherit;
26
+ background-color: currentColor;
27
+ opacity: 0.15;
28
+ }
29
+ }
30
+
31
+ &:focus {
32
+ box-shadow: ${theme.components.button['focus-shadow']};
33
+ }
34
+ `;
35
+ });
36
+ InlineBareButton.defaultProps = defaultThemeProp;
37
+ const FeedLikeButton = forwardRef(function FeedLikeButton(props, ref) {
38
+ const { id, liked, likeCount = 0, likes = [], onLikeClick, onLikeCountInteraction, onLoadMoreLikes, likesLoading } = props;
39
+ const t = useI18n();
40
+ const { locale } = useConfiguration();
41
+ const { create } = useModalManager();
42
+ const { userInfo: loggedInUser } = useContext(FeedContext);
43
+ const [countEl, setCountEl] = useElement(null);
44
+ const likesModalRef = useRef();
45
+ const likeCountId = useUID();
46
+ useEffect(() => {
47
+ likesModalRef.current?.update({
48
+ count: likeCount,
49
+ heading: t('feed_likes'),
50
+ listItems: likes,
51
+ onLoadMore: onLoadMoreLikes,
52
+ loading: likesLoading
53
+ });
54
+ }, [likeCount, likes, onLoadMoreLikes, likesLoading]);
55
+ const likesAttributes = useMemo(() => {
56
+ const likesList = likes.map(x => x.primary.toString());
57
+ return {
58
+ ariaLabel: likeCount
59
+ ? `${t('feed_liked_by')} ${formatListToLocaleString(likesList.slice(0, 2), t, locale, {
60
+ count: likeCount
61
+ })}`
62
+ : t('feed_post_likes', [likeCount], { count: likeCount }),
63
+ label: `${t('feed_liked_by')}:\n${formatListToLocaleString(likesList.slice(0, 2), t, locale, {
64
+ count: likeCount,
65
+ separator: '\n'
66
+ })}`
67
+ };
68
+ }, [likes, likeCount]);
69
+ const onLikeCountClick = () => {
70
+ if (likes.length) {
71
+ likesModalRef.current = create(FeedModalList, {
72
+ count: likeCount,
73
+ heading: t('feed_likes'),
74
+ listItems: likes,
75
+ onLoadMore: onLoadMoreLikes,
76
+ loading: likesLoading
77
+ });
78
+ }
79
+ else {
80
+ onLikeCountInteraction?.();
81
+ }
82
+ };
83
+ return (_jsxs(Flex, { container: { gap: 0.5, alignItems: 'center' }, children: [_jsx(Button, { variant: 'simple', icon: true, compact: true, as: FeedButton, onClick: () => {
84
+ const user = {
85
+ id: loggedInUser.username,
86
+ primary: loggedInUser.fullname,
87
+ secondary: loggedInUser.meta,
88
+ visual: (_jsx(Avatar, { size: 'l', imageSrc: loggedInUser.avatarSrc, name: loggedInUser.fullname }))
89
+ };
90
+ onLikeClick({
91
+ id,
92
+ user
93
+ });
94
+ }, emphasized: liked, "aria-pressed": liked, label: liked ? t('feed_unlike_label') : t('feed_like_label'), "aria-describedby": likeCount > 0 ? likeCountId : undefined, ref: ref, children: _jsx(Icon, { name: liked ? 'thumbs-up-solid' : 'thumbs-up' }) }), likeCount > 0 && (_jsxs(_Fragment, { children: [_jsx(InlineBareButton, { ref: setCountEl, role: likes.length ? 'button' : undefined, onClick: onLikeCountClick, onFocus: onLikeCountInteraction, onMouseOver: onLikeCountInteraction, "aria-label": likesAttributes.ariaLabel, tabIndex: 0, onKeyDown: (e) => {
95
+ if (e.key === 'Enter') {
96
+ e.preventDefault();
97
+ onLikeCountClick();
98
+ }
99
+ }, children: _jsx(Count, { id: likeCountId, "aria-label": t('feed_post_likes', [likeCount], { count: likeCount }), children: likeCount }) }), _jsx(Tooltip, { target: countEl, showDelay: 'none', hideDelay: 'none', describeTarget: false, children: likesAttributes.label || t('feed_post_likes', [likeCount], { count: likeCount }) })] }))] }));
100
+ });
101
+ export default FeedLikeButton;
102
+ //# sourceMappingURL=FeedLikeButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedLikeButton.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedLikeButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAO,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AACnG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAEL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,KAAK,EACL,OAAO,EAEP,eAAe,EACf,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,wBAAwB,EACxB,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACP,MAAM,yBAAyB,CAAC;AACjC,OAAO,cAAc,MAAM,8DAA8D,CAAC;AAE1F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAG5C,MAAM,gBAAgB,GAAG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C,CAAC,CAAC,SAAS,EACzC,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,sBAAsB,EAC/B,WAAW,EAAE,sBAAsB,gBACvB,eAAe,CAAC,SAAS,EACrC,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,CAAC,CAAgB,EAAE,EAAE;4BAC9B,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE;gCACrB,CAAC,CAAC,cAAc,EAAE,CAAC;gCACnB,gBAAgB,EAAE,CAAC;6BACpB;wBACH,CAAC,YAED,KAAC,KAAK,IACJ,EAAE,EAAE,WAAW,gBACH,CAAC,CAAC,iBAAiB,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,YAElE,SAAS,GACJ,GACS,EACnB,KAAC,OAAO,IAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,EAAC,cAAc,EAAE,KAAK,YAC9E,eAAe,CAAC,KAAK,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,GACzE,IACT,CACJ,IACI,CACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,cAAc,CAAC","sourcesContent":["import { FC, forwardRef, Ref, useContext, useMemo, useRef, useEffect, KeyboardEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n ForwardProps,\n Button,\n Icon,\n Avatar,\n Count,\n Tooltip,\n ModalMethods,\n useModalManager,\n useI18n,\n useConfiguration,\n useElement,\n formatListToLocaleString,\n Flex,\n defaultThemeProp,\n useUID\n} from '@pega/cosmos-react-core';\nimport BareRoleButton from '@pega/cosmos-react-core/lib/components/Button/BareRoleButton';\n\nimport { FeedContext } from './Feed.context';\nimport FeedButton from './FeedButton';\nimport FeedModalList from './FeedModalList';\nimport { FeedMessageBaseProps, FeedModalListProps } from './Feed.types';\n\nconst InlineBareButton = styled(BareRoleButton)(({ theme }) => {\n return css`\n position: relative;\n display: inline-block;\n line-height: 1;\n outline: none;\n border-radius: calc(${theme.base['border-radius']} * 9999);\n\n &:hover {\n ::before {\n content: '';\n position: absolute;\n top: calc(${theme.components.button['border-width']} * -1);\n bottom: calc(${theme.components.button['border-width']} * -1);\n left: calc(${theme.components.button['border-width']} * -1);\n right: calc(${theme.components.button['border-width']} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.15;\n }\n }\n\n &:focus {\n box-shadow: ${theme.components.button['focus-shadow']};\n }\n `;\n});\n\nInlineBareButton.defaultProps = defaultThemeProp;\n\ntype FeedLikeButtonProps = Pick<\n FeedMessageBaseProps,\n | 'id'\n | 'liked'\n | 'likeCount'\n | 'likes'\n | 'onLikeClick'\n | 'onLikeCountInteraction'\n | 'onLoadMoreLikes'\n | 'likesLoading'\n>;\n\nconst FeedLikeButton: FC<FeedLikeButtonProps & ForwardProps> = forwardRef(function FeedLikeButton(\n props,\n ref: Ref<HTMLButtonElement>\n) {\n const {\n id,\n liked,\n likeCount = 0,\n likes = [],\n onLikeClick,\n onLikeCountInteraction,\n onLoadMoreLikes,\n likesLoading\n } = props;\n const t = useI18n();\n const { locale } = useConfiguration();\n const { create } = useModalManager();\n const { userInfo: loggedInUser } = useContext(FeedContext);\n const [countEl, setCountEl] = useElement(null);\n const likesModalRef = useRef<ModalMethods<FeedModalListProps>>();\n const likeCountId = useUID();\n\n useEffect(() => {\n likesModalRef.current?.update({\n count: likeCount,\n heading: t('feed_likes'),\n listItems: likes,\n onLoadMore: onLoadMoreLikes,\n loading: likesLoading\n });\n }, [likeCount, likes, onLoadMoreLikes, likesLoading]);\n\n const likesAttributes = useMemo(() => {\n const likesList = likes.map(x => x.primary.toString());\n return {\n ariaLabel: likeCount\n ? `${t('feed_liked_by')} ${formatListToLocaleString(likesList.slice(0, 2), t, locale, {\n count: likeCount\n })}`\n : t('feed_post_likes', [likeCount], { count: likeCount }),\n label: `${t('feed_liked_by')}:\\n${formatListToLocaleString(likesList.slice(0, 2), t, locale, {\n count: likeCount,\n separator: '\\n'\n })}`\n };\n }, [likes, likeCount]);\n\n const onLikeCountClick = () => {\n if (likes.length) {\n likesModalRef.current = create(FeedModalList, {\n count: likeCount,\n heading: t('feed_likes'),\n listItems: likes,\n onLoadMore: onLoadMoreLikes,\n loading: likesLoading\n });\n } else {\n onLikeCountInteraction?.();\n }\n };\n\n return (\n <Flex container={{ gap: 0.5, alignItems: 'center' }}>\n <Button\n variant='simple'\n icon\n compact\n as={FeedButton}\n onClick={() => {\n const user = {\n id: loggedInUser.username,\n primary: loggedInUser.fullname,\n secondary: loggedInUser.meta,\n visual: (\n <Avatar size='l' imageSrc={loggedInUser.avatarSrc} name={loggedInUser.fullname} />\n )\n };\n onLikeClick({\n id,\n user\n });\n }}\n emphasized={liked}\n aria-pressed={liked}\n label={liked ? t('feed_unlike_label') : t('feed_like_label')}\n aria-describedby={likeCount > 0 ? likeCountId : undefined}\n ref={ref}\n >\n <Icon name={liked ? 'thumbs-up-solid' : 'thumbs-up'} />\n </Button>\n {likeCount > 0 && (\n <>\n <InlineBareButton\n ref={setCountEl}\n role={likes.length ? 'button' : undefined}\n onClick={onLikeCountClick}\n onFocus={onLikeCountInteraction}\n onMouseOver={onLikeCountInteraction}\n aria-label={likesAttributes.ariaLabel}\n tabIndex={0}\n onKeyDown={(e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n onLikeCountClick();\n }\n }}\n >\n <Count\n id={likeCountId}\n aria-label={t('feed_post_likes', [likeCount], { count: likeCount })}\n >\n {likeCount}\n </Count>\n </InlineBareButton>\n <Tooltip target={countEl} showDelay='none' hideDelay='none' describeTarget={false}>\n {likesAttributes.label || t('feed_post_likes', [likeCount], { count: likeCount })}\n </Tooltip>\n </>\n )}\n </Flex>\n );\n});\n\nexport default FeedLikeButton;\n"]}
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { FeedModalListProps } from './Feed.types';
3
+ declare const FeedModalList: FC<FeedModalListProps>;
4
+ export default FeedModalList;
5
+ //# sourceMappingURL=FeedModalList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedModalList.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedModalList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AAiBxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAYlD,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA2DzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef, useEffect, useState } from 'react';
3
+ import styled, { css } from 'styled-components';
4
+ import { defaultThemeProp, Flex, Progress, Count, Modal, SummaryListItems, useItemIntersection, usePrevious, useI18n, MetaList } from '@pega/cosmos-react-core';
5
+ import FeedAnnouncer from './FeedAnnouncer';
6
+ const StyledLoadMore = styled.div(({ theme }) => {
7
+ return css `
8
+ margin-top: ${theme.base.spacing};
9
+ min-height: 2rem;
10
+ min-width: 2rem;
11
+ `;
12
+ });
13
+ StyledLoadMore.defaultProps = defaultThemeProp;
14
+ const FeedModalList = ({ loading, count, heading, listItems, onLoadMore }) => {
15
+ const t = useI18n();
16
+ const listRef = useRef(null);
17
+ const prevItems = usePrevious(listItems);
18
+ const [announcementText, setAnnouncementText] = useState('');
19
+ useEffect(() => {
20
+ if (loading)
21
+ setAnnouncementText(t('loading'));
22
+ }, [loading]);
23
+ useEffect(() => {
24
+ if (prevItems) {
25
+ const difference = listItems.length - prevItems.length;
26
+ if (difference > 0)
27
+ setAnnouncementText(t('new_item_added', [difference], { count: difference }));
28
+ }
29
+ }, [listItems]);
30
+ useItemIntersection(listRef, listItems.length - 1, () => {
31
+ onLoadMore?.();
32
+ }, ':scope li');
33
+ return (_jsxs(Modal, { heading: _jsxs(Flex, { container: { gap: 1 }, children: [heading, _jsx(Flex, { item: { alignSelf: 'center' }, as: Count, children: count })] }), ref: listRef, children: [_jsx(FeedAnnouncer, { children: announcementText }), _jsx(SummaryListItems, { items: listItems.map(item => ({
34
+ ...item,
35
+ secondary: item.secondary && _jsx(MetaList, { items: item.secondary })
36
+ })) }), loading && (_jsx(Flex, { container: { justify: 'center' }, as: StyledLoadMore, children: _jsx(Progress, { placement: 'inline' }) }))] }));
37
+ };
38
+ export default FeedModalList;
39
+ //# sourceMappingURL=FeedModalList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedModalList.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedModalList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,gBAAgB,EAChB,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,OAAO,EACP,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAEjC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAG5C,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC9C,OAAO,GAAG,CAAA;kBACM,KAAK,CAAC,IAAI,CAAC,OAAO;;;GAGjC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,aAAa,GAA2B,CAAC,EAC7C,OAAO,EACP,KAAK,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACS,EAAE,EAAE;IACvB,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,SAAS,GAAG,WAAW,CAAC,S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ACjE,CAAC,CAAC,GACH,EACD,OAAO,IAAI,CACV,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,cAAc,YACxD,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,GAC1B,CACR,IACK,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FC, useRef, useEffect, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n defaultThemeProp,\n Flex,\n Progress,\n Count,\n Modal,\n SummaryListItems,\n useItemIntersection,\n usePrevious,\n useI18n,\n MetaList\n} from '@pega/cosmos-react-core';\n\nimport FeedAnnouncer from './FeedAnnouncer';\nimport { FeedModalListProps } from './Feed.types';\n\nconst StyledLoadMore = styled.div(({ theme }) => {\n return css`\n margin-top: ${theme.base.spacing};\n min-height: 2rem;\n min-width: 2rem;\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst FeedModalList: FC<FeedModalListProps> = ({\n loading,\n count,\n heading,\n listItems,\n onLoadMore\n}: FeedModalListProps) => {\n const t = useI18n();\n const listRef = useRef(null);\n const prevItems = usePrevious(listItems);\n const [announcementText, setAnnouncementText] = useState('');\n\n useEffect(() => {\n if (loading) setAnnouncementText(t('loading'));\n }, [loading]);\n\n useEffect(() => {\n if (prevItems) {\n const difference = listItems.length - prevItems.length;\n if (difference > 0)\n setAnnouncementText(t('new_item_added', [difference], { count: difference }));\n }\n }, [listItems]);\n\n useItemIntersection(\n listRef,\n listItems.length - 1,\n () => {\n onLoadMore?.();\n },\n ':scope li'\n );\n\n return (\n <Modal\n heading={\n <Flex container={{ gap: 1 }}>\n {heading}\n <Flex item={{ alignSelf: 'center' }} as={Count}>\n {count}\n </Flex>\n </Flex>\n }\n ref={listRef}\n >\n <FeedAnnouncer>{announcementText}</FeedAnnouncer>\n <SummaryListItems\n items={listItems.map(item => ({\n ...item,\n secondary: item.secondary && <MetaList items={item.secondary} />\n }))}\n />\n {loading && (\n <Flex container={{ justify: 'center' }} as={StyledLoadMore}>\n <Progress placement='inline' />\n </Flex>\n )}\n </Modal>\n );\n};\n\nexport default FeedModalList;\n"]}
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { FeedNewPostProps } from './Feed.types';
4
+ export declare const StyledFeedNewPost: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
5
+ declare const FeedNewPost: FC<ForwardProps & FeedNewPostProps>;
6
+ export default FeedNewPost;
7
+ //# sourceMappingURL=FeedNewPost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedNewPost.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedNewPost.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAoB,MAAM,OAAO,CAAC;AAG7C,OAAO,EAIL,YAAY,EAEb,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,gBAAgB,EAAkD,MAAM,cAAc,CAAC;AAKhG,eAAO,MAAM,iBAAiB,yGAAe,CAAC;AAI9C,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,YAAY,GAAG,gBAAgB,CAmDpD,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useRef } from 'react';
3
+ import styled from 'styled-components';
4
+ import { registerIcon, defaultThemeProp, useElement, useAfterInitialEffect } from '@pega/cosmos-react-core';
5
+ import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
6
+ import * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';
7
+ import FeedNewPostTypeMenu from './FeedNewPostTypeMenu';
8
+ import FeedInputRegion from './FeedInputRegion';
9
+ registerIcon(timesIcon, paperClipIcon);
10
+ export const StyledFeedNewPost = styled.div ``;
11
+ StyledFeedNewPost.defaultProps = defaultThemeProp;
12
+ const FeedNewPost = (props) => {
13
+ const { id, attachments = [], onSubmit, onFilesAdded, autoFocus, recipients, onRecipientSearch, ...restProps } = props;
14
+ const rteRef = useRef();
15
+ const [postType, setPostType] = useState('post');
16
+ const [resetPostTypeMenu, setResetPostTypeMenu] = useState(false);
17
+ const [selectedRecipients, setSelectedRecipients] = useState([]);
18
+ const [newPostEl, setNewPostEl] = useElement();
19
+ useAfterInitialEffect(() => {
20
+ if (postType === 'post') {
21
+ rteRef.current?.focus();
22
+ }
23
+ if (postType !== 'private') {
24
+ setSelectedRecipients([]);
25
+ }
26
+ }, [postType]);
27
+ return (_jsxs(StyledFeedNewPost, { ref: setNewPostEl, ...restProps, children: [onRecipientSearch && (_jsx(FeedNewPostTypeMenu, { recipients: recipients || [], onSetPostType: setPostType, onSelectedRecipientsUpdate: setSelectedRecipients, onRecipientSearch: onRecipientSearch, reset: resetPostTypeMenu, onReset: () => setResetPostTypeMenu(false) })), _jsx(FeedInputRegion, { variant: 'post', id: id, attachments: attachments, onFilesAdded: onFilesAdded, onSubmit: onSubmit, inputRegionEl: newPostEl, rteRef: rteRef, selectedRecipients: selectedRecipients })] }));
28
+ };
29
+ export default FeedNewPost;
30
+ //# sourceMappingURL=FeedNewPost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedNewPost.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedNewPost.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,UAAU,EAEV,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,SAAS,MAAM,8DAA8D,CAAC;AAC1F,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AAEnG,OAAO,mBAAmB,MAAM,uBAAuB,C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,EACjD,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAC1C,CACH,EAED,KAAC,eAAe,IACd,OAAO,EAAC,MAAM,EACd,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,SAAS,EACxB,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,GACtC,IACgB,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FC, useState, useRef } from 'react';\nimport styled from 'styled-components';\n\nimport {\n registerIcon,\n defaultThemeProp,\n useElement,\n ForwardProps,\n useAfterInitialEffect\n} from '@pega/cosmos-react-core';\nimport { RichTextEditorState } from '@pega/cosmos-react-rte';\nimport * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nimport FeedNewPostTypeMenu from './FeedNewPostTypeMenu';\nimport { FeedNewPostProps, PostType, PostTypeMenuProps, RecipientMenuItem } from './Feed.types';\nimport FeedInputRegion from './FeedInputRegion';\n\nregisterIcon(timesIcon, paperClipIcon);\n\nexport const StyledFeedNewPost = styled.div``;\n\nStyledFeedNewPost.defaultProps = defaultThemeProp;\n\nconst FeedNewPost: FC<ForwardProps & FeedNewPostProps> = (props: FeedNewPostProps) => {\n const {\n id,\n attachments = [],\n onSubmit,\n onFilesAdded,\n autoFocus,\n recipients,\n onRecipientSearch,\n ...restProps\n } = props;\n const rteRef = useRef<RichTextEditorState>();\n const [postType, setPostType] = useState<PostType>('post');\n const [resetPostTypeMenu, setResetPostTypeMenu] = useState(false);\n const [selectedRecipients, setSelectedRecipients] = useState<RecipientMenuItem[]>([]);\n const [newPostEl, setNewPostEl] = useElement<HTMLDivElement>();\n\n useAfterInitialEffect(() => {\n if (postType === 'post') {\n rteRef.current?.focus();\n }\n if (postType !== 'private') {\n setSelectedRecipients([] as RecipientMenuItem[]);\n }\n }, [postType]);\n\n return (\n <StyledFeedNewPost ref={setNewPostEl} {...restProps}>\n {onRecipientSearch && (\n <FeedNewPostTypeMenu\n recipients={recipients || ([] as PostTypeMenuProps['recipients'])}\n onSetPostType={setPostType}\n onSelectedRecipientsUpdate={setSelectedRecipients}\n onRecipientSearch={onRecipientSearch}\n reset={resetPostTypeMenu}\n onReset={() => setResetPostTypeMenu(false)}\n />\n )}\n\n <FeedInputRegion\n variant='post'\n id={id}\n attachments={attachments}\n onFilesAdded={onFilesAdded}\n onSubmit={onSubmit}\n inputRegionEl={newPostEl}\n rteRef={rteRef}\n selectedRecipients={selectedRecipients}\n />\n </StyledFeedNewPost>\n );\n};\n\nexport default FeedNewPost;\n"]}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { ForwardProps } from '@pega/cosmos-react-core';
3
+ import { PostTypeMenuProps } from './Feed.types';
4
+ declare const FeedNewPostTypeMenu: ({ recipients, onSetPostType, onSelectedRecipientsUpdate, onRecipientSearch, reset, onReset, ...restProps }: PostTypeMenuProps & ForwardProps) => JSX.Element;
5
+ export default FeedNewPostTypeMenu;
6
+ //# sourceMappingURL=FeedNewPostTypeMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedNewPostTypeMenu.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedNewPostTypeMenu.tsx"],"names":[],"mappings":";AAGA,OAAO,EAiBL,YAAY,EAKb,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAIL,iBAAiB,EAGlB,MAAM,cAAc,CAAC;AAyJtB,QAAA,MAAM,mBAAmB,+GAQtB,iBAAiB,GAAG,YAAY,gBAialC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}