@pega/cosmos-react-social 4.0.0-dev.20.0 → 4.0.0-dev.22.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 (96) hide show
  1. package/lib/components/Chat/SuggestedReplyPicker.d.ts +6 -0
  2. package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
  3. package/lib/components/Chat/SuggestedReplyPicker.js +32 -34
  4. package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
  5. package/lib/components/Chat/index.d.ts +9 -5
  6. package/lib/components/Chat/index.d.ts.map +1 -1
  7. package/lib/components/Chat/index.js.map +1 -1
  8. package/lib/components/Email/index.d.ts +1 -1
  9. package/lib/components/Email/index.d.ts.map +1 -1
  10. package/lib/components/Email/index.js.map +1 -1
  11. package/lib/components/Feed/Feed.context.d.ts +2 -1
  12. package/lib/components/Feed/Feed.context.d.ts.map +1 -1
  13. package/lib/components/Feed/Feed.context.js.map +1 -1
  14. package/lib/components/Feed/Feed.d.ts +3 -53
  15. package/lib/components/Feed/Feed.d.ts.map +1 -1
  16. package/lib/components/Feed/Feed.js +27 -29
  17. package/lib/components/Feed/Feed.js.map +1 -1
  18. package/lib/components/Feed/Feed.types.d.ts +330 -0
  19. package/lib/components/Feed/Feed.types.d.ts.map +1 -0
  20. package/lib/components/Feed/Feed.types.js +2 -0
  21. package/lib/components/Feed/Feed.types.js.map +1 -0
  22. package/lib/components/Feed/FeedAnnouncer.d.ts +2 -3
  23. package/lib/components/Feed/FeedAnnouncer.d.ts.map +1 -1
  24. package/lib/components/Feed/FeedAnnouncer.js.map +1 -1
  25. package/lib/components/Feed/FeedAttachments.d.ts +3 -9
  26. package/lib/components/Feed/FeedAttachments.d.ts.map +1 -1
  27. package/lib/components/Feed/FeedAttachments.js +17 -10
  28. package/lib/components/Feed/FeedAttachments.js.map +1 -1
  29. package/lib/components/Feed/FeedButton.d.ts +0 -1
  30. package/lib/components/Feed/FeedButton.d.ts.map +1 -1
  31. package/lib/components/Feed/FeedButton.js +2 -10
  32. package/lib/components/Feed/FeedButton.js.map +1 -1
  33. package/lib/components/Feed/FeedContent.d.ts +2 -10
  34. package/lib/components/Feed/FeedContent.d.ts.map +1 -1
  35. package/lib/components/Feed/FeedContent.js +8 -1
  36. package/lib/components/Feed/FeedContent.js.map +1 -1
  37. package/lib/components/Feed/FeedContentFooter.d.ts +5 -0
  38. package/lib/components/Feed/FeedContentFooter.d.ts.map +1 -0
  39. package/lib/components/Feed/FeedContentFooter.js +34 -0
  40. package/lib/components/Feed/FeedContentFooter.js.map +1 -0
  41. package/lib/components/Feed/FeedContentHeader.d.ts +5 -0
  42. package/lib/components/Feed/FeedContentHeader.d.ts.map +1 -0
  43. package/lib/components/Feed/FeedContentHeader.js +101 -0
  44. package/lib/components/Feed/FeedContentHeader.js.map +1 -0
  45. package/lib/components/Feed/FeedEditRegion.d.ts +6 -0
  46. package/lib/components/Feed/FeedEditRegion.d.ts.map +1 -0
  47. package/lib/components/Feed/FeedEditRegion.js +46 -0
  48. package/lib/components/Feed/FeedEditRegion.js.map +1 -0
  49. package/lib/components/Feed/FeedInputRegion.d.ts +8 -0
  50. package/lib/components/Feed/FeedInputRegion.d.ts.map +1 -0
  51. package/lib/components/Feed/FeedInputRegion.js +86 -0
  52. package/lib/components/Feed/FeedInputRegion.js.map +1 -0
  53. package/lib/components/Feed/FeedLikeButton.d.ts +5 -17
  54. package/lib/components/Feed/FeedLikeButton.d.ts.map +1 -1
  55. package/lib/components/Feed/FeedLikeButton.js +44 -30
  56. package/lib/components/Feed/FeedLikeButton.js.map +1 -1
  57. package/lib/components/Feed/FeedModalList.d.ts +1 -13
  58. package/lib/components/Feed/FeedModalList.d.ts.map +1 -1
  59. package/lib/components/Feed/FeedModalList.js +5 -2
  60. package/lib/components/Feed/FeedModalList.js.map +1 -1
  61. package/lib/components/Feed/FeedNewPost.d.ts +1 -30
  62. package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
  63. package/lib/components/Feed/FeedNewPost.js +7 -85
  64. package/lib/components/Feed/FeedNewPost.js.map +1 -1
  65. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +2 -28
  66. package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -1
  67. package/lib/components/Feed/FeedNewPostTypeMenu.js +2 -2
  68. package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
  69. package/lib/components/Feed/FeedPost.d.ts +2 -4
  70. package/lib/components/Feed/FeedPost.d.ts.map +1 -1
  71. package/lib/components/Feed/FeedPost.js +96 -159
  72. package/lib/components/Feed/FeedPost.js.map +1 -1
  73. package/lib/components/Feed/FeedReply.d.ts +1 -4
  74. package/lib/components/Feed/FeedReply.d.ts.map +1 -1
  75. package/lib/components/Feed/FeedReply.js +56 -138
  76. package/lib/components/Feed/FeedReply.js.map +1 -1
  77. package/lib/components/Feed/FeedReplyInput.d.ts +2 -27
  78. package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
  79. package/lib/components/Feed/FeedReplyInput.js +9 -96
  80. package/lib/components/Feed/FeedReplyInput.js.map +1 -1
  81. package/lib/components/Feed/FeedRichText.d.ts +1 -4
  82. package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
  83. package/lib/components/Feed/FeedRichText.js +3 -8
  84. package/lib/components/Feed/FeedRichText.js.map +1 -1
  85. package/lib/components/Feed/index.d.ts +4 -7
  86. package/lib/components/Feed/index.d.ts.map +1 -1
  87. package/lib/components/Feed/index.js.map +1 -1
  88. package/package.json +10 -12
  89. package/lib/components/Feed/FeedPost.types.d.ts +0 -105
  90. package/lib/components/Feed/FeedPost.types.d.ts.map +0 -1
  91. package/lib/components/Feed/FeedPost.types.js +0 -2
  92. package/lib/components/Feed/FeedPost.types.js.map +0 -1
  93. package/lib/components/Feed/FeedReply.types.d.ts +0 -70
  94. package/lib/components/Feed/FeedReply.types.d.ts.map +0 -1
  95. package/lib/components/Feed/FeedReply.types.js +0 -2
  96. package/lib/components/Feed/FeedReply.types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FeedReply.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAuD,MAAM,OAAO,CAAC;AAGhF,OAAO,EAQL,YAAY,EAUb,MAAM,yBAAyB,CAAC;AAUjC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAYnD,eAAO,MAAM,sBAAsB,yGAQjC,CAAC;AAIH,eAAO,MAAM,mBAAmB,4GAO9B,CAAC;AAIH,eAAO,MAAM,kBAAkB,4GAE9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,yGA2BnC,CAAC;AAIH,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,YAAY,GAAG,cAAc,CA+PhD,CAAC;AAEF,eAAe,SAAS,CAAC"}
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,CA0GhD,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,155 +1,73 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useContext, useState, useRef, useEffect } from 'react';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import { Avatar, Button, Flex, Icon, registerIcon, MenuButton, defaultThemeProp, MetaList, useI18n, useOuterEvent, useElement, Text, Tooltip, DateTimeDisplay, useConfiguration } from '@pega/cosmos-react-core';
5
- import { StyledAvatar } from '@pega/cosmos-react-core/lib/components/Avatar/Avatar';
6
- import BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';
7
- import { StyledRichTextEditor } from '@pega/cosmos-react-rte';
4
+ import { Flex, registerIcon, defaultThemeProp } from '@pega/cosmos-react-core';
8
5
  import * as chatIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chat.icon';
9
6
  import * as thumbsUpSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up-solid.icon';
10
7
  import * as thumbsUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up.icon';
11
- import { parseToDate } from '@pega/cosmos-react-core/lib/components/DateTime/Input/utils';
12
- import { formatDateTime } from '@pega/cosmos-react-core/lib/components/DateTime/utils';
13
8
  import FeedAttachments from './FeedAttachments';
14
- import FeedButton from './FeedButton';
15
9
  import FeedContent from './FeedContent';
