@pega/cosmos-react-demos 4.0.0-dev.21.0 → 4.0.0-dev.22.1
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/jsx/social/Feed/Feed.mocks.d.ts +18 -13
- package/jsx/social/Feed/Feed.mocks.d.ts.map +1 -1
- package/jsx/social/Feed/Feed.mocks.jsx +74 -8
- package/jsx/social/Feed/Feed.mocks.jsx.map +1 -1
- package/jsx/social/Feed/Feed.stories.d.ts +1 -1
- package/jsx/social/Feed/Feed.stories.d.ts.map +1 -1
- package/jsx/social/Feed/Feed.stories.jsx +12 -12
- package/jsx/social/Feed/Feed.stories.jsx.map +1 -1
- package/jsx/social/Feed/FeedNewPost.mocks.d.ts +8 -0
- package/jsx/social/Feed/FeedNewPost.mocks.d.ts.map +1 -0
- package/jsx/social/Feed/FeedNewPost.mocks.jsx +44 -0
- package/jsx/social/Feed/FeedNewPost.mocks.jsx.map +1 -0
- package/jsx/social/Feed/FeedPost.mocks.d.ts +4 -0
- package/jsx/social/Feed/FeedPost.mocks.d.ts.map +1 -0
- package/jsx/social/Feed/FeedPost.mocks.jsx +167 -0
- package/jsx/social/Feed/FeedPost.mocks.jsx.map +1 -0
- package/jsx/social/Feed/FeedReply.mocks.d.ts +13 -0
- package/jsx/social/Feed/FeedReply.mocks.d.ts.map +1 -0
- package/jsx/social/Feed/FeedReply.mocks.jsx +76 -0
- package/jsx/social/Feed/FeedReply.mocks.jsx.map +1 -0
- package/jsx/work/CaseView/CaseView.mocks.d.ts +1 -1
- package/jsx/work/CaseView/CaseView.mocks.d.ts.map +1 -1
- package/jsx/work/CaseView/CaseView.mocks.jsx.map +1 -1
- package/jsx/work/CaseView/Pulse.mocks.d.ts +1 -1
- package/jsx/work/CaseView/Pulse.mocks.d.ts.map +1 -1
- package/jsx/work/CaseView/Pulse.mocks.jsx.map +1 -1
- package/jsx/wss/CaseView/CaseView.stories.jsx +2 -2
- package/jsx/wss/CaseView/CaseView.stories.jsx.map +1 -1
- package/lib/social/Feed/Feed.mocks.d.ts +18 -13
- package/lib/social/Feed/Feed.mocks.d.ts.map +1 -1
- package/lib/social/Feed/Feed.mocks.js +74 -8
- package/lib/social/Feed/Feed.mocks.js.map +1 -1
- package/lib/social/Feed/Feed.stories.d.ts +1 -1
- package/lib/social/Feed/Feed.stories.d.ts.map +1 -1
- package/lib/social/Feed/Feed.stories.js +12 -12
- package/lib/social/Feed/Feed.stories.js.map +1 -1
- package/lib/social/Feed/FeedNewPost.mocks.d.ts +8 -0
- package/lib/social/Feed/FeedNewPost.mocks.d.ts.map +1 -0
- package/lib/social/Feed/FeedNewPost.mocks.js +46 -0
- package/lib/social/Feed/FeedNewPost.mocks.js.map +1 -0
- package/lib/social/Feed/FeedPost.mocks.d.ts +4 -0
- package/lib/social/Feed/FeedPost.mocks.d.ts.map +1 -0
- package/lib/social/Feed/FeedPost.mocks.js +165 -0
- package/lib/social/Feed/FeedPost.mocks.js.map +1 -0
- package/lib/social/Feed/FeedReply.mocks.d.ts +13 -0
- package/lib/social/Feed/FeedReply.mocks.d.ts.map +1 -0
- package/lib/social/Feed/FeedReply.mocks.js +74 -0
- package/lib/social/Feed/FeedReply.mocks.js.map +1 -0
- package/lib/work/CaseView/CaseView.mocks.d.ts +1 -1
- package/lib/work/CaseView/CaseView.mocks.d.ts.map +1 -1
- package/lib/work/CaseView/CaseView.mocks.js.map +1 -1
- package/lib/work/CaseView/Pulse.mocks.d.ts +1 -1
- package/lib/work/CaseView/Pulse.mocks.d.ts.map +1 -1
- package/lib/work/CaseView/Pulse.mocks.js.map +1 -1
- package/lib/wss/CaseView/CaseView.stories.js +2 -2
- package/lib/wss/CaseView/CaseView.stories.js.map +1 -1
- package/package.json +9 -9
- package/jsx/social/Feed/FeedNewPost.stories.d.ts +0 -10
- package/jsx/social/Feed/FeedNewPost.stories.d.ts.map +0 -1
- package/jsx/social/Feed/FeedNewPost.stories.jsx +0 -81
- package/jsx/social/Feed/FeedNewPost.stories.jsx.map +0 -1
- package/jsx/social/Feed/FeedPost.stories.d.ts +0 -8
- package/jsx/social/Feed/FeedPost.stories.d.ts.map +0 -1
- package/jsx/social/Feed/FeedPost.stories.jsx +0 -266
- package/jsx/social/Feed/FeedPost.stories.jsx.map +0 -1
- package/jsx/social/Feed/FeedReply.stories.d.ts +0 -16
- package/jsx/social/Feed/FeedReply.stories.d.ts.map +0 -1
- package/jsx/social/Feed/FeedReply.stories.jsx +0 -112
- package/jsx/social/Feed/FeedReply.stories.jsx.map +0 -1
- package/jsx/social/Feed/FeedReplyInput.stories.d.ts +0 -10
- package/jsx/social/Feed/FeedReplyInput.stories.d.ts.map +0 -1
- package/jsx/social/Feed/FeedReplyInput.stories.jsx +0 -60
- package/jsx/social/Feed/FeedReplyInput.stories.jsx.map +0 -1
- package/lib/social/Feed/FeedNewPost.stories.d.ts +0 -10
- package/lib/social/Feed/FeedNewPost.stories.d.ts.map +0 -1
- package/lib/social/Feed/FeedNewPost.stories.js +0 -83
- package/lib/social/Feed/FeedNewPost.stories.js.map +0 -1
- package/lib/social/Feed/FeedPost.stories.d.ts +0 -8
- package/lib/social/Feed/FeedPost.stories.d.ts.map +0 -1
- package/lib/social/Feed/FeedPost.stories.js +0 -259
- package/lib/social/Feed/FeedPost.stories.js.map +0 -1
- package/lib/social/Feed/FeedReply.stories.d.ts +0 -16
- package/lib/social/Feed/FeedReply.stories.d.ts.map +0 -1
- package/lib/social/Feed/FeedReply.stories.js +0 -108
- package/lib/social/Feed/FeedReply.stories.js.map +0 -1
- package/lib/social/Feed/FeedReplyInput.stories.d.ts +0 -10
- package/lib/social/Feed/FeedReplyInput.stories.d.ts.map +0 -1
- package/lib/social/Feed/FeedReplyInput.stories.js +0 -61
- package/lib/social/Feed/FeedReplyInput.stories.js.map +0 -1
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback } from 'react';
|
|
2
|
-
import { Avatar, CardContent, Popover, useUID } from '@pega/cosmos-react-core';
|
|
3
|
-
import { Feed, FeedReply, HashtagButtonConfig, MentionButtonConfig } from '@pega/cosmos-react-social';
|
|
4
|
-
import { Glimpse } from '@pega/cosmos-react-work';
|
|
5
|
-
import { generatedLikes, userMentions } from './Feed.mocks';
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Social/Feed/FeedReply',
|
|
8
|
-
component: FeedReply
|
|
9
|
-
};
|
|
10
|
-
export const FeedReplyDemo = ({ fullname = 'Demo User', username = 'demo_user', content, attachments, postTimestamp = new Date(2022, 0, 1), userStatus, renderFeed = true }) => {
|
|
11
|
-
const defaultContent = attachments
|
|
12
|
-
? ''
|
|
13
|
-
: "This reply mentions <pega-mention id='deans' text='Seth DeAngelo' type='user'/> and also contains a tag! <pega-tag tag='cosmos'/>";
|
|
14
|
-
const key = useUID();
|
|
15
|
-
const [likes, setLikes] = useState([]);
|
|
16
|
-
const [liked, setLiked] = useState(false);
|
|
17
|
-
const [likeCount, setLikeCount] = useState(renderFeed ? generatedLikes.length : 0);
|
|
18
|
-
const [replyContent, setReplyContent] = useState(content || defaultContent);
|
|
19
|
-
const [edited, setEdited] = useState(false);
|
|
20
|
-
const [editTimestamp, setEditTimestamp] = useState(new Date());
|
|
21
|
-
const [popoverOpen, setPopoverOpen] = useState(false);
|
|
22
|
-
const [popoverTarget, setPopoverTarget] = useState();
|
|
23
|
-
const [additionalLikeAdded, setAdditionalLikeAdded] = useState(false);
|
|
24
|
-
const getInitialLikes = () => {
|
|
25
|
-
if (likes.length)
|
|
26
|
-
return;
|
|
27
|
-
setLikes(renderFeed ? generatedLikes : []);
|
|
28
|
-
};
|
|
29
|
-
const [likesLoading, setLikesLoading] = useState(false);
|
|
30
|
-
const generateNewLike = useCallback(() => {
|
|
31
|
-
if (!likesLoading) {
|
|
32
|
-
setLikesLoading(true);
|
|
33
|
-
setTimeout(() => {
|
|
34
|
-
setLikesLoading(false);
|
|
35
|
-
setLikes(oldLikes => [
|
|
36
|
-
...oldLikes,
|
|
37
|
-
{
|
|
38
|
-
primary: 'Generated Like',
|
|
39
|
-
secondary: ['This like was added after the onLoadMore callback triggered'],
|
|
40
|
-
visual: <Avatar size='l' name='Generated Like'/>,
|
|
41
|
-
id: 'generatedLike'
|
|
42
|
-
}
|
|
43
|
-
]);
|
|
44
|
-
setAdditionalLikeAdded(true);
|
|
45
|
-
}, 1000);
|
|
46
|
-
}
|
|
47
|
-
}, [likesLoading]);
|
|
48
|
-
const onMentionClick = ({ id, type, target, closeGlimpse }) => {
|
|
49
|
-
if (type === 'user') {
|
|
50
|
-
const user = userMentions.find(mention => mention.id === id);
|
|
51
|
-
if (user && target && closeGlimpse) {
|
|
52
|
-
const { primary, secondary, visual, ...restUser } = user;
|
|
53
|
-
return (<Glimpse {...restUser} heading={{
|
|
54
|
-
primary,
|
|
55
|
-
secondary: Array.isArray(secondary) ? secondary.join(', ') : secondary,
|
|
56
|
-
visual
|
|
57
|
-
}} target={target} onDismiss={() => {
|
|
58
|
-
closeGlimpse();
|
|
59
|
-
}} placement='right'/>);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const reply = (<>
|
|
64
|
-
<FeedReply id={key} key={key} info={{
|
|
65
|
-
postTimestamp,
|
|
66
|
-
content: replyContent,
|
|
67
|
-
attachments,
|
|
68
|
-
username,
|
|
69
|
-
fullname,
|
|
70
|
-
fullnameLabel: `${fullname}'s Profile`,
|
|
71
|
-
liked,
|
|
72
|
-
userStatus
|
|
73
|
-
}} interactionInfo={{
|
|
74
|
-
likes,
|
|
75
|
-
likeCount: likeCount >= 10 ? likeCount + 1 : likeCount,
|
|
76
|
-
likeLabel: 'Like',
|
|
77
|
-
commentLabel: 'Comment'
|
|
78
|
-
}} maxContentHeight={40} menuItems={[{ primary: 'Custom action', id: 'custom', onClick: () => { } }]} onEditSubmit={({ value }) => {
|
|
79
|
-
setReplyContent(value);
|
|
80
|
-
setEdited(true);
|
|
81
|
-
setEditTimestamp(new Date());
|
|
82
|
-
}} edited={edited} editTimestamp={editTimestamp} onCommentClick={() => { }} onLikeClick={({ user }) => {
|
|
83
|
-
const userLikedIndex = likes.findIndex(x => x.id === user.id);
|
|
84
|
-
if (userLikedIndex !== -1) {
|
|
85
|
-
setLikes(oldLikes => {
|
|
86
|
-
const oldLikesArr = [...oldLikes];
|
|
87
|
-
oldLikesArr.splice(userLikedIndex, 1);
|
|
88
|
-
return oldLikesArr;
|
|
89
|
-
});
|
|
90
|
-
setLikeCount(curr => curr - 1);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
setLikes(oldLikes => [user, ...oldLikes]);
|
|
94
|
-
setLikeCount(curr => curr + 1);
|
|
95
|
-
}
|
|
96
|
-
setLiked(curr => !curr);
|
|
97
|
-
}} onLikeCountInteraction={getInitialLikes} onLoadMoreLikes={!additionalLikeAdded ? generateNewLike : undefined} likesLoading={likesLoading} onUserClick={(_, clickEvent) => {
|
|
98
|
-
if (clickEvent) {
|
|
99
|
-
setPopoverTarget(clickEvent.target);
|
|
100
|
-
setPopoverOpen(curr => !curr);
|
|
101
|
-
}
|
|
102
|
-
}}/>
|
|
103
|
-
{popoverTarget && (<Popover show={popoverOpen} target={popoverTarget} placement='bottom' portal>
|
|
104
|
-
<CardContent>{fullname}</CardContent>
|
|
105
|
-
</Popover>)}
|
|
106
|
-
</>);
|
|
107
|
-
return renderFeed ? (<Feed title='Pulse' onMentionClick={onMentionClick} interactionRenderers={[MentionButtonConfig, HashtagButtonConfig]} userInfo={{ username: 'demo_user', fullname: 'Demo User' }} posts={[reply]}/>) : (reply);
|
|
108
|
-
};
|
|
109
|
-
export const FeedReplyWithPresence = () => {
|
|
110
|
-
return <FeedReplyDemo userStatus='active'/>;
|
|
111
|
-
};
|
|
112
|
-
//# sourceMappingURL=FeedReply.stories.jsx.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedReply.stories.jsx","sourceRoot":"","sources":["../../../src/social/Feed/FeedReply.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QA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UAAU,CAAC,QAAQ,EAAG,CAAC;AAC/C,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useState, useCallback } from 'react';\n\nimport { Avatar, CardContent, Popover, useUID } from '@pega/cosmos-react-core';\nimport type { SummaryListItem } from '@pega/cosmos-react-core';\nimport {\n Feed,\n FeedReply,\n HashtagButtonConfig,\n MentionButtonConfig\n} from '@pega/cosmos-react-social';\nimport type { FeedReplyProps } from '@pega/cosmos-react-social';\nimport { Glimpse } from '@pega/cosmos-react-work';\nimport type { GlimpseProps } from '@pega/cosmos-react-work';\n\nimport { generatedLikes, userMentions } from './Feed.mocks';\n\nexport default {\n title: 'Social/Feed/FeedReply',\n component: FeedReply\n} as Meta;\n\ninterface FeedReplyDemoProps {\n fullname?: FeedReplyProps['info']['fullname'];\n username?: FeedReplyProps['info']['username'];\n content?: FeedReplyProps['info']['content'];\n attachments?: FeedReplyProps['info']['attachments'];\n postTimestamp?: FeedReplyProps['info']['postTimestamp'];\n userStatus?: FeedReplyProps['info']['userStatus'];\n renderFeed?: boolean;\n}\n\nexport const FeedReplyDemo: StoryFn<FeedReplyDemoProps> = ({\n fullname = 'Demo User',\n username = 'demo_user',\n content,\n attachments,\n postTimestamp = new Date(2022, 0, 1),\n userStatus,\n renderFeed = true\n}: FeedReplyDemoProps) => {\n const defaultContent = attachments\n ? ''\n : \"This reply mentions <pega-mention id='deans' text='Seth DeAngelo' type='user'/> and also contains a tag! <pega-tag tag='cosmos'/>\";\n\n const key = useUID();\n const [likes, setLikes] = useState<SummaryListItem[]>([]);\n const [liked, setLiked] = useState(false);\n const [likeCount, setLikeCount] = useState(renderFeed ? generatedLikes.length : 0);\n const [replyContent, setReplyContent] = useState(content || defaultContent);\n const [edited, setEdited] = useState(false);\n const [editTimestamp, setEditTimestamp] = useState(new Date());\n const [popoverOpen, setPopoverOpen] = useState(false);\n const [popoverTarget, setPopoverTarget] = useState<Element>();\n const [additionalLikeAdded, setAdditionalLikeAdded] = useState(false);\n\n const getInitialLikes = () => {\n if (likes.length) return;\n\n setLikes(renderFeed ? generatedLikes : []);\n };\n\n const [likesLoading, setLikesLoading] = useState(false);\n\n const generateNewLike = useCallback(() => {\n if (!likesLoading) {\n setLikesLoading(true);\n setTimeout(() => {\n setLikesLoading(false);\n setLikes(oldLikes => [\n ...oldLikes,\n {\n primary: 'Generated Like',\n secondary: ['This like was added after the onLoadMore callback triggered'],\n visual: <Avatar size='l' name='Generated Like' />,\n id: 'generatedLike'\n }\n ]);\n setAdditionalLikeAdded(true);\n }, 1000);\n }\n }, [likesLoading]);\n\n const onMentionClick = ({\n id,\n type,\n target,\n closeGlimpse\n }: { id: string; type: string; closeGlimpse?: () => void } & Partial<\n Pick<GlimpseProps, 'target'>\n >) => {\n if (type === 'user') {\n const user = userMentions.find(mention => mention.id === id);\n if (user && target && closeGlimpse) {\n const { primary, secondary, visual, ...restUser } = user;\n\n return (\n <Glimpse\n {...restUser}\n heading={{\n primary,\n secondary: Array.isArray(secondary) ? secondary.join(', ') : secondary,\n visual\n }}\n target={target}\n onDismiss={() => {\n closeGlimpse();\n }}\n placement='right'\n />\n );\n }\n }\n };\n\n const reply = (\n <>\n <FeedReply\n id={key}\n key={key}\n info={{\n postTimestamp,\n content: replyContent,\n attachments,\n username,\n fullname,\n fullnameLabel: `${fullname}'s Profile`,\n liked,\n userStatus\n }}\n interactionInfo={{\n likes,\n likeCount: likeCount >= 10 ? likeCount + 1 : likeCount,\n likeLabel: 'Like',\n commentLabel: 'Comment'\n }}\n maxContentHeight={40}\n menuItems={[{ primary: 'Custom action', id: 'custom', onClick: () => {} }]}\n onEditSubmit={({ value }) => {\n setReplyContent(value);\n setEdited(true);\n setEditTimestamp(new Date());\n }}\n edited={edited}\n editTimestamp={editTimestamp}\n onCommentClick={() => {}}\n onLikeClick={({ user }) => {\n const userLikedIndex = likes.findIndex(x => x.id === user.id);\n if (userLikedIndex !== -1) {\n setLikes(oldLikes => {\n const oldLikesArr = [...oldLikes];\n oldLikesArr.splice(userLikedIndex, 1);\n return oldLikesArr;\n });\n setLikeCount(curr => curr - 1);\n } else {\n setLikes(oldLikes => [user, ...oldLikes]);\n setLikeCount(curr => curr + 1);\n }\n setLiked(curr => !curr);\n }}\n onLikeCountInteraction={getInitialLikes}\n onLoadMoreLikes={!additionalLikeAdded ? generateNewLike : undefined}\n likesLoading={likesLoading}\n onUserClick={(_, clickEvent) => {\n if (clickEvent) {\n setPopoverTarget(clickEvent.target as Element);\n setPopoverOpen(curr => !curr);\n }\n }}\n />\n {popoverTarget && (\n <Popover show={popoverOpen} target={popoverTarget} placement='bottom' portal>\n <CardContent>{fullname}</CardContent>\n </Popover>\n )}\n </>\n );\n\n return renderFeed ? (\n <Feed\n title='Pulse'\n onMentionClick={onMentionClick}\n interactionRenderers={[MentionButtonConfig, HashtagButtonConfig]}\n userInfo={{ username: 'demo_user', fullname: 'Demo User' }}\n posts={[reply]}\n />\n ) : (\n reply\n );\n};\n\nexport const FeedReplyWithPresence: StoryFn = () => {\n return <FeedReplyDemo userStatus='active' />;\n};\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { StoryFn } from '@storybook/react';
|
|
2
|
-
import type { FeedReplyInputProps } from '@pega/cosmos-react-social';
|
|
3
|
-
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
|
|
4
|
-
export default _default;
|
|
5
|
-
interface FeedReplyInputDemoProps {
|
|
6
|
-
onSubmit?: FeedReplyInputProps['onSubmit'];
|
|
7
|
-
renderFeed?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const FeedReplyInputDemo: StoryFn<FeedReplyInputDemoProps>;
|
|
10
|
-
//# sourceMappingURL=FeedReplyInput.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedReplyInput.stories.d.ts","sourceRoot":"","sources":["../../../src/social/Feed/FeedReplyInput.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAKtD,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,2BAA2B,CAAC;;AAIpF,wBAGU;AAEV,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC3C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,uBAAuB,CA2F/D,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { useUID } from '@pega/cosmos-react-core';
|
|
3
|
-
import { Feed, FeedReplyInput } from '@pega/cosmos-react-social';
|
|
4
|
-
import { caseMentions, userMentions } from './Feed.mocks';
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Social/Feed/FeedReplyInput',
|
|
7
|
-
component: FeedReplyInput
|
|
8
|
-
};
|
|
9
|
-
export const FeedReplyInputDemo = ({ onSubmit, renderFeed = true }) => {
|
|
10
|
-
const key = useUID();
|
|
11
|
-
const [searchResults, setSearchResults] = useState([]);
|
|
12
|
-
const [attachments, setAttachments] = useState([]);
|
|
13
|
-
const onSearch = ({ type, search, mentionType }) => {
|
|
14
|
-
if (type === 'mention') {
|
|
15
|
-
const availableMentions = mentionType === 'case' ? caseMentions : userMentions;
|
|
16
|
-
const mentions = availableMentions
|
|
17
|
-
.filter(user => {
|
|
18
|
-
const names = user.primary.toLowerCase().split(' ');
|
|
19
|
-
const searchWords = search.toLowerCase().split(' ');
|
|
20
|
-
return !!searchWords.every((word) => names.find((name) => name.startsWith(word)));
|
|
21
|
-
})
|
|
22
|
-
.map(({ id, primary, secondary, visual, href }) => {
|
|
23
|
-
return {
|
|
24
|
-
id,
|
|
25
|
-
primary,
|
|
26
|
-
secondary: secondary !== undefined && !Array.isArray(secondary) ? [secondary] : secondary,
|
|
27
|
-
visual,
|
|
28
|
-
href
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
setSearchResults(mentions);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
setSearchResults(['cosmos', 'hashtag', 'pega']
|
|
35
|
-
.filter(tag => {
|
|
36
|
-
return tag.toLowerCase().includes(search.toLowerCase());
|
|
37
|
-
})
|
|
38
|
-
.map(tag => ({ id: tag, primary: tag })));
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const onFilesAdded = (files) => {
|
|
42
|
-
files.forEach(file => {
|
|
43
|
-
if (file.type.split('/')[0] === 'image')
|
|
44
|
-
file.thumbnail = URL.createObjectURL(file);
|
|
45
|
-
file.onDelete = () => {
|
|
46
|
-
setAttachments(current => {
|
|
47
|
-
return current.filter(x => x.name !== file.name);
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
setAttachments(files);
|
|
52
|
-
};
|
|
53
|
-
const replyInput = (<FeedReplyInput id={key} commentLabel='Send Comment' attachments={attachments} placeholder='Add a comment' onFilesAdded={onFilesAdded} onSubmit={replyEvent => {
|
|
54
|
-
onSubmit?.(replyEvent);
|
|
55
|
-
setAttachments([]);
|
|
56
|
-
replyEvent.clear();
|
|
57
|
-
}}/>);
|
|
58
|
-
return renderFeed ? (<Feed title='Pulse' searchTypes={['user', 'case']} onDecoratorSearch={onSearch} searchResults={searchResults} userInfo={{ username: 'demo_user', fullname: 'Demo User' }} posts={[replyInput]}/>) : (replyInput);
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=FeedReplyInput.stories.jsx.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedReplyInput.stories.jsx","sourceRoot":"","sources":["../../../src/social/Feed/FeedReplyInput.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAiB,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,cAAc,E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AC;IACxB,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,CACjB,CAAC,cAAc,CACb,EAAE,CAAC,CAAC,GAAG,CAAC,CACR,YAAY,CAAC,cAAc,CAC3B,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,WAAW,CAAC,eAAe,CAC3B,YAAY,CAAC,CAAC,YAAY,CAAC,CAC3B,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE;YACrB,QAAQ,EAAE,CAAC,UAAU,CAAC,CAAC;YACvB,cAAc,CAAC,EAAE,CAAC,CAAC;YACnB,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC,CAAC,EACF,CACH,CAAC;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,CAClB,CAAC,IAAI,CACH,KAAK,CAAC,OAAO,CACb,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAC9B,iBAAiB,CAAC,CAAC,QAAQ,CAAC,CAC5B,aAAa,CAAC,CAAC,aAAa,CAAC,CAC7B,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAC3D,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EACpB,CACH,CAAC,CAAC,CAAC,CACF,UAAU,CACX,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useState } from 'react';\n\nimport { MenuItemProps, useUID } from '@pega/cosmos-react-core';\nimport { Feed, FeedReplyInput } from '@pega/cosmos-react-social';\nimport type { FeedReplyInputProps, AttachedFiles } from '@pega/cosmos-react-social';\n\nimport { caseMentions, userMentions } from './Feed.mocks';\n\nexport default {\n title: 'Social/Feed/FeedReplyInput',\n component: FeedReplyInput\n} as Meta;\n\ninterface FeedReplyInputDemoProps {\n onSubmit?: FeedReplyInputProps['onSubmit'];\n renderFeed?: boolean;\n}\n\nexport const FeedReplyInputDemo: StoryFn<FeedReplyInputDemoProps> = ({\n onSubmit,\n renderFeed = true\n}: FeedReplyInputDemoProps) => {\n const key = useUID();\n const [searchResults, setSearchResults] = useState<MenuItemProps[]>([]);\n const [attachments, setAttachments] = useState<AttachedFiles[]>([]);\n\n const onSearch = ({\n type,\n search,\n mentionType\n }: {\n type: 'mention' | 'tag';\n search: string;\n mentionType: string;\n }) => {\n if (type === 'mention') {\n const availableMentions = mentionType === 'case' ? caseMentions : userMentions;\n\n const mentions: MenuItemProps[] = availableMentions\n .filter(user => {\n const names = user.primary.toLowerCase().split(' ');\n const searchWords = search.toLowerCase().split(' ');\n return !!searchWords.every((word: string) =>\n names.find((name: string) => name.startsWith(word))\n );\n })\n .map(({ id, primary, secondary, visual, href }) => {\n return {\n id,\n primary,\n secondary:\n secondary !== undefined && !Array.isArray(secondary) ? [secondary] : secondary,\n visual,\n href\n };\n });\n setSearchResults(mentions);\n } else {\n setSearchResults(\n ['cosmos', 'hashtag', 'pega']\n .filter(tag => {\n return tag.toLowerCase().includes(search.toLowerCase());\n })\n .map(tag => ({ id: tag, primary: tag }))\n );\n }\n };\n\n const onFilesAdded = (files: AttachedFiles[]) => {\n files.forEach(file => {\n if (file.type.split('/')[0] === 'image') file.thumbnail = URL.createObjectURL(file);\n\n file.onDelete = () => {\n setAttachments(current => {\n return current.filter(x => x.name !== file.name);\n });\n };\n });\n\n setAttachments(files);\n };\n\n const replyInput = (\n <FeedReplyInput\n id={key}\n commentLabel='Send Comment'\n attachments={attachments}\n placeholder='Add a comment'\n onFilesAdded={onFilesAdded}\n onSubmit={replyEvent => {\n onSubmit?.(replyEvent);\n setAttachments([]);\n replyEvent.clear();\n }}\n />\n );\n\n return renderFeed ? (\n <Feed\n title='Pulse'\n searchTypes={['user', 'case']}\n onDecoratorSearch={onSearch}\n searchResults={searchResults}\n userInfo={{ username: 'demo_user', fullname: 'Demo User' }}\n posts={[replyInput]}\n />\n ) : (\n replyInput\n );\n};\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { StoryFn } from '@storybook/react';
|
|
2
|
-
import type { FeedNewPostProps } from '@pega/cosmos-react-social';
|
|
3
|
-
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
|
|
4
|
-
export default _default;
|
|
5
|
-
interface FeedNewPostDemoProps {
|
|
6
|
-
onPost?: FeedNewPostProps['onPost'];
|
|
7
|
-
renderFeed?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const FeedNewPostDemo: StoryFn<FeedNewPostDemoProps>;
|
|
10
|
-
//# sourceMappingURL=FeedNewPost.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedNewPost.stories.d.ts","sourceRoot":"","sources":["../../../src/social/Feed/FeedNewPost.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMtD,OAAO,KAAK,EAAE,gBAAgB,EAAkC,MAAM,2BAA2B,CAAC;;AAIlG,wBAGU;AAEV,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,oBAAoB,CAwHzD,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
import { useUID } from '@pega/cosmos-react-core';
|
|
4
|
-
import { Feed, FeedNewPost } from '@pega/cosmos-react-social';
|
|
5
|
-
import { availableRecipients, caseMentions, userMentions } from './Feed.mocks';
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Social/Feed/FeedNewPost',
|
|
8
|
-
component: FeedNewPost
|
|
9
|
-
};
|
|
10
|
-
export const FeedNewPostDemo = ({ onPost = () => { }, renderFeed = true }) => {
|
|
11
|
-
const key = useUID();
|
|
12
|
-
const [searchResults, setSearchResults] = useState([]);
|
|
13
|
-
const [attachments, setAttachments] = useState([]);
|
|
14
|
-
const [filterValue, setFilterValue] = useState('');
|
|
15
|
-
const [itemsToRender, setItemsToRender] = useState(availableRecipients);
|
|
16
|
-
const onSearch = ({ type, search, mentionType }) => {
|
|
17
|
-
if (type === 'mention') {
|
|
18
|
-
const availableMentions = mentionType === 'case' ? caseMentions : userMentions;
|
|
19
|
-
const mentions = availableMentions
|
|
20
|
-
.filter(user => {
|
|
21
|
-
const names = user.primary.toLowerCase().split(' ');
|
|
22
|
-
const searchWords = search.toLowerCase().split(' ');
|
|
23
|
-
return !!searchWords.every((word) => names.find((name) => name.startsWith(word)));
|
|
24
|
-
})
|
|
25
|
-
.map(({ id, primary, secondary, visual, href }) => {
|
|
26
|
-
return {
|
|
27
|
-
id,
|
|
28
|
-
primary,
|
|
29
|
-
secondary: secondary !== undefined && !Array.isArray(secondary) ? [secondary] : secondary,
|
|
30
|
-
visual,
|
|
31
|
-
href
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
setSearchResults(mentions);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
setSearchResults(['cosmos', 'hashtag', 'pega']
|
|
38
|
-
.filter(tag => {
|
|
39
|
-
return tag.toLowerCase().includes(search.toLowerCase());
|
|
40
|
-
})
|
|
41
|
-
.map(tag => ({ id: tag, primary: tag })));
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const onFilesAdded = (files) => {
|
|
45
|
-
files.forEach(file => {
|
|
46
|
-
if (file.type.split('/')[0] === 'image')
|
|
47
|
-
file.thumbnail = URL.createObjectURL(file);
|
|
48
|
-
if (file.size / 1000000 > 100) {
|
|
49
|
-
file.meta = 'File size cannot exceed 100MB';
|
|
50
|
-
file.error = true;
|
|
51
|
-
}
|
|
52
|
-
file.onDelete = () => {
|
|
53
|
-
setAttachments(current => {
|
|
54
|
-
return current.filter(x => x.name !== file.name);
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
setAttachments(current => [...current, ...files]);
|
|
59
|
-
};
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
// Synthetic delay to mimic async request
|
|
62
|
-
const timeout = setTimeout(() => {
|
|
63
|
-
const newItems = availableRecipients.filter(({ primary, secondary }) => {
|
|
64
|
-
return (primary.toLowerCase().includes(filterValue) ||
|
|
65
|
-
secondary.find(x => x.toLowerCase().includes(filterValue)));
|
|
66
|
-
});
|
|
67
|
-
setItemsToRender(newItems);
|
|
68
|
-
}, 500);
|
|
69
|
-
return () => {
|
|
70
|
-
clearTimeout(timeout);
|
|
71
|
-
};
|
|
72
|
-
}, [filterValue]);
|
|
73
|
-
const newPost = (_jsx(FeedNewPost, { id: key, attachments: attachments, interactionInfo: {
|
|
74
|
-
textAreaPlaceholder: 'Start a conversation',
|
|
75
|
-
postLabel: 'Post'
|
|
76
|
-
}, onFilesAdded: onFilesAdded, onPost: postEvent => {
|
|
77
|
-
onPost?.(postEvent);
|
|
78
|
-
setAttachments([]);
|
|
79
|
-
postEvent.clear();
|
|
80
|
-
}, recipients: itemsToRender, onRecipientSearch: (newSearch) => setFilterValue(newSearch) }));
|
|
81
|
-
return renderFeed ? (_jsx(Feed, { title: 'Pulse', searchTypes: ['user', 'case'], onDecoratorSearch: onSearch, searchResults: searchResults, userInfo: { username: 'demo_user', fullname: 'Demo User' }, newPostRegion: newPost })) : (newPost);
|
|
82
|
-
};
|
|
83
|
-
//# sourceMappingURL=FeedNewPost.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedNewPost.stories.js","sourceRoot":"","sources":["../../../src/social/Feed/FeedNewPost.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAAE,IAAI,EAAE,WAAW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EACD,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,SAAS,CAAC,EAAE;YAClB,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;YACpB,cAAc,CAAC,EAAE,CAAC,CAAC;YACnB,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC,EACD,UAAU,EAAE,aAAa,EACzB,iBAAiB,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,GACnE,CACH,CAAC;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,CAClB,KAAC,IAAI,IACH,KAAK,EAAC,OAAO,EACb,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,iBAAiB,EAAE,QAAQ,EAC3B,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,EAC1D,aAAa,EAAE,OAAO,GACtB,CACH,CAAC,CAAC,CAAC,CACF,OAAO,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useState, useEffect } from 'react';\n\nimport { useUID } from '@pega/cosmos-react-core';\nimport type { MenuItemProps } from '@pega/cosmos-react-core';\nimport { Feed, FeedNewPost } from '@pega/cosmos-react-social';\nimport type { FeedNewPostProps, RecipientOption, AttachedFiles } from '@pega/cosmos-react-social';\n\nimport { availableRecipients, caseMentions, userMentions } from './Feed.mocks';\n\nexport default {\n title: 'Social/Feed/FeedNewPost',\n component: FeedNewPost\n} as Meta;\n\ninterface FeedNewPostDemoProps {\n onPost?: FeedNewPostProps['onPost'];\n renderFeed?: boolean;\n}\n\nexport const FeedNewPostDemo: StoryFn<FeedNewPostDemoProps> = ({\n onPost = () => {},\n renderFeed = true\n}: FeedNewPostDemoProps) => {\n const key = useUID();\n const [searchResults, setSearchResults] = useState<MenuItemProps[]>([]);\n const [attachments, setAttachments] = useState<AttachedFiles[]>([]);\n const [filterValue, setFilterValue] = useState('');\n const [itemsToRender, setItemsToRender] = useState<RecipientOption[]>(availableRecipients);\n\n const onSearch = ({\n type,\n search,\n mentionType\n }: {\n type: 'mention' | 'tag';\n search: string;\n mentionType: string;\n }) => {\n if (type === 'mention') {\n const availableMentions = mentionType === 'case' ? caseMentions : userMentions;\n\n const mentions: MenuItemProps[] = availableMentions\n .filter(user => {\n const names = user.primary.toLowerCase().split(' ');\n const searchWords = search.toLowerCase().split(' ');\n return !!searchWords.every((word: string) =>\n names.find((name: string) => name.startsWith(word))\n );\n })\n .map(({ id, primary, secondary, visual, href }) => {\n return {\n id,\n primary,\n secondary:\n secondary !== undefined && !Array.isArray(secondary) ? [secondary] : secondary,\n visual,\n href\n };\n });\n setSearchResults(mentions);\n } else {\n setSearchResults(\n ['cosmos', 'hashtag', 'pega']\n .filter(tag => {\n return tag.toLowerCase().includes(search.toLowerCase());\n })\n .map(tag => ({ id: tag, primary: tag }))\n );\n }\n };\n\n const onFilesAdded = (files: AttachedFiles[]) => {\n files.forEach(file => {\n if (file.type.split('/')[0] === 'image') file.thumbnail = URL.createObjectURL(file);\n\n if (file.size / 1000000 > 100) {\n file.meta = 'File size cannot exceed 100MB';\n file.error = true;\n }\n\n file.onDelete = () => {\n setAttachments(current => {\n return current.filter(x => x.name !== file.name);\n });\n };\n });\n\n setAttachments(current => [...current, ...files]);\n };\n\n useEffect(() => {\n // Synthetic delay to mimic async request\n const timeout = setTimeout(() => {\n const newItems = availableRecipients.filter(({ primary, secondary }) => {\n return (\n primary.toLowerCase().includes(filterValue) ||\n secondary.find(x => x.toLowerCase().includes(filterValue))\n );\n });\n\n setItemsToRender(newItems);\n }, 500);\n\n return () => {\n clearTimeout(timeout);\n };\n }, [filterValue]);\n\n const newPost = (\n <FeedNewPost\n id={key}\n attachments={attachments}\n interactionInfo={{\n textAreaPlaceholder: 'Start a conversation',\n postLabel: 'Post'\n }}\n onFilesAdded={onFilesAdded}\n onPost={postEvent => {\n onPost?.(postEvent);\n setAttachments([]);\n postEvent.clear();\n }}\n recipients={itemsToRender}\n onRecipientSearch={(newSearch: string) => setFilterValue(newSearch)}\n />\n );\n\n return renderFeed ? (\n <Feed\n title='Pulse'\n searchTypes={['user', 'case']}\n onDecoratorSearch={onSearch}\n searchResults={searchResults}\n userInfo={{ username: 'demo_user', fullname: 'Demo User' }}\n newPostRegion={newPost}\n />\n ) : (\n newPost\n );\n};\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { StoryFn } from '@storybook/react';
|
|
2
|
-
import type { FeedPostDemoProps } from './Feed.mocks';
|
|
3
|
-
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
|
|
4
|
-
export default _default;
|
|
5
|
-
export declare const FeedPostDemo: StoryFn<FeedPostDemoProps>;
|
|
6
|
-
export declare const FeedPostWithPresence: StoryFn;
|
|
7
|
-
export declare const FeedPostWithJSX: StoryFn;
|
|
8
|
-
//# sourceMappingURL=FeedPost.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FeedPost.stories.d.ts","sourceRoot":"","sources":["../../../src/social/Feed/FeedPost.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAiBtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;;AAEtD,wBAGU;AAEV,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,iBAAiB,CAoVnD,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,OAElC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,OAgD7B,CAAC"}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useState } from 'react';
|
|
3
|
-
import { Avatar, CardContent, Link, Popover, Table, useUID } from '@pega/cosmos-react-core';
|
|
4
|
-
import { HashtagButtonConfig, MentionButtonConfig, Feed, FeedPost } from '@pega/cosmos-react-social';
|
|
5
|
-
import { Glimpse } from '@pega/cosmos-react-work';
|
|
6
|
-
import { FeedReplyDemo } from './FeedReply.stories';
|
|
7
|
-
import { generatedLikes, caseMentions, userMentions, availableRecipients } from './Feed.mocks';
|
|
8
|
-
export default {
|
|
9
|
-
title: 'Social/Feed/FeedPost',
|
|
10
|
-
component: FeedPost
|
|
11
|
-
};
|
|
12
|
-
export const FeedPostDemo = ({ fullname = 'Demo User', username = 'demo_user', icon, content, postType, recipients, attachments: postAttachments, replies, postTimestamp = new Date(2022, 0, 1), userStatus, likes: userLikes, likeCount: userLikeCount, onDelete = () => { }, renderFeed = true }) => {
|
|
13
|
-
const defaultContent = postAttachments
|
|
14
|
-
? ''
|
|
15
|
-
: "This post mentions <pega-mention id='deans' text='Seth DeAngelo' type='user'/> and also contains a tag! <pega-tag tag='cosmos'/>";
|
|
16
|
-
const defaultReplies = Array.from(Array(12).keys(), index => {
|
|
17
|
-
return (_jsx(FeedReplyDemo, { fullname: fullname, content: `This is reply number ${index + 1}!`, renderFeed: false }, `reply-story-${index + 1}`));
|
|
18
|
-
});
|
|
19
|
-
const key = useUID();
|
|
20
|
-
const [postContent, setPostContent] = useState(content || defaultContent);
|
|
21
|
-
const [searchResults, setSearchResults] = useState([]);
|
|
22
|
-
const [likes, setLikes] = useState([]);
|
|
23
|
-
const [liked, setLiked] = useState(false);
|
|
24
|
-
const [likeCount, setLikeCount] = useState(userLikeCount || (renderFeed ? generatedLikes.length : 0));
|
|
25
|
-
const [recipientsList, setRecipientsList] = useState([]);
|
|
26
|
-
const [edited, setEdited] = useState(false);
|
|
27
|
-
const [editTimestamp, setEditTimestamp] = useState(new Date());
|
|
28
|
-
const [popoverOpen, setPopoverOpen] = useState(false);
|
|
29
|
-
const [popoverTarget, setPopoverTarget] = useState();
|
|
30
|
-
const [extraReplies, setExtraReplies] = useState([]);
|
|
31
|
-
const [replyAttachments, setReplyAttachments] = useState([]);
|
|
32
|
-
const [replyCount, setReplyCount] = useState(replies ? replies.length : defaultReplies.length);
|
|
33
|
-
const [repliesLoading, setRepliesLoading] = useState(false);
|
|
34
|
-
const [repliesShown, setRepliesShown] = useState(3);
|
|
35
|
-
const [additionalLikeAdded, setAdditionalLikeAdded] = useState(false);
|
|
36
|
-
const [allRecipientsVisible, setAllRecipientsVisible] = useState(false);
|
|
37
|
-
const onShowMoreReplies = () => {
|
|
38
|
-
setRepliesLoading(true);
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
setRepliesShown(curr => {
|
|
41
|
-
if (curr + 3 <= defaultReplies.length)
|
|
42
|
-
return curr + 3;
|
|
43
|
-
return defaultReplies.length;
|
|
44
|
-
});
|
|
45
|
-
setRepliesLoading(false);
|
|
46
|
-
}, 1000);
|
|
47
|
-
};
|
|
48
|
-
const onShowLessReplies = () => {
|
|
49
|
-
setRepliesLoading(true);
|
|
50
|
-
setTimeout(() => {
|
|
51
|
-
setRepliesShown(3);
|
|
52
|
-
setRepliesLoading(false);
|
|
53
|
-
}, 1000);
|
|
54
|
-
};
|
|
55
|
-
const onSearch = ({ type, search, mentionType }) => {
|
|
56
|
-
if (type === 'mention') {
|
|
57
|
-
const availableMentions = mentionType === 'case' ? caseMentions : userMentions;
|
|
58
|
-
const mentions = availableMentions
|
|
59
|
-
.filter(user => {
|
|
60
|
-
const names = user.primary.toLowerCase().split(' ');
|
|
61
|
-
const searchWords = search.toLowerCase().split(' ');
|
|
62
|
-
return !!searchWords.every((word) => names.find((name) => name.startsWith(word)));
|
|
63
|
-
})
|
|
64
|
-
.map(({ id, primary, secondary, visual, href }) => {
|
|
65
|
-
return {
|
|
66
|
-
id,
|
|
67
|
-
primary,
|
|
68
|
-
secondary: secondary !== undefined && !Array.isArray(secondary) ? [secondary] : secondary,
|
|
69
|
-
visual,
|
|
70
|
-
href
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
setSearchResults(mentions);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
setSearchResults(['cosmos', 'hashtag', 'pega']
|
|
77
|
-
.filter(tag => {
|
|
78
|
-
return tag.toLowerCase().includes(search.toLowerCase());
|
|
79
|
-
})
|
|
80
|
-
.map(tag => ({ id: tag, primary: tag })));
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const onFilesAdded = (files) => {
|
|
84
|
-
files.forEach(file => {
|
|
85
|
-
if (file.type.split('/')[0] === 'image')
|
|
86
|
-
file.thumbnail = URL.createObjectURL(file);
|
|
87
|
-
file.onDelete = () => {
|
|
88
|
-
setReplyAttachments?.(current => {
|
|
89
|
-
return current.filter(x => x.name !== file.name);
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
setReplyAttachments(files);
|
|
94
|
-
};
|
|
95
|
-
const getInitialLikes = () => {
|
|
96
|
-
if (likes.length)
|
|
97
|
-
return;
|
|
98
|
-
setLikes(userLikes || (renderFeed ? generatedLikes : []));
|
|
99
|
-
};
|
|
100
|
-
const [likesLoading, setLikesLoading] = useState(false);
|
|
101
|
-
const generateNewLike = useCallback(() => {
|
|
102
|
-
if (!likesLoading) {
|
|
103
|
-
setLikesLoading(true);
|
|
104
|
-
setTimeout(() => {
|
|
105
|
-
setLikesLoading(false);
|
|
106
|
-
setLikes(oldLikes => [
|
|
107
|
-
...oldLikes,
|
|
108
|
-
{
|
|
109
|
-
primary: 'Generated Like',
|
|
110
|
-
secondary: ['This like was added after the onLoadMore callback triggered'],
|
|
111
|
-
visual: _jsx(Avatar, { size: 'l', name: 'Generated Like' }),
|
|
112
|
-
id: 'generatedLike'
|
|
113
|
-
}
|
|
114
|
-
]);
|
|
115
|
-
setAdditionalLikeAdded(true);
|
|
116
|
-
}, 1000);
|
|
117
|
-
}
|
|
118
|
-
}, [likesLoading]);
|
|
119
|
-
const getInitialRecipients = () => {
|
|
120
|
-
if (recipientsList.length)
|
|
121
|
-
return;
|
|
122
|
-
setRecipientsList(recipients ||
|
|
123
|
-
availableRecipients.slice(0, !allRecipientsVisible ? 10 : availableRecipients.length));
|
|
124
|
-
};
|
|
125
|
-
const [recipientsLoading, setRecipientsLoading] = useState(false);
|
|
126
|
-
const getAllRecipients = () => {
|
|
127
|
-
if (!recipientsLoading) {
|
|
128
|
-
setRecipientsLoading(true);
|
|
129
|
-
setTimeout(() => {
|
|
130
|
-
setRecipientsLoading(false);
|
|
131
|
-
setAllRecipientsVisible(true);
|
|
132
|
-
setRecipientsList(recipients || availableRecipients);
|
|
133
|
-
}, 1000);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const onMentionClick = ({ id, type, target, closeGlimpse }) => {
|
|
137
|
-
if (type === 'user') {
|
|
138
|
-
const user = userMentions.find(mention => mention.id === id);
|
|
139
|
-
if (user && target && closeGlimpse) {
|
|
140
|
-
const { primary, secondary, visual, ...restUser } = user;
|
|
141
|
-
return (_jsx(Glimpse, { ...restUser, heading: {
|
|
142
|
-
primary,
|
|
143
|
-
secondary: Array.isArray(secondary) ? secondary.join(', ') : secondary,
|
|
144
|
-
visual
|
|
145
|
-
}, target: target, onDismiss: () => {
|
|
146
|
-
closeGlimpse();
|
|
147
|
-
}, placement: 'right' }));
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
const post = (_jsxs(_Fragment, { children: [_jsx(FeedPost, { id: key, info: {
|
|
152
|
-
fullname,
|
|
153
|
-
username,
|
|
154
|
-
icon,
|
|
155
|
-
postTimestamp,
|
|
156
|
-
content: postContent,
|
|
157
|
-
postType,
|
|
158
|
-
recipients: recipientsList,
|
|
159
|
-
recipientsCount: recipients ? recipients.length : availableRecipients.length,
|
|
160
|
-
attachments: postAttachments,
|
|
161
|
-
liked,
|
|
162
|
-
postContext: renderFeed ? _jsx(Link, { href: 'https://www.pega.com', children: "Pega" }) : undefined,
|
|
163
|
-
userStatus
|
|
164
|
-
}, interactionInfo: {
|
|
165
|
-
likeLabel: 'Like',
|
|
166
|
-
likes,
|
|
167
|
-
likeCount: likeCount >= 10 ? likeCount + 1 : likeCount,
|
|
168
|
-
commentLabel: 'Comment'
|
|
169
|
-
}, maxContentHeight: 80, onLikeClick: ({ user }) => {
|
|
170
|
-
const userLikedIndex = likes.findIndex(x => x.id === user.id);
|
|
171
|
-
if (userLikedIndex !== -1) {
|
|
172
|
-
setLikes(oldLikes => {
|
|
173
|
-
const oldLikesArr = [...oldLikes];
|
|
174
|
-
oldLikesArr.splice(userLikedIndex, 1);
|
|
175
|
-
return oldLikesArr;
|
|
176
|
-
});
|
|
177
|
-
setLikeCount(curr => curr - 1);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
setLikes(oldLikes => [user, ...oldLikes]);
|
|
181
|
-
setLikeCount(curr => curr + 1);
|
|
182
|
-
}
|
|
183
|
-
setLiked(curr => !curr);
|
|
184
|
-
}, onLikeCountInteraction: getInitialLikes, likesLoading: likesLoading, onLoadMoreLikes: !additionalLikeAdded ? generateNewLike : undefined, onRecipientInteraction: getInitialRecipients, recipientsLoading: recipientsLoading, onLoadMoreRecipients: !allRecipientsVisible ? getAllRecipients : undefined, onUserClick: (_, clickEvent) => {
|
|
185
|
-
if (clickEvent) {
|
|
186
|
-
setPopoverTarget(clickEvent.target);
|
|
187
|
-
setPopoverOpen(curr => !curr);
|
|
188
|
-
}
|
|
189
|
-
}, menuItems: [
|
|
190
|
-
{ primary: 'Custom action', id: 'custom', onClick: () => { } },
|
|
191
|
-
{ primary: 'Delete', id: 'delete', onClick: onDelete }
|
|
192
|
-
], onEditSubmit: ({ value }) => {
|
|
193
|
-
setPostContent(value);
|
|
194
|
-
setEdited(true);
|
|
195
|
-
setEditTimestamp(new Date());
|
|
196
|
-
}, edited: edited, editTimestamp: editTimestamp, replies: replies
|
|
197
|
-
? [...replies, ...extraReplies]
|
|
198
|
-
: [...defaultReplies.slice(-repliesShown), ...extraReplies], replyCount: replyCount, repliesLoading: repliesLoading, onShowMoreReplies: onShowMoreReplies, onShowLessReplies: repliesShown > 3 ? onShowLessReplies : undefined, replyInput: {
|
|
199
|
-
commentLabel: 'Send Comment',
|
|
200
|
-
attachments: replyAttachments,
|
|
201
|
-
onFilesAdded,
|
|
202
|
-
onSubmit: replyEvent => {
|
|
203
|
-
setReplyAttachments([]);
|
|
204
|
-
replyEvent.attachments.forEach(file => {
|
|
205
|
-
delete file.onDelete;
|
|
206
|
-
file.onPreview = () => { };
|
|
207
|
-
file.onDownload = () => { };
|
|
208
|
-
});
|
|
209
|
-
setExtraReplies(oldReplies => [
|
|
210
|
-
...oldReplies,
|
|
211
|
-
_jsx(FeedReplyDemo, { fullname: 'Demo User', username: 'demo_user', content: replyEvent.value, attachments: replyEvent.attachments, postTimestamp: new Date(), renderFeed: false }, `replies-${oldReplies.length}`)
|
|
212
|
-
]);
|
|
213
|
-
setReplyCount(oldReplyCount => oldReplyCount + 1);
|
|
214
|
-
replyEvent.clear();
|
|
215
|
-
},
|
|
216
|
-
placeholder: 'Add a comment'
|
|
217
|
-
} }, key), popoverTarget && (_jsx(Popover, { show: popoverOpen, target: popoverTarget, placement: 'bottom', hideOnTargetHidden: true, children: _jsx(CardContent, { children: fullname }) }))] }));
|
|
218
|
-
return renderFeed ? (_jsx(Feed, { title: 'Pulse', searchTypes: ['user', 'case'], onDecoratorSearch: onSearch, searchResults: searchResults, onMentionClick: onMentionClick, interactionRenderers: [MentionButtonConfig, HashtagButtonConfig], userInfo: { username: 'demo_user', fullname: 'Demo User' }, posts: [post] })) : (post);
|
|
219
|
-
};
|
|
220
|
-
export const FeedPostWithPresence = () => {
|
|
221
|
-
return _jsx(FeedPostDemo, { userStatus: 'active' });
|
|
222
|
-
};
|
|
223
|
-
export const FeedPostWithJSX = () => {
|
|
224
|
-
const data = [
|
|
225
|
-
{
|
|
226
|
-
id: '123',
|
|
227
|
-
name: 'Jane Smith',
|
|
228
|
-
dob: '12/31/1990',
|
|
229
|
-
address: 'Boston, MA',
|
|
230
|
-
email: 'jsmith@email.com',
|
|
231
|
-
balance: '$2,200'
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
id: '456',
|
|
235
|
-
name: 'Joe Smith',
|
|
236
|
-
dob: '01/01/1980',
|
|
237
|
-
address: '',
|
|
238
|
-
email: 'joe.smith@email.com',
|
|
239
|
-
balance: '$1,350'
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
id: '789',
|
|
243
|
-
name: 'Mirian Lou',
|
|
244
|
-
dob: '02/29/1985',
|
|
245
|
-
address: (_jsxs(_Fragment, { children: [_jsx("div", { children: "100 Main St." }), _jsx("div", { children: "Cambridge, MA" })] })),
|
|
246
|
-
email: '',
|
|
247
|
-
balance: '$10'
|
|
248
|
-
}
|
|
249
|
-
];
|
|
250
|
-
const columns = [
|
|
251
|
-
{ renderer: 'name', label: 'Name' },
|
|
252
|
-
{ renderer: 'dob', label: 'Date of Birth' },
|
|
253
|
-
{ renderer: 'address', label: 'Address' },
|
|
254
|
-
{ renderer: 'email', label: 'Email' },
|
|
255
|
-
{ renderer: 'balance', label: 'Account Balance', align: 'right' }
|
|
256
|
-
];
|
|
257
|
-
return (_jsx(Feed, { title: 'Pulse', userInfo: { username: 'demo_user', fullname: 'Demo User' }, posts: [_jsx(FeedPostDemo, { content: _jsx(Table, { columns: columns, data: data }), replies: [] })] }));
|
|
258
|
-
};
|
|
259
|
-
//# sourceMappingURL=FeedPost.stories.js.map
|