@pega/cosmos-react-social 5.0.0-dev.1.0 → 5.0.0-dev.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Autopilot/Autopilot.d.ts +15 -0
- package/lib/components/Autopilot/Autopilot.d.ts.map +1 -0
- package/lib/components/Autopilot/Autopilot.js +50 -0
- package/lib/components/Autopilot/Autopilot.js.map +1 -0
- package/lib/components/Autopilot/AutopilotAvatar.d.ts +8 -0
- package/lib/components/Autopilot/AutopilotAvatar.d.ts.map +1 -0
- package/lib/components/Autopilot/AutopilotAvatar.js +14 -0
- package/lib/components/Autopilot/AutopilotAvatar.js.map +1 -0
- package/lib/components/Autopilot/AutopilotGlimpse.d.ts +9 -0
- package/lib/components/Autopilot/AutopilotGlimpse.d.ts.map +1 -0
- package/lib/components/Autopilot/AutopilotGlimpse.js +26 -0
- package/lib/components/Autopilot/AutopilotGlimpse.js.map +1 -0
- package/lib/components/Autopilot/index.d.ts +4 -0
- package/lib/components/Autopilot/index.d.ts.map +1 -0
- package/lib/components/Autopilot/index.js +3 -0
- package/lib/components/Autopilot/index.js.map +1 -0
- package/lib/components/Chat/Chat.d.ts +6 -6
- package/lib/components/Chat/Chat.d.ts.map +1 -1
- package/lib/components/Chat/Chat.js.map +1 -1
- package/lib/components/Chat/Chat.types.d.ts +3 -3
- package/lib/components/Chat/Chat.types.d.ts.map +1 -1
- package/lib/components/Chat/Chat.types.js.map +1 -1
- package/lib/components/Chat/ChatBody.d.ts +3 -3
- package/lib/components/Chat/ChatBody.d.ts.map +1 -1
- package/lib/components/Chat/ChatBody.js +1 -1
- package/lib/components/Chat/ChatBody.js.map +1 -1
- package/lib/components/Chat/ChatComposer.d.ts +9 -2
- package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
- package/lib/components/Chat/ChatComposer.js +4 -4
- package/lib/components/Chat/ChatComposer.js.map +1 -1
- package/lib/components/Chat/ChatHeader.d.ts +2 -2
- package/lib/components/Chat/ChatHeader.d.ts.map +1 -1
- package/lib/components/Chat/ChatHeader.js.map +1 -1
- package/lib/components/Chat/ChatSettingsPanel.d.ts +2 -2
- package/lib/components/Chat/ChatSettingsPanel.d.ts.map +1 -1
- package/lib/components/Chat/ChatSettingsPanel.js.map +1 -1
- package/lib/components/Chat/ChatSettingsPanel.styles.d.ts +2 -2
- package/lib/components/Chat/ChatSettingsPanel.styles.d.ts.map +1 -1
- package/lib/components/Chat/ChatSettingsPanel.styles.js.map +1 -1
- package/lib/components/Chat/Message.d.ts +3 -3
- package/lib/components/Chat/Message.d.ts.map +1 -1
- package/lib/components/Chat/Message.js.map +1 -1
- package/lib/components/Chat/Message.styles.d.ts +4 -4
- package/lib/components/Chat/Message.styles.d.ts.map +1 -1
- package/lib/components/Chat/Message.styles.js.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.d.ts +19 -8
- package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.js +80 -30
- package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
- package/lib/components/Chat/SystemMessage.d.ts +3 -3
- package/lib/components/Chat/SystemMessage.d.ts.map +1 -1
- package/lib/components/Chat/SystemMessage.js.map +1 -1
- package/lib/components/Chat/TypeIndicator.d.ts +3 -3
- package/lib/components/Chat/TypeIndicator.d.ts.map +1 -1
- package/lib/components/Chat/TypeIndicator.js.map +1 -1
- package/lib/components/Chat/index.d.ts +1 -1
- package/lib/components/Chat/index.d.ts.map +1 -1
- package/lib/components/Chat/index.js +1 -1
- package/lib/components/Chat/index.js.map +1 -1
- package/lib/components/Email/ContextMenuPopover.d.ts +2 -2
- package/lib/components/Email/ContextMenuPopover.d.ts.map +1 -1
- package/lib/components/Email/ContextMenuPopover.js.map +1 -1
- package/lib/components/Email/Email.d.ts +3 -3
- package/lib/components/Email/Email.d.ts.map +1 -1
- package/lib/components/Email/Email.js +8 -4
- package/lib/components/Email/Email.js.map +1 -1
- package/lib/components/Email/Email.styles.d.ts +4 -2
- package/lib/components/Email/Email.styles.d.ts.map +1 -1
- package/lib/components/Email/Email.styles.js +5 -7
- package/lib/components/Email/Email.styles.js.map +1 -1
- package/lib/components/Email/Email.types.d.ts +18 -7
- package/lib/components/Email/Email.types.d.ts.map +1 -1
- package/lib/components/Email/Email.types.js.map +1 -1
- package/lib/components/Email/EmailCaseView.d.ts +3 -3
- package/lib/components/Email/EmailCaseView.d.ts.map +1 -1
- package/lib/components/Email/EmailCaseView.js.map +1 -1
- package/lib/components/Email/EmailComposer.d.ts +4 -4
- package/lib/components/Email/EmailComposer.d.ts.map +1 -1
- package/lib/components/Email/EmailComposer.js +25 -6
- package/lib/components/Email/EmailComposer.js.map +1 -1
- package/lib/components/Email/EmailConversation.d.ts +3 -3
- package/lib/components/Email/EmailConversation.d.ts.map +1 -1
- package/lib/components/Email/EmailConversation.js.map +1 -1
- package/lib/components/Email/EmailEntity.d.ts +3 -3
- package/lib/components/Email/EmailEntity.d.ts.map +1 -1
- package/lib/components/Email/EmailEntity.js.map +1 -1
- package/lib/components/Email/EmailManager.d.ts +3 -3
- package/lib/components/Email/EmailManager.d.ts.map +1 -1
- package/lib/components/Email/EmailManager.js.map +1 -1
- package/lib/components/Email/EmailNotificationPanel.d.ts +2 -2
- package/lib/components/Email/EmailNotificationPanel.d.ts.map +1 -1
- package/lib/components/Email/EmailNotificationPanel.js +2 -2
- package/lib/components/Email/EmailNotificationPanel.js.map +1 -1
- package/lib/components/Email/EmailSelector.d.ts +3 -3
- package/lib/components/Email/EmailSelector.d.ts.map +1 -1
- package/lib/components/Email/EmailSelector.js.map +1 -1
- package/lib/components/Email/EmailShell.d.ts +3 -3
- package/lib/components/Email/EmailShell.d.ts.map +1 -1
- package/lib/components/Email/EmailShell.js.map +1 -1
- package/lib/components/Email/EmailSummaryItem.d.ts +3 -3
- package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -1
- package/lib/components/Email/EmailSummaryItem.js +5 -3
- package/lib/components/Email/EmailSummaryItem.js.map +1 -1
- package/lib/components/Email/EmailSummaryList.d.ts +3 -3
- package/lib/components/Email/EmailSummaryList.d.ts.map +1 -1
- package/lib/components/Email/EmailSummaryList.js +17 -7
- package/lib/components/Email/EmailSummaryList.js.map +1 -1
- package/lib/components/Email/EntityList.d.ts +3 -3
- package/lib/components/Email/EntityList.d.ts.map +1 -1
- package/lib/components/Email/EntityList.js +3 -2
- package/lib/components/Email/EntityList.js.map +1 -1
- package/lib/components/Email/utils/EntityHighlighter.d.ts +1 -1
- package/lib/components/Email/utils/EntityHighlighter.d.ts.map +1 -1
- package/lib/components/Email/utils/EntityHighlighter.js.map +1 -1
- package/lib/components/Feed/Feed.context.d.ts +14 -4
- package/lib/components/Feed/Feed.context.d.ts.map +1 -1
- package/lib/components/Feed/Feed.context.js +4 -0
- package/lib/components/Feed/Feed.context.js.map +1 -1
- package/lib/components/Feed/Feed.d.ts +3 -3
- package/lib/components/Feed/Feed.d.ts.map +1 -1
- package/lib/components/Feed/Feed.js +7 -2
- package/lib/components/Feed/Feed.js.map +1 -1
- package/lib/components/Feed/Feed.types.d.ts +8 -4
- package/lib/components/Feed/Feed.types.d.ts.map +1 -1
- package/lib/components/Feed/Feed.types.js.map +1 -1
- package/lib/components/Feed/FeedAnnouncer.d.ts +1 -1
- package/lib/components/Feed/FeedAnnouncer.d.ts.map +1 -1
- package/lib/components/Feed/FeedAnnouncer.js.map +1 -1
- package/lib/components/Feed/FeedAttachments.d.ts +2 -2
- package/lib/components/Feed/FeedAttachments.d.ts.map +1 -1
- package/lib/components/Feed/FeedAttachments.js.map +1 -1
- package/lib/components/Feed/FeedContent.d.ts +3 -3
- package/lib/components/Feed/FeedContent.d.ts.map +1 -1
- package/lib/components/Feed/FeedContent.js.map +1 -1
- package/lib/components/Feed/FeedContentFooter.d.ts +2 -2
- package/lib/components/Feed/FeedContentFooter.d.ts.map +1 -1
- package/lib/components/Feed/FeedContentFooter.js.map +1 -1
- package/lib/components/Feed/FeedContentHeader.d.ts +2 -2
- package/lib/components/Feed/FeedContentHeader.d.ts.map +1 -1
- package/lib/components/Feed/FeedContentHeader.js +10 -4
- package/lib/components/Feed/FeedContentHeader.js.map +1 -1
- package/lib/components/Feed/FeedEditRegion.d.ts +3 -3
- package/lib/components/Feed/FeedEditRegion.d.ts.map +1 -1
- package/lib/components/Feed/FeedEditRegion.js.map +1 -1
- package/lib/components/Feed/FeedInputRegion.d.ts +3 -3
- package/lib/components/Feed/FeedInputRegion.d.ts.map +1 -1
- package/lib/components/Feed/FeedInputRegion.js.map +1 -1
- package/lib/components/Feed/FeedLikeButton.d.ts +3 -3
- package/lib/components/Feed/FeedLikeButton.d.ts.map +1 -1
- package/lib/components/Feed/FeedLikeButton.js.map +1 -1
- package/lib/components/Feed/FeedModalList.d.ts +2 -2
- package/lib/components/Feed/FeedModalList.d.ts.map +1 -1
- package/lib/components/Feed/FeedModalList.js.map +1 -1
- package/lib/components/Feed/FeedNewPost.d.ts +3 -3
- package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPost.js +1 -1
- package/lib/components/Feed/FeedNewPost.js.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts +2 -2
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
- package/lib/components/Feed/FeedPost.d.ts +3 -3
- package/lib/components/Feed/FeedPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedPost.js +3 -53
- package/lib/components/Feed/FeedPost.js.map +1 -1
- package/lib/components/Feed/FeedReply.d.ts +3 -3
- package/lib/components/Feed/FeedReply.d.ts.map +1 -1
- package/lib/components/Feed/FeedReply.js +5 -39
- package/lib/components/Feed/FeedReply.js.map +1 -1
- package/lib/components/Feed/FeedReplyInput.d.ts +3 -3
- package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
- package/lib/components/Feed/FeedReplyInput.js +1 -1
- package/lib/components/Feed/FeedReplyInput.js.map +1 -1
- package/lib/components/Feed/FeedRichText.d.ts +3 -3
- package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
- package/lib/components/Feed/FeedRichText.js +41 -5
- package/lib/components/Feed/FeedRichText.js.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.d.ts +2 -2
- package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
- package/lib/components/MentionButton/MentionButton.d.ts +2 -2
- package/lib/components/MentionButton/MentionButton.d.ts.map +1 -1
- package/lib/components/MentionButton/MentionButton.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +14 -20
|
@@ -40,7 +40,7 @@ export const StyledReplies = styled.div(({ theme }) => css `
|
|
|
40
40
|
StyledReplies.defaultProps = defaultThemeProp;
|
|
41
41
|
const FeedPost = (props) => {
|
|
42
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);
|
|
43
|
+
const { announce, autopilotInfo } = useContext(FeedContext);
|
|
44
44
|
const variant = 'post';
|
|
45
45
|
const t = useI18n();
|
|
46
46
|
const [editMode, setEditMode] = useState(false);
|
|
@@ -66,62 +66,12 @@ const FeedPost = (props) => {
|
|
|
66
66
|
}
|
|
67
67
|
}, [replies]);
|
|
68
68
|
const hasReplies = !!replies?.length;
|
|
69
|
+
const adjustedUsername = username === autopilotInfo.label ? autopilotInfo.id : username;
|
|
69
70
|
return (_jsx(FeedReplyContext.Provider, { value: replyCtxValue, children: _jsx(StyledFeedPost, { ...restProps, onMouseEnter: () => {
|
|
70
71
|
onMouseEnter?.({ id });
|
|
71
72
|
}, onMouseLeave: () => {
|
|
72
73
|
onMouseLeave?.({ id });
|
|
73
|
-
}, children: _jsxs(CardContent, { children: [_jsx(FeedContentHeader, {
|
|
74
|
-
variant,
|
|
75
|
-
id,
|
|
76
|
-
fullname,
|
|
77
|
-
username,
|
|
78
|
-
postTimestamp,
|
|
79
|
-
content,
|
|
80
|
-
avatarSrc,
|
|
81
|
-
icon,
|
|
82
|
-
userStatus,
|
|
83
|
-
postType,
|
|
84
|
-
postContext,
|
|
85
|
-
recipients,
|
|
86
|
-
recipientsCount,
|
|
87
|
-
menuItems,
|
|
88
|
-
edited,
|
|
89
|
-
editTimestamp,
|
|
90
|
-
recipientsLoading,
|
|
91
|
-
onEditSubmit,
|
|
92
|
-
onLoadMoreRecipients,
|
|
93
|
-
onRecipientInteraction,
|
|
94
|
-
onUserClick,
|
|
95
|
-
setEditMode
|
|
96
|
-
} }), _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, { ...{
|
|
97
|
-
variant,
|
|
98
|
-
id,
|
|
99
|
-
content,
|
|
100
|
-
setEditMode,
|
|
101
|
-
onEditSubmit,
|
|
102
|
-
emptyEditText,
|
|
103
|
-
setEmptyEditText
|
|
104
|
-
} })) : (_jsx(FeedContent, { maxContentHeight: maxContentHeight, children: content })), _jsx(FeedAttachments, { variant: variant, attachments: attachments, readOnly: true })] }), _jsx(FeedContentFooter, { ...{
|
|
105
|
-
variant,
|
|
106
|
-
id,
|
|
107
|
-
username,
|
|
108
|
-
liked,
|
|
109
|
-
likes,
|
|
110
|
-
likeCount,
|
|
111
|
-
interactionsEnabled,
|
|
112
|
-
likesLoading,
|
|
113
|
-
replies,
|
|
114
|
-
replyCount,
|
|
115
|
-
repliesLoading,
|
|
116
|
-
onCommentClick,
|
|
117
|
-
onLikeClick,
|
|
118
|
-
onLikeCountInteraction,
|
|
119
|
-
onLoadMoreLikes,
|
|
120
|
-
onShowMoreReplies,
|
|
121
|
-
onShowLessReplies,
|
|
122
|
-
replyInputOpen,
|
|
123
|
-
setReplyInputOpen
|
|
124
|
-
} }), _jsxs(StyledReplies, { children: [hasReplies && replies, replyInputShown ||
|
|
74
|
+
}, children: _jsxs(CardContent, { children: [_jsx(FeedContentHeader, { variant: variant, id: id, fullname: fullname, username: adjustedUsername, 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: adjustedUsername, 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 ||
|
|
125
75
|
(replyInputOpen && (_jsx(FeedReplyInput, { onSetInputRef: ({ ref }) => {
|
|
126
76
|
setReplyInputRef(ref);
|
|
127
77
|
}, id: id, attachments: replyInput.attachments, onFilesAdded: replyInput.onFilesAdded, onSubmit: e => {
|
|
@@ -1 +1 @@
|
|
|
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,qBAAqB,CAAC;AACpD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,YAAY,CAAC,kBAAk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Z,iBAAiB,CAAC,KAAK,CAAC,CAAC;gDACzB,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;4CACzB,CAAC,GACD,CACH,CAAC,IACU,EACf,iBAAiB,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CACxC,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,aAC5D,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;4CACZ,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;4CAC1B,wBAAwB,CAAC,OAAO,GAAG,IAAI,CAAC;wCAC1C,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 {...{\n variant,\n id,\n fullname,\n username,\n postTimestamp,\n content,\n avatarSrc,\n icon,\n userStatus,\n postType,\n postContext,\n recipients,\n recipientsCount,\n menuItems,\n edited,\n editTimestamp,\n recipientsLoading,\n onEditSubmit,\n onLoadMoreRecipients,\n onRecipientInteraction,\n onUserClick,\n setEditMode\n }}\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 {...{\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 <FeedContentFooter\n {...{\n variant,\n id,\n username,\n liked,\n likes,\n likeCount,\n interactionsEnabled,\n likesLoading,\n replies,\n replyCount,\n repliesLoading,\n onCommentClick,\n onLikeClick,\n onLikeCountInteraction,\n onLoadMoreLikes,\n onShowMoreReplies,\n onShowLessReplies,\n replyInputOpen,\n setReplyInputOpen\n }}\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
|
+
{"version":3,"file":"FeedPost.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedPost.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,WAAW,EACZ,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,kBAAkB,MAAM,yEAAyE,CAAC;AAC9G,OAAO,KAAK,a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AC,GACD,CACH,CAAC,IACU,EACf,iBAAiB,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CACxC,MAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,aAC5D,KAAC,MAAM,IACL,OAAO,EAAC,MAAM,EACd,OAAO,EAAE,GAAG,EAAE;4CACZ,iBAAiB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;4CAC1B,wBAAwB,CAAC,OAAO,GAAG,IAAI,CAAC;wCAC1C,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 { useState, useEffect, useRef, useContext, useMemo } from 'react';\nimport type { FC, MutableRefObject } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n Card,\n CardContent,\n Flex,\n registerIcon,\n defaultThemeProp,\n useI18n,\n Progress,\n usePrevious\n} from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\nimport type { 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 type { 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, autopilotInfo } = 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 const adjustedUsername = username === autopilotInfo.label ? autopilotInfo.id : username;\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={adjustedUsername}\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={adjustedUsername}\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,6 +1,6 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { FeedReplyProps } from './Feed.types';
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { FeedReplyProps } from './Feed.types';
|
|
4
4
|
export declare const StyledFeedReplyContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
5
5
|
declare const FeedReply: FC<ForwardProps & FeedReplyProps>;
|
|
6
6
|
export default FeedReply;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedReply.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeedReply.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAUnD,eAAO,MAAM,wBAAwB,yGAAe,CAAC;AAcrD,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,YAAY,GAAG,cAAc,CAuGhD,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import { useContext, useState } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { Flex, registerIcon, defaultThemeProp } from '@pega/cosmos-react-core';
|
|
5
5
|
import * as chatIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/chat.icon';
|
|
@@ -10,6 +10,7 @@ import FeedContent from './FeedContent';
|
|
|
10
10
|
import FeedContentHeader from './FeedContentHeader';
|
|
11
11
|
import FeedContentFooter from './FeedContentFooter';
|
|
12
12
|
import FeedEditRegion from './FeedEditRegion';
|
|
13
|
+
import { FeedContext } from './Feed.context';
|
|
13
14
|
registerIcon(chatIcon, thumbsUpSolidIcon, thumbsUpIcon);
|
|
14
15
|
export const StyledFeedReplyContainer = styled.div ``;
|
|
15
16
|
StyledFeedReplyContainer.defaultProps = defaultThemeProp;
|
|
@@ -24,50 +25,15 @@ StyledReplyContent.defaultProps = defaultThemeProp;
|
|
|
24
25
|
const FeedReply = (props) => {
|
|
25
26
|
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
27
|
const variant = 'reply';
|
|
28
|
+
const { autopilotInfo } = useContext(FeedContext);
|
|
27
29
|
const [editMode, setEditMode] = useState(false);
|
|
28
30
|
const [emptyEditText, setEmptyEditText] = useState(false);
|
|
31
|
+
const adjustedUsername = username === autopilotInfo.label ? autopilotInfo.id : username;
|
|
29
32
|
return (_jsxs(StyledFeedReplyContainer, { onMouseEnter: () => {
|
|
30
33
|
onMouseEnter?.({ id });
|
|
31
34
|
}, onMouseLeave: () => {
|
|
32
35
|
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
|
-
} })] })] }));
|
|
36
|
+
}, ...restProps, children: [_jsx(FeedContentHeader, { variant: variant, id: id, fullname: fullname, username: adjustedUsername, 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: adjustedUsername, liked: liked, likes: likes, likeCount: likeCount, interactionsEnabled: interactionsEnabled, likesLoading: likesLoading, onCommentClick: onCommentClick, onLikeClick: onLikeClick, onLikeCountInteraction: onLikeCountInteraction, onLoadMoreLikes: onLoadMoreLikes })] })] }));
|
|
71
37
|
};
|
|
72
38
|
export default FeedReply;
|
|
73
39
|
//# sourceMappingURL=FeedReply.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedReply.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FeedReply.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedReply.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE/E,OAAO,KAAK,QAAQ,MAAM,6DAA6D,CAAC;AACxF,OAAO,KAAK,iBAAiB,MAAM,wEAAwE,CAAC;AAC5G,OAAO,KAAK,YAAY,MAAM,kEAAkE,CAAC;AAGjG,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAErD,wBAAwB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEzD,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAClD,OAAO,GAAG,CAAA;oCACwB,KAAK,CAAC,IAAI,CAAC,OAAO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pB,mBAAmB,EAAE,mBAAmB,EACxC,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW,EACxB,sBAAsB,EAAE,sBAAsB,EAC9C,eAAe,EAAE,eAAe,GAChC,IACiB,IACI,CAC5B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import { useContext, useState } from 'react';\nimport type { FC } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { Flex, registerIcon, defaultThemeProp } from '@pega/cosmos-react-core';\nimport type { 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 type { FeedReplyProps } from './Feed.types';\nimport FeedAttachments from './FeedAttachments';\nimport FeedContent from './FeedContent';\nimport FeedContentHeader from './FeedContentHeader';\nimport FeedContentFooter from './FeedContentFooter';\nimport FeedEditRegion from './FeedEditRegion';\nimport { FeedContext } from './Feed.context';\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 { autopilotInfo } = useContext(FeedContext);\n const [editMode, setEditMode] = useState(false);\n const [emptyEditText, setEmptyEditText] = useState(false);\n\n const adjustedUsername = username === autopilotInfo.label ? autopilotInfo.id : username;\n\n return (\n <StyledFeedReplyContainer\n onMouseEnter={() => {\n onMouseEnter?.({ id });\n }}\n onMouseLeave={() => {\n onMouseLeave?.({ id });\n }}\n {...restProps}\n >\n <FeedContentHeader\n variant={variant}\n id={id}\n fullname={fullname}\n username={adjustedUsername}\n postTimestamp={postTimestamp}\n content={content}\n avatarSrc={avatarSrc}\n icon={icon}\n userStatus={userStatus}\n menuItems={menuItems}\n edited={edited}\n editTimestamp={editTimestamp}\n onEditSubmit={onEditSubmit}\n onUserClick={onUserClick}\n setEditMode={setEditMode}\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 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\n <FeedContentFooter\n variant={variant}\n id={id}\n username={adjustedUsername}\n liked={liked}\n likes={likes}\n likeCount={likeCount}\n interactionsEnabled={interactionsEnabled}\n likesLoading={likesLoading}\n onCommentClick={onCommentClick}\n onLikeClick={onLikeClick}\n onLikeCountInteraction={onLikeCountInteraction}\n onLoadMoreLikes={onLoadMoreLikes}\n />\n </StyledReplyContent>\n </StyledFeedReplyContainer>\n );\n};\n\nexport default FeedReply;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { FeedReplyInputProps } from './Feed.types';
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { FeedReplyInputProps } from './Feed.types';
|
|
4
4
|
export declare const StyledReplyInputContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
5
5
|
declare const FeedReplyInput: FC<ForwardProps & FeedReplyInputProps>;
|
|
6
6
|
export default FeedReplyInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedReplyInput.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReplyInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeedReplyInput.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedReplyInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAKxD,eAAO,MAAM,yBAAyB,yGAAe,CAAC;AAItD,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,YAAY,GAAG,mBAAmB,CAwB1D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -15,7 +15,7 @@ const FeedReplyInput = (props) => {
|
|
|
15
15
|
useEffect(() => {
|
|
16
16
|
onSetInputRef?.({ ref: rteRef });
|
|
17
17
|
}, [rteRef]);
|
|
18
|
-
return (_jsx(StyledReplyInputContainer, { ref: setNewReplyEl, ...restProps, children: _jsx(FeedInputRegion, { variant: 'reply',
|
|
18
|
+
return (_jsx(StyledReplyInputContainer, { ref: setNewReplyEl, ...restProps, children: _jsx(FeedInputRegion, { variant: 'reply', id: id, attachments: attachments, onFilesAdded: onFilesAdded, onSubmit: onSubmit, inputRegionEl: newReplyEl, rteRef: rteRef }) }));
|
|
19
19
|
};
|
|
20
20
|
export default FeedReplyInput;
|
|
21
21
|
//# sourceMappingURL=FeedReplyInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedReplyInput.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedReplyInput.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FeedReplyInput.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedReplyInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrF,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,EACf,EAAE,EAAE,EAAE,EACN,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,UAAU,EACzB,MAAM,EAAE,MAAM,GACd,GACwB,CAC7B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { useRef, useEffect } from 'react';\nimport type { FC } from 'react';\nimport styled from 'styled-components';\n\nimport { registerIcon, defaultThemeProp, useElement } from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\nimport type { 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 type { 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={id}\n attachments={attachments}\n onFilesAdded={onFilesAdded}\n onSubmit={onSubmit}\n inputRegionEl={newReplyEl}\n rteRef={rteRef}\n />\n </StyledReplyInputContainer>\n );\n};\n\nexport default FeedReplyInput;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
-
import { FeedRichTextProps } from './Feed.types';
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
|
+
import type { FeedRichTextProps } from './Feed.types';
|
|
4
4
|
declare const FeedRichText: FC<FeedRichTextProps & ForwardProps>;
|
|
5
5
|
export default FeedRichText;
|
|
6
6
|
//# sourceMappingURL=FeedRichText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedRichText.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeedRichText.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedRichText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAO,MAAM,OAAO,CAAC;AAGrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAS5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,QAAA,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,GAAG,YAAY,CAgLrD,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useContext, forwardRef, useState, useRef } from 'react';
|
|
3
|
-
import { cap, useI18n } from '@pega/cosmos-react-core';
|
|
3
|
+
import { cap, Icon, useI18n } from '@pega/cosmos-react-core';
|
|
4
4
|
import { getXMLAttributes, RichTextEditor } from '@pega/cosmos-react-rte';
|
|
5
5
|
import { MentionButtonConfig } from '../MentionButton';
|
|
6
6
|
import { HashtagButtonConfig } from '../HashtagButton';
|
|
7
|
+
import { AutopilotConfig } from '../Autopilot';
|
|
7
8
|
import { FeedContext } from './Feed.context';
|
|
8
9
|
const FeedRichText = forwardRef(function FeedRichText(props, ref) {
|
|
9
10
|
const { height = { min: 'auto' }, ...restProps } = props;
|
|
10
|
-
const { searchTypes = [], onSearch, searchResults = [], showSearchResults } = useContext(FeedContext);
|
|
11
|
+
const { autopilotInfo: { id: autopilotId, label: autopilotLabel }, searchTypes = [], onSearch, searchResults = [], showSearchResults } = useContext(FeedContext);
|
|
11
12
|
const [triggerType, setTriggerType] = useState('mention');
|
|
12
13
|
const [showMentionType, setShowMentionType] = useState(false);
|
|
13
14
|
const searchType = useRef('');
|
|
@@ -20,7 +21,11 @@ const FeedRichText = forwardRef(function FeedRichText(props, ref) {
|
|
|
20
21
|
}
|
|
21
22
|
else {
|
|
22
23
|
setShowMentionType(false);
|
|
23
|
-
onSearch?.({
|
|
24
|
+
onSearch?.({
|
|
25
|
+
type: trigger,
|
|
26
|
+
search: event.search,
|
|
27
|
+
mentionType: searchType.current
|
|
28
|
+
});
|
|
24
29
|
}
|
|
25
30
|
};
|
|
26
31
|
const typesMenu = {
|
|
@@ -30,10 +35,16 @@ const FeedRichText = forwardRef(function FeedRichText(props, ref) {
|
|
|
30
35
|
onItemClick: (id) => {
|
|
31
36
|
searchType.current = id;
|
|
32
37
|
setShowMentionType(false);
|
|
33
|
-
|
|
38
|
+
if (id !== autopilotId) {
|
|
39
|
+
onSearch?.({ type: 'mention', search: '', mentionType: id });
|
|
40
|
+
}
|
|
34
41
|
},
|
|
35
42
|
items: searchTypes.map(type => {
|
|
36
|
-
return {
|
|
43
|
+
return {
|
|
44
|
+
id: type,
|
|
45
|
+
primary: type === autopilotId ? autopilotLabel : cap(type),
|
|
46
|
+
visual: _jsx(Icon, { name: type === autopilotId ? 'polaris' : type })
|
|
47
|
+
};
|
|
37
48
|
})
|
|
38
49
|
};
|
|
39
50
|
const searchMenu = searchResults.length && showSearchResults
|
|
@@ -68,6 +79,17 @@ const FeedRichText = forwardRef(function FeedRichText(props, ref) {
|
|
|
68
79
|
text: attributes.tag
|
|
69
80
|
};
|
|
70
81
|
}
|
|
82
|
+
case 'pega-autopilot': {
|
|
83
|
+
const attributes = getXMLAttributes(searchResult);
|
|
84
|
+
if (!attributes)
|
|
85
|
+
return;
|
|
86
|
+
return {
|
|
87
|
+
markdown: searchResult,
|
|
88
|
+
component: AutopilotConfig.component,
|
|
89
|
+
props: attributes,
|
|
90
|
+
text: autopilotLabel
|
|
91
|
+
};
|
|
92
|
+
}
|
|
71
93
|
default:
|
|
72
94
|
}
|
|
73
95
|
};
|
|
@@ -75,6 +97,14 @@ const FeedRichText = forwardRef(function FeedRichText(props, ref) {
|
|
|
75
97
|
{ trigger: '@', regex: String.raw `(?:\S+(?:[^\n\S][^@#\s]\S*)*[^\n\S]?|)` },
|
|
76
98
|
{ trigger: '#', regex: String.raw `[^\s,]*` }
|
|
77
99
|
], getSearchItemReplacement: (id) => {
|
|
100
|
+
if (id === autopilotId) {
|
|
101
|
+
return {
|
|
102
|
+
markdown: AutopilotConfig.inject(),
|
|
103
|
+
component: AutopilotConfig.component,
|
|
104
|
+
props: {},
|
|
105
|
+
text: autopilotLabel
|
|
106
|
+
};
|
|
107
|
+
}
|
|
78
108
|
const item = searchResults?.find(({ id: itemId }) => itemId === id);
|
|
79
109
|
if (!item)
|
|
80
110
|
return undefined;
|
|
@@ -112,6 +142,12 @@ const FeedRichText = forwardRef(function FeedRichText(props, ref) {
|
|
|
112
142
|
xmlElement: HashtagButtonConfig.xmlElement,
|
|
113
143
|
regexPattern: HashtagButtonConfig.regexPattern,
|
|
114
144
|
getSearchAttributes
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
type: AutopilotConfig.type,
|
|
148
|
+
xmlElement: AutopilotConfig.xmlElement,
|
|
149
|
+
regexPattern: AutopilotConfig.regexPattern,
|
|
150
|
+
getSearchAttributes
|
|
115
151
|
}
|
|
116
152
|
], onSearch: onDecoSearch, menu: showMentionType ? typesMenu : searchMenu }));
|
|
117
153
|
});
|
|
@@ -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,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,CAAC,SAAS,YAAY,CACzF,KAAwB,EACxB,GAA6B;IAE7B,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,OAAO,GAAG,KAAK,CAAC,O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C,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,CAAC,CAAC;AAEH,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(function FeedRichText(\n props: FeedRichTextProps,\n ref: Ref<RichTextEditorState>\n) {\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\nexport default FeedRichText;\n"]}
|
|
1
|
+
{"version":3,"file":"FeedRichText.js","sourceRoot":"","sources":["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AAC,CAAC,mBAAmB,CAAC,SAAS;gBACnC,KAAK,EACH,WAAW,KAAK,SAAS;oBACvB,CAAC,CAAC;wBACE,EAAE,EAAE,IAAI,CAAC,EAAE;wBACX,IAAI,EAAE,IAAI,CAAC,OAAO;wBAClB,IAAI,EAAE,UAAU,CAAC,OAAO;wBACxB,QAAQ,EAAE,CAAC,CAAC;qBACb;oBACH,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;gBACzC,IAAI,EAAE,IAAI,CAAC,OAAO;aACnB,CAAC;QACJ,CAAC,EACD,eAAe,EAAE;YACf;gBACE,IAAI,EAAE,mBAAmB,CAAC,IAAI;gBAC9B,UAAU,EAAE,mBAAmB,CAAC,UAAU;gBAC1C,YAAY,EAAE,mBAAmB,CAAC,YAAY;gBAC9C,mBAAmB;aACpB;YACD;gBACE,IAAI,EAAE,mBAAmB,CAAC,IAAI;gBAC9B,UAAU,EAAE,mBAAmB,CAAC,UAAU;gBAC1C,YAAY,EAAE,mBAAmB,CAAC,YAAY;gBAC9C,mBAAmB;aACpB;YACD;gBACE,IAAI,EAAE,eAAe,CAAC,IAAI;gBAC1B,UAAU,EAAE,eAAe,CAAC,UAAU;gBACtC,YAAY,EAAE,eAAe,CAAC,YAAY;gBAC1C,mBAAmB;aACpB;SACF,EACD,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAC9C,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,YAAY,CAAC","sourcesContent":["import { useContext, forwardRef, useState, useRef } from 'react';\nimport type { FC, Ref } from 'react';\n\nimport { cap, Icon, useI18n } from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\nimport { getXMLAttributes, RichTextEditor } from '@pega/cosmos-react-rte';\nimport type { RichTextEditorState } from '@pega/cosmos-react-rte';\n\nimport { MentionButtonConfig } from '../MentionButton';\nimport { HashtagButtonConfig } from '../HashtagButton';\nimport { AutopilotConfig } from '../Autopilot';\n\nimport { FeedContext } from './Feed.context';\nimport type { FeedRichTextProps } from './Feed.types';\n\nconst FeedRichText: FC<FeedRichTextProps & ForwardProps> = forwardRef(function FeedRichText(\n props: FeedRichTextProps,\n ref: Ref<RichTextEditorState>\n) {\n const { height = { min: 'auto' }, ...restProps } = props;\n const {\n autopilotInfo: { id: autopilotId, label: autopilotLabel },\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?.({\n type: trigger,\n search: event.search,\n mentionType: searchType.current\n });\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\n if (id !== autopilotId) {\n onSearch?.({ type: 'mention', search: '', mentionType: id });\n }\n },\n items: searchTypes.map(type => {\n return {\n id: type,\n primary: type === autopilotId ? autopilotLabel : cap(type),\n visual: <Icon name={type === autopilotId ? 'polaris' : type} />\n };\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 case 'pega-autopilot': {\n const attributes = getXMLAttributes(searchResult);\n\n if (!attributes) return;\n return {\n markdown: searchResult,\n component: AutopilotConfig.component,\n props: attributes,\n text: autopilotLabel\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 if (id === autopilotId) {\n return {\n markdown: AutopilotConfig.inject(),\n component: AutopilotConfig.component,\n props: {},\n text: autopilotLabel\n };\n }\n\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 type: AutopilotConfig.type,\n xmlElement: AutopilotConfig.xmlElement,\n regexPattern: AutopilotConfig.regexPattern,\n getSearchAttributes\n }\n ]}\n onSearch={onDecoSearch}\n menu={showMentionType ? typesMenu : searchMenu}\n />\n );\n});\n\nexport default FeedRichText;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FunctionComponent, ReactElement } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
1
|
+
import type { FunctionComponent, ReactElement } from 'react';
|
|
2
|
+
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
3
|
interface HashtagButtonProps {
|
|
4
4
|
/** Text for the button, or an object containing all necessary props. */
|
|
5
5
|
children: Record<string, string> | ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashtagButton.d.ts","sourceRoot":"","sources":["../../../src/components/HashtagButton/HashtagButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HashtagButton.d.ts","sourceRoot":"","sources":["../../../src/components/HashtagButton/HashtagButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAmB,YAAY,EAAO,MAAM,OAAO,CAAC;AAInF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK5D,UAAU,kBAAkB;IAC1B,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC;IAChD,qBAAqB;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAQD,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAsBvE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;aAKL,MAAM;;uBAQZ,MAAM;;;CAM1B,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashtagButton.js","sourceRoot":"","sources":["../../../src/components/HashtagButton/HashtagButton.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"HashtagButton.js","sourceRoot":"","sources":["../../../src/components/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AAK;IACX,UAAU,EAAE,UAAU;IACtB,YAAY,EAAE,0CAA0C;IACxD,SAAS,EAAE,aAAa;IACxB,MAAM,EAAE,CAAC,EAAE,GAAG,EAAmB,EAAE,EAAE;QACnC,IAAI,CAAC,GAAG;YAAE,OAAO;QAEjB,MAAM,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC3D,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEjC,OAAO,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE,CAAC,OAAe,EAAE,EAAE;QAC3B,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAE7C,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,GAAG;YAAE,OAAO,SAAS,CAAC;QACrD,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC;IACjC,CAAC;CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef, isValidElement, useContext } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, ReactElement, Ref } from 'react';\nimport styled from 'styled-components';\n\nimport { Tag } from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\nimport { getXMLAttributes } from '@pega/cosmos-react-rte';\n\nimport { FeedContext } from '../Feed/Feed.context';\n\ninterface HashtagButtonProps {\n /** Text for the button, or an object containing all necessary props. */\n children: Record<string, string> | ReactElement;\n /** The tag value. */\n tag?: string;\n}\n\nconst StyledTag = styled(Tag)`\n cursor: pointer;\n`;\n\nconst serializer = new XMLSerializer();\n\nconst HashtagButton: FunctionComponent<HashtagButtonProps & ForwardProps> = forwardRef(\n function HashtagButton(\n { children, tag: tagProp = '', ...restProps }: PropsWithoutRef<HashtagButtonProps>,\n ref: Ref<HTMLButtonElement>\n ) {\n const { onTagClick } = useContext(FeedContext);\n\n let tag = '';\n\n if (!isValidElement<any>(children)) {\n if (!children.tag) return <span>{children.rawText}</span>;\n tag = children.tag;\n } else {\n tag = tagProp;\n }\n\n return (\n <StyledTag {...restProps} ref={ref} onClick={() => onTagClick?.(tag)} spellCheck={false}>\n {isValidElement(children) ? children : tag}\n </StyledTag>\n );\n }\n);\n\nexport const HashtagButtonConfig = {\n type: 'tag',\n xmlElement: 'pega-tag',\n regexPattern: /(?:^|)<pega-tag (?:[^\\n/]|\\/(?!>))+\\/>/gm,\n component: HashtagButton,\n inject: ({ tag }: { tag: string }) => {\n if (!tag) return;\n\n const element = document.createElementNS(null, 'pega-tag');\n element.setAttribute('tag', tag);\n\n return serializer.serializeToString(element);\n },\n extract: (element: string) => {\n const attributes = getXMLAttributes(element);\n\n if (!attributes || !attributes.tag) return undefined;\n return { tag: attributes.tag };\n }\n};\n\nexport default HashtagButton;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FunctionComponent, ReactElement } from 'react';
|
|
2
|
-
import { ForwardProps } from '@pega/cosmos-react-core';
|
|
1
|
+
import type { FunctionComponent, ReactElement } from 'react';
|
|
2
|
+
import type { ForwardProps } from '@pega/cosmos-react-core';
|
|
3
3
|
interface MentionButtonProps {
|
|
4
4
|
/** Text for the button, or an object containing all necessary props. */
|
|
5
5
|
children: Record<string, string> | ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionButton.d.ts","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MentionButton.d.ts","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAmB,YAAY,EAAmB,MAAM,OAAO,CAAC;AAI/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAK5D,UAAU,kBAAkB;IAC1B,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC;IAChD,6BAA6B;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAoBD,QAAA,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,GAAG,YAAY,CAoFvE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;YAKW,MAAM;cAAQ,MAAM;cAAQ,MAAM;;;uBAWxD,MAAM;;;;;;CAW1B,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MentionButton.js","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"MentionButton.js","sourceRoot":"","sources":["../../../src/components/MentionButton/MentionButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAenD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;;;;;;CAMlC,CAAC;AAEF,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;;;CAM9B,CAAC;AAEF,MAAM,UAAU,GAAG,IAAI,aAAa,EAAE,CAAC;AAEvC,MAAM,aAAa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,EAAE,IAAI,EAAE,IAAI,EAA6D,EAAE,EAAE;QAC9F,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO;QAElC,MAAM,OAAO,GAAG,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC/D,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/B,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACnC,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI;YAAE,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAE7C,OAAO,UAAU,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE,CAAC,OAAe,EAAE,EAAE;QAC3B,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAE7C,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAC5F,OAAO;YACL,EAAE,EAAE,UAAU,CAAC,EAAE;YACjB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,IAAI,EAAE,UAAU,CAAC,IAAI;SACtB,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { forwardRef, isValidElement, useContext, useState } from 'react';\nimport type { FunctionComponent, PropsWithoutRef, ReactElement, Ref, MouseEvent } from 'react';\nimport styled from 'styled-components';\n\nimport { Button, Link, useConsolidatedRef, useElement } from '@pega/cosmos-react-core';\nimport type { ForwardProps } from '@pega/cosmos-react-core';\nimport { getXMLAttributes } from '@pega/cosmos-react-rte';\n\nimport { FeedContext } from '../Feed/Feed.context';\n\ninterface MentionButtonProps {\n /** Text for the button, or an object containing all necessary props. */\n children: Record<string, string> | ReactElement;\n /** The id of the mention. */\n id?: string;\n /** The text of the mention button. */\n text?: string;\n /** Designates the type of the mention for proper handling on click. */\n type?: string;\n /** If an href is provided, render a link. Otherwise, render a button. */\n href?: string;\n}\n\nconst StyledButton = styled(Button)`\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: none;\n text-decoration: underline;\n }\n`;\n\nconst StyledLink = styled(Link)`\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: none;\n text-decoration: underline;\n }\n`;\n\nconst serializer = new XMLSerializer();\n\nconst MentionButton: FunctionComponent<MentionButtonProps & ForwardProps> = forwardRef(\n function MentionButton(\n {\n children,\n id: idProp = '',\n text: textProp = '',\n type: typeProp = '',\n href: hrefProp = '',\n ...restProps\n }: PropsWithoutRef<MentionButtonProps>,\n ref: Ref<HTMLButtonElement>\n ) {\n const { onMentionClick, onMentionPreview } = useContext(FeedContext);\n const [mentionContent, setMentionContent] = useState<JSX.Element | undefined>();\n const [target, setTarget] = useElement<HTMLButtonElement>(null);\n const mentionRef = useConsolidatedRef(ref);\n\n let id = '';\n let text = '';\n let type = '';\n let href = '';\n\n if (!isValidElement<any>(children)) {\n if (!children.id || !children.text || !children.type) return <span>{children.rawText}</span>;\n id = children.id;\n text = children.text;\n type = children.type;\n href = children.href || '';\n } else {\n id = idProp;\n text = textProp;\n type = typeProp;\n href = hrefProp;\n }\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n setTarget(e.currentTarget);\n const comp = onMentionClick?.({\n id,\n text,\n type,\n target: e.currentTarget,\n closeGlimpse: () => setTarget(null)\n });\n if (comp) setMentionContent(comp);\n };\n\n return (\n <>\n {href ? (\n <StyledLink\n {...restProps}\n ref={mentionRef}\n href={href}\n previewable={!!onMentionPreview}\n onPreview={\n onMentionPreview\n ? () =>\n onMentionPreview({\n id,\n text,\n type\n })\n : undefined\n }\n spellCheck={false}\n >\n {isValidElement(children) ? children : text}\n </StyledLink>\n ) : (\n <StyledButton\n {...restProps}\n ref={mentionRef}\n variant='link'\n onClick={handleClick}\n spellCheck={false}\n >\n {isValidElement(children) ? children : text}\n </StyledButton>\n )}\n {target && mentionContent}\n </>\n );\n }\n);\n\nexport const MentionButtonConfig = {\n type: 'mention',\n xmlElement: 'pega-mention',\n regexPattern: /(?:^|)<pega-mention (?:[^\\n/]|\\/(?!>))+\\/>/g,\n component: MentionButton,\n inject: ({ id, type, text, href }: { id: string; type: string; text: string; href?: string }) => {\n if (!id || !type || !text) return;\n\n const element = document.createElementNS(null, 'pega-mention');\n element.setAttribute('id', id);\n element.setAttribute('text', text);\n element.setAttribute('type', type);\n if (href) element.setAttribute('href', href);\n\n return serializer.serializeToString(element);\n },\n extract: (element: string) => {\n const attributes = getXMLAttributes(element);\n\n if (!attributes || !attributes.id || !attributes.text || !attributes.type) return undefined;\n return {\n id: attributes.id,\n text: attributes.text,\n type: attributes.type,\n href: attributes.href\n };\n }\n};\n\nexport default MentionButton;\n"]}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACtD,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACtD,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,cAAc,4BAA4B,CAAC"}
|