@pega/cosmos-react-social 5.0.0-dev.4.7 → 5.0.0-dev.4.9

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/package.json +4 -4
  2. package/lib/components/Autopilot/Autopilot.d.ts +0 -15
  3. package/lib/components/Autopilot/Autopilot.d.ts.map +0 -1
  4. package/lib/components/Autopilot/Autopilot.js +0 -50
  5. package/lib/components/Autopilot/Autopilot.js.map +0 -1
  6. package/lib/components/Autopilot/AutopilotAvatar.d.ts +0 -8
  7. package/lib/components/Autopilot/AutopilotAvatar.d.ts.map +0 -1
  8. package/lib/components/Autopilot/AutopilotAvatar.js +0 -11
  9. package/lib/components/Autopilot/AutopilotAvatar.js.map +0 -1
  10. package/lib/components/Autopilot/AutopilotGlimpse.d.ts +0 -9
  11. package/lib/components/Autopilot/AutopilotGlimpse.d.ts.map +0 -1
  12. package/lib/components/Autopilot/AutopilotGlimpse.js +0 -24
  13. package/lib/components/Autopilot/AutopilotGlimpse.js.map +0 -1
  14. package/lib/components/Autopilot/index.d.ts +0 -4
  15. package/lib/components/Autopilot/index.d.ts.map +0 -1
  16. package/lib/components/Autopilot/index.js +0 -3
  17. package/lib/components/Autopilot/index.js.map +0 -1
  18. package/lib/components/Chat/Chat.d.ts +0 -29
  19. package/lib/components/Chat/Chat.d.ts.map +0 -1
  20. package/lib/components/Chat/Chat.js +0 -64
  21. package/lib/components/Chat/Chat.js.map +0 -1
  22. package/lib/components/Chat/Chat.types.d.ts +0 -136
  23. package/lib/components/Chat/Chat.types.d.ts.map +0 -1
  24. package/lib/components/Chat/Chat.types.js +0 -10
  25. package/lib/components/Chat/Chat.types.js.map +0 -1
  26. package/lib/components/Chat/ChatBody.d.ts +0 -7
  27. package/lib/components/Chat/ChatBody.d.ts.map +0 -1
  28. package/lib/components/Chat/ChatBody.js +0 -292
  29. package/lib/components/Chat/ChatBody.js.map +0 -1
  30. package/lib/components/Chat/ChatComposer.d.ts +0 -50
  31. package/lib/components/Chat/ChatComposer.d.ts.map +0 -1
  32. package/lib/components/Chat/ChatComposer.js +0 -221
  33. package/lib/components/Chat/ChatComposer.js.map +0 -1
  34. package/lib/components/Chat/ChatHeader.d.ts +0 -29
  35. package/lib/components/Chat/ChatHeader.d.ts.map +0 -1
  36. package/lib/components/Chat/ChatHeader.js +0 -44
  37. package/lib/components/Chat/ChatHeader.js.map +0 -1
  38. package/lib/components/Chat/ChatSettingsPanel.d.ts +0 -7
  39. package/lib/components/Chat/ChatSettingsPanel.d.ts.map +0 -1
  40. package/lib/components/Chat/ChatSettingsPanel.js +0 -15
  41. package/lib/components/Chat/ChatSettingsPanel.js.map +0 -1
  42. package/lib/components/Chat/ChatSettingsPanel.styles.d.ts +0 -16
  43. package/lib/components/Chat/ChatSettingsPanel.styles.d.ts.map +0 -1
  44. package/lib/components/Chat/ChatSettingsPanel.styles.js +0 -47
  45. package/lib/components/Chat/ChatSettingsPanel.styles.js.map +0 -1
  46. package/lib/components/Chat/Message.d.ts +0 -6
  47. package/lib/components/Chat/Message.d.ts.map +0 -1
  48. package/lib/components/Chat/Message.js +0 -98
  49. package/lib/components/Chat/Message.js.map +0 -1
  50. package/lib/components/Chat/Message.styles.d.ts +0 -43
  51. package/lib/components/Chat/Message.styles.d.ts.map +0 -1
  52. package/lib/components/Chat/Message.styles.js +0 -270
  53. package/lib/components/Chat/Message.styles.js.map +0 -1
  54. package/lib/components/Chat/SuggestedReplyPicker.d.ts +0 -42
  55. package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +0 -1
  56. package/lib/components/Chat/SuggestedReplyPicker.js +0 -143
  57. package/lib/components/Chat/SuggestedReplyPicker.js.map +0 -1
  58. package/lib/components/Chat/SystemMessage.d.ts +0 -8
  59. package/lib/components/Chat/SystemMessage.d.ts.map +0 -1
  60. package/lib/components/Chat/SystemMessage.js +0 -50
  61. package/lib/components/Chat/SystemMessage.js.map +0 -1
  62. package/lib/components/Chat/TypeIndicator.d.ts +0 -6
  63. package/lib/components/Chat/TypeIndicator.d.ts.map +0 -1
  64. package/lib/components/Chat/TypeIndicator.js +0 -12
  65. package/lib/components/Chat/TypeIndicator.js.map +0 -1
  66. package/lib/components/Chat/index.d.ts +0 -15
  67. package/lib/components/Chat/index.d.ts.map +0 -1
  68. package/lib/components/Chat/index.js +0 -10
  69. package/lib/components/Chat/index.js.map +0 -1
  70. package/lib/components/Email/ContextMenuPopover.d.ts +0 -5
  71. package/lib/components/Email/ContextMenuPopover.d.ts.map +0 -1
  72. package/lib/components/Email/ContextMenuPopover.js +0 -53
  73. package/lib/components/Email/ContextMenuPopover.js.map +0 -1
  74. package/lib/components/Email/Email.d.ts +0 -7
  75. package/lib/components/Email/Email.d.ts.map +0 -1
  76. package/lib/components/Email/Email.js +0 -244
  77. package/lib/components/Email/Email.js.map +0 -1
  78. package/lib/components/Email/Email.styles.d.ts +0 -67
  79. package/lib/components/Email/Email.styles.d.ts.map +0 -1
  80. package/lib/components/Email/Email.styles.js +0 -392
  81. package/lib/components/Email/Email.styles.js.map +0 -1
  82. package/lib/components/Email/Email.types.d.ts +0 -394
  83. package/lib/components/Email/Email.types.d.ts.map +0 -1
  84. package/lib/components/Email/Email.types.js +0 -2
  85. package/lib/components/Email/Email.types.js.map +0 -1
  86. package/lib/components/Email/EmailCaseView.d.ts +0 -6
  87. package/lib/components/Email/EmailCaseView.d.ts.map +0 -1
  88. package/lib/components/Email/EmailCaseView.js +0 -36
  89. package/lib/components/Email/EmailCaseView.js.map +0 -1
  90. package/lib/components/Email/EmailComposer.d.ts +0 -10
  91. package/lib/components/Email/EmailComposer.d.ts.map +0 -1
  92. package/lib/components/Email/EmailComposer.js +0 -255
  93. package/lib/components/Email/EmailComposer.js.map +0 -1
  94. package/lib/components/Email/EmailConversation.d.ts +0 -17
  95. package/lib/components/Email/EmailConversation.d.ts.map +0 -1
  96. package/lib/components/Email/EmailConversation.js +0 -174
  97. package/lib/components/Email/EmailConversation.js.map +0 -1
  98. package/lib/components/Email/EmailEntity.d.ts +0 -11
  99. package/lib/components/Email/EmailEntity.d.ts.map +0 -1
  100. package/lib/components/Email/EmailEntity.js +0 -51
  101. package/lib/components/Email/EmailEntity.js.map +0 -1
  102. package/lib/components/Email/EmailManager.d.ts +0 -6
  103. package/lib/components/Email/EmailManager.d.ts.map +0 -1
  104. package/lib/components/Email/EmailManager.js +0 -21
  105. package/lib/components/Email/EmailManager.js.map +0 -1
  106. package/lib/components/Email/EmailNotificationPanel.d.ts +0 -7
  107. package/lib/components/Email/EmailNotificationPanel.d.ts.map +0 -1
  108. package/lib/components/Email/EmailNotificationPanel.js +0 -15
  109. package/lib/components/Email/EmailNotificationPanel.js.map +0 -1
  110. package/lib/components/Email/EmailSelector.d.ts +0 -22
  111. package/lib/components/Email/EmailSelector.d.ts.map +0 -1
  112. package/lib/components/Email/EmailSelector.js +0 -121
  113. package/lib/components/Email/EmailSelector.js.map +0 -1
  114. package/lib/components/Email/EmailShell.d.ts +0 -6
  115. package/lib/components/Email/EmailShell.d.ts.map +0 -1
  116. package/lib/components/Email/EmailShell.js +0 -46
  117. package/lib/components/Email/EmailShell.js.map +0 -1
  118. package/lib/components/Email/EmailSummaryItem.d.ts +0 -11
  119. package/lib/components/Email/EmailSummaryItem.d.ts.map +0 -1
  120. package/lib/components/Email/EmailSummaryItem.js +0 -118
  121. package/lib/components/Email/EmailSummaryItem.js.map +0 -1
  122. package/lib/components/Email/EmailSummaryList.d.ts +0 -6
  123. package/lib/components/Email/EmailSummaryList.d.ts.map +0 -1
  124. package/lib/components/Email/EmailSummaryList.js +0 -95
  125. package/lib/components/Email/EmailSummaryList.js.map +0 -1
  126. package/lib/components/Email/EntityList.d.ts +0 -6
  127. package/lib/components/Email/EntityList.d.ts.map +0 -1
  128. package/lib/components/Email/EntityList.js +0 -74
  129. package/lib/components/Email/EntityList.js.map +0 -1
  130. package/lib/components/Email/index.d.ts +0 -13
  131. package/lib/components/Email/index.d.ts.map +0 -1
  132. package/lib/components/Email/index.js +0 -12
  133. package/lib/components/Email/index.js.map +0 -1
  134. package/lib/components/Email/utils/EntityHighlighter.d.ts +0 -10
  135. package/lib/components/Email/utils/EntityHighlighter.d.ts.map +0 -1
  136. package/lib/components/Email/utils/EntityHighlighter.js +0 -260
  137. package/lib/components/Email/utils/EntityHighlighter.js.map +0 -1
  138. package/lib/components/Feed/Feed.context.d.ts +0 -51
  139. package/lib/components/Feed/Feed.context.d.ts.map +0 -1
  140. package/lib/components/Feed/Feed.context.js +0 -10
  141. package/lib/components/Feed/Feed.context.js.map +0 -1
  142. package/lib/components/Feed/Feed.d.ts +0 -6
  143. package/lib/components/Feed/Feed.d.ts.map +0 -1
  144. package/lib/components/Feed/Feed.js +0 -149
  145. package/lib/components/Feed/Feed.js.map +0 -1
  146. package/lib/components/Feed/Feed.types.d.ts +0 -334
  147. package/lib/components/Feed/Feed.types.d.ts.map +0 -1
  148. package/lib/components/Feed/Feed.types.js +0 -2
  149. package/lib/components/Feed/Feed.types.js.map +0 -1
  150. package/lib/components/Feed/FeedAnnouncer.d.ts +0 -6
  151. package/lib/components/Feed/FeedAnnouncer.d.ts.map +0 -1
  152. package/lib/components/Feed/FeedAnnouncer.js +0 -11
  153. package/lib/components/Feed/FeedAnnouncer.js.map +0 -1
  154. package/lib/components/Feed/FeedAttachments.d.ts +0 -8
  155. package/lib/components/Feed/FeedAttachments.d.ts.map +0 -1
  156. package/lib/components/Feed/FeedAttachments.js +0 -97
  157. package/lib/components/Feed/FeedAttachments.js.map +0 -1
  158. package/lib/components/Feed/FeedButton.d.ts +0 -5
  159. package/lib/components/Feed/FeedButton.d.ts.map +0 -1
  160. package/lib/components/Feed/FeedButton.js +0 -15
  161. package/lib/components/Feed/FeedButton.js.map +0 -1
  162. package/lib/components/Feed/FeedContent.d.ts +0 -6
  163. package/lib/components/Feed/FeedContent.d.ts.map +0 -1
  164. package/lib/components/Feed/FeedContent.js +0 -46
  165. package/lib/components/Feed/FeedContent.js.map +0 -1
  166. package/lib/components/Feed/FeedContentFooter.d.ts +0 -5
  167. package/lib/components/Feed/FeedContentFooter.d.ts.map +0 -1
  168. package/lib/components/Feed/FeedContentFooter.js +0 -34
  169. package/lib/components/Feed/FeedContentFooter.js.map +0 -1
  170. package/lib/components/Feed/FeedContentHeader.d.ts +0 -5
  171. package/lib/components/Feed/FeedContentHeader.d.ts.map +0 -1
  172. package/lib/components/Feed/FeedContentHeader.js +0 -107
  173. package/lib/components/Feed/FeedContentHeader.js.map +0 -1
  174. package/lib/components/Feed/FeedEditRegion.d.ts +0 -6
  175. package/lib/components/Feed/FeedEditRegion.d.ts.map +0 -1
  176. package/lib/components/Feed/FeedEditRegion.js +0 -57
  177. package/lib/components/Feed/FeedEditRegion.js.map +0 -1
  178. package/lib/components/Feed/FeedInputRegion.d.ts +0 -8
  179. package/lib/components/Feed/FeedInputRegion.d.ts.map +0 -1
  180. package/lib/components/Feed/FeedInputRegion.js +0 -86
  181. package/lib/components/Feed/FeedInputRegion.js.map +0 -1
  182. package/lib/components/Feed/FeedLikeButton.d.ts +0 -7
  183. package/lib/components/Feed/FeedLikeButton.d.ts.map +0 -1
  184. package/lib/components/Feed/FeedLikeButton.js +0 -102
  185. package/lib/components/Feed/FeedLikeButton.js.map +0 -1
  186. package/lib/components/Feed/FeedModalList.d.ts +0 -5
  187. package/lib/components/Feed/FeedModalList.d.ts.map +0 -1
  188. package/lib/components/Feed/FeedModalList.js +0 -39
  189. package/lib/components/Feed/FeedModalList.js.map +0 -1
  190. package/lib/components/Feed/FeedNewPost.d.ts +0 -7
  191. package/lib/components/Feed/FeedNewPost.d.ts.map +0 -1
  192. package/lib/components/Feed/FeedNewPost.js +0 -30
  193. package/lib/components/Feed/FeedNewPost.js.map +0 -1
  194. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +0 -6
  195. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +0 -1
  196. package/lib/components/Feed/FeedNewPostTypeMenu.js +0 -375
  197. package/lib/components/Feed/FeedNewPostTypeMenu.js.map +0 -1
  198. package/lib/components/Feed/FeedPost.d.ts +0 -8
  199. package/lib/components/Feed/FeedPost.d.ts.map +0 -1
  200. package/lib/components/Feed/FeedPost.js +0 -85
  201. package/lib/components/Feed/FeedPost.js.map +0 -1
  202. package/lib/components/Feed/FeedReply.d.ts +0 -7
  203. package/lib/components/Feed/FeedReply.d.ts.map +0 -1
  204. package/lib/components/Feed/FeedReply.js +0 -36
  205. package/lib/components/Feed/FeedReply.js.map +0 -1
  206. package/lib/components/Feed/FeedReplyInput.d.ts +0 -7
  207. package/lib/components/Feed/FeedReplyInput.d.ts.map +0 -1
  208. package/lib/components/Feed/FeedReplyInput.js +0 -21
  209. package/lib/components/Feed/FeedReplyInput.js.map +0 -1
  210. package/lib/components/Feed/FeedRichText.d.ts +0 -6
  211. package/lib/components/Feed/FeedRichText.d.ts.map +0 -1
  212. package/lib/components/Feed/FeedRichText.js +0 -163
  213. package/lib/components/Feed/FeedRichText.js.map +0 -1
  214. package/lib/components/Feed/index.d.ts +0 -7
  215. package/lib/components/Feed/index.d.ts.map +0 -1
  216. package/lib/components/Feed/index.js +0 -6
  217. package/lib/components/Feed/index.js.map +0 -1
  218. package/lib/components/HashtagButton/HashtagButton.d.ts +0 -23
  219. package/lib/components/HashtagButton/HashtagButton.d.ts.map +0 -1
  220. package/lib/components/HashtagButton/HashtagButton.js +0 -44
  221. package/lib/components/HashtagButton/HashtagButton.js.map +0 -1
  222. package/lib/components/HashtagButton/index.d.ts +0 -3
  223. package/lib/components/HashtagButton/index.d.ts.map +0 -1
  224. package/lib/components/HashtagButton/index.js +0 -3
  225. package/lib/components/HashtagButton/index.js.map +0 -1
  226. package/lib/components/MentionButton/MentionButton.d.ts +0 -35
  227. package/lib/components/MentionButton/MentionButton.d.ts.map +0 -1
  228. package/lib/components/MentionButton/MentionButton.js +0 -94
  229. package/lib/components/MentionButton/MentionButton.js.map +0 -1
  230. package/lib/components/MentionButton/index.d.ts +0 -3
  231. package/lib/components/MentionButton/index.d.ts.map +0 -1
  232. package/lib/components/MentionButton/index.js +0 -3
  233. package/lib/components/MentionButton/index.js.map +0 -1
  234. package/lib/index.d.ts +0 -12
  235. package/lib/index.d.ts.map +0 -1
  236. package/lib/index.js +0 -13
  237. package/lib/index.js.map +0 -1