16
- import { FeedContext, FeedReplyContext } from './Feed.context';
17
- import FeedRichText from './FeedRichText';
18
- import { StyledFeedReply } from './FeedReplyInput';
19
- import { FeedLikeButton } from './FeedLikeButton';
10
+ import FeedContentHeader from './FeedContentHeader';
11
+ import FeedContentFooter from './FeedContentFooter';
12
+ import FeedEditRegion from './FeedEditRegion';
20
13
  registerIcon(chatIcon, thumbsUpSolidIcon, thumbsUpIcon);
21
- export const StyledFeedReplyContent = styled.div(props => {
22
- const { theme } = props;
23
- return css `
24
- background-color: ${theme.base.palette['secondary-background']};
25
- border-radius: calc(2 * ${theme.base['border-radius']});
26
- padding: calc(1.5 * ${theme.base.spacing});
27
- `;
28
- });
29
- StyledFeedReplyContent.defaultProps = defaultThemeProp;
30
- export const StyledFeedReplyUser = styled.button(props => {
31
- const { theme } = props;
32
- return css `
33
- font-weight: ${theme.base['font-weight']['semi-bold']};
34
- margin-inline-end: ${theme.base.spacing};
35
- `;
36
- });
37
- StyledFeedReplyUser.defaultProps = defaultThemeProp;
38
- export const StyledVisualButton = styled.button `
39
- height: min-content;
40
- `;
41
- export const StyledFeedReplyContainer = styled.div(props => {
42
- const { theme } = props;
14
+ export const StyledFeedReplyContainer = styled.div ``;
15
+ StyledFeedReplyContainer.defaultProps = defaultThemeProp;
16
+ const StyledReplyContent = styled.div(({ theme }) => {
43
17
  return css `
44
- ${StyledAvatar} {
45
- margin-inline-end: ${theme.base.spacing};
46
- }
47
-
48
- ${StyledFeedReplyContent} {
49
- margin-bottom: calc(0.5 * ${theme.base.spacing});
50
- }
51
-
52
- ${StyledFeedReply} {
53
- &:focus-within {
54
- border-color: ${theme.base.palette.interactive};
55
- }
56
- }
57
-
58
- ${StyledRichTextEditor} {
59
- padding-top: calc(0.5 * ${theme.base.spacing});
60
- padding-bottom: ${theme.base.spacing};
61
-
62
- &:focus-within {
63
- box-shadow: none;
64
- }
65
- }
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});
66
21
  `;
67
22
  });
68
- StyledFeedReplyContainer.defaultProps = defaultThemeProp;
23
+ StyledReplyContent.defaultProps = defaultThemeProp;
69
24
  const FeedReply = (props) => {
70
- const { id, info, interactionInfo, maxContentHeight = Infinity, menuItems, onEditSubmit, edited = false, editTimestamp, onMouseEnter, onMouseLeave, onCommentClick, onLikeClick, onLikeCountInteraction, onLoadMoreLikes, likesLoading, onUserClick, ...restProps } = props;
71
- const { avatarSrc, postTimestamp, content, attachments, username, fullname, fullnameLabel, liked, icon, userStatus } = info;
72
- const { likes = [], likeCount = 0, likeLabel, commentLabel, interactionsEnabled = true } = interactionInfo;
73
- const loggedInUser = useContext(FeedContext).userInfo;
74
- const t = useI18n();
75
- const { locale } = useConfiguration();
76
- const rteRef = useRef();
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';
77
27
  const [editMode, setEditMode] = useState(false);
78
- const editTextAreaRef = useRef(null);
79
28
  const [emptyEditText, setEmptyEditText] = useState(false);
80
- const [replyModified, setReplyModified] = useState(false);
81
- const { onShowReplyInput } = useContext(FeedReplyContext);
82
- const likesModalRef = useRef();
83
- const [postTimestampEl, setPostTimestampEl] = useElement();
84
- const [editTimestampEl, setEditTimestampEl] = useElement();
85
- useEffect(() => {
86
- likesModalRef.current?.update({
87
- count: likeCount,
88
- heading: likeLabel,
89
- listItems: likes,
90
- onLoadMore: onLoadMoreLikes
91
- });
92
- }, [likeCount, likeLabel, likes, onLoadMoreLikes]);
93
- useOuterEvent('mousedown', [editTextAreaRef], () => {
94
- if (emptyEditText)
95
- setEditMode(false);
96
- });
97
- const handleEdit = () => {
98
- if (!emptyEditText && replyModified) {
99
- onEditSubmit?.({
100
- replyId: id,
101
- value: rteRef.current?.getPlainText() || ''
102
- });
103
- setEditMode(false);
104
- }
105
- };
106
- const userVisual = icon ? (_jsx(Icon, { name: icon })) : (_jsx(Avatar, { name: fullname, size: 'm', imageSrc: avatarSrc, status: userStatus }));
107
- const timestamps = [
108
- _jsxs(_Fragment, { children: [_jsx(DateTimeDisplay, { ref: setPostTimestampEl, value: postTimestamp, variant: 'relative' }), postTimestamp && (_jsx(Tooltip, { target: postTimestampEl, children: formatDateTime(parseToDate(postTimestamp), {
109
- t,
110
- locale,
111
- format: 'short',
112
- variant: 'datetime',
113
- timeZone: 'UTC'
114
- }) }))] })
115
- ];
116
- if (edited) {
117
- timestamps.push(_jsxs(_Fragment, { children: [_jsx(Text, { ref: setEditTimestampEl, variant: 'secondary', children: t('edited', [_jsx(DateTimeDisplay, { value: editTimestamp, variant: 'relative' })]) }), editTimestamp && (_jsx(Tooltip, { target: editTimestampEl, children: formatDateTime(parseToDate(editTimestamp), {
118
- t,
119
- locale,
120
- format: 'short',
121
- variant: 'datetime',
122
- timeZone: 'UTC'
123
- }) }))] }));
124
- }
125
- return (_jsxs(Flex, { container: true, as: StyledFeedReplyContainer, onMouseEnter: () => {
126
- onMouseEnter?.({ replyId: id });
29
+ return (_jsxs(StyledFeedReplyContainer, { onMouseEnter: () => {
30
+ onMouseEnter?.({ id });
127
31
  }, onMouseLeave: () => {
128
- onMouseLeave?.({ replyId: id });
129
- }, ...restProps, children: [onUserClick ? (_jsx(BareButton, { as: StyledVisualButton, onClick: (event) => {
130
- onUserClick?.({ replyId: id, username }, event);
131
- }, children: userVisual })) : (userVisual), _jsxs(Flex, { container: { direction: 'column' }, item: { grow: 1 }, children: [editMode ? (_jsxs(_Fragment, { children: [_jsx(StyledFeedReply, { children: _jsx(FeedRichText, { label: t('feed_edit_reply'), onChange: () => {
132
- setEmptyEditText(rteRef.current?.getPlainText().trim() === '');
133
- setReplyModified(rteRef.current?.getPlainText() !== content);
134
- }, autoFocus: true, onSubmit: handleEdit, defaultValue: content, ref: rteRef }) }), _jsxs(Flex, { container: { justify: 'between', pad: [2, 0, 1] }, children: [_jsx(Button, { onClick: () => setEditMode(false), "aria-label": `${t('cancel')} ${t('edit')} ${id}`, children: t('cancel') }), _jsx(Button, { variant: 'primary', disabled: emptyEditText || !replyModified, onClick: handleEdit, "aria-label": `${t('update')} ${t('edit')} ${id}`, children: t('update') })] })] })) : (_jsxs(Flex, { container: { gap: 1, alignItems: 'center' }, item: { grow: 1 }, children: [_jsxs(Flex, { item: { grow: 1 }, as: StyledFeedReplyContent, children: [_jsxs(Flex, { container: { direction: 'column', gap: 0.5 }, children: [_jsx("div", { children: _jsx(Button, { as: StyledFeedReplyUser, variant: 'text', onClick: (event) => {
135
- onUserClick?.({ replyId: id, username }, event);
136
- }, "aria-label": fullnameLabel, children: fullname }) }), _jsx(FeedContent, { maxContentHeight: maxContentHeight, children: content })] }), _jsx(FeedAttachments, { attachments: attachments, readOnly: true })] }), menuItems ? (_jsx(MenuButton, { text: 'More', menu: {
137
- items: onEditSubmit &&
138
- typeof content === 'string' &&
139
- username === loggedInUser.username
140
- ? [
141
- {
142
- primary: t('edit'),
143
- id: 'edit',
144
- onClick: () => setEditMode(true)
145
- },
146
- ...menuItems
147
- ]
148
- : menuItems
149
- }, icon: 'more', iconOnly: true, variant: 'simple' })) : undefined] })), _jsxs(Flex, { container: { alignItems: 'center', gap: 2 }, children: [interactionsEnabled && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: 'text', icon: true, as: FeedButton, onClick: () => {
150
- onCommentClick({ replyId: id, username });
151
- onShowReplyInput?.();
152
- }, label: commentLabel, children: _jsx(Icon, { name: 'chat' }) }), _jsx(FeedLikeButton, { ...interactionInfo, variant: 'reply', id: id, onLikeClick: onLikeClick, onLikeCountInteraction: onLikeCountInteraction, onLoadMoreLikes: onLoadMoreLikes, likesLoading: likesLoading, liked: liked })] })), _jsx(MetaList, { items: timestamps })] })] })] }));
32
+ onMouseLeave?.({ id });
33
+ }, ...restProps, children: [_jsx(FeedContentHeader, { ...{
34
+ variant,
35
+ id,
36
+ fullname,
37
+ username,
38
+ postTimestamp,
39
+ content,
40
+ avatarSrc,
41
+ icon,
42
+ userStatus,
43
+ menuItems,
44
+ edited,
45
+ editTimestamp,
46
+ onEditSubmit,
47
+ onUserClick,
48
+ setEditMode
49
+ } }), _jsxs(StyledReplyContent, { children: [_jsxs(Flex, { container: { direction: 'column', pad: [0, editMode ? 0 : 2, 0, 0] }, item: { grow: 1 }, children: [editMode ? (_jsx(FeedEditRegion, { ...{
50
+ variant,
51
+ id,
52
+ content,
53
+ setEditMode,
54
+ onEditSubmit,
55
+ emptyEditText,
56
+ setEmptyEditText
57
+ } })) : (_jsx(FeedContent, { maxContentHeight: maxContentHeight, children: content })), _jsx(FeedAttachments, { variant: variant, attachments: attachments, readOnly: true })] }), _jsx(FeedContentFooter, { ...{
58
+ variant,
59
+ id,
60
+ username,
61
+ liked,
62
+ likes,
63
+ likeCount,
64
+ interactionsEnabled,
65
+ likesLoading,
66
+ onCommentClick,
67
+ onLikeClick,
68
+ onLikeCountInteraction,
69
+ onLoadMoreLikes
70
+ } })] })] }));
153
71
  };