@@ -1,375 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useRef, useMemo, useEffect, useCallback, useReducer } from 'react';
3
- import styled, { css } from 'styled-components';
4
- import { Button, Flex, StyledPrimary, StyledMenuItem, Icon, StyledIcon, useElement, useOuterEvent, Popover, Tooltip, Menu, Count, defaultThemeProp, createUID, useAfterInitialEffect, formatListToLocaleString, useConfiguration, useI18n, useModalManager } from '@pega/cosmos-react-core';
5
- import BareRoleButton from '@pega/cosmos-react-core/lib/components/Button/BareRoleButton';
6
- import { StyledMenuListHeader } from '@pega/cosmos-react-core/lib/components/Menu/Menu.styles';
7
- import MultiSelectInput from '@pega/cosmos-react-core/lib/components/ComboBox/MultiSelectInput/MultiSelectInput';
8
- import FeedModalList from './FeedModalList';
9
- const StyledCountButton = styled(BareRoleButton) `
10
- display: inline-block;
11
- `;
12
- const StyledCountBadgePopoverContent = styled.div(({ theme }) => {
13
- const { base: { spacing } } = theme;
14
- return css `
15
- padding: ${spacing};
16
-
17
- p:not(:last-child) {
18
- margin-bottom: ${spacing};
19
- }
20
- `;
21
- });
22
- StyledCountBadgePopoverContent.defaultProps = defaultThemeProp;
23
- const StyledPostTypePopoverContent = styled.div `
24
- width: clamp(16rem, 60vw, 40rem);
25
- `;
26
- const StyledSelectedInputContainer = styled.div(({ theme }) => {
27
- const { base: { spacing } } = theme;
28
- return css `
29
- margin: ${spacing} calc(2 * ${spacing}) calc(2 * ${spacing});
30
- `;
31
- });
32
- StyledSelectedInputContainer.defaultProps = defaultThemeProp;
33
- const StyledRecipientBackButton = styled(StyledMenuListHeader)(({ theme }) => {
34
- const { base: { 'font-weight': { 'semi-bold': fontWeight }, spacing } } = theme;
35
- return css `
36
- font-weight: ${fontWeight};
37
- padding: ${spacing} calc(2 * ${spacing});
38
-
39
- &:hover,
40
- &:focus {
41
- text-decoration: none;
42
- }
43
-
44
- && ${StyledIcon} {
45
- display: inline-block;
46
- margin-inline-end: ${spacing};
47
- }
48
- `;
49
- });
50
- StyledRecipientBackButton.defaultProps = defaultThemeProp;
51
- const StyledRecipientMenuHeader = styled.div ``;
52
- const StyledTypeMenuToggle = styled(Button)(({ theme }) => {
53
- const { base: { spacing } } = theme;
54
- return css `
55
- margin-block-end: ${spacing};
56
- `;
57
- });
58
- StyledTypeMenuToggle.defaultProps = defaultThemeProp;
59
- const StyledRecipientMenu = styled(Menu)(({ theme }) => {
60
- const { base: { spacing } } = theme;
61
- return css `
62
- ${StyledMenuItem} > button {
63
- padding: ${spacing} calc(2 * ${spacing});
64
- }
65
- `;
66
- });
67
- StyledRecipientMenu.defaultProps = defaultThemeProp;
68
- const StyledPostTypePopover = styled(Popover)(({ theme }) => {
69
- const { base: { 'font-weight': { normal: fontWeight } } } = theme;
70
- return css `
71
- ${StyledPrimary} {
72
- font-weight: ${fontWeight};
73
- }
74
- `;
75
- });
76
- StyledPostTypePopover.defaultProps = defaultThemeProp;
77
- const typeCopy = {
78
- post: {
79
- primary: 'Public post'
80
- },
81
- private: {
82
- primary: 'Private post'
83
- }
84
- };
85
- const createRecipientMenuItem = (recipient, selectedIds) => {
86
- const checkIds = selectedIds || [];
87
- const id = `option_${recipient.value}`;
88
- return {
89
- ...recipient,
90
- id,
91
- selected: checkIds.includes(id)
92
- };
93
- };
94
- const getTypeMenuItems = (type) => {
95
- return [
96
- {
97
- id: '1',
98
- primary: typeCopy.post.primary,
99
- selected: type === 'post',
100
- value: 'post'
101
- },
102
- {
103
- id: '2',
104
- primary: typeCopy.private.primary,
105
- selected: type === 'private',
106
- value: 'private'
107
- }
108
- ];
109
- };
110
- const initialState = {
111
- postType: 'post',
112
- itemsLoading: false,
113
- showTypeMenu: false,
114
- showRecipientMenu: false,
115
- viewingRecipients: false,
116
- searchValue: '',
117
- typeMenuItems: getTypeMenuItems('post'),
118
- recipientMenuItems: [],
119
- multiSelectItems: []
120
- };
121
- const FeedNewPostTypeMenu = ({ recipients, onSetPostType, onSelectedRecipientsUpdate, onRecipientSearch, reset, onReset, ...restProps }) => {
122
- const t = useI18n();
123
- const { locale } = useConfiguration();
124
- const { create } = useModalManager();
125
- const menuPopoverId = useMemo(() => createUID(), []);
126
- const recipientsModalRef = useRef();
127
- const multiSelectInputRef = useRef(null);
128
- const [toggleEl, setToggleEl] = useElement();
129
- const [recipientCountEl, setRecipientCountEl] = useElement();
130
- const [typePopoverEl, setTypePopoverEl] = useElement(null);
131
- const [typeMenuPopoverTarget, setTypeMenuPopoverTarget] = useElement(null);
132
- const reducer = (state, action) => {
133
- const type = action.type;
134
- const payload = action.payload;
135
- switch (type) {
136
- case 'reset': {
137
- return initialState;
138
- }
139
- case 'setPostType': {
140
- const postType = payload;
141
- const privateSelected = postType === 'private';
142
- return {
143
- ...state,
144
- postType,
145
- showTypeMenu: !privateSelected ? false : state.showTypeMenu,
146
- viewingRecipients: privateSelected ? true : state.viewingRecipients,
147
- multiSelectItems: initialState.multiSelectItems,
148
- searchValue: initialState.searchValue
149
- };
150
- }
151
- case 'setShowTypeMenu': {
152
- return {
153
- ...state,
154
- showTypeMenu: payload
155
- };
156
- }
157
- case 'setShowRecipientMenu': {
158
- return {
159
- ...state,
160
- showRecipientMenu: payload
161
- };
162
- }
163
- case 'setSearchValue': {
164
- return {
165
- ...state,
166
- searchValue: payload
167
- };
168
- }
169
- case 'setViewingRecipients': {
170
- return {
171
- ...state,
172
- viewingRecipients: payload
173
- };
174
- }
175
- case 'setItemsLoading': {
176
- return {
177
- ...state,
178
- itemsLoading: payload
179
- };
180
- }
181
- case 'updateTypeMenuItems': {
182
- return {
183
- ...state,
184
- typeMenuItems: getTypeMenuItems(state.postType)
185
- };
186
- }
187
- case 'toggleTypeMenu': {
188
- return {
189
- ...state,
190
- showTypeMenu: !state.showTypeMenu
191
- };
192
- }
193
- case 'removeRecipientViaMultiSelect': {
194
- const selectedId = payload;
195
- const multiSelectItems = state.multiSelectItems.reduce((acc, recipient) => {
196
- if (recipient.id === selectedId)
197
- return acc;
198
- return acc.concat([recipient]);
199
- }, []);
200
- const recipientMenuItems = state.recipientMenuItems.map(item => {
201
- if (item.id === selectedId) {
202
- return {
203
- ...item,
204
- selected: false
205
- };
206
- }
207
- return {
208
- ...item
209
- };
210
- });
211
- return {
212
- ...state,
213
- multiSelectItems,
214
- recipientMenuItems
215
- };
216
- }
217
- case 'selectRecipientViaMenu': {
218
- const selectedId = payload;
219
- if (!state.multiSelectItems.some(item => item.id === selectedId)) {
220
- const selectedFromMenu = state.recipientMenuItems.filter(item => item.id === selectedId)[0];
221
- const multiSelectItems = state.multiSelectItems.concat([selectedFromMenu]);
222
- return {
223
- ...state,
224
- multiSelectItems,
225
- searchValue: ''
226
- };
227
- }
228
- return {
229
- ...state,
230
- searchValue: ''
231
- };
232
- }
233
- case 'updateRecipientMenuItems': {
234
- const selectedIds = state.multiSelectItems.map(item => item.id);
235
- return {
236
- ...state,
237
- itemsLoading: false,
238
- recipientMenuItems: recipients.map(recipient => createRecipientMenuItem(recipient, selectedIds))
239
- };
240
- }
241
- case 'resetUnappliedState': {
242
- const postType = state.postType === 'private' && state.multiSelectItems.length === 0
243
- ? 'post'
244
- : state.postType;
245
- const searchValue = '';
246
- return {
247
- ...state,
248
- postType,
249
- searchValue
250
- };
251
- }
252
- default:
253
- return {
254
- ...state
255
- };
256
- }
257
- };
258
- const [state, dispatch] = useReducer(reducer, initialState);
259
- const handleKeydownToggle = useCallback((e) => {
260
- if (e.key === 'Escape' && state.showTypeMenu)
261
- dispatch({ type: 'toggleTypeMenu' });
262
- }, [state.showTypeMenu]);
263
- useOuterEvent('mousedown', [typePopoverEl, typeMenuPopoverTarget], () => {
264
- dispatch({ type: 'setShowTypeMenu', payload: false });
265
- });
266
- useEffect(() => {
267
- if (reset) {
268
- dispatch({ type: 'reset' });
269
- onReset();
270
- }
271
- }, [reset]);
272
- useEffect(() => {
273
- dispatch({ type: 'updateRecipientMenuItems' });
274
- }, [recipients]);
275
- useEffect(() => {
276
- onSelectedRecipientsUpdate(state.multiSelectItems);
277
- }, [state.multiSelectItems]);
278
- useEffect(() => {
279
- if (!state.showTypeMenu) {
280
- let timeoutId;
281
- if (state.postType === 'private') {
282
- // Timeout to prevent flash of recipients options when closing menu.
283
- timeoutId = setTimeout(() => {
284
- dispatch({ type: 'setViewingRecipients', payload: true });
285
- }, 100);
286
- }
287
- timeoutId = setTimeout(() => {
288
- // Timeout to prevent flash of type menu when resetting postType on close
289
- dispatch({ type: 'resetUnappliedState' });
290
- }, 100);
291
- return () => clearTimeout(timeoutId);
292
- }
293
- }, [state.showTypeMenu]);
294
- useEffect(() => {
295
- if (multiSelectInputRef.current) {
296
- multiSelectInputRef.current?.focus();
297
- }
298
- }, [multiSelectInputRef.current]);
299
- useEffect(() => {
300
- if (state.postType === 'private') {
301
- if (!state.viewingRecipients) {
302
- toggleEl?.focus();
303
- }
304
- else {
305
- multiSelectInputRef.current?.focus();
306
- }
307
- }
308
- }, [state.viewingRecipients]);
309
- useAfterInitialEffect(() => {
310
- onSetPostType(state.postType);
311
- dispatch({ type: 'updateTypeMenuItems' });
312
- if (state.postType === 'private') {
313
- multiSelectInputRef.current?.focus();
314
- }
315
- }, [state.postType]);
316
- useEffect(() => {
317
- const interactionTimeout = setTimeout(() => {
318
- onRecipientSearch(state.searchValue);
319
- dispatch({ type: 'setItemsLoading', payload: true });
320
- dispatch({ type: 'setShowRecipientMenu', payload: !!state.searchValue.length });
321
- }, 300);
322
- return () => clearTimeout(interactionTimeout);
323
- }, [state.searchValue]);
324
- useEffect(() => {
325
- toggleEl?.addEventListener('keydown', handleKeydownToggle);
326
- return () => toggleEl?.removeEventListener('keydown', handleKeydownToggle);
327
- }, [toggleEl, state.showTypeMenu]);
328
- useEffect(() => {
329
- multiSelectInputRef.current?.addEventListener('keydown', handleKeydownToggle);
330
- return () => multiSelectInputRef.current?.removeEventListener('keydown', handleKeydownToggle);
331
- }, [multiSelectInputRef.current, state.showTypeMenu]);
332
- const onRecipientsCountClick = () => {
333
- recipientsModalRef.current = create(FeedModalList, {
334
- count: state.multiSelectItems.length,
335
- heading: t('feed_recipients'),
336
- listItems: state.multiSelectItems.map(item => ({
337
- id: item.id,
338
- primary: item.primary,
339
- secondary: item.secondary,
340
- visual: item.visual
341
- }))
342
- });
343
- };
344
- return (_jsxs(Flex, { container: { gap: 0.5 }, children: [_jsxs(StyledTypeMenuToggle, { ...restProps, onClick: () => {
345
- dispatch({ type: 'toggleTypeMenu' });
346
- }, ref: setToggleEl, variant: 'link', "aria-haspopup": 'menu', "aria-expanded": state.showTypeMenu, children: [_jsx("span", { ref: setTypeMenuPopoverTarget, children: typeCopy[state.postType].primary }), _jsx(Icon, { name: 'arrow-micro-down' })] }), state.postType === 'private' && state.multiSelectItems.length > 0 && (_jsxs(_Fragment, { children: [_jsx(StyledCountButton, { ref: setRecipientCountEl, onClick: onRecipientsCountClick, "aria-label": `${t('feed_private_post')} ${t('feed_recipients')} ${formatListToLocaleString(state.multiSelectItems.map(item => item.primary).slice(0, 2), t, locale, {
347
- count: state.multiSelectItems.length
348
- })}`, tabIndex: 0, children: _jsx(Count, { children: state.multiSelectItems.length }) }), _jsx(Tooltip, { target: recipientCountEl, showDelay: 'none', hideDelay: 'none', describeTarget: false, children: formatListToLocaleString(state.multiSelectItems.map(item => item.primary).slice(0, 2), t, locale, {
349
- count: state.multiSelectItems.length,
350
- separator: '\n'
351
- }) })] })), _jsxs(StyledPostTypePopover, { id: menuPopoverId, ref: setTypePopoverEl, target: typeMenuPopoverTarget, show: state.showTypeMenu, placement: 'bottom-start', children: [(state.postType !== 'private' || !state.viewingRecipients) && (_jsx(Menu, { items: state.typeMenuItems, focusControlEl: toggleEl || undefined, mode: 'single-select', onItemClick: selectedId => {
352
- const postType = state.typeMenuItems.find(item => item.id === selectedId).value;
353
- dispatch({ type: 'setPostType', payload: postType });
354
- }, onItemExpand: () => {
355
- if (state.postType === 'private') {
356
- dispatch({ type: 'setViewingRecipients', payload: true });
357
- }
358
- else {
359
- dispatch({ type: 'setPostType', payload: 'private' });
360
- }
361
- } })), state.postType === 'private' && state.viewingRecipients && (_jsxs(StyledPostTypePopoverContent, { children: [_jsxs(StyledRecipientMenuHeader, { children: [_jsxs(Button, { as: StyledRecipientBackButton, variant: 'text', "aria-label": 'close submenu', onClick: () => {
362
- dispatch({ type: 'setViewingRecipients', payload: false });
363
- }, children: [_jsx(Icon, { name: 'caret-left' }), typeCopy.private.primary] }), _jsx(StyledSelectedInputContainer, { children: _jsx(MultiSelectInput, { ref: multiSelectInputRef, selected: state.multiSelectItems.map(item => ({
364
- id: item.id,
365
- text: item.primary
366
- })), onRemove: (selectedId) => {
367
- dispatch({ type: 'removeRecipientViaMultiSelect', payload: selectedId });
368
- }, value: state.searchValue, onChange: (e) => {
369
- dispatch({ type: 'setSearchValue', payload: e.target.value });
370
- } }) })] }), state.showRecipientMenu && (_jsx(StyledRecipientMenu, { loading: state.itemsLoading, focusControlEl: multiSelectInputRef.current, items: state.itemsLoading ? [] : state.recipientMenuItems, scrollAt: 11, mode: 'action', emptyText: 'No items', onItemClick: (selectedId) => {
371
- dispatch({ type: 'selectRecipientViaMenu', payload: selectedId });
372
- } }))] }))] })] }));
373
- };
374
- export default FeedNewPostTypeMenu;
375
- //# sourceMappingURL=FeedNewPostTypeMenu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeedNewPostTypeMenu.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedNewPostTypeMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAe,MAAM,OAAO,CAAC;AACzF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,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KAAC,gBAAgB,IACf,GAAG,EAAE,mBAAmB,EACxB,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gDAC5C,EAAE,EAAE,IAAI,CAAC,EAAE;gDACX,IAAI,EAAE,IAAI,CAAC,OAAO;6CACnB,CAAC,CAAC,EACH,QAAQ,EAAE,CAAC,UAAmC,EAAE,EAAE;gDAChD,QAAQ,CAAC,EAAE,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;4CAC3E,CAAC,EACD,KAAK,EAAE,KAAK,CAAC,WAAW,EACxB,QAAQ,EAAE,CAAC,CAAgC,EAAE,EAAE;gDAC7C,QAAQ,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;4CAChE,CAAC,GACD,GAC2B,IACL,EAE3B,KAAK,CAAC,iBAAiB,IAAI,CAC1B,KAAC,mBAAmB,IAClB,OAAO,EAAE,KAAK,CAAC,YAAY,EAC3B,cAAc,EAAE,mBAAmB,CAAC,OAAO,EAC3C,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,kBAAkB,EACzD,QAAQ,EAAE,EAAE,EACZ,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,UAAU,EACpB,WAAW,EAAE,CAAC,UAAmC,EAAE,EAAE;oCACnD,QAAQ,CAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;gCACpE,CAAC,GACD,CACH,IAC4B,CAChC,IACqB,IACnB,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import { useRef, useMemo, useEffect, useCallback, useReducer, ChangeEvent } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n Flex,\n StyledPrimary,\n StyledMenuItem,\n Icon,\n StyledIcon,\n useElement,\n useOuterEvent,\n Popover,\n Tooltip,\n Menu,\n Count,\n defaultThemeProp,\n createUID,\n useAfterInitialEffect,\n formatListToLocaleString,\n ForwardProps,\n useConfiguration,\n useI18n,\n ModalMethods,\n useModalManager\n} from '@pega/cosmos-react-core';\nimport BareRoleButton from '@pega/cosmos-react-core/lib/components/Button/BareRoleButton';\nimport { StyledMenuListHeader } from '@pega/cosmos-react-core/lib/components/Menu/Menu.styles';\nimport MultiSelectInput from '@pega/cosmos-react-core/lib/components/ComboBox/MultiSelectInput/MultiSelectInput';\n\nimport FeedModalList from './FeedModalList';\nimport {\n RecipientMenuItem,\n PostType,\n PostTypeMenuState,\n PostTypeMenuProps,\n FeedModalListProps,\n RecipientOption\n} from './Feed.types';\n\nconst StyledCountButton = styled(BareRoleButton)`\n display: inline-block;\n`;\n\nconst StyledCountBadgePopoverContent = styled.div(({ theme }) => {\n const {\n base: { spacing }\n } = theme;\n\n return css`\n padding: ${spacing};\n\n p:not(:last-child) {\n margin-bottom: ${spacing};\n }\n `;\n});\nStyledCountBadgePopoverContent.defaultProps = defaultThemeProp;\n\nconst StyledPostTypePopoverContent = styled.div`\n width: clamp(16rem, 60vw, 40rem);\n`;\n\nconst StyledSelectedInputContainer = styled.div(({ theme }) => {\n const {\n base: { spacing }\n } = theme;\n\n return css`\n margin: ${spacing} calc(2 * ${spacing}) calc(2 * ${spacing});\n `;\n});\nStyledSelectedInputContainer.defaultProps = defaultThemeProp;\n\nconst StyledRecipientBackButton = styled(StyledMenuListHeader)(({ theme }) => {\n const {\n base: {\n 'font-weight': { 'semi-bold': fontWeight },\n spacing\n }\n } = theme;\n\n return css`\n font-weight: ${fontWeight};\n padding: ${spacing} calc(2 * ${spacing});\n\n &:hover,\n &:focus {\n text-decoration: none;\n }\n\n && ${StyledIcon} {\n display: inline-block;\n margin-inline-end: ${spacing};\n }\n `;\n});\nStyledRecipientBackButton.defaultProps = defaultThemeProp;\n\nconst StyledRecipientMenuHeader = styled.div``;\n\nconst StyledTypeMenuToggle = styled(Button)(({ theme }) => {\n const {\n base: { spacing }\n } = theme;\n\n return css`\n margin-block-end: ${spacing};\n `;\n});\nStyledTypeMenuToggle.defaultProps = defaultThemeProp;\n\nconst StyledRecipientMenu = styled(Menu)(({ theme }) => {\n const {\n base: { spacing }\n } = theme;\n\n return css`\n ${StyledMenuItem} > button {\n padding: ${spacing} calc(2 * ${spacing});\n }\n `;\n});\nStyledRecipientMenu.defaultProps = defaultThemeProp;\n\nconst StyledPostTypePopover = styled(Popover)(({ theme }) => {\n const {\n base: {\n 'font-weight': { normal: fontWeight }\n }\n } = theme;\n return css`\n ${StyledPrimary} {\n font-weight: ${fontWeight};\n }\n `;\n});\nStyledPostTypePopover.defaultProps = defaultThemeProp;\n\nconst typeCopy = {\n post: {\n primary: 'Public post'\n },\n private: {\n primary: 'Private post'\n }\n};\n\nconst createRecipientMenuItem = (\n recipient: RecipientOption,\n selectedIds?: RecipientMenuItem['id'][]\n) => {\n const checkIds = selectedIds || [];\n const id = `option_${recipient.value}`;\n\n return {\n ...recipient,\n id,\n selected: checkIds.includes(id)\n };\n};\n\nconst getTypeMenuItems = (type: PostType): PostTypeMenuState['typeMenuItems'] => {\n return [\n {\n id: '1',\n primary: typeCopy.post.primary,\n selected: type === 'post',\n value: 'post'\n },\n {\n id: '2',\n primary: typeCopy.private.primary,\n selected: type === 'private',\n value: 'private'\n }\n ];\n};\n\nconst initialState: PostTypeMenuState = {\n postType: 'post',\n itemsLoading: false,\n showTypeMenu: false,\n showRecipientMenu: false,\n viewingRecipients: false,\n searchValue: '',\n typeMenuItems: getTypeMenuItems('post'),\n recipientMenuItems: [] as RecipientMenuItem[],\n multiSelectItems: [] as RecipientMenuItem[]\n};\n\nconst FeedNewPostTypeMenu = ({\n recipients,\n onSetPostType,\n onSelectedRecipientsUpdate,\n onRecipientSearch,\n reset,\n onReset,\n ...restProps\n}: PostTypeMenuProps & ForwardProps) => {\n const t = useI18n();\n const { locale } = useConfiguration();\n const { create } = useModalManager();\n const menuPopoverId = useMemo(() => createUID(), []);\n const recipientsModalRef = useRef<ModalMethods<FeedModalListProps>>();\n\n const multiSelectInputRef = useRef<HTMLInputElement>(null);\n const [toggleEl, setToggleEl] = useElement<HTMLButtonElement>();\n const [recipientCountEl, setRecipientCountEl] = useElement<HTMLElement>();\n const [typePopoverEl, setTypePopoverEl] = useElement<HTMLElement>(null);\n const [typeMenuPopoverTarget, setTypeMenuPopoverTarget] = useElement<HTMLButtonElement>(null);\n\n const reducer = (\n state: PostTypeMenuState,\n action: {\n type:\n | 'reset'\n | 'setPostType'\n | 'setShowTypeMenu'\n | 'setShowRecipientMenu'\n | 'setSearchValue'\n | 'setViewingRecipients'\n | 'setItemsLoading'\n | 'updateTypeMenuItems'\n | 'toggleTypeMenu'\n | 'removeRecipientViaMultiSelect'\n | 'selectRecipientViaMenu'\n | 'updateRecipientMenuItems'\n | 'resetUnappliedState';\n payload?: any;\n }\n ): PostTypeMenuState => {\n const type = action.type;\n const payload = action.payload;\n\n switch (type) {\n case 'reset': {\n return initialState;\n }\n case 'setPostType': {\n const postType = payload;\n const privateSelected = postType === 'private';\n\n return {\n ...state,\n postType,\n showTypeMenu: !privateSelected ? false : state.showTypeMenu,\n viewingRecipients: privateSelected ? true : state.viewingRecipients,\n multiSelectItems: initialState.multiSelectItems,\n searchValue: initialState.searchValue\n };\n }\n case 'setShowTypeMenu': {\n return {\n ...state,\n showTypeMenu: payload\n };\n }\n case 'setShowRecipientMenu': {\n return {\n ...state,\n showRecipientMenu: payload\n };\n }\n case 'setSearchValue': {\n return {\n ...state,\n searchValue: payload\n };\n }\n case 'setViewingRecipients': {\n return {\n ...state,\n viewingRecipients: payload\n };\n }\n case 'setItemsLoading': {\n return {\n ...state,\n itemsLoading: payload\n };\n }\n case 'updateTypeMenuItems': {\n return {\n ...state,\n typeMenuItems: getTypeMenuItems(state.postType)\n };\n }\n case 'toggleTypeMenu': {\n return {\n ...state,\n showTypeMenu: !state.showTypeMenu\n };\n }\n case 'removeRecipientViaMultiSelect': {\n const selectedId = payload;\n\n const multiSelectItems = state.multiSelectItems.reduce<RecipientMenuItem[]>(\n (acc, recipient) => {\n if (recipient.id === selectedId) return acc;\n\n return acc.concat([recipient]);\n },\n []\n );\n\n const recipientMenuItems = state.recipientMenuItems.map(item => {\n if (item.id === selectedId) {\n return {\n ...item,\n selected: false\n };\n }\n\n return {\n ...item\n };\n });\n\n return {\n ...state,\n multiSelectItems,\n recipientMenuItems\n };\n }\n case 'selectRecipientViaMenu': {\n const selectedId = payload;\n\n if (!state.multiSelectItems.some(item => item.id === selectedId)) {\n const selectedFromMenu = state.recipientMenuItems.filter(\n item => item.id === selectedId\n )[0];\n\n const multiSelectItems = state.multiSelectItems.concat([selectedFromMenu]);\n\n return {\n ...state,\n multiSelectItems,\n searchValue: ''\n };\n }\n\n return {\n ...state,\n searchValue: ''\n };\n }\n case 'updateRecipientMenuItems': {\n const selectedIds = state.multiSelectItems.map(item => item.id);\n\n return {\n ...state,\n itemsLoading: false,\n recipientMenuItems: recipients.map(recipient =>\n createRecipientMenuItem(recipient, selectedIds)\n )\n };\n }\n case 'resetUnappliedState': {\n const postType =\n state.postType === 'private' && state.multiSelectItems.length === 0\n ? 'post'\n : state.postType;\n\n const searchValue = '';\n\n return {\n ...state,\n postType,\n searchValue\n };\n }\n default:\n return {\n ...state\n };\n }\n };\n const [state, dispatch] = useReducer(reducer, initialState);\n\n const handleKeydownToggle = useCallback(\n (e: KeyboardEvent) => {\n if (e.key === 'Escape' && state.showTypeMenu) dispatch({ type: 'toggleTypeMenu' });\n },\n [state.showTypeMenu]\n );\n\n useOuterEvent('mousedown', [typePopoverEl, typeMenuPopoverTarget], () => {\n dispatch({ type: 'setShowTypeMenu', payload: false });\n });\n\n useEffect(() => {\n if (reset) {\n dispatch({ type: 'reset' });\n onReset();\n }\n }, [reset]);\n\n useEffect(() => {\n dispatch({ type: 'updateRecipientMenuItems' });\n }, [recipients]);\n\n useEffect(() => {\n onSelectedRecipientsUpdate(state.multiSelectItems);\n }, [state.multiSelectItems]);\n\n useEffect(() => {\n if (!state.showTypeMenu) {\n let timeoutId: ReturnType<typeof setTimeout>;\n if (state.postType === 'private') {\n // Timeout to prevent flash of recipients options when closing menu.\n timeoutId = setTimeout(() => {\n dispatch({ type: 'setViewingRecipients', payload: true });\n }, 100);\n }\n\n timeoutId = setTimeout(() => {\n // Timeout to prevent flash of type menu when resetting postType on close\n dispatch({ type: 'resetUnappliedState' });\n }, 100);\n\n return () => clearTimeout(timeoutId);\n }\n }, [state.showTypeMenu]);\n\n useEffect(() => {\n if (multiSelectInputRef.current) {\n multiSelectInputRef.current?.focus();\n }\n }, [multiSelectInputRef.current]);\n\n useEffect(() => {\n if (state.postType === 'private') {\n if (!state.viewingRecipients) {\n toggleEl?.focus();\n } else {\n multiSelectInputRef.current?.focus();\n }\n }\n }, [state.viewingRecipients]);\n\n useAfterInitialEffect(() => {\n onSetPostType(state.postType);\n dispatch({ type: 'updateTypeMenuItems' });\n\n if (state.postType === 'private') {\n multiSelectInputRef.current?.focus();\n }\n }, [state.postType]);\n\n useEffect(() => {\n const interactionTimeout = setTimeout(() => {\n onRecipientSearch(state.searchValue);\n dispatch({ type: 'setItemsLoading', payload: true });\n dispatch({ type: 'setShowRecipientMenu', payload: !!state.searchValue.length });\n }, 300);\n\n return () => clearTimeout(interactionTimeout);\n }, [state.searchValue]);\n\n useEffect(() => {\n toggleEl?.addEventListener('keydown', handleKeydownToggle);\n\n return () => toggleEl?.removeEventListener('keydown', handleKeydownToggle);\n }, [toggleEl, state.showTypeMenu]);\n\n useEffect(() => {\n multiSelectInputRef.current?.addEventListener('keydown', handleKeydownToggle);\n\n return () => multiSelectInputRef.current?.removeEventListener('keydown', handleKeydownToggle);\n }, [multiSelectInputRef.current, state.showTypeMenu]);\n\n const onRecipientsCountClick = () => {\n recipientsModalRef.current = create(FeedModalList, {\n count: state.multiSelectItems.length,\n heading: t('feed_recipients'),\n listItems: state.multiSelectItems.map(item => ({\n id: item.id,\n primary: item.primary,\n secondary: item.secondary,\n visual: item.visual\n }))\n });\n };\n\n return (\n <Flex container={{ gap: 0.5 }}>\n <StyledTypeMenuToggle\n {...restProps}\n onClick={() => {\n dispatch({ type: 'toggleTypeMenu' });\n }}\n ref={setToggleEl}\n variant='link'\n aria-haspopup='menu'\n aria-expanded={state.showTypeMenu}\n >\n <span ref={setTypeMenuPopoverTarget}>{typeCopy[state.postType].primary}</span>\n <Icon name='arrow-micro-down' />\n </StyledTypeMenuToggle>\n\n {state.postType === 'private' && state.multiSelectItems.length > 0 && (\n <>\n <StyledCountButton\n ref={setRecipientCountEl}\n onClick={onRecipientsCountClick}\n aria-label={`${t('feed_private_post')} ${t(\n 'feed_recipients'\n )} ${formatListToLocaleString(\n state.multiSelectItems.map(item => item.primary).slice(0, 2),\n t,\n locale,\n {\n count: state.multiSelectItems.length\n }\n )}`}\n tabIndex={0}\n >\n <Count>{state.multiSelectItems.length}</Count>\n </StyledCountButton>\n <Tooltip\n target={recipientCountEl}\n showDelay='none'\n hideDelay='none'\n describeTarget={false}\n >\n {formatListToLocaleString(\n state.multiSelectItems.map(item => item.primary).slice(0, 2),\n t,\n locale,\n {\n count: state.multiSelectItems.length,\n separator: '\\n'\n }\n )}\n </Tooltip>\n </>\n )}\n\n <StyledPostTypePopover\n id={menuPopoverId}\n ref={setTypePopoverEl}\n target={typeMenuPopoverTarget}\n show={state.showTypeMenu}\n placement='bottom-start'\n >\n {(state.postType !== 'private' || !state.viewingRecipients) && (\n <Menu\n items={state.typeMenuItems}\n focusControlEl={toggleEl || undefined}\n mode='single-select'\n onItemClick={selectedId => {\n const postType = state.typeMenuItems.find(item => item.id === selectedId)!.value;\n dispatch({ type: 'setPostType', payload: postType });\n }}\n onItemExpand={() => {\n if (state.postType === 'private') {\n dispatch({ type: 'setViewingRecipients', payload: true });\n } else {\n dispatch({ type: 'setPostType', payload: 'private' });\n }\n }}\n />\n )}\n\n {state.postType === 'private' && state.viewingRecipients && (\n <StyledPostTypePopoverContent>\n <StyledRecipientMenuHeader>\n <Button\n as={StyledRecipientBackButton}\n variant='text'\n aria-label='close submenu'\n onClick={() => {\n dispatch({ type: 'setViewingRecipients', payload: false });\n }}\n >\n <Icon name='caret-left' />\n {typeCopy.private.primary}\n </Button>\n\n <StyledSelectedInputContainer>\n <MultiSelectInput\n ref={multiSelectInputRef}\n selected={state.multiSelectItems.map(item => ({\n id: item.id,\n text: item.primary\n }))}\n onRemove={(selectedId: RecipientMenuItem['id']) => {\n dispatch({ type: 'removeRecipientViaMultiSelect', payload: selectedId });\n }}\n value={state.searchValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n dispatch({ type: 'setSearchValue', payload: e.target.value });\n }}\n />\n </StyledSelectedInputContainer>\n </StyledRecipientMenuHeader>\n\n {state.showRecipientMenu && (\n <StyledRecipientMenu\n loading={state.itemsLoading}\n focusControlEl={multiSelectInputRef.current}\n items={state.itemsLoading ? [] : state.recipientMenuItems}\n scrollAt={11}\n mode='action'\n emptyText='No items'\n onItemClick={(selectedId: RecipientMenuItem['id']) => {\n dispatch({ type: 'selectRecipientViaMenu', payload: selectedId });\n }}\n />\n )}\n </StyledPostTypePopoverContent>\n )}\n </StyledPostTypePopover>\n </Flex>\n );\n};\n\nexport default FeedNewPostTypeMenu;\n"]}
@@ -1,8 +0,0 @@
1
- import { FC } from 'react';
2
- import { ForwardProps } from '@pega/cosmos-react-core';
3
- import { FeedPostProps } from './Feed.types';
4
- export declare const StyledFeedPost: import("styled-components").StyledComponent<import("react").FunctionComponent<import("@pega/cosmos-react-core").CardProps & ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
5
- export declare const StyledReplies: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
6
- declare const FeedPost: FC<ForwardProps & FeedPostProps>;
7
- export default FeedPost;
8
- //# sourceMappingURL=FeedPost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeedPost.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedPost.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAsE,MAAM,OAAO,CAAC;AAG/F,OAAO,EAOL,YAAY,EAIb,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQ7C,eAAO,MAAM,cAAc,iMAI1B,CAAC;AAmBF,eAAO,MAAM,aAAa,yGAQzB,CAAC;AAIF,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,YAAY,GAAG,aAAa,CAmM9C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,85 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useEffect, useRef, useContext, useMemo } from 'react';
3
- import styled, { css } from 'styled-components';
4
- import { Button, Card, CardContent, Flex, registerIcon, defaultThemeProp, useI18n, Progress, usePrevious } from '@pega/cosmos-react-core';
5
- import * as arrowMicroDownIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/arrow-micro-down.icon';
6
- import * as caretLeftIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/caret-left.icon';
7
- import FeedAttachments from './FeedAttachments';
8
- import FeedContent from './FeedContent';
9
- import FeedReplyInput, { StyledReplyInputContainer } from './FeedReplyInput';
10
- import { FeedContext, FeedReplyContext } from './Feed.context';
11
- import FeedContentHeader from './FeedContentHeader';
12
- import FeedContentFooter from './FeedContentFooter';
13
- import FeedEditRegion from './FeedEditRegion';
14
- import { StyledFeedReplyContainer } from './FeedReply';
15
- registerIcon(arrowMicroDownIcon, caretLeftIcon);
16
- export const StyledFeedPost = styled(Card)(({ theme }) => css `
17
- margin-block-start: calc(2 * ${theme.base.spacing});
18
- `);
19
- StyledFeedPost.defaultProps = defaultThemeProp;
20
- const StyledPostContent = styled.div(({ showLines, theme }) => {
21
- return css `
22
- padding-inline-start: calc(6 * ${theme.base.spacing});
23
-
24
- ${showLines &&
25
- css `
26
- margin-inline-start: calc(2.5 * ${theme.base.spacing});
27
- border-inline-start: solid 0.0625rem ${theme.base.palette['border-line']};
28
- padding-inline-start: calc(3.5 * ${theme.base.spacing});
29
- `}
30
- `;
31
- });
32
- StyledPostContent.defaultProps = defaultThemeProp;
33
- export const StyledReplies = styled.div(({ theme }) => css `
34
- margin-inline-start: calc(-1.75 * ${theme.base.spacing});
35
-
36
- ${StyledFeedReplyContainer}, ${StyledReplyInputContainer} {
37
- padding-block-start: ${theme.base.spacing};
38
- }
39
- `);
40
- StyledReplies.defaultProps = defaultThemeProp;
41
- const FeedPost = (props) => {
42
- const { id, avatarSrc, fullname, username, postTimestamp, content, postType = 'public', recipients, recipientsCount, attachments, liked, icon, postContext, userStatus, likes, likeCount, interactionsEnabled, maxContentHeight = Infinity, onMouseEnter, onMouseLeave, onCommentClick, onLikeClick, onLikeCountInteraction, likesLoading, onLoadMoreLikes, onRecipientInteraction, recipientsLoading, onLoadMoreRecipients, onUserClick, onShowMoreClick, newReplyField, menuItems, onEditSubmit, edited = false, editTimestamp, replies = [], replyInput, replyInputShown, replyCount, repliesLoading, onShowLessReplies, onShowMoreReplies, ...restProps } = props;
43
- const { announce } = useContext(FeedContext);
44
- const variant = 'post';
45
- const t = useI18n();
46
- const [editMode, setEditMode] = useState(false);
47
- const [emptyEditText, setEmptyEditText] = useState(false);
48
- const [replyInputOpen, setReplyInputOpen] = useState(false);
49
- const [replyInputRef, setReplyInputRef] = useState(null);
50
- const prevReplies = usePrevious(replies);
51
- const suppressNextAnnouncement = useRef(false);
52
- useEffect(() => {
53
- if ((replyInputOpen || replyInputShown) && replyInputRef) {
54
- replyInputRef.current?.focus();
55
- }
56
- }, [replyInputOpen, replyInputShown, replyInputRef]);
57
- const replyCtxValue = useMemo(() => ({ onShowReplyInput: () => setReplyInputOpen(true) }), []);
58
- useEffect(() => {
59
- if (prevReplies) {
60
- const difference = prevReplies.length - replies.length;
61
- if (difference > 0 && !suppressNextAnnouncement.current) {
62
- const timeoutId = announce(t('feed_comment_removed'));
63
- return () => clearTimeout(timeoutId);
64
- }
65
- suppressNextAnnouncement.current = false;
66
- }
67
- }, [replies]);
68
- const hasReplies = !!replies?.length;
69
- return (_jsx(FeedReplyContext.Provider, { value: replyCtxValue, children: _jsx(StyledFeedPost, { ...restProps, onMouseEnter: () => {
70
- onMouseEnter?.({ id });
71
- }, onMouseLeave: () => {
72
- onMouseLeave?.({ id });
73
- }, children: _jsxs(CardContent, { children: [_jsx(FeedContentHeader, { variant: variant, id: id, fullname: fullname, username: username, postTimestamp: postTimestamp, content: content, avatarSrc: avatarSrc, icon: icon, userStatus: userStatus, postType: postType, postContext: postContext, recipients: recipients, recipientsCount: recipientsCount, menuItems: menuItems, edited: edited, editTimestamp: editTimestamp, recipientsLoading: recipientsLoading, onEditSubmit: onEditSubmit, onLoadMoreRecipients: onLoadMoreRecipients, onRecipientInteraction: onRecipientInteraction, onUserClick: onUserClick, setEditMode: setEditMode }), _jsxs(StyledPostContent, { showLines: hasReplies || replyInputOpen, children: [_jsxs(Flex, { container: { direction: 'column', pad: [0, editMode ? 0 : 2, 0, 0] }, item: { grow: 1 }, children: [editMode ? (_jsx(FeedEditRegion, { variant: variant, id: id, content: content, setEditMode: setEditMode, onEditSubmit: onEditSubmit, emptyEditText: emptyEditText, setEmptyEditText: setEmptyEditText })) : (_jsx(FeedContent, { maxContentHeight: maxContentHeight, children: content })), _jsx(FeedAttachments, { variant: variant, attachments: attachments, readOnly: true })] }), _jsx(FeedContentFooter, { variant: variant, id: id, username: username, liked: liked, likes: likes, likeCount: likeCount, interactionsEnabled: interactionsEnabled, likesLoading: likesLoading, replies: replies, replyCount: replyCount, repliesLoading: repliesLoading, onCommentClick: onCommentClick, onLikeClick: onLikeClick, onLikeCountInteraction: onLikeCountInteraction, onLoadMoreLikes: onLoadMoreLikes, onShowMoreReplies: onShowMoreReplies, onShowLessReplies: onShowLessReplies, replyInputOpen: replyInputOpen, setReplyInputOpen: setReplyInputOpen }), _jsxs(StyledReplies, { children: [hasReplies && replies, replyInputShown ||
74
- (replyInputOpen && (_jsx(FeedReplyInput, { onSetInputRef: ({ ref }) => {
75
- setReplyInputRef(ref);
76
- }, id: id, attachments: replyInput.attachments, onFilesAdded: replyInput.onFilesAdded, onSubmit: e => {
77
- setReplyInputOpen(false);
78
- replyInput.onSubmit(e);
79
- } })))] }), onShowLessReplies && !!replies.length && (_jsxs(Flex, { container: { justify: 'center', pad: [0, 0, 1], gap: 1 }, children: [_jsx(Button, { variant: 'link', onClick: () => {
80
- onShowLessReplies({ id });
81
- suppressNextAnnouncement.current = true;
82
- }, children: t('show_less') }), repliesLoading && _jsx(Progress, { placement: 'inline' })] }))] })] }) }) }));
83
- };
84
- export default FeedPost;
85
- //# sourceMappingURL=FeedPost.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeedPost.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedPost.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,SAAS,EAAoB,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/F,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,gBAAgB,EAEhB,OAAO,EACP,QAAQ,EACR,WAAW,EACZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,kBAAkB,MAAM,yEAAyE,CAAC;AAC9G,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AAEnG,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,cAAc,EAAE,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,iBAAiB,MAAM,qB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C1C,CAAC,YAEA,CAAC,CAAC,WAAW,CAAC,GACR,EACR,cAAc,IAAI,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,IAC7C,CACR,IACiB,IACR,GACC,GACS,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import { FC, useState, useEffect, MutableRefObject, useRef, useContext, useMemo } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n Card,\n CardContent,\n Flex,\n registerIcon,\n defaultThemeProp,\n ForwardProps,\n useI18n,\n Progress,\n usePrevious\n} from '@pega/cosmos-react-core';\nimport { RichTextEditorState } from '@pega/cosmos-react-rte';\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';\n\nimport FeedAttachments from './FeedAttachments';\nimport FeedContent from './FeedContent';\nimport FeedReplyInput, { StyledReplyInputContainer } from './FeedReplyInput';\nimport { FeedContext, FeedReplyContext } from './Feed.context';\nimport { FeedPostProps } from './Feed.types';\nimport FeedContentHeader from './FeedContentHeader';\nimport FeedContentFooter from './FeedContentFooter';\nimport FeedEditRegion from './FeedEditRegion';\nimport { StyledFeedReplyContainer } from './FeedReply';\n\nregisterIcon(arrowMicroDownIcon, caretLeftIcon);\n\nexport const StyledFeedPost = styled(Card)(\n ({ theme }) => css`\n margin-block-start: calc(2 * ${theme.base.spacing});\n `\n);\n\nStyledFeedPost.defaultProps = defaultThemeProp;\n\nconst StyledPostContent = styled.div<{ showLines: boolean }>(({ showLines, theme }) => {\n return css`\n padding-inline-start: calc(6 * ${theme.base.spacing});\n\n ${showLines &&\n css`\n margin-inline-start: calc(2.5 * ${theme.base.spacing});\n border-inline-start: solid 0.0625rem ${theme.base.palette['border-line']};\n padding-inline-start: calc(3.5 * ${theme.base.spacing});\n `}\n `;\n});\n\nStyledPostContent.defaultProps = defaultThemeProp;\n\nexport const StyledReplies = styled.div(\n ({ theme }) => css`\n margin-inline-start: calc(-1.75 * ${theme.base.spacing});\n\n ${StyledFeedReplyContainer}, ${StyledReplyInputContainer} {\n padding-block-start: ${theme.base.spacing};\n }\n `\n);\n\nStyledReplies.defaultProps = defaultThemeProp;\n\nconst FeedPost: FC<ForwardProps & FeedPostProps> = (props: ForwardProps & FeedPostProps) => {\n const {\n id,\n avatarSrc,\n fullname,\n username,\n postTimestamp,\n content,\n postType = 'public',\n recipients,\n recipientsCount,\n attachments,\n liked,\n icon,\n postContext,\n userStatus,\n likes,\n likeCount,\n interactionsEnabled,\n maxContentHeight = Infinity,\n onMouseEnter,\n onMouseLeave,\n onCommentClick,\n onLikeClick,\n onLikeCountInteraction,\n likesLoading,\n onLoadMoreLikes,\n onRecipientInteraction,\n recipientsLoading,\n onLoadMoreRecipients,\n onUserClick,\n onShowMoreClick,\n newReplyField,\n menuItems,\n onEditSubmit,\n edited = false,\n editTimestamp,\n replies = [],\n replyInput,\n replyInputShown,\n replyCount,\n repliesLoading,\n onShowLessReplies,\n onShowMoreReplies,\n ...restProps\n } = props;\n const { announce } = useContext(FeedContext);\n const variant = 'post';\n\n const t = useI18n();\n const [editMode, setEditMode] = useState(false);\n const [emptyEditText, setEmptyEditText] = useState(false);\n const [replyInputOpen, setReplyInputOpen] = useState(false);\n const [replyInputRef, setReplyInputRef] = useState<MutableRefObject<\n RichTextEditorState | undefined\n > | null>(null);\n const prevReplies = usePrevious(replies);\n const suppressNextAnnouncement = useRef(false);\n\n useEffect(() => {\n if ((replyInputOpen || replyInputShown) && replyInputRef) {\n replyInputRef.current?.focus();\n }\n }, [replyInputOpen, replyInputShown, replyInputRef]);\n\n const replyCtxValue = useMemo(() => ({ onShowReplyInput: () => setReplyInputOpen(true) }), []);\n\n useEffect(() => {\n if (prevReplies) {\n const difference = prevReplies.length - replies.length;\n if (difference > 0 && !suppressNextAnnouncement.current) {\n const timeoutId = announce(t('feed_comment_removed'));\n return () => clearTimeout(timeoutId);\n }\n suppressNextAnnouncement.current = false;\n }\n }, [replies]);\n\n const hasReplies = !!replies?.length;\n\n return (\n <FeedReplyContext.Provider value={replyCtxValue}>\n <StyledFeedPost\n {...restProps}\n onMouseEnter={() => {\n onMouseEnter?.({ id });\n }}\n onMouseLeave={() => {\n onMouseLeave?.({ id });\n }}\n >\n <CardContent>\n <FeedContentHeader\n variant={variant}\n id={id}\n fullname={fullname}\n username={username}\n postTimestamp={postTimestamp}\n content={content}\n avatarSrc={avatarSrc}\n icon={icon}\n userStatus={userStatus}\n postType={postType}\n postContext={postContext}\n recipients={recipients}\n recipientsCount={recipientsCount}\n menuItems={menuItems}\n edited={edited}\n editTimestamp={editTimestamp}\n recipientsLoading={recipientsLoading}\n onEditSubmit={onEditSubmit}\n onLoadMoreRecipients={onLoadMoreRecipients}\n onRecipientInteraction={onRecipientInteraction}\n onUserClick={onUserClick}\n setEditMode={setEditMode}\n />\n <StyledPostContent showLines={hasReplies || replyInputOpen}>\n <Flex\n container={{ direction: 'column', pad: [0, editMode ? 0 : 2, 0, 0] }}\n item={{ grow: 1 }}\n >\n {editMode ? (\n <FeedEditRegion\n variant={variant}\n id={id}\n content={content}\n setEditMode={setEditMode}\n onEditSubmit={onEditSubmit}\n emptyEditText={emptyEditText}\n setEmptyEditText={setEmptyEditText}\n />\n ) : (\n <FeedContent maxContentHeight={maxContentHeight}>{content}</FeedContent>\n )}\n <FeedAttachments variant={variant} attachments={attachments} readOnly />\n </Flex>\n <FeedContentFooter\n variant={variant}\n id={id}\n username={username}\n liked={liked}\n likes={likes}\n likeCount={likeCount}\n interactionsEnabled={interactionsEnabled}\n likesLoading={likesLoading}\n replies={replies}\n replyCount={replyCount}\n repliesLoading={repliesLoading}\n onCommentClick={onCommentClick}\n onLikeClick={onLikeClick}\n onLikeCountInteraction={onLikeCountInteraction}\n onLoadMoreLikes={onLoadMoreLikes}\n onShowMoreReplies={onShowMoreReplies}\n onShowLessReplies={onShowLessReplies}\n replyInputOpen={replyInputOpen}\n setReplyInputOpen={setReplyInputOpen}\n />\n\n <StyledReplies>\n {hasReplies && replies}\n {replyInputShown ||\n (replyInputOpen && (\n <FeedReplyInput\n onSetInputRef={({ ref }) => {\n setReplyInputRef(ref);\n }}\n id={id}\n attachments={replyInput.attachments}\n onFilesAdded={replyInput.onFilesAdded}\n onSubmit={e => {\n setReplyInputOpen(false);\n replyInput.onSubmit(e);\n }}\n />\n ))}\n </StyledReplies>\n {onShowLessReplies && !!replies.length && (\n <Flex container={{ justify: 'center', pad: [0, 0, 1], gap: 1 }}>\n <Button\n variant='link'\n onClick={() => {\n onShowLessReplies({ id });\n suppressNextAnnouncement.current = true;\n }}\n >\n {t('show_less')}\n </Button>\n {repliesLoading && <Progress placement='inline' />}\n </Flex>\n )}\n </StyledPostContent>\n </CardContent>\n </StyledFeedPost>\n </FeedReplyContext.Provider>\n );\n};\n\nexport default FeedPost;\n"]}
@@ -1,7 +0,0 @@
1
- import { FC } from 'react';
2
- import { ForwardProps } from '@pega/cosmos-react-core';
3
- import { FeedReplyProps } from './Feed.types';
4
- export declare const StyledFeedReplyContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
5
- declare const FeedReply: FC<ForwardProps & FeedReplyProps>;
6
- export default FeedReply;
7
- //# sourceMappingURL=FeedReply.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FeedReply.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAGrC,OAAO,EAAwC,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK7F,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAS9C,eAAO,MAAM,wBAAwB,yGAAe,CAAC;AAcrD,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,YAAY,GAAG,cAAc,CAoGhD,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,36 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
- import styled, { css } from 'styled-components';
4
- import { Flex, registerIcon, defaultThemeProp } from '@pega/cosmos-react-core';
5
- import * as chatIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chat.icon';
6
- import * as thumbsUpSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up-solid.icon';
7
- import * as thumbsUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up.icon';
8
- import FeedAttachments from './FeedAttachments';
9
- import FeedContent from './FeedContent';
10
- import FeedContentHeader from './FeedContentHeader';
11
- import FeedContentFooter from './FeedContentFooter';
12
- import FeedEditRegion from './FeedEditRegion';
13
- registerIcon(chatIcon, thumbsUpSolidIcon, thumbsUpIcon);
14
- export const StyledFeedReplyContainer = styled.div ``;
15
- StyledFeedReplyContainer.defaultProps = defaultThemeProp;
16
- const StyledReplyContent = styled.div(({ theme }) => {
17
- return css `
18
- margin-inline-start: calc(2 * ${theme.base.spacing});
19
- border-inline-start: solid 0.0625rem ${theme.base.palette['border-line']};
20
- padding-inline-start: calc(3 * ${theme.base.spacing});
21
- `;
22
- });
23
- StyledReplyContent.defaultProps = defaultThemeProp;
24
- const FeedReply = (props) => {
25
- const { id, avatarSrc, postTimestamp, content, attachments, username, fullname, liked, likes, likeCount, interactionsEnabled, icon, userStatus, maxContentHeight = Infinity, menuItems, onEditSubmit, edited = false, editTimestamp, onMouseEnter, onMouseLeave, onCommentClick, onLikeClick, onLikeCountInteraction, onLoadMoreLikes, likesLoading, onUserClick, ...restProps } = props;
26
- const variant = 'reply';
27
- const [editMode, setEditMode] = useState(false);
28
- const [emptyEditText, setEmptyEditText] = useState(false);
29
- return (_jsxs(StyledFeedReplyContainer, { onMouseEnter: () => {
30
- onMouseEnter?.({ id });
31
- }, onMouseLeave: () => {
32
- onMouseLeave?.({ id });
33
- }, ...restProps, children: [_jsx(FeedContentHeader, { variant: variant, id: id, fullname: fullname, username: username, postTimestamp: postTimestamp, content: content, avatarSrc: avatarSrc, icon: icon, userStatus: userStatus, menuItems: menuItems, edited: edited, editTimestamp: editTimestamp, onEditSubmit: onEditSubmit, onUserClick: onUserClick, setEditMode: setEditMode }), _jsxs(StyledReplyContent, { children: [_jsxs(Flex, { container: { direction: 'column', pad: [0, editMode ? 0 : 2, 0, 0] }, item: { grow: 1 }, children: [editMode ? (_jsx(FeedEditRegion, { variant: variant, id: id, content: content, setEditMode: setEditMode, onEditSubmit: onEditSubmit, emptyEditText: emptyEditText, setEmptyEditText: setEmptyEditText })) : (_jsx(FeedContent, { maxContentHeight: maxContentHeight, children: content })), _jsx(FeedAttachments, { variant: variant, attachments: attachments, readOnly: true })] }), _jsx(FeedContentFooter, { variant: variant, id: id, username: username, liked: liked, likes: likes, likeCount: likeCount, interactionsEnabled: interactionsEnabled, likesLoading: likesLoading, onCommentClick: onCommentClick, onLikeClick: onLikeClick, onLikeCountInteraction: onLikeCountInteraction, onLoadMoreLikes: onLoadMoreLikes })] })] }));
34
- };
35
- export default FeedReply;
36
- //# sourceMappingURL=FeedReply.js.map