154
72
  export default FeedReply;
155
73
  //# sourceMappingURL=FeedReply.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeedReply.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAc,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,gBAAgB,EAEhB,QAAQ,EACR,OAAO,EACP,aAAa,EAEb,UAAU,EACV,IAAI,EACJ,OAAO,EACP,eAAe,EACf,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,sDAAsD,CAAC;AACpF,OAAO,UAAU,MAAM,0DAA0D,CAAC;AAClF,OAAO,EAAuB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AACxF,OAAO,KAAK,iBAAiB,MAAM,wEAAwE,CAAC;AAC5G,OAAO,KAAK,YAAY,MAAM,kEAAkE,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,6DAA6D,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAC;AAGvF,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE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AG,SAAS;yCACb;wCACH,CAAC,CAAC,SAAS;iCAChB,EACD,IAAI,EAAC,MAAM,EACX,QAAQ,QACR,OAAO,EAAC,QAAQ,GAChB,CACH,CAAC,CAAC,CAAC,SAAS,IACR,CACR,EAED,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAC9C,mBAAmB,IAAI,CACtB,8BACE,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,IAAI,QACJ,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,GAAG,EAAE;4CACZ,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;4CAC1C,gBAAgB,EAAE,EAAE,CAAC;wCACvB,CAAC,EACD,KAAK,EAAE,YAAY,YAEnB,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,EACT,KAAC,cAAc,OACT,eAAe,EACnB,OAAO,EAAC,OAAO,EACf,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,WAAW,EACxB,sBAAsB,EAAE,sBAAsB,EAC9C,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,GACZ,IACD,CACJ,EACD,KAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,GAAI,IAC1B,IACF,IACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { FC, useContext, MouseEvent, useState, useRef, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Avatar,\n Button,\n Flex,\n Icon,\n registerIcon,\n MenuButton,\n defaultThemeProp,\n ForwardProps,\n MetaList,\n useI18n,\n useOuterEvent,\n ModalMethods,\n useElement,\n Text,\n Tooltip,\n DateTimeDisplay,\n useConfiguration\n} from '@pega/cosmos-react-core';\nimport { StyledAvatar } from '@pega/cosmos-react-core/lib/components/Avatar/Avatar';\nimport BareButton from '@pega/cosmos-react-core/lib/components/Button/BareButton';\nimport { RichTextEditorState, StyledRichTextEditor } from '@pega/cosmos-react-rte';\nimport * as chatIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chat.icon';\nimport * as thumbsUpSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up-solid.icon';\nimport * as thumbsUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up.icon';\nimport { parseToDate } from '@pega/cosmos-react-core/lib/components/DateTime/Input/utils';\nimport { formatDateTime } from '@pega/cosmos-react-core/lib/components/DateTime/utils';\n\nimport { FeedReplyProps } from './FeedReply.types';\nimport FeedAttachments from './FeedAttachments';\nimport FeedButton from './FeedButton';\nimport FeedContent from './FeedContent';\nimport { FeedContext, FeedReplyContext } from './Feed.context';\nimport FeedRichText from './FeedRichText';\nimport { StyledFeedReply } from './FeedReplyInput';\nimport { FeedModalListProps } from './FeedModalList';\nimport { FeedLikeButton } from './FeedLikeButton';\n\nregisterIcon(chatIcon, thumbsUpSolidIcon, thumbsUpIcon);\n\nexport const StyledFeedReplyContent = styled.div(props => {\n const { theme } = props;\n\n return css`\n background-color: ${theme.base.palette['secondary-background']};\n border-radius: calc(2 * ${theme.base['border-radius']});\n padding: calc(1.5 * ${theme.base.spacing});\n `;\n});\n\nStyledFeedReplyContent.defaultProps = defaultThemeProp;\n\nexport const StyledFeedReplyUser = styled.button(props => {\n const { theme } = props;\n\n return css`\n font-weight: ${theme.base['font-weight']['semi-bold']};\n margin-inline-end: ${theme.base.spacing};\n `;\n});\n\nStyledFeedReplyUser.defaultProps = defaultThemeProp;\n\nexport const StyledVisualButton = styled.button`\n height: min-content;\n`;\n\nexport const StyledFeedReplyContainer = styled.div(props => {\n const { theme } = props;\n\n return css`\n ${StyledAvatar} {\n margin-inline-end: ${theme.base.spacing};\n }\n\n ${StyledFeedReplyContent} {\n margin-bottom: calc(0.5 * ${theme.base.spacing});\n }\n\n ${StyledFeedReply} {\n &:focus-within {\n border-color: ${theme.base.palette.interactive};\n }\n }\n\n ${StyledRichTextEditor} {\n padding-top: calc(0.5 * ${theme.base.spacing});\n padding-bottom: ${theme.base.spacing};\n\n &:focus-within {\n box-shadow: none;\n }\n }\n `;\n});\n\nStyledFeedReplyContainer.defaultProps = defaultThemeProp;\n\nconst FeedReply: FC<ForwardProps & FeedReplyProps> = (props: ForwardProps & FeedReplyProps) => {\n const {\n id,\n info,\n interactionInfo,\n maxContentHeight = Infinity,\n menuItems,\n onEditSubmit,\n edited = false,\n editTimestamp,\n onMouseEnter,\n onMouseLeave,\n onCommentClick,\n onLikeClick,\n onLikeCountInteraction,\n onLoadMoreLikes,\n likesLoading,\n onUserClick,\n ...restProps\n } = props;\n const {\n avatarSrc,\n postTimestamp,\n content,\n attachments,\n username,\n fullname,\n fullnameLabel,\n liked,\n icon,\n userStatus\n } = info;\n const {\n likes = [],\n likeCount = 0,\n likeLabel,\n commentLabel,\n interactionsEnabled = true\n } = interactionInfo;\n const loggedInUser = useContext(FeedContext).userInfo;\n\n const t = useI18n();\n const { locale } = useConfiguration();\n const rteRef = useRef<RichTextEditorState>();\n const [editMode, setEditMode] = useState(false);\n const editTextAreaRef = useRef<HTMLDivElement>(null);\n const [emptyEditText, setEmptyEditText] = useState(false);\n const [replyModified, setReplyModified] = useState(false);\n const { onShowReplyInput } = useContext(FeedReplyContext);\n const likesModalRef = useRef<ModalMethods<FeedModalListProps>>();\n const [postTimestampEl, setPostTimestampEl] = useElement<HTMLSpanElement>();\n const [editTimestampEl, setEditTimestampEl] = useElement<HTMLSpanElement>();\n\n useEffect(() => {\n likesModalRef.current?.update({\n count: likeCount,\n heading: likeLabel,\n listItems: likes,\n onLoadMore: onLoadMoreLikes\n });\n }, [likeCount, likeLabel, likes, onLoadMoreLikes]);\n\n useOuterEvent('mousedown', [editTextAreaRef], () => {\n if (emptyEditText) setEditMode(false);\n });\n\n const handleEdit = () => {\n if (!emptyEditText && replyModified) {\n onEditSubmit?.({\n replyId: id,\n value: rteRef.current?.getPlainText() || ''\n });\n setEditMode(false);\n }\n };\n\n const userVisual = icon ? (\n <Icon name={icon} />\n ) : (\n <Avatar name={fullname} size='m' imageSrc={avatarSrc} status={userStatus} />\n );\n\n const timestamps = [\n <>\n <DateTimeDisplay ref={setPostTimestampEl} value={postTimestamp} variant='relative' />\n {postTimestamp && (\n <Tooltip target={postTimestampEl}>\n {formatDateTime(parseToDate(postTimestamp), {\n t,\n locale,\n format: 'short',\n variant: 'datetime',\n timeZone: 'UTC'\n })}\n </Tooltip>\n )}\n </>\n ];\n\n if (edited) {\n timestamps.push(\n <>\n <Text ref={setEditTimestampEl} variant='secondary'>\n {t('edited', [<DateTimeDisplay value={editTimestamp} variant='relative' />])}\n </Text>\n {editTimestamp && (\n <Tooltip target={editTimestampEl}>\n {formatDateTime(parseToDate(editTimestamp), {\n t,\n locale,\n format: 'short',\n variant: 'datetime',\n timeZone: 'UTC'\n })}\n </Tooltip>\n )}\n </>\n );\n }\n\n return (\n <Flex\n container\n as={StyledFeedReplyContainer}\n onMouseEnter={() => {\n onMouseEnter?.({ replyId: id });\n }}\n onMouseLeave={() => {\n onMouseLeave?.({ replyId: id });\n }}\n {...restProps}\n >\n {onUserClick ? (\n <BareButton\n as={StyledVisualButton}\n onClick={(event: MouseEvent) => {\n onUserClick?.({ replyId: id, username }, event);\n }}\n >\n {userVisual}\n </BareButton>\n ) : (\n userVisual\n )}\n <Flex container={{ direction: 'column' }} item={{ grow: 1 }}>\n {editMode ? (\n <>\n <StyledFeedReply>\n <FeedRichText\n label={t('feed_edit_reply')}\n onChange={() => {\n setEmptyEditText(rteRef.current?.getPlainText().trim() === '');\n setReplyModified(rteRef.current?.getPlainText() !== content);\n }}\n autoFocus\n onSubmit={handleEdit}\n defaultValue={content}\n ref={rteRef}\n />\n </StyledFeedReply>\n <Flex container={{ justify: 'between', pad: [2, 0, 1] }}>\n <Button\n onClick={() => setEditMode(false)}\n aria-label={`${t('cancel')} ${t('edit')} ${id}`}\n >\n {t('cancel')}\n </Button>\n <Button\n variant='primary'\n disabled={emptyEditText || !replyModified}\n onClick={handleEdit}\n aria-label={`${t('update')} ${t('edit')} ${id}`}\n >\n {t('update')}\n </Button>\n </Flex>\n </>\n ) : (\n <Flex container={{ gap: 1, alignItems: 'center' }} item={{ grow: 1 }}>\n <Flex item={{ grow: 1 }} as={StyledFeedReplyContent}>\n <Flex container={{ direction: 'column', gap: 0.5 }}>\n <div>\n <Button\n as={StyledFeedReplyUser}\n variant='text'\n onClick={(event: MouseEvent) => {\n onUserClick?.({ replyId: id, username }, event);\n }}\n aria-label={fullnameLabel}\n >\n {fullname}\n </Button>\n </div>\n <FeedContent maxContentHeight={maxContentHeight}>{content}</FeedContent>\n </Flex>\n <FeedAttachments attachments={attachments} readOnly />\n </Flex>\n {menuItems ? (\n <MenuButton\n text='More'\n menu={{\n items:\n onEditSubmit &&\n typeof content === 'string' &&\n username === loggedInUser.username\n ? [\n {\n primary: t('edit'),\n id: 'edit',\n onClick: () => setEditMode(true)\n },\n ...menuItems\n ]\n : menuItems\n }}\n icon='more'\n iconOnly\n variant='simple'\n />\n ) : undefined}\n </Flex>\n )}\n\n <Flex container={{ alignItems: 'center', gap: 2 }}>\n {interactionsEnabled && (\n <>\n <Button\n variant='text'\n icon\n as={FeedButton}\n onClick={() => {\n onCommentClick({ replyId: id, username });\n onShowReplyInput?.();\n }}\n label={commentLabel}\n >\n <Icon name='chat' />\n </Button>\n <FeedLikeButton\n {...interactionInfo}\n variant='reply'\n id={id}\n onLikeClick={onLikeClick}\n onLikeCountInteraction={onLikeCountInteraction}\n onLoadMoreLikes={onLoadMoreLikes}\n likesLoading={likesLoading}\n liked={liked}\n />\n </>\n )}\n <MetaList items={timestamps} />\n </Flex>\n </Flex>\n </Flex>\n );\n};\n\nexport default FeedReply;\n"]}
1
+ {"version":3,"file":"FeedReply.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,QAAQ,EAAE,M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CACZ,aAAa;oCACb,gBAAgB;iCACjB,GACD,CACH,CAAC,CAAC,CAAC,CACF,KAAC,WAAW,IAAC,gBAAgB,EAAE,gBAAgB,YAAG,OAAO,GAAe,CACzE,EACD,KAAC,eAAe,IAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,SAAG,IACnE,EAEP,KAAC,iBAAiB,OACZ;4BACF,OAAO;4BACP,EAAE;4BACF,QAAQ;4BACR,KAAK;4BACL,KAAK;4BACL,SAAS;4BACT,mBAAmB;4BACnB,YAAY;4BACZ,cAAc;4BACd,WAAW;4BACX,sBAAsB;4BACtB,eAAe;yBAChB,GACD,IACiB,IACI,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { FC, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Flex, registerIcon, defaultThemeProp, ForwardProps } from '@pega/cosmos-react-core';\nimport * as chatIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chat.icon';\nimport * as thumbsUpSolidIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up-solid.icon';\nimport * as thumbsUpIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/thumbs-up.icon';\n\nimport { FeedReplyProps } from './Feed.types';\nimport FeedAttachments from './FeedAttachments';\nimport FeedContent from './FeedContent';\nimport FeedContentHeader from './FeedContentHeader';\nimport FeedContentFooter from './FeedContentFooter';\nimport FeedEditRegion from './FeedEditRegion';\n\nregisterIcon(chatIcon, thumbsUpSolidIcon, thumbsUpIcon);\n\nexport const StyledFeedReplyContainer = styled.div``;\n\nStyledFeedReplyContainer.defaultProps = defaultThemeProp;\n\nconst StyledReplyContent = styled.div(({ theme }) => {\n return css`\n margin-inline-start: calc(2 * ${theme.base.spacing});\n border-inline-start: solid 0.0625rem ${theme.base.palette['border-line']};\n padding-inline-start: calc(3 * ${theme.base.spacing});\n `;\n});\n\nStyledReplyContent.defaultProps = defaultThemeProp;\n\nconst FeedReply: FC<ForwardProps & FeedReplyProps> = (props: ForwardProps & FeedReplyProps) => {\n const {\n id,\n avatarSrc,\n postTimestamp,\n content,\n attachments,\n username,\n fullname,\n liked,\n likes,\n likeCount,\n interactionsEnabled,\n icon,\n userStatus,\n maxContentHeight = Infinity,\n menuItems,\n onEditSubmit,\n edited = false,\n editTimestamp,\n onMouseEnter,\n onMouseLeave,\n onCommentClick,\n onLikeClick,\n onLikeCountInteraction,\n onLoadMoreLikes,\n likesLoading,\n onUserClick,\n ...restProps\n } = props;\n const variant = 'reply';\n\n const [editMode, setEditMode] = useState(false);\n const [emptyEditText, setEmptyEditText] = useState(false);\n\n return (\n <StyledFeedReplyContainer\n onMouseEnter={() => {\n onMouseEnter?.({ id });\n }}\n onMouseLeave={() => {\n onMouseLeave?.({ id });\n }}\n {...restProps}\n >\n <FeedContentHeader\n {...{\n variant,\n id,\n fullname,\n username,\n postTimestamp,\n content,\n avatarSrc,\n icon,\n userStatus,\n menuItems,\n edited,\n editTimestamp,\n onEditSubmit,\n onUserClick,\n setEditMode\n }}\n />\n <StyledReplyContent>\n <Flex\n container={{ direction: 'column', pad: [0, editMode ? 0 : 2, 0, 0] }}\n item={{ grow: 1 }}\n >\n {editMode ? (\n <FeedEditRegion\n {...{\n variant,\n id,\n content,\n setEditMode,\n onEditSubmit,\n emptyEditText,\n setEmptyEditText\n }}\n />\n ) : (\n <FeedContent maxContentHeight={maxContentHeight}>{content}</FeedContent>\n )}\n <FeedAttachments variant={variant} attachments={attachments} readOnly />\n </Flex>\n\n <FeedContentFooter\n {...{\n variant,\n id,\n username,\n liked,\n likes,\n likeCount,\n interactionsEnabled,\n likesLoading,\n onCommentClick,\n onLikeClick,\n onLikeCountInteraction,\n onLoadMoreLikes\n }}\n />\n </StyledReplyContent>\n </StyledFeedReplyContainer>\n );\n};\n\nexport default FeedReply;\n"]}
@@ -1,32 +1,7 @@
1
- import { FC, MutableRefObject } from 'react';
1
+ import { FC } from 'react';
2
2
  import { ForwardProps } from '@pega/cosmos-react-core';
3
- import { RichTextEditorState } from '@pega/cosmos-react-rte';
4
- import { AttachedFiles } from './FeedAttachments';
5
- export interface FeedReplyInputProps {
6
- /** Unique ID for this Reply Input */
7
- id: string;
8
- /** Label text for the reply submit button. */
9
- commentLabel: string;
10
- /** A set of attachment files. */
11
- attachments?: AttachedFiles[];
12
- /** Placeholder string for the input */
13
- placeholder: string;
14
- /** A callback containing a list of added files that will run whenever files are added to the post. */
15
- onFilesAdded?: (files: AttachedFiles[]) => void;
16
- /** Callback that runs when the submit button has been pressed */
17
- onSubmit: (event: {
18
- replyId: string;
19
- value: string;
20
- attachments: AttachedFiles[];
21
- clear: () => void;
22
- }) => void;
23
- /** Callback that sets returns a shared ref to the RTE component */
24
- onSetInputRef?: (event: {
25
- ref: MutableRefObject<RichTextEditorState | undefined>;
26
- }) => void;
27
- }
3
+ import { FeedReplyInputProps } from './Feed.types';
28
4
  export declare const StyledReplyInputContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
29
- export declare const StyledFeedReply: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
30
5
  declare const FeedReplyInput: FC<ForwardProps & FeedReplyInputProps>;
31
6
  export default FeedReplyInput;
32
7
  //# sourceMappingURL=FeedReplyInput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeedReplyInput.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReplyInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,gBAAgB,EAA0B,MAAM,OAAO,CAAC;AAGlG,OAAO,EAQL,YAAY,EAEb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAwB,MAAM,wBAAwB,CAAC;AAMnF,OAAwB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKnE,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,sGAAsG;IACtG,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;IAChD,iEAAiE;IACjE,QAAQ,EAAE,CAAC,KAAK,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,aAAa,EAAE,CAAC;QAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;KACnB,KAAK,IAAI,CAAC;IACX,mEAAmE;IACnE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,gBAAgB,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;CAC7F;AAED,eAAO,MAAM,yBAAyB,yGAQpC,CAAC;AAIH,eAAO,MAAM,eAAe,yGAa1B,CAAC;AAwBH,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,YAAY,GAAG,mBAAmB,CAuI1D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"FeedReplyInput.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReplyInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAqB,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAkC,YAAY,EAAc,MAAM,yBAAyB,CAAC;AAKnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAKnD,eAAO,MAAM,yBAAyB,yGAAe,CAAC;AAItD,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,YAAY,GAAG,mBAAmB,CAqB1D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,108 +1,21 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useRef, useState, useEffect, useContext } from 'react';
3
- import styled, { css } from 'styled-components';
4
- import { Avatar, Button, StyledAvatar, Flex, Icon, registerIcon, defaultThemeProp, useI18n } from '@pega/cosmos-react-core';
5
- import { StyledRichTextEditor } from '@pega/cosmos-react-rte';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef, useEffect } from 'react';
3
+ import styled from 'styled-components';
4
+ import { registerIcon, defaultThemeProp, useElement } from '@pega/cosmos-react-core';
6
5
  import * as sendIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/send.icon';
7
6
  import * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';
8
- import FeedRichText from './FeedRichText';
9
- import FeedButton from './FeedButton';
10
- import FeedAttachments from './FeedAttachments';
11
- import { FeedContext } from './Feed.context';
7
+ import FeedInputRegion from './FeedInputRegion';
12
8
  registerIcon(sendIcon, paperClipIcon);
13
- export const StyledReplyInputContainer = styled.div(props => {
14
- const { theme } = props;
15
- return css `
16
- ${StyledAvatar} {
17
- margin-inline-end: ${theme.base.spacing};
18
- }
19
- `;
20
- });
9
+ export const StyledReplyInputContainer = styled.div ``;
21
10
  StyledReplyInputContainer.defaultProps = defaultThemeProp;
22
- export const StyledFeedReply = styled.div(props => {
23
- const { theme } = props;
24
- return css `
25
- border: 0.0625rem solid ${theme.base.palette['border-line']};
26
- border-radius: calc(2.5 * ${theme.base['border-radius']});
27
- padding: 0 calc(2 * ${theme.base.spacing});
28
- cursor: text;
29
-
30
- ${FeedButton} {
31
- align-self: flex-end;
32
- }
33
- `;
34
- });
35
- StyledFeedReply.defaultProps = defaultThemeProp;
36
- const StyledFeedReplyInput = styled.div(props => {
37
- const { theme } = props;
38
- return css `
39
- padding-top: calc(0.75 * ${theme.base.spacing});
40
-
41
- ${StyledRichTextEditor} {
42
- &:focus-within {
43
- box-shadow: none;
44
- }
45
- }
46
- `;
47
- });
48
- StyledFeedReplyInput.defaultProps = defaultThemeProp;
49
- const HiddenFileInput = styled.input `
50
- display: none;
51
- `;
52
11
  const FeedReplyInput = (props) => {
12
+ const { id, attachments, onFilesAdded, onSubmit, onSetInputRef, ...restProps } = props;
53
13
  const rteRef = useRef();
54
- const { id, commentLabel, attachments = [], placeholder, onAddAttachment, onSubmit, onSetInputRef, onFilesAdded, ...restProps } = props;
55
- const [emptyText, setEmptyText] = useState(true);
56
- const hiddenInputRef = useRef(null);
57
- const attachmentListRef = useRef(null);
58
- const attachmentsButtonRef = useRef(null);
59
- const submitButtonRef = useRef(null);
60
- const { setShowSearchResults } = useContext(FeedContext);
61
- const { avatarSrc, fullname } = useContext(FeedContext).userInfo;
14
+ const [newReplyEl, setNewReplyEl] = useElement();
62
15
  useEffect(() => {
63
16
  onSetInputRef?.({ ref: rteRef });
64
17
  }, [rteRef]);
65
- const t = useI18n();
66
- const handleSubmit = () => {
67
- setShowSearchResults?.(false);
68
- if (!emptyText || attachments.length > 0) {
69
- onSubmit({
70
- replyId: id,
71
- value: rteRef.current?.getPlainText() || '',
72
- attachments: attachments || [],
73
- clear: () => {
74
- rteRef.current?.clear();
75
- }
76
- });
77
- }
78
- };
79
- return (_jsxs(Flex, { container: true, as: StyledReplyInputContainer, ...restProps, children: [_jsx(Avatar, { name: fullname, size: 'm', imageSrc: avatarSrc }), _jsx(Flex, { container: { alignItems: 'start' }, item: { grow: 1 }, as: StyledFeedReply, onClick: (event) => {
80
- if (attachmentListRef.current &&
81
- event.target !== attachmentListRef.current &&
82
- attachmentListRef.current.contains(event.target)) {
83
- return;
84
- }
85
- if (attachmentsButtonRef.current?.contains(event.target) ||
86
- submitButtonRef.current?.contains(event.target)) {
87
- return;
88
- }
89
- rteRef.current?.focus();
90
- }, children: _jsxs(Flex, { container: { direction: 'column' }, item: { grow: 1 }, children: [_jsxs(Flex, { container: true, item: { grow: 1 }, children: [_jsx(Flex, { as: StyledFeedReplyInput, item: { grow: 1 }, children: _jsx(FeedRichText, { label: t('feed_new_reply'), ref: rteRef, placeholder: placeholder, onChange: () => {
91
- setEmptyText(rteRef.current?.getPlainText().trim() === '');
92
- }, onSubmit: handleSubmit }) }), onFilesAdded && (_jsxs(_Fragment, { children: [_jsx(HiddenFileInput, { ref: hiddenInputRef, type: 'file', multiple: true, onChange: () => {
93
- if (hiddenInputRef.current?.files) {
94
- onFilesAdded?.(Array.from(hiddenInputRef.current?.files));
95
- }
96
- },
97
- // Must trick input to believe there is no value when activated so that the same file may be added consecutively.
98
- onClick: (event) => {
99
- event.target.value = '';
100
- } }), _jsx(Button, { ref: attachmentsButtonRef, as: FeedButton, variant: 'simple', onClick: () => {
101
- setShowSearchResults?.(false);
102
- hiddenInputRef.current?.click();
103
- }, icon: true, label: attachments.length
104
- ? t('attachments_count', [], { count: 1 }).toUpperCase()
105
- : t('file_upload_text_multiple'), children: _jsx(Icon, { name: 'paper-clip' }) })] })), _jsx(Button, { ref: submitButtonRef, as: FeedButton, disabled: emptyText && attachments.length === 0, variant: 'simple', onClick: handleSubmit, icon: true, label: commentLabel, children: _jsx(Icon, { name: 'send' }) })] }), _jsx(FeedAttachments, { ref: attachmentListRef, attachments: attachments })] }) })] }));
18
+ return (_jsx(StyledReplyInputContainer, { ref: setNewReplyEl, ...restProps, children: _jsx(FeedInputRegion, { variant: 'reply', ...{ id, attachments, onFilesAdded, onSubmit }, inputRegionEl: newReplyEl, rteRef: rteRef }) }));
106
19
  };
107
20
  export default FeedReplyInput;
108
21
  //# sourceMappingURL=FeedReplyInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeedReplyInput.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedReplyInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAgC,UAAU,EAAE,MAAM,OAAO,CAAC;AAClG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,IAAI,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,CAAC,CAAC,WAAW,EAAE;gDACxD,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC,YAGpC,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,GACnB,IACR,CACJ,EACD,KAAC,MAAM,IACL,GAAG,EAAE,eAAe,EACpB,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,SAAS,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAC/C,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAE,YAAY,EACrB,IAAI,QACJ,KAAK,EAAE,YAAY,YAEnB,KAAC,IAAI,IAAC,IAAI,EAAC,MAAM,GAAG,GACb,IACJ,EACP,KAAC,eAAe,IAAC,GAAG,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,GAAI,IAChE,GACF,IACF,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FC, useRef, useState, useEffect, MutableRefObject, MouseEvent, useContext } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Avatar,\n Button,\n StyledAvatar,\n Flex,\n Icon,\n registerIcon,\n defaultThemeProp,\n ForwardProps,\n useI18n\n} from '@pega/cosmos-react-core';\nimport { RichTextEditorState, StyledRichTextEditor } from '@pega/cosmos-react-rte';\nimport * as sendIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/send.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nimport FeedRichText from './FeedRichText';\nimport FeedButton from './FeedButton';\nimport FeedAttachments, { AttachedFiles } from './FeedAttachments';\nimport { FeedContext } from './Feed.context';\n\nregisterIcon(sendIcon, paperClipIcon);\n\nexport interface FeedReplyInputProps {\n /** Unique ID for this Reply Input */\n id: string;\n /** Label text for the reply submit button. */\n commentLabel: string;\n /** A set of attachment files. */\n attachments?: AttachedFiles[];\n /** Placeholder string for the input */\n placeholder: string;\n /** A callback containing a list of added files that will run whenever files are added to the post. */\n onFilesAdded?: (files: AttachedFiles[]) => void;\n /** Callback that runs when the submit button has been pressed */\n onSubmit: (event: {\n replyId: string;\n value: string;\n attachments: AttachedFiles[];\n clear: () => void;\n }) => void;\n /** Callback that sets returns a shared ref to the RTE component */\n onSetInputRef?: (event: { ref: MutableRefObject<RichTextEditorState | undefined> }) => void;\n}\n\nexport const StyledReplyInputContainer = styled.div(props => {\n const { theme } = props;\n\n return css`\n ${StyledAvatar} {\n margin-inline-end: ${theme.base.spacing};\n }\n `;\n});\n\nStyledReplyInputContainer.defaultProps = defaultThemeProp;\n\nexport const StyledFeedReply = styled.div(props => {\n const { theme } = props;\n\n return css`\n border: 0.0625rem solid ${theme.base.palette['border-line']};\n border-radius: calc(2.5 * ${theme.base['border-radius']});\n padding: 0 calc(2 * ${theme.base.spacing});\n cursor: text;\n\n ${FeedButton} {\n align-self: flex-end;\n }\n `;\n});\n\nStyledFeedReply.defaultProps = defaultThemeProp;\n\nconst StyledFeedReplyInput = styled.div(props => {\n const { theme } = props;\n\n return css`\n padding-top: calc(0.75 * ${theme.base.spacing});\n\n ${StyledRichTextEditor} {\n &:focus-within {\n box-shadow: none;\n }\n }\n `;\n});\n\nStyledFeedReplyInput.defaultProps = defaultThemeProp;\n\nconst HiddenFileInput = styled.input`\n display: none;\n`;\n\nconst FeedReplyInput: FC<ForwardProps & FeedReplyInputProps> = (\n props: ForwardProps & FeedReplyInputProps\n) => {\n const rteRef = useRef<RichTextEditorState>();\n const {\n id,\n commentLabel,\n attachments = [],\n placeholder,\n onAddAttachment,\n onSubmit,\n onSetInputRef,\n onFilesAdded,\n ...restProps\n } = props;\n\n const [emptyText, setEmptyText] = useState(true);\n const hiddenInputRef = useRef<HTMLInputElement>(null);\n const attachmentListRef = useRef<HTMLUListElement>(null);\n const attachmentsButtonRef = useRef<HTMLButtonElement>(null);\n const submitButtonRef = useRef<HTMLButtonElement>(null);\n const { setShowSearchResults } = useContext(FeedContext);\n const { avatarSrc, fullname } = useContext(FeedContext).userInfo;\n\n useEffect(() => {\n onSetInputRef?.({ ref: rteRef });\n }, [rteRef]);\n\n const t = useI18n();\n\n const handleSubmit = () => {\n setShowSearchResults?.(false);\n if (!emptyText || attachments.length > 0) {\n onSubmit({\n replyId: id,\n value: rteRef.current?.getPlainText() || '',\n attachments: attachments || [],\n clear: () => {\n rteRef.current?.clear();\n }\n });\n }\n };\n\n return (\n <Flex container as={StyledReplyInputContainer} {...restProps}>\n <Avatar name={fullname} size='m' imageSrc={avatarSrc} />\n <Flex\n container={{ alignItems: 'start' }}\n item={{ grow: 1 }}\n as={StyledFeedReply}\n onClick={(event: MouseEvent) => {\n if (\n attachmentListRef.current &&\n event.target !== attachmentListRef.current &&\n attachmentListRef.current.contains(event.target as Node)\n ) {\n return;\n }\n\n if (\n attachmentsButtonRef.current?.contains(event.target as Node) ||\n submitButtonRef.current?.contains(event.target as Node)\n ) {\n return;\n }\n\n rteRef.current?.focus();\n }}\n >\n <Flex container={{ direction: 'column' }} item={{ grow: 1 }}>\n <Flex container item={{ grow: 1 }}>\n <Flex as={StyledFeedReplyInput} item={{ grow: 1 }}>\n <FeedRichText\n label={t('feed_new_reply')}\n ref={rteRef}\n placeholder={placeholder}\n onChange={() => {\n setEmptyText(rteRef.current?.getPlainText().trim() === '');\n }}\n onSubmit={handleSubmit}\n />\n </Flex>\n {onFilesAdded && (\n <>\n <HiddenFileInput\n ref={hiddenInputRef}\n type='file'\n multiple\n onChange={() => {\n if (hiddenInputRef.current?.files) {\n onFilesAdded?.(Array.from(hiddenInputRef.current?.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 <Button\n ref={attachmentsButtonRef}\n as={FeedButton}\n variant='simple'\n onClick={() => {\n setShowSearchResults?.(false);\n hiddenInputRef.current?.click();\n }}\n icon\n label={\n attachments.length\n ? t('attachments_count', [], { count: 1 }).toUpperCase()\n : t('file_upload_text_multiple')\n }\n >\n <Icon name='paper-clip' />\n </Button>\n </>\n )}\n <Button\n ref={submitButtonRef}\n as={FeedButton}\n disabled={emptyText && attachments.length === 0}\n variant='simple'\n onClick={handleSubmit}\n icon\n label={commentLabel}\n >\n <Icon name='send' />\n </Button>\n </Flex>\n <FeedAttachments ref={attachmentListRef} attachments={attachments} />\n </Flex>\n </Flex>\n </Flex>\n );\n};\n\nexport default FeedReplyInput;\n"]}
1
+ {"version":3,"file":"FeedReplyInput.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedReplyInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAgB,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEnG,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AACxF,OAAO,KAAK,aAAa,MAAM,mEAAmE,CAAC;AAGnG,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,YAAY,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEtD,yBAAyB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE1D,MAAM,cAAc,GAA2C,CAC7D,KAAyC,EACzC,EAAE;IACF,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACvF,MAAM,MAAM,GAAG,MAAM,EAAuB,CAAC;IAC7C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,UAAU,EAAkB,CAAC;IAEjE,SAAS,CAAC,GAAG,EAAE;QACb,aAAa,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACL,KAAC,yBAAyB,IAAC,GAAG,EAAE,aAAa,KAAM,SAAS,YAC1D,KAAC,eAAe,IACd,OAAO,EAAC,OAAO,KACX,EAAE,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,EAC/C,aAAa,EAAE,UAAU,EACzB,MAAM,EAAE,MAAM,GACd,GACwB,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { FC, useRef, useEffect } from 'react';\nimport styled from 'styled-components';\n\nimport { registerIcon, defaultThemeProp, ForwardProps, useElement } from '@pega/cosmos-react-core';\nimport { RichTextEditorState } from '@pega/cosmos-react-rte';\nimport * as sendIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/send.icon';\nimport * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';\n\nimport { FeedReplyInputProps } from './Feed.types';\nimport FeedInputRegion from './FeedInputRegion';\n\nregisterIcon(sendIcon, paperClipIcon);\n\nexport const StyledReplyInputContainer = styled.div``;\n\nStyledReplyInputContainer.defaultProps = defaultThemeProp;\n\nconst FeedReplyInput: FC<ForwardProps & FeedReplyInputProps> = (\n props: ForwardProps & FeedReplyInputProps\n) => {\n const { id, attachments, onFilesAdded, onSubmit, onSetInputRef, ...restProps } = props;\n const rteRef = useRef<RichTextEditorState>();\n const [newReplyEl, setNewReplyEl] = useElement<HTMLDivElement>();\n\n useEffect(() => {\n onSetInputRef?.({ ref: rteRef });\n }, [rteRef]);\n\n return (\n <StyledReplyInputContainer ref={setNewReplyEl} {...restProps}>\n <FeedInputRegion\n variant='reply'\n {...{ id, attachments, onFilesAdded, onSubmit }}\n inputRegionEl={newReplyEl}\n rteRef={rteRef}\n />\n </StyledReplyInputContainer>\n );\n};\n\nexport default FeedReplyInput;\n"]}
@@ -1,9 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { ForwardProps } from '@pega/cosmos-react-core';
3
- import { RichTextEditorProps } from '@pega/cosmos-react-rte';
4
- export interface FeedRichTextProps extends Pick<RichTextEditorProps, 'label' | 'onChange' | 'onFocus' | 'onBlur' | 'placeholder' | 'height'> {
5
- onSubmit: () => void;
6
- }
3
+ import { FeedRichTextProps } from './Feed.types';
7
4
  declare const FeedRichText: FC<FeedRichTextProps & ForwardProps>;
8
5
  export default FeedRichText;
9
6
  //# sourceMappingURL=FeedRichText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeedRichText.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAiD,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAO,YAAY,EAAW,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAGL,mBAAmB,EAEpB,MAAM,wBAAwB,CAAC;AAOhC,MAAM,WAAW,iBACf,SAAQ,IAAI,CACV,mBAAmB,EACnB,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CACvE;IACD,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,GAAG,YAAY,CAiJtD,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"FeedRichText.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAiD,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAO,YAAY,EAAW,MAAM,yBAAyB,CAAC;AAOrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,GAAG,YAAY,CAyItD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -6,8 +6,8 @@ import { MentionButtonConfig } from '../MentionButton';
6
6
  import { HashtagButtonConfig } from '../HashtagButton';
7
7
  import { FeedContext } from './Feed.context';
8
8
  const FeedRichText = forwardRef((props, ref) => {
9
- const { onSubmit, height = { min: 'auto' }, ...restProps } = props;
10
- const { searchTypes = [], onSearch, searchResults = [], showSearchResults, setShowSearchResults } = useContext(FeedContext);
9
+ const { height = { min: 'auto' }, ...restProps } = props;
10
+ const { searchTypes = [], onSearch, searchResults = [], showSearchResults } = useContext(FeedContext);
11
11
  const [triggerType, setTriggerType] = useState('mention');
12
12
  const [showMentionType, setShowMentionType] = useState(false);
13
13
  const searchType = useRef('');
@@ -23,11 +23,6 @@ const FeedRichText = forwardRef((props, ref) => {
23
23
  onSearch?.({ type: trigger, search: event.search, mentionType: searchType.current });
24
24
  }
25
25
  };
26
- const onKeyDown = (event) => {
27
- setShowSearchResults?.(true);
28
- if ((event.metaKey || event.ctrlKey) && event.key === 'Enter')
29
- onSubmit();
30
- };
31
26
  const typesMenu = {
32
27
  onItemActive: (id) => {
33
28
  searchType.current = id;
@@ -76,7 +71,7 @@ const FeedRichText = forwardRef((props, ref) => {
76
71
  default:
77
72
  }
78
73
  };
79
- return (_jsx(RichTextEditor, { ...restProps, labelHidden: true, markdownOnly: true, onKeyDown: onKeyDown, ref: ref, height: height, searchTriggers: [
74
+ return (_jsx(RichTextEditor, { ...restProps, markdownOnly: true, ref: ref, height: height, searchTriggers: [
80
75
  { trigger: '@', regex: String.raw `(?:\S+(?:[^\n\S][^@#\s]\S*)*[^\n\S]?|)` },
81
76
  { trigger: '#', regex: String.raw `[^\s,]*` }
82
77
  ], getSearchItemReplacement: (id) => {
@@ -1 +1 @@
1
- {"version":3,"file":"FeedRichText.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,UAAU,EAAO,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,GAAG,EAAgB,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EACL,gBAAg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AAI,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAC9C,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { FC, useContext, forwardRef, Ref, useState, useRef } from 'react';\n\nimport { cap, ForwardProps, useI18n } from '@pega/cosmos-react-core';\nimport {\n getXMLAttributes,\n RichTextEditor,\n RichTextEditorProps,\n RichTextEditorState\n} from '@pega/cosmos-react-rte';\n\nimport { MentionButtonConfig } from '../MentionButton';\nimport { HashtagButtonConfig } from '../HashtagButton';\n\nimport { FeedContext } from './Feed.context';\n\nexport interface FeedRichTextProps\n extends Pick<\n RichTextEditorProps,\n 'label' | 'onChange' | 'onFocus' | 'onBlur' | 'placeholder' | 'height'\n > {\n onSubmit: () => void;\n}\n\nconst FeedRichText: FC<FeedRichTextProps & ForwardProps> = forwardRef(\n (props: FeedRichTextProps, ref: Ref<RichTextEditorState>) => {\n const { onSubmit, height = { min: 'auto' }, ...restProps } = props;\n const {\n searchTypes = [],\n onSearch,\n searchResults = [],\n showSearchResults,\n setShowSearchResults\n } = useContext(FeedContext);\n const [triggerType, setTriggerType] = useState<'mention' | 'tag'>('mention');\n const [showMentionType, setShowMentionType] = useState(false);\n const searchType = useRef('');\n const t = useI18n();\n\n const onDecoSearch = (event: { search: string; trigger: string }) => {\n const trigger = event.trigger === '@' ? 'mention' : 'tag';\n setTriggerType(trigger);\n if (trigger === 'mention' && event.search === '') {\n setShowMentionType(true);\n } else {\n setShowMentionType(false);\n onSearch?.({ type: trigger, search: event.search, mentionType: searchType.current });\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n setShowSearchResults?.(true);\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') onSubmit();\n };\n\n const typesMenu = {\n onItemActive: (id: string) => {\n searchType.current = id;\n },\n onItemClick: (id: string) => {\n searchType.current = id;\n setShowMentionType(false);\n onSearch?.({ type: 'mention', search: '', mentionType: id });\n },\n items: searchTypes.map(type => {\n return { id: type, primary: cap(type) };\n })\n };\n\n const searchMenu =\n searchResults.length && showSearchResults\n ? {\n header: triggerType === 'mention' ? t('mention_type', [searchType.current]) : '',\n items: searchResults.map(res => {\n return { ...res, href: undefined };\n })\n }\n : undefined;\n\n const getSearchAttributes = (xmlElement: string, searchResult: string) => {\n switch (xmlElement) {\n case 'pega-mention': {\n const attributes = getXMLAttributes(searchResult);\n\n if (!attributes) return;\n return {\n markdown: searchResult,\n component: MentionButtonConfig.component,\n props: attributes,\n text: attributes.text\n };\n }\n case 'pega-tag': {\n const attributes = getXMLAttributes(searchResult);\n\n if (!attributes) return;\n return {\n markdown: searchResult,\n component: HashtagButtonConfig.component,\n props: attributes,\n text: attributes.tag\n };\n }\n default:\n }\n };\n\n return (\n <RichTextEditor\n {...restProps}\n labelHidden\n markdownOnly\n onKeyDown={onKeyDown}\n ref={ref}\n height={height}\n searchTriggers={[\n { trigger: '@', regex: String.raw`(?:\\S+(?:[^\\n\\S][^@#\\s]\\S*)*[^\\n\\S]?|)` },\n { trigger: '#', regex: String.raw`[^\\s,]*` }\n ]}\n getSearchItemReplacement={(id: string) => {\n const item = searchResults?.find(({ id: itemId }) => itemId === id);\n\n if (!item) return undefined;\n\n return {\n markdown:\n triggerType === 'mention'\n ? MentionButtonConfig.inject({\n id: item.id,\n type: searchType.current,\n text: item.primary,\n href: item.href\n })\n : HashtagButtonConfig.inject({ tag: item.id }),\n component:\n triggerType === 'mention'\n ? MentionButtonConfig.component\n : HashtagButtonConfig.component,\n props:\n triggerType === 'mention'\n ? {\n id: item.id,\n text: item.primary,\n type: searchType.current,\n tabIndex: -1\n }\n : { tag: item.primary, tabIndex: -1 },\n text: item.primary\n };\n }}\n searchRenderers={[\n {\n type: MentionButtonConfig.type,\n xmlElement: MentionButtonConfig.xmlElement,\n regexPattern: MentionButtonConfig.regexPattern,\n getSearchAttributes\n },\n {\n type: HashtagButtonConfig.type,\n xmlElement: HashtagButtonConfig.xmlElement,\n regexPattern: HashtagButtonConfig.regexPattern,\n getSearchAttributes\n }\n ]}\n onSearch={onDecoSearch}\n menu={showMentionType ? typesMenu : searchMenu}\n />\n );\n }\n);\n\nexport default FeedRichText;\n"]}
1
+ {"version":3,"file":"FeedRichText.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,UAAU,EAAO,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,GAAG,EAAgB,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAuB,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,YAAY,GAAyC,UAAU,CACnE,CAAC,KAAwB,EAAE,GAA6B,EAAE,EAAE;IAC1D,MAAM,EAAE,MAAM,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IACzD,MAAM,EACJ,WAAW,GAAG,EAAE,EAChB,QAAQ,EACR,aAAa,GAAG,EAAE,EAClB,iBAAiB,EAClB,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAC5B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAoB,SAAS,CAAC,CAAC;IAC7E,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAC9B,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IAEpB,MAAM,YAAY,GAAG,CAAC,KAA0C,EAAE,EAAE;QAClE,MAAM,OAA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AY,EAAE,mBAAmB,CAAC,YAAY;gBAC9C,mBAAmB;aACpB;SACF,EACD,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAC9C,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { FC, useContext, forwardRef, Ref, useState, useRef } from 'react';\n\nimport { cap, ForwardProps, useI18n } from '@pega/cosmos-react-core';\nimport { getXMLAttributes, RichTextEditor, RichTextEditorState } from '@pega/cosmos-react-rte';\n\nimport { MentionButtonConfig } from '../MentionButton';\nimport { HashtagButtonConfig } from '../HashtagButton';\n\nimport { FeedContext } from './Feed.context';\nimport { FeedRichTextProps } from './Feed.types';\n\nconst FeedRichText: FC<FeedRichTextProps & ForwardProps> = forwardRef(\n (props: FeedRichTextProps, ref: Ref<RichTextEditorState>) => {\n const { height = { min: 'auto' }, ...restProps } = props;\n const {\n searchTypes = [],\n onSearch,\n searchResults = [],\n showSearchResults\n } = useContext(FeedContext);\n const [triggerType, setTriggerType] = useState<'mention' | 'tag'>('mention');\n const [showMentionType, setShowMentionType] = useState(false);\n const searchType = useRef('');\n const t = useI18n();\n\n const onDecoSearch = (event: { search: string; trigger: string }) => {\n const trigger = event.trigger === '@' ? 'mention' : 'tag';\n setTriggerType(trigger);\n if (trigger === 'mention' && event.search === '') {\n setShowMentionType(true);\n } else {\n setShowMentionType(false);\n onSearch?.({ type: trigger, search: event.search, mentionType: searchType.current });\n }\n };\n\n const typesMenu = {\n onItemActive: (id: string) => {\n searchType.current = id;\n },\n onItemClick: (id: string) => {\n searchType.current = id;\n setShowMentionType(false);\n onSearch?.({ type: 'mention', search: '', mentionType: id });\n },\n items: searchTypes.map(type => {\n return { id: type, primary: cap(type) };\n })\n };\n\n const searchMenu =\n searchResults.length && showSearchResults\n ? {\n header: triggerType === 'mention' ? t('mention_type', [searchType.current]) : '',\n items: searchResults.map(res => {\n return { ...res, href: undefined };\n })\n }\n : undefined;\n\n const getSearchAttributes = (xmlElement: string, searchResult: string) => {\n switch (xmlElement) {\n case 'pega-mention': {\n const attributes = getXMLAttributes(searchResult);\n\n if (!attributes) return;\n return {\n markdown: searchResult,\n component: MentionButtonConfig.component,\n props: attributes,\n text: attributes.text\n };\n }\n case 'pega-tag': {\n const attributes = getXMLAttributes(searchResult);\n\n if (!attributes) return;\n return {\n markdown: searchResult,\n component: HashtagButtonConfig.component,\n props: attributes,\n text: attributes.tag\n };\n }\n default:\n }\n };\n\n return (\n <RichTextEditor\n {...restProps}\n markdownOnly\n ref={ref}\n height={height}\n searchTriggers={[\n { trigger: '@', regex: String.raw`(?:\\S+(?:[^\\n\\S][^@#\\s]\\S*)*[^\\n\\S]?|)` },\n { trigger: '#', regex: String.raw`[^\\s,]*` }\n ]}\n getSearchItemReplacement={(id: string) => {\n const item = searchResults?.find(({ id: itemId }) => itemId === id);\n\n if (!item) return undefined;\n\n return {\n markdown:\n triggerType === 'mention'\n ? MentionButtonConfig.inject({\n id: item.id,\n type: searchType.current,\n text: item.primary,\n href: item.href\n })\n : HashtagButtonConfig.inject({ tag: item.id }),\n component:\n triggerType === 'mention'\n ? MentionButtonConfig.component\n : HashtagButtonConfig.component,\n props:\n triggerType === 'mention'\n ? {\n id: item.id,\n text: item.primary,\n type: searchType.current,\n tabIndex: -1\n }\n : { tag: item.primary, tabIndex: -1 },\n text: item.primary\n };\n }}\n searchRenderers={[\n {\n type: MentionButtonConfig.type,\n xmlElement: MentionButtonConfig.xmlElement,\n regexPattern: MentionButtonConfig.regexPattern,\n getSearchAttributes\n },\n {\n type: HashtagButtonConfig.type,\n xmlElement: HashtagButtonConfig.xmlElement,\n regexPattern: HashtagButtonConfig.regexPattern,\n getSearchAttributes\n }\n ]}\n onSearch={onDecoSearch}\n menu={showMentionType ? typesMenu : searchMenu}\n />\n );\n }\n);\n\nexport default FeedRichText;\n"]}
@@ -1,10 +1,7 @@
1
- export { default, Filter } from './Feed';
1
+ export { default } from './Feed';
2
2
  export { default as FeedPost } from './FeedPost';
3
- export { FeedPostProps } from './FeedPost.types';
4
- export { default as FeedReplyInput, FeedReplyInputProps } from './FeedReplyInput';
3
+ export { default as FeedReplyInput } from './FeedReplyInput';
5
4
  export { default as FeedReply } from './FeedReply';
6
- export { FeedReplyProps } from './FeedReply.types';
7
- export { default as FeedNewPost, FeedNewPostProps } from './FeedNewPost';
8
- export { RecipientOption } from './FeedNewPostTypeMenu';
9
- export { AttachedFiles } from './FeedAttachments';
5
+ export { default as FeedNewPost } from './FeedNewPost';
6
+ export type { AttachedFiles, Filter, FeedProps, FeedNewPostProps, FeedPostProps, FeedReplyInputProps, FeedReplyProps, RecipientOption } from './Feed.types';
10
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EACV,aAAa,EACb,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,eAAe,EAChB,MAAM,cAAc,CAAC"}