@pega/cosmos-react-social 2.0.0-dev.2.0 → 2.0.0-dev.21.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/lib/components/Chat/Chat.d.ts.map +1 -1
- package/lib/components/Chat/Chat.js +9 -16
- 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.map +1 -1
- package/lib/components/Chat/ChatBody.js +4 -3
- package/lib/components/Chat/ChatBody.js.map +1 -1
- package/lib/components/Chat/ChatComposer.d.ts.map +1 -1
- package/lib/components/Chat/ChatComposer.js +36 -51
- package/lib/components/Chat/ChatComposer.js.map +1 -1
- package/lib/components/Chat/ChatHeader.d.ts.map +1 -1
- package/lib/components/Chat/ChatHeader.js +10 -13
- package/lib/components/Chat/ChatHeader.js.map +1 -1
- package/lib/components/Chat/ChatTranscript.d.ts.map +1 -1
- package/lib/components/Chat/ChatTranscript.js +15 -16
- package/lib/components/Chat/ChatTranscript.js.map +1 -1
- package/lib/components/Chat/Message.d.ts.map +1 -1
- package/lib/components/Chat/Message.js +41 -59
- package/lib/components/Chat/Message.js.map +1 -1
- package/lib/components/Chat/Message.styles.js +2 -2
- package/lib/components/Chat/Message.styles.js.map +1 -1
- package/lib/components/Chat/MessageList.d.ts.map +1 -1
- package/lib/components/Chat/MessageList.js +36 -41
- package/lib/components/Chat/MessageList.js.map +1 -1
- package/lib/components/Chat/RepeatingView.d.ts.map +1 -1
- package/lib/components/Chat/RepeatingView.js +10 -14
- package/lib/components/Chat/RepeatingView.js.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.d.ts.map +1 -1
- package/lib/components/Chat/SuggestedReplyPicker.js +46 -54
- package/lib/components/Chat/SuggestedReplyPicker.js.map +1 -1
- package/lib/components/Chat/SystemMessage.d.ts.map +1 -1
- package/lib/components/Chat/SystemMessage.js +4 -6
- package/lib/components/Chat/SystemMessage.js.map +1 -1
- package/lib/components/Chat/TranscriptMessage.d.ts.map +1 -1
- package/lib/components/Chat/TranscriptMessage.js +7 -13
- package/lib/components/Chat/TranscriptMessage.js.map +1 -1
- package/lib/components/Chat/TypeIndicator.d.ts.map +1 -1
- package/lib/components/Chat/TypeIndicator.js +3 -2
- package/lib/components/Chat/TypeIndicator.js.map +1 -1
- package/lib/components/Email/Email.d.ts.map +1 -1
- package/lib/components/Email/Email.js +102 -129
- package/lib/components/Email/Email.js.map +1 -1
- package/lib/components/Email/Email.styles.d.ts +8 -1
- package/lib/components/Email/Email.styles.d.ts.map +1 -1
- package/lib/components/Email/Email.styles.js +85 -4
- package/lib/components/Email/Email.styles.js.map +1 -1
- package/lib/components/Email/Email.types.d.ts +139 -62
- 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/EmailComposer.d.ts +4 -6
- package/lib/components/Email/EmailComposer.d.ts.map +1 -1
- package/lib/components/Email/EmailComposer.js +155 -73
- package/lib/components/Email/EmailComposer.js.map +1 -1
- package/lib/components/Email/EmailConversation.d.ts +7 -4
- package/lib/components/Email/EmailConversation.d.ts.map +1 -1
- package/lib/components/Email/EmailConversation.js +132 -76
- package/lib/components/Email/EmailConversation.js.map +1 -1
- package/lib/components/Email/EmailEntity.d.ts +6 -0
- package/lib/components/Email/EmailEntity.d.ts.map +1 -0
- package/lib/components/Email/EmailEntity.js +19 -0
- package/lib/components/Email/EmailEntity.js.map +1 -0
- package/lib/components/Email/EmailSelector.d.ts +14 -0
- package/lib/components/Email/EmailSelector.d.ts.map +1 -0
- package/lib/components/Email/EmailSelector.js +62 -0
- package/lib/components/Email/EmailSelector.js.map +1 -0
- package/lib/components/Email/EmailShell.d.ts.map +1 -1
- package/lib/components/Email/EmailShell.js +23 -31
- package/lib/components/Email/EmailShell.js.map +1 -1
- package/lib/components/Email/EmailSummaryItem.d.ts +10 -0
- package/lib/components/Email/EmailSummaryItem.d.ts.map +1 -0
- package/lib/components/Email/EmailSummaryItem.js +93 -0
- package/lib/components/Email/EmailSummaryItem.js.map +1 -0
- package/lib/components/Email/EmailSummaryList.d.ts +6 -0
- package/lib/components/Email/EmailSummaryList.d.ts.map +1 -0
- package/lib/components/Email/EmailSummaryList.js +115 -0
- package/lib/components/Email/EmailSummaryList.js.map +1 -0
- package/lib/components/Email/ViewAnalysis.d.ts +6 -0
- package/lib/components/Email/ViewAnalysis.d.ts.map +1 -0
- package/lib/components/Email/ViewAnalysis.js +20 -0
- package/lib/components/Email/ViewAnalysis.js.map +1 -0
- package/lib/components/Feed/Feed.context.d.ts +16 -6
- package/lib/components/Feed/Feed.context.d.ts.map +1 -1
- package/lib/components/Feed/Feed.context.js +1 -0
- package/lib/components/Feed/Feed.context.js.map +1 -1
- package/lib/components/Feed/Feed.d.ts +13 -17
- package/lib/components/Feed/Feed.d.ts.map +1 -1
- package/lib/components/Feed/Feed.js +20 -31
- package/lib/components/Feed/Feed.js.map +1 -1
- package/lib/components/Feed/FeedAttachments.d.ts.map +1 -1
- package/lib/components/Feed/FeedAttachments.js +7 -6
- package/lib/components/Feed/FeedAttachments.js.map +1 -1
- package/lib/components/Feed/FeedButton.d.ts.map +1 -1
- package/lib/components/Feed/FeedButton.js.map +1 -1
- package/lib/components/Feed/FeedContent.d.ts.map +1 -1
- package/lib/components/Feed/FeedContent.js +12 -6
- package/lib/components/Feed/FeedContent.js.map +1 -1
- package/lib/components/Feed/FeedModalList.d.ts +15 -0
- package/lib/components/Feed/FeedModalList.d.ts.map +1 -0
- package/lib/components/Feed/FeedModalList.js +49 -0
- package/lib/components/Feed/FeedModalList.js.map +1 -0
- package/lib/components/Feed/FeedNewPost.d.ts +2 -1
- package/lib/components/Feed/FeedNewPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPost.js +44 -44
- package/lib/components/Feed/FeedNewPost.js.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.d.ts.map +1 -1
- package/lib/components/Feed/FeedNewPostTypeMenu.js +47 -79
- package/lib/components/Feed/FeedNewPostTypeMenu.js.map +1 -1
- package/lib/components/Feed/FeedPost.d.ts +34 -12
- package/lib/components/Feed/FeedPost.d.ts.map +1 -1
- package/lib/components/Feed/FeedPost.js +165 -101
- package/lib/components/Feed/FeedPost.js.map +1 -1
- package/lib/components/Feed/FeedReply.d.ts +31 -13
- package/lib/components/Feed/FeedReply.d.ts.map +1 -1
- package/lib/components/Feed/FeedReply.js +123 -39
- package/lib/components/Feed/FeedReply.js.map +1 -1
- package/lib/components/Feed/FeedReplyInput.d.ts +6 -6
- package/lib/components/Feed/FeedReplyInput.d.ts.map +1 -1
- package/lib/components/Feed/FeedReplyInput.js +43 -46
- package/lib/components/Feed/FeedReplyInput.js.map +1 -1
- package/lib/components/Feed/FeedRichText.d.ts.map +1 -1
- package/lib/components/Feed/FeedRichText.js +81 -19
- package/lib/components/Feed/FeedRichText.js.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.d.ts +6 -4
- package/lib/components/HashtagButton/HashtagButton.d.ts.map +1 -1
- package/lib/components/HashtagButton/HashtagButton.js +23 -17
- package/lib/components/HashtagButton/HashtagButton.js.map +1 -1
- package/lib/components/MentionButton/MentionButton.d.ts +10 -4
- package/lib/components/MentionButton/MentionButton.d.ts.map +1 -1
- package/lib/components/MentionButton/MentionButton.js +34 -18
- package/lib/components/MentionButton/MentionButton.js.map +1 -1
- package/package.json +15 -16
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
3
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import { Button, defaultThemeProp, Flex, Grid, Icon, Popover, Switch, Text, Progress, StyledProgressRing } from '@pega/cosmos-react-core';
|
|
4
|
+
import { Button, defaultThemeProp, Flex, Grid, Icon, registerIcon, Popover, Switch, Text, Progress, StyledProgressRing } from '@pega/cosmos-react-core';
|
|
4
5
|
import { useArrows, useElement, useI18n, useOuterEvent } from '@pega/cosmos-react-core/lib/hooks';
|
|
5
|
-
import
|
|
6
|
+
import * as filterIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter.icon';
|
|
7
|
+
import * as filterOnIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter-on.icon';
|
|
6
8
|
import { FeedContext } from './Feed.context';
|
|
7
9
|
import { StyledFeedNewPost } from './FeedNewPost';
|
|
8
10
|
import { StyledFeedPost } from './FeedPost';
|
|
9
11
|
import FeedButton from './FeedButton';
|
|
12
|
+
registerIcon(filterIcon, filterOnIcon);
|
|
10
13
|
const StyledFeed = styled.div(props => {
|
|
11
14
|
return css `
|
|
12
15
|
${StyledFeedNewPost}:not(:last-child), ${StyledFeedPost}:not(:last-child) {
|
|
13
16
|
margin-bottom: calc(2 * ${props.theme.base.spacing});
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
${StyledRichTextEditor} {
|
|
17
|
-
&:focus-within {
|
|
18
|
-
box-shadow: none;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
18
|
`;
|
|
22
19
|
});
|
|
23
20
|
StyledFeed.defaultProps = defaultThemeProp;
|
|
@@ -63,12 +60,13 @@ const StyledLoadMore = styled.div(({ theme, visible }) => {
|
|
|
63
60
|
});
|
|
64
61
|
StyledLoadMore.defaultProps = defaultThemeProp;
|
|
65
62
|
const Feed = (props) => {
|
|
66
|
-
const { variant, children, userInfo, className, title, onDecoratorSearch, searchResults = [],
|
|
63
|
+
const { variant, children, userInfo, className, title, searchTypes, onDecoratorSearch, searchResults = [], onMentionClick, onTagClick, mentionContent, interactionRenderers = [], markdownMap, filters, onFilterChange, onLoadMore, ...restProps } = props;
|
|
67
64
|
const [popoverEl, setPopoverEl] = useElement();
|
|
68
65
|
const [buttonEl, setButtonEl] = useElement();
|
|
69
66
|
const [loadMoreEl, setLoadMoreEl] = useElement();
|
|
70
67
|
const [mountPopover, setMountPopover] = useState(false);
|
|
71
68
|
const [feedOverflows, setFeedOverflows] = useState(false);
|
|
69
|
+
const [showSearchResults, setShowSearchResults] = useState(false);
|
|
72
70
|
const feedOverflowsRef = useRef(false);
|
|
73
71
|
const filterRef = useRef(null);
|
|
74
72
|
useArrows(filterRef);
|
|
@@ -93,7 +91,7 @@ const Feed = (props) => {
|
|
|
93
91
|
feedOverflowsRef.current = true;
|
|
94
92
|
}
|
|
95
93
|
else if (entries[0].isIntersecting && feedOverflowsRef.current) {
|
|
96
|
-
onLoadMore
|
|
94
|
+
onLoadMore?.();
|
|
97
95
|
}
|
|
98
96
|
});
|
|
99
97
|
intersectionObserver.observe(loadMoreEl);
|
|
@@ -103,34 +101,25 @@ const Feed = (props) => {
|
|
|
103
101
|
}
|
|
104
102
|
}, [loadMoreEl, feedOverflowsRef.current]);
|
|
105
103
|
const t = useI18n();
|
|
106
|
-
return (
|
|
104
|
+
return (_jsx(FeedContext.Provider, { value: {
|
|
105
|
+
searchTypes,
|
|
107
106
|
onSearch: e => {
|
|
108
107
|
if (onDecoratorSearch)
|
|
109
108
|
onDecoratorSearch(e);
|
|
110
109
|
},
|
|
111
110
|
searchResults,
|
|
112
|
-
|
|
111
|
+
showSearchResults,
|
|
112
|
+
setShowSearchResults,
|
|
113
|
+
onMentionClick,
|
|
114
|
+
onTagClick,
|
|
113
115
|
interactionRenderers,
|
|
114
116
|
markdownMap,
|
|
115
117
|
userInfo
|
|
116
|
-
} },
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
React.createElement(Icon, { name: (filters === null || filters === void 0 ? void 0 : filters.map(filter => !!filter.on).reduce((acc, curr) => acc || curr))
|
|
122
|
-
? 'filter-on'
|
|
123
|
-
: 'filter' }))))),
|
|
124
|
-
React.createElement(Popover, { show: !!filters && mountPopover, ref: setPopoverEl, target: buttonEl, as: StyledFilterMenu },
|
|
125
|
-
React.createElement(Flex, { container: { direction: 'column', itemGap: 2 }, as: 'fieldset' },
|
|
126
|
-
React.createElement(Text, { variant: 'h3', as: 'legend' }, t('filters')),
|
|
127
|
-
React.createElement(Grid, { container: { gap: 1 }, as: StyledFilterList, ref: filterRef }, filters === null || filters === void 0 ? void 0 : filters.map(filter => {
|
|
128
|
-
return (React.createElement("li", { key: filter.id },
|
|
129
|
-
React.createElement(Switch, { ...filter, onChange: (event) => onFilterChange === null || onFilterChange === void 0 ? void 0 : onFilterChange(event.target.id, event.target.checked) })));
|
|
130
|
-
})))),
|
|
131
|
-
React.createElement("div", null, children),
|
|
132
|
-
onLoadMore && (React.createElement(Flex, { ref: setLoadMoreEl, as: StyledLoadMore, visible: feedOverflows, container: { justify: 'center' } },
|
|
133
|
-
React.createElement(Progress, { placement: 'inline' }))))));
|
|
118
|
+
}, children: _jsxs(StyledFeed, { ...restProps, children: [(title || (filters && !!filters.length)) && (_jsxs(Flex, { container: { justify: 'between', alignItems: 'center' }, as: StyledHeading, children: [title ? _jsx(Text, { variant: 'h2', children: title }, void 0) : _jsx("div", {}, void 0), filters && (_jsx(Button, { as: FeedButton, ref: setButtonEl, variant: 'simple', icon: true, onClick: () => setMountPopover(curr => !curr), label: `${title || ''} ${t('filters')}`, emphasized: true, children: _jsx(Icon, { name: filters?.map(filter => !!filter.on).reduce((acc, curr) => acc || curr)
|
|
119
|
+
? 'filter-on'
|
|
120
|
+
: 'filter' }, void 0) }, void 0))] }, void 0)), _jsx(Popover, { show: !!filters && mountPopover, ref: setPopoverEl, target: buttonEl, as: StyledFilterMenu, children: _jsxs(Flex, { container: { direction: 'column', gap: 2 }, as: 'fieldset', children: [_jsx(Text, { variant: 'h3', as: 'legend', children: t('filters') }, void 0), _jsx(Grid, { container: { gap: 1 }, as: StyledFilterList, ref: filterRef, children: filters?.map(filter => {
|
|
121
|
+
return (_jsx("li", { children: _jsx(Switch, { ...filter, onChange: (event) => onFilterChange?.(event.target.id, event.target.checked) }, void 0) }, filter.id));
|
|
122
|
+
}) }, void 0)] }, void 0) }, void 0), _jsx("div", { children: children }, void 0), onLoadMore && (_jsx(Flex, { ref: setLoadMoreEl, as: StyledLoadMore, visible: feedOverflows, container: { justify: 'center' }, children: _jsx(Progress, { placement: 'inline' }, void 0) }, void 0))] }, void 0) }, void 0));
|
|
134
123
|
};
|
|
135
124
|
export default Feed;
|
|
136
125
|
//# sourceMappingURL=Feed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Feed.js","sourceRoot":"","sources":["../../../src/components/Feed/Feed.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA8B,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,IAAI,EAEJ,IAAI,EACJ,IAAI,EAEJ,OAAO,EACP,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClG,OAAO,EAA+B,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE3F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,UAAU,MAAM,cAAc,CAAC;AA8CtC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;IACpC,OAAO,GAAG,CAAA;MACN,iBAAiB,sBAAsB,cAAc;gCAC3B,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO;;;MAGlD,oBAAoB;;;;;GAKvB,CAAC;AACJ,CAAC,C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AAM,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAEzD,CACC,CACN,CAAC;oBACJ,CAAC,CAAC,CACG,CACF,CACC;YAEV,iCAAM,QAAQ,CAAO;YAEpB,UAAU,IAAI,CACb,oBAAC,IAAI,IACH,GAAG,EAAE,aAAa,EAClB,EAAE,EAAE,cAAc,EAClB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;gBAEhC,oBAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,CAC1B,CACR,CACU,CACQ,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import React, { ChangeEvent, ReactNode, FC, useState, useRef, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n defaultThemeProp,\n Flex,\n ForwardProps,\n Grid,\n Icon,\n MenuItemProps,\n Popover,\n Switch,\n Text,\n Progress,\n StyledProgressRing\n} from '@pega/cosmos-react-core';\nimport { GlimpseProps } from '@pega/cosmos-react-work';\nimport { useArrows, useElement, useI18n, useOuterEvent } from '@pega/cosmos-react-core/lib/hooks';\nimport { InteractionRenderers, MDMap, StyledRichTextEditor } from '@pega/cosmos-react-rte';\n\nimport { FeedContext } from './Feed.context';\nimport { StyledFeedNewPost } from './FeedNewPost';\nimport { StyledFeedPost } from './FeedPost';\nimport FeedButton from './FeedButton';\n\nexport interface Filter {\n /** Sets DOM id for the control and associates label element via 'for' attribute. */\n id: string;\n /** Pass a string or a fragment with an Icon and string for the filter label. */\n label: ReactNode;\n /**\n * Disables the filter.\n * @default false\n */\n disabled?: boolean;\n /**\n * Sets on prop via onFilterChange.\n * @default false\n */\n on?: boolean;\n}\nexport interface FeedProps {\n children: ReactNode;\n /** Title for the feed. */\n title?: string;\n /** Information related to the user of the Feed. */\n userInfo: {\n avatarSrc?: string;\n username: string;\n fullname: string;\n };\n /** A callback that runs when a decorator search has been run inside of the feed. */\n onDecoratorSearch?: (e: { type: 'mention' | 'tag'; search: string }) => void;\n /** Results that will be shown in a Popover for a mention or tag search. */\n searchResults?: MenuItemProps[];\n /** A list of available users that map directly to the initial set of search results for a mention. */\n availableMentions?: GlimpseProps[];\n /** A list of configuration objects used to render custom components within Feed posts and replies based off of a given regex pattern. */\n interactionRenderers?: InteractionRenderers[];\n /** A mapping for various element types to render custom components for within posts. */\n markdownMap?: MDMap;\n /** A set of filters to apply to the Feed. */\n filters?: Filter[];\n /** A callback that runs when the filter is toggled. */\n onFilterChange?: (filterId: string, on: boolean) => void;\n /** A callback that is triggered when the bottom of the Feed is scrolled into view so that additional posts may be displayed. */\n onLoadMore?: () => void;\n}\n\nconst StyledFeed = styled.div(props => {\n return css`\n ${StyledFeedNewPost}:not(:last-child), ${StyledFeedPost}:not(:last-child) {\n margin-bottom: calc(2 * ${props.theme.base.spacing});\n }\n\n ${StyledRichTextEditor} {\n &:focus-within {\n box-shadow: none;\n }\n }\n `;\n});\n\nStyledFeed.defaultProps = defaultThemeProp;\n\nconst StyledHeading = styled.div(props => {\n return css`\n margin: ${props.theme.base.spacing} 0;\n `;\n});\n\nStyledHeading.defaultProps = defaultThemeProp;\n\nconst StyledFilterMenu = styled.div(props => {\n return css`\n padding: calc(2 * ${props.theme.base.spacing});\n\n fieldset {\n border: none;\n }\n `;\n});\n\nStyledFilterMenu.defaultProps = defaultThemeProp;\n\nconst StyledFilterList = styled.ul`\n list-style-type: none;\n min-width: 10rem;\n`;\n\nStyledFilterList.defaultProps = defaultThemeProp;\n\nconst StyledLoadMore = styled.div<{ visible: boolean }>(({ theme, visible }) => {\n return css`\n ${visible &&\n css`\n margin-top: calc(2 * ${theme.base.spacing});\n `}\n\n ${StyledProgressRing} {\n min-height: 0;\n min-width: 0;\n\n ${visible &&\n css`\n min-height: 2rem;\n min-width: 2rem;\n `}\n }\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst Feed: FC<ForwardProps & FeedProps> = (props: ForwardProps & FeedProps) => {\n const {\n variant,\n children,\n userInfo,\n className,\n title,\n onDecoratorSearch,\n searchResults = [],\n availableMentions = [],\n interactionRenderers = [],\n markdownMap,\n filters,\n onFilterChange,\n onLoadMore,\n ...restProps\n } = props;\n\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>();\n const [buttonEl, setButtonEl] = useElement<HTMLElement>();\n const [loadMoreEl, setLoadMoreEl] = useElement<HTMLDivElement>();\n const [mountPopover, setMountPopover] = useState(false);\n const [feedOverflows, setFeedOverflows] = useState(false);\n const feedOverflowsRef = useRef(false);\n\n const filterRef = useRef(null);\n useArrows(filterRef);\n\n useOuterEvent('mousedown', [popoverEl, buttonEl], () => {\n setMountPopover(false);\n });\n\n const onKeydown = ({ key }: KeyboardEvent) => {\n if (key === 'Escape') setMountPopover(false);\n };\n\n useEffect(() => {\n document.addEventListener('keydown', onKeydown);\n return () => {\n document.removeEventListener('keydown', onKeydown);\n };\n }, []);\n\n useEffect(() => {\n if (loadMoreEl) {\n const intersectionObserver = new IntersectionObserver(entries => {\n if (!entries[0].isIntersecting) {\n setFeedOverflows(true);\n feedOverflowsRef.current = true;\n } else if (entries[0].isIntersecting && feedOverflowsRef.current) {\n onLoadMore?.();\n }\n });\n\n intersectionObserver.observe(loadMoreEl);\n\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [loadMoreEl, feedOverflowsRef.current]);\n\n const t = useI18n();\n\n return (\n <FeedContext.Provider\n value={{\n onSearch: e => {\n if (onDecoratorSearch) onDecoratorSearch(e);\n },\n searchResults,\n availableMentions,\n interactionRenderers,\n markdownMap,\n userInfo\n }}\n >\n <StyledFeed {...restProps}>\n {(title || (filters && !!filters.length)) && (\n <Flex container={{ justify: 'between', alignItems: 'center' }} as={StyledHeading}>\n {title ? <Text variant='h2'>{title}</Text> : <div />}\n {filters && (\n <Button\n as={FeedButton}\n ref={setButtonEl}\n variant='simple'\n icon\n onClick={() => setMountPopover(curr => !curr)}\n label={`${title || ''} ${t('filters')}`}\n emphasized\n >\n <Icon\n name={\n filters?.map(filter => !!filter.on).reduce((acc, curr) => acc || curr)\n ? 'filter-on'\n : 'filter'\n }\n />\n </Button>\n )}\n </Flex>\n )}\n <Popover\n show={!!filters && mountPopover}\n ref={setPopoverEl}\n target={buttonEl}\n as={StyledFilterMenu}\n >\n <Flex container={{ direction: 'column', itemGap: 2 }} as='fieldset'>\n <Text variant='h3' as='legend'>\n {t('filters')}\n </Text>\n <Grid container={{ gap: 1 }} as={StyledFilterList} ref={filterRef}>\n {filters?.map(filter => {\n return (\n <li key={filter.id}>\n <Switch\n {...filter}\n onChange={(event: ChangeEvent<HTMLInputElement>) =>\n onFilterChange?.(event.target.id, event.target.checked)\n }\n />\n </li>\n );\n })}\n </Grid>\n </Flex>\n </Popover>\n\n <div>{children}</div>\n\n {onLoadMore && (\n <Flex\n ref={setLoadMoreEl}\n as={StyledLoadMore}\n visible={feedOverflows}\n container={{ justify: 'center' }}\n >\n <Progress placement='inline' />\n </Flex>\n )}\n </StyledFeed>\n </FeedContext.Provider>\n );\n};\n\nexport default Feed;\n"]}
|
|
1
|
+
{"version":3,"file":"Feed.js","sourceRoot":"","sources":["../../../src/components/Feed/Feed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA8B,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,IAAI,EAEJ,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClG,OAAO,KAAK,UAAU,MAAM,+DAA+D,CAAC;AAC5F,OAAO,KAAK,YAAY,MAA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AQ,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAC,UAAU,aAC7D,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,EAAC,EAAE,EAAC,QAAQ,YAC3B,CAAC,CAAC,SAAS,CAAC,WACR,EACP,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,gBAAgB,EAAE,GAAG,EAAE,SAAS,YAC9D,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE;oCACrB,OAAO,CACL,uBACE,KAAC,MAAM,OACD,MAAM,EACV,QAAQ,EAAE,CAAC,KAAoC,EAAE,EAAE,CACjD,cAAc,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,WAEzD,IANK,MAAM,CAAC,EAAE,CAOb,CACN,CAAC;gCACJ,CAAC,CAAC,WACG,YACF,WACC,EAEV,wBAAM,QAAQ,WAAO,EAEpB,UAAU,IAAI,CACb,KAAC,IAAI,IACH,GAAG,EAAE,aAAa,EAClB,EAAE,EAAE,cAAc,EAClB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,YAEhC,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,WAAG,WAC1B,CACR,YACU,WACQ,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC","sourcesContent":["import { ChangeEvent, ReactNode, FC, useState, useRef, useEffect } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Button,\n defaultThemeProp,\n Flex,\n ForwardProps,\n Grid,\n Icon,\n registerIcon,\n Popover,\n Switch,\n Text,\n Progress,\n StyledProgressRing\n} from '@pega/cosmos-react-core';\nimport { useArrows, useElement, useI18n, useOuterEvent } from '@pega/cosmos-react-core/lib/hooks';\nimport * as filterIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter.icon';\nimport * as filterOnIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/filter-on.icon';\n\nimport { FeedContext, FeedContextValue } from './Feed.context';\nimport { StyledFeedNewPost } from './FeedNewPost';\nimport { StyledFeedPost } from './FeedPost';\nimport FeedButton from './FeedButton';\n\nregisterIcon(filterIcon, filterOnIcon);\n\nexport interface Filter {\n /** Sets DOM id for the control and associates label element via 'for' attribute. */\n id: string;\n /** Pass a string or a fragment with an Icon and string for the filter label. */\n label: ReactNode;\n /**\n * Disables the filter.\n * @default false\n */\n disabled?: boolean;\n /**\n * Sets on prop via onFilterChange.\n * @default false\n */\n on?: boolean;\n}\nexport interface FeedProps {\n children: ReactNode;\n /** Title for the feed. */\n title?: string;\n /** Information related to the user of the Feed. */\n userInfo: FeedContextValue['userInfo'];\n /** A set of search types that can be used to determine which data set to conduct a mention search on. */\n searchTypes?: FeedContextValue['searchTypes'];\n /** A callback that runs when a decorator search has been run inside of the feed. */\n onDecoratorSearch?: FeedContextValue['onSearch'];\n /** Results that will be shown in a Popover for a mention or tag search. */\n searchResults?: FeedContextValue['searchResults'];\n /** A callback that is triggered when a mention is clicked. The callback sends back the id, text, and type of the mention. The callback should return a function component. */\n onMentionClick?: FeedContextValue['onMentionClick'];\n /** A callback that is triggered when a hashtag is clicked. The callback sends back the test of the tag. */\n onTagClick?: FeedContextValue['onTagClick'];\n /** A list of configuration objects used to render custom components within Feed posts and replies based off of a given regex pattern. */\n interactionRenderers?: FeedContextValue['interactionRenderers'];\n /** A mapping for various element types to render custom components for within posts. */\n markdownMap?: FeedContextValue['markdownMap'];\n /** A set of filters to apply to the Feed. */\n filters?: Filter[];\n /** A callback that runs when the filter is toggled. */\n onFilterChange?: (filterId: string, on: boolean) => void;\n /** A callback that is triggered when the bottom of the Feed is scrolled into view so that additional posts may be displayed. */\n onLoadMore?: () => void;\n}\n\nconst StyledFeed = styled.div(props => {\n return css`\n ${StyledFeedNewPost}:not(:last-child), ${StyledFeedPost}:not(:last-child) {\n margin-bottom: calc(2 * ${props.theme.base.spacing});\n }\n `;\n});\n\nStyledFeed.defaultProps = defaultThemeProp;\n\nconst StyledHeading = styled.div(props => {\n return css`\n margin: ${props.theme.base.spacing} 0;\n `;\n});\n\nStyledHeading.defaultProps = defaultThemeProp;\n\nconst StyledFilterMenu = styled.div(props => {\n return css`\n padding: calc(2 * ${props.theme.base.spacing});\n\n fieldset {\n border: none;\n }\n `;\n});\n\nStyledFilterMenu.defaultProps = defaultThemeProp;\n\nconst StyledFilterList = styled.ul`\n list-style-type: none;\n min-width: 10rem;\n`;\n\nStyledFilterList.defaultProps = defaultThemeProp;\n\nconst StyledLoadMore = styled.div<{ visible: boolean }>(({ theme, visible }) => {\n return css`\n ${visible &&\n css`\n margin-top: calc(2 * ${theme.base.spacing});\n `}\n\n ${StyledProgressRing} {\n min-height: 0;\n min-width: 0;\n\n ${visible &&\n css`\n min-height: 2rem;\n min-width: 2rem;\n `}\n }\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst Feed: FC<ForwardProps & FeedProps> = (props: ForwardProps & FeedProps) => {\n const {\n variant,\n children,\n userInfo,\n className,\n title,\n searchTypes,\n onDecoratorSearch,\n searchResults = [],\n onMentionClick,\n onTagClick,\n mentionContent,\n interactionRenderers = [],\n markdownMap,\n filters,\n onFilterChange,\n onLoadMore,\n ...restProps\n } = props;\n\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>();\n const [buttonEl, setButtonEl] = useElement<HTMLElement>();\n const [loadMoreEl, setLoadMoreEl] = useElement<HTMLDivElement>();\n const [mountPopover, setMountPopover] = useState(false);\n const [feedOverflows, setFeedOverflows] = useState(false);\n const [showSearchResults, setShowSearchResults] = useState(false);\n const feedOverflowsRef = useRef(false);\n\n const filterRef = useRef(null);\n useArrows(filterRef);\n\n useOuterEvent('mousedown', [popoverEl, buttonEl], () => {\n setMountPopover(false);\n });\n\n const onKeydown = ({ key }: KeyboardEvent) => {\n if (key === 'Escape') setMountPopover(false);\n };\n\n useEffect(() => {\n document.addEventListener('keydown', onKeydown);\n return () => {\n document.removeEventListener('keydown', onKeydown);\n };\n }, []);\n\n useEffect(() => {\n if (loadMoreEl) {\n const intersectionObserver = new IntersectionObserver(entries => {\n if (!entries[0].isIntersecting) {\n setFeedOverflows(true);\n feedOverflowsRef.current = true;\n } else if (entries[0].isIntersecting && feedOverflowsRef.current) {\n onLoadMore?.();\n }\n });\n\n intersectionObserver.observe(loadMoreEl);\n\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [loadMoreEl, feedOverflowsRef.current]);\n\n const t = useI18n();\n\n return (\n <FeedContext.Provider\n value={{\n searchTypes,\n onSearch: e => {\n if (onDecoratorSearch) onDecoratorSearch(e);\n },\n searchResults,\n showSearchResults,\n setShowSearchResults,\n onMentionClick,\n onTagClick,\n interactionRenderers,\n markdownMap,\n userInfo\n }}\n >\n <StyledFeed {...restProps}>\n {(title || (filters && !!filters.length)) && (\n <Flex container={{ justify: 'between', alignItems: 'center' }} as={StyledHeading}>\n {title ? <Text variant='h2'>{title}</Text> : <div />}\n {filters && (\n <Button\n as={FeedButton}\n ref={setButtonEl}\n variant='simple'\n icon\n onClick={() => setMountPopover(curr => !curr)}\n label={`${title || ''} ${t('filters')}`}\n emphasized\n >\n <Icon\n name={\n filters?.map(filter => !!filter.on).reduce((acc, curr) => acc || curr)\n ? 'filter-on'\n : 'filter'\n }\n />\n </Button>\n )}\n </Flex>\n )}\n <Popover\n show={!!filters && mountPopover}\n ref={setPopoverEl}\n target={buttonEl}\n as={StyledFilterMenu}\n >\n <Flex container={{ direction: 'column', gap: 2 }} as='fieldset'>\n <Text variant='h3' as='legend'>\n {t('filters')}\n </Text>\n <Grid container={{ gap: 1 }} as={StyledFilterList} ref={filterRef}>\n {filters?.map(filter => {\n return (\n <li key={filter.id}>\n <Switch\n {...filter}\n onChange={(event: ChangeEvent<HTMLInputElement>) =>\n onFilterChange?.(event.target.id, event.target.checked)\n }\n />\n </li>\n );\n })}\n </Grid>\n </Flex>\n </Popover>\n\n <div>{children}</div>\n\n {onLoadMore && (\n <Flex\n ref={setLoadMoreEl}\n as={StyledLoadMore}\n visible={feedOverflows}\n container={{ justify: 'center' }}\n >\n <Progress placement='inline' />\n </Flex>\n )}\n </StyledFeed>\n </FeedContext.Provider>\n );\n};\n\nexport default Feed;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedAttachments.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedAttachments.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"FeedAttachments.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedAttachments.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,GAAG,EAAE,MAAM,OAAO,CAAC;AAG7D,OAAO,EAEL,mBAAmB,EAGpB,MAAM,yBAAyB,CAAC;AAEjC,oBAAY,aAAa,GAAG,mBAAmB,GAAG,IAAI,CAAC;AAEvD,UAAU,oBAAoB;IAC5B,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAED,eAAO,MAAM,qBAAqB,wGAYhC,CAAC;AAIH,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAoB7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
2
3
|
import styled, { css } from 'styled-components';
|
|
3
4
|
import { FileUploadItem, Grid, defaultThemeProp } from '@pega/cosmos-react-core';
|
|
4
5
|
export const StyledFeedAttachments = styled.ul(props => {
|
|
@@ -16,13 +17,13 @@ export const StyledFeedAttachments = styled.ul(props => {
|
|
|
16
17
|
StyledFeedAttachments.defaultProps = defaultThemeProp;
|
|
17
18
|
const FeedAttachments = forwardRef((props, ref) => {
|
|
18
19
|
const { attachments } = props;
|
|
19
|
-
return attachments && !!attachments.length ? (
|
|
20
|
+
return attachments && !!attachments.length ? (_jsx(Grid, { ref: ref, as: StyledFeedAttachments, container: {
|
|
20
21
|
cols: 'repeat(auto-fill, minmax(15rem, 1fr))',
|
|
21
22
|
gap: 1
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
}, children: Array.from(attachments).map(file => {
|
|
24
|
+
const { name, ...restProps } = file;
|
|
25
|
+
return _jsx(FileUploadItem, { name: name, ...restProps }, file.lastModified);
|
|
26
|
+
}) }, void 0)) : null;
|
|
26
27
|
});
|
|
27
28
|
export default FeedAttachments;
|
|
28
29
|
//# sourceMappingURL=FeedAttachments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedAttachments.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedAttachments.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FeedAttachments.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedAttachments.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAwB,MAAM,OAAO,CAAC;AAC7D,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,cAAc,EAEd,IAAI,EACJ,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AASjC,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;IACrD,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAExB,OAAO,GAAG,CAAA;cACE,KAAK,CAAC,IAAI,CAAC,OAAO;;;;0BAIN,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;;;GAG/D,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,qBAAqB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEtD,MAAM,eAAe,GAA6B,UAAU,CAC1D,CAAC,KAA4C,EAAE,GAAgC,EAAE,EAAE;IACjF,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAE9B,OAAO,WAAW,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAC3C,KAAC,IAAI,IACH,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,qBAAqB,EACzB,SAAS,EAAE;YACT,IAAI,EAAE,uCAAuC;YAC7C,GAAG,EAAE,CAAC;SACP,YAEA,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAClC,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,GAAG,IAAI,CAAC;YACpC,OAAO,KAAC,cAAc,IAAyB,IAAI,EAAE,IAAI,KAAM,SAAS,IAA5C,IAAI,CAAC,YAAY,CAA+B,CAAC;QAC/E,CAAC,CAAC,WACG,CACR,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { FC, forwardRef, PropsWithoutRef, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n FileUploadItem,\n FileUploadItemProps,\n Grid,\n defaultThemeProp\n} from '@pega/cosmos-react-core';\n\nexport type AttachedFiles = FileUploadItemProps & File;\n\ninterface FeedAttachmentsProps {\n attachments?: AttachedFiles[];\n ref?: Ref<HTMLUListElement>;\n}\n\nexport const StyledFeedAttachments = styled.ul(props => {\n const { theme } = props;\n\n return css`\n margin: ${theme.base.spacing} 0;\n overflow-x: auto;\n\n > li {\n background-color: ${theme.base.palette['primary-background']};\n cursor: initial;\n }\n `;\n});\n\nStyledFeedAttachments.defaultProps = defaultThemeProp;\n\nconst FeedAttachments: FC<FeedAttachmentsProps> = forwardRef(\n (props: PropsWithoutRef<FeedAttachmentsProps>, ref: FeedAttachmentsProps['ref']) => {\n const { attachments } = props;\n\n return attachments && !!attachments.length ? (\n <Grid\n ref={ref}\n as={StyledFeedAttachments}\n container={{\n cols: 'repeat(auto-fill, minmax(15rem, 1fr))',\n gap: 1\n }}\n >\n {Array.from(attachments).map(file => {\n const { name, ...restProps } = file;\n return <FileUploadItem key={file.lastModified} name={name} {...restProps} />;\n })}\n </Grid>\n ) : null;\n }\n);\n\nexport default FeedAttachments;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedButton.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.
|
|
1
|
+
{"version":3,"file":"FeedButton.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU;;;SAkBd,CAAC;AAIH,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedButton.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.
|
|
1
|
+
{"version":3,"file":"FeedButton.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedButton.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAA2C,KAAK,CAAC,EAAE;IACjF,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAE1C,OAAO,GAAG,CAAA;aACC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;;;;wCAIzD,KAAK,CAAC,IAAI,CAAC,OAAO;;;MAGpD,IAAI;QACN,GAAG,CAAA;;;;KAIF;GACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,UAAU,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE3C,eAAe,UAAU,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '@pega/cosmos-react-core';\n\nconst FeedButton = styled.button<{ emphasized?: boolean; icon?: boolean }>(props => {\n const { emphasized, icon, theme } = props;\n\n return css`\n color: ${emphasized ? theme.base.palette.interactive : theme.base.palette['foreground-color']};\n vertical-align: top;\n\n span {\n margin-inline-start: calc(0.5 * ${theme.base.spacing});\n }\n\n ${icon &&\n css`\n display: inline-flex;\n flex-direction: row;\n align-items: center;\n `}\n `;\n});\n\nFeedButton.defaultProps = defaultThemeProp;\n\nexport default FeedButton;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedContent.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"FeedContent.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EACF,GAAG,EAOH,YAAY,EAEb,MAAM,OAAO,CAAC;AAEf,OAAO,EAAgC,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKrF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC;IAChC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,GAAG,YAAY,CAsEpD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useState, useMemo, useRef, useLayoutEffect, useContext } from 'react';
|
|
2
3
|
import { Button, ExpandCollapse, Flex } from '@pega/cosmos-react-core';
|
|
3
4
|
import { RichTextViewer } from '@pega/cosmos-react-rte';
|
|
4
5
|
import { FeedContext } from './Feed.context';
|
|
@@ -23,11 +24,16 @@ const FeedContent = forwardRef(({ children, maxContentHeight = Infinity, ...rest
|
|
|
23
24
|
observer.disconnect();
|
|
24
25
|
};
|
|
25
26
|
}, [rtvRef.current, maxContentHeight]);
|
|
26
|
-
return useMemo(() => typeof children === 'string' ? (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
exceedsMaxHeight
|
|
30
|
-
|
|
27
|
+
return useMemo(() => typeof children === 'string' ? (_jsxs(Flex, { ref: ref, container: { direction: 'column', gap: 1 }, children: [_jsx(ExpandCollapse, { collapsed: collapsed, min: exceedsMaxHeight ? `${maxContentHeight}px` : 'max-content', ...restProps, children: _jsx(RichTextViewer, { ref: rtvRef, content: children, type: 'markdown', interactionRenderers: interactionRenderers, markdownMap: markdownMap }, void 0) }, void 0), exceedsMaxHeight && (_jsx(Flex, { container: { justify: 'center' }, children: _jsx(Button, { variant: 'link', onClick: () => setCollapsed(current => !current), children: collapsed ? 'Show more' : 'Show less' }, void 0) }, void 0))] }, void 0)) : (children), [
|
|
28
|
+
children,
|
|
29
|
+
collapsed,
|
|
30
|
+
exceedsMaxHeight,
|
|
31
|
+
interactionRenderers,
|
|
32
|
+
markdownMap,
|
|
33
|
+
maxContentHeight,
|
|
34
|
+
ref,
|
|
35
|
+
restProps
|
|
36
|
+
]);
|
|
31
37
|
});
|
|
32
38
|
export default FeedContent;
|
|
33
39
|
//# sourceMappingURL=FeedContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedContent.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FeedContent.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EACV,QAAQ,EACR,OAAO,E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xB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEvC,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAC7B,MAAC,IAAI,IAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aACxD,KAAC,cAAc,IACb,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC,aAAa,KAC3D,SAAS,YAEb,KAAC,cAAc,IACb,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAC,UAAU,EACf,oBAAoB,EAAE,oBAAoB,EAC1C,WAAW,EAAE,WAAW,WACxB,WACa,EAChB,gBAAgB,IAAI,CACnB,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,YACpC,KAAC,MAAM,IAAC,OAAO,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,YACpE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,WAC/B,WACJ,CACR,YACI,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,EACH;QACE,QAAQ;QACR,SAAS;QACT,gBAAgB;QAChB,oBAAoB;QACpB,WAAW;QACX,gBAAgB;QAChB,GAAG;QACH,SAAS;KACV,CACF,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n FC,\n Ref,\n forwardRef,\n useState,\n useMemo,\n useRef,\n useLayoutEffect,\n PropsWithoutRef,\n ReactElement,\n useContext\n} from 'react';\n\nimport { Button, ExpandCollapse, Flex, ForwardProps } from '@pega/cosmos-react-core';\nimport { RichTextViewer } from '@pega/cosmos-react-rte';\n\nimport { FeedContext } from './Feed.context';\n\nexport interface FeedContentProps {\n children: ReactElement | string;\n /**\n * A maximum height in pixels to display post content within before prompting to expand the post.\n * @default Infinity\n */\n maxContentHeight?: number;\n ref?: Ref<HTMLDivElement>;\n}\n\nconst FeedContent: FC<FeedContentProps & ForwardProps> = forwardRef(\n (\n { children, maxContentHeight = Infinity, ...restProps }: PropsWithoutRef<FeedContentProps>,\n ref: FeedContentProps['ref']\n ) => {\n const { interactionRenderers, markdownMap } = useContext(FeedContext);\n const [collapsed, setCollapsed] = useState(true);\n const [exceedsMaxHeight, setExceedsMaxHeight] = useState(true);\n const rtvRef = useRef<HTMLDivElement>(null);\n\n useLayoutEffect(() => {\n if (!rtvRef.current) return;\n\n const observer = new ResizeObserver(entries => {\n const exceedsHeight = entries.some(({ target, contentRect }) => {\n if (target !== rtvRef.current) return;\n\n return contentRect.height > maxContentHeight;\n });\n\n setExceedsMaxHeight(exceedsHeight);\n });\n\n observer.observe(rtvRef.current);\n\n return () => {\n observer.disconnect();\n };\n }, [rtvRef.current, maxContentHeight]);\n\n return useMemo(\n () =>\n typeof children === 'string' ? (\n <Flex ref={ref} container={{ direction: 'column', gap: 1 }}>\n <ExpandCollapse\n collapsed={collapsed}\n min={exceedsMaxHeight ? `${maxContentHeight}px` : 'max-content'}\n {...restProps}\n >\n <RichTextViewer\n ref={rtvRef}\n content={children}\n type='markdown'\n interactionRenderers={interactionRenderers}\n markdownMap={markdownMap}\n />\n </ExpandCollapse>\n {exceedsMaxHeight && (\n <Flex container={{ justify: 'center' }}>\n <Button variant='link' onClick={() => setCollapsed(current => !current)}>\n {collapsed ? 'Show more' : 'Show less'}\n </Button>\n </Flex>\n )}\n </Flex>\n ) : (\n children\n ),\n [\n children,\n collapsed,\n exceedsMaxHeight,\n interactionRenderers,\n markdownMap,\n maxContentHeight,\n ref,\n restProps\n ]\n );\n }\n);\n\nexport default FeedContent;\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { SummaryListItem } from '@pega/cosmos-react-core';
|
|
3
|
+
export interface FeedModalListProps {
|
|
4
|
+
/** The count for the list of items. */
|
|
5
|
+
count: number;
|
|
6
|
+
/** The heading for the Modal. */
|
|
7
|
+
heading: string;
|
|
8
|
+
/** The list of MenuItems to render in the Modal. */
|
|
9
|
+
listItems: SummaryListItem[];
|
|
10
|
+
/** A callback that is triggered when the bottom of the Modal list is scrolled into view so that additional data may be displayed. */
|
|
11
|
+
onLoadMore?: () => void;
|
|
12
|
+
}
|
|
13
|
+
declare const FeedModalList: FC<FeedModalListProps>;
|
|
14
|
+
export default FeedModalList;
|
|
15
|
+
//# sourceMappingURL=FeedModalList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FeedModalList.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedModalList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AAGxD,OAAO,EACL,eAAe,EAShB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,qIAAqI;IACrI,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAwBD,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAsDzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
|
+
import { defaultThemeProp, Flex, Progress, useElement, StyledProgressRing, Count, Modal, SummaryListItems } from '@pega/cosmos-react-core';
|
|
5
|
+
const StyledLoadMore = styled.div(({ theme, visible }) => {
|
|
6
|
+
return css `
|
|
7
|
+
${visible &&
|
|
8
|
+
css `
|
|
9
|
+
margin-top: calc(2 * ${theme.base.spacing});
|
|
10
|
+
`}
|
|
11
|
+
|
|
12
|
+
${StyledProgressRing} {
|
|
13
|
+
min-height: 0;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
|
|
16
|
+
${visible &&
|
|
17
|
+
css `
|
|
18
|
+
min-height: 2rem;
|
|
19
|
+
min-width: 2rem;
|
|
20
|
+
`}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
});
|
|
24
|
+
StyledLoadMore.defaultProps = defaultThemeProp;
|
|
25
|
+
const FeedModalList = ({ count, heading, listItems, onLoadMore }) => {
|
|
26
|
+
const [loadMoreEl, setLoadMoreEl] = useElement();
|
|
27
|
+
const [listOverflows, setListOverflows] = useState(false);
|
|
28
|
+
const listOverflowsRef = useRef(false);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (loadMoreEl) {
|
|
31
|
+
const intersectionObserver = new IntersectionObserver(entries => {
|
|
32
|
+
if (!entries[0].isIntersecting) {
|
|
33
|
+
setListOverflows(true);
|
|
34
|
+
listOverflowsRef.current = true;
|
|
35
|
+
}
|
|
36
|
+
else if (entries[0].isIntersecting && listOverflowsRef.current) {
|
|
37
|
+
onLoadMore?.();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
intersectionObserver.observe(loadMoreEl);
|
|
41
|
+
return () => {
|
|
42
|
+
intersectionObserver.disconnect();
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}, [loadMoreEl, listOverflowsRef.current]);
|
|
46
|
+
return (_jsxs(Modal, { heading: _jsxs(Flex, { container: { gap: 1 }, children: [heading, _jsx(Flex, { item: { alignSelf: 'center' }, as: Count, children: count }, void 0)] }, void 0), children: [_jsx(SummaryListItems, { items: listItems }, void 0), onLoadMore && (_jsx(Flex, { ref: setLoadMoreEl, as: StyledLoadMore, visible: listOverflows, container: { justify: 'center' }, children: _jsx(Progress, { placement: 'inline' }, void 0) }, void 0))] }, void 0));
|
|
47
|
+
};
|
|
48
|
+
export default FeedModalList;
|
|
49
|
+
//# sourceMappingURL=FeedModalList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FeedModalList.js","sourceRoot":"","sources":["../../../src/components/Feed/FeedModalList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAEL,gBAAgB,EAChB,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,KAAK,EACL,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAajC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAuB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;IAC7E,OAAO,GAAG,CAAA;MACN,OAAO;QACT,GAAG,CAAA;6BACsB,KAAK,CAAC,IAAI,CAAC,OAAO;KAC1C;;MAEC,kBAAkB;;;;QAIhB,OAAO;QACT,GAAG,CAAA;;;OAGF;;GAEJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,aAAa,GAA2B,CAAC,EAC7C,KAAK,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACS,EAAE,EAAE;IACvB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,UAAU,EAAkB,CAAC;IACjE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1D,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CA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';\nimport styled, { css } from 'styled-components';\n\nimport {\n SummaryListItem,\n defaultThemeProp,\n Flex,\n Progress,\n useElement,\n StyledProgressRing,\n Count,\n Modal,\n SummaryListItems\n} from '@pega/cosmos-react-core';\n\nexport interface FeedModalListProps {\n /** The count for the list of items. */\n count: number;\n /** The heading for the Modal. */\n heading: string;\n /** The list of MenuItems to render in the Modal. */\n listItems: SummaryListItem[];\n /** A callback that is triggered when the bottom of the Modal list is scrolled into view so that additional data may be displayed. */\n onLoadMore?: () => void;\n}\n\nconst StyledLoadMore = styled.div<{ visible: boolean }>(({ theme, visible }) => {\n return css`\n ${visible &&\n css`\n margin-top: calc(2 * ${theme.base.spacing});\n `}\n\n ${StyledProgressRing} {\n min-height: 0;\n min-width: 0;\n\n ${visible &&\n css`\n min-height: 2rem;\n min-width: 2rem;\n `}\n }\n `;\n});\n\nStyledLoadMore.defaultProps = defaultThemeProp;\n\nconst FeedModalList: FC<FeedModalListProps> = ({\n count,\n heading,\n listItems,\n onLoadMore\n}: FeedModalListProps) => {\n const [loadMoreEl, setLoadMoreEl] = useElement<HTMLDivElement>();\n const [listOverflows, setListOverflows] = useState(false);\n const listOverflowsRef = useRef(false);\n\n useEffect(() => {\n if (loadMoreEl) {\n const intersectionObserver = new IntersectionObserver(entries => {\n if (!entries[0].isIntersecting) {\n setListOverflows(true);\n listOverflowsRef.current = true;\n } else if (entries[0].isIntersecting && listOverflowsRef.current) {\n onLoadMore?.();\n }\n });\n\n intersectionObserver.observe(loadMoreEl);\n\n return () => {\n intersectionObserver.disconnect();\n };\n }\n }, [loadMoreEl, listOverflowsRef.current]);\n\n return (\n <Modal\n heading={\n <Flex container={{ gap: 1 }}>\n {heading}\n <Flex item={{ alignSelf: 'center' }} as={Count}>\n {count}\n </Flex>\n </Flex>\n }\n >\n <SummaryListItems items={listItems} />\n\n {onLoadMore && (\n <Flex\n ref={setLoadMoreEl}\n as={StyledLoadMore}\n visible={listOverflows}\n container={{ justify: 'center' }}\n >\n <Progress placement='inline' />\n </Flex>\n )}\n </Modal>\n );\n};\n\nexport default FeedModalList;\n"]}
|
|
@@ -21,7 +21,7 @@ export interface FeedNewPostProps {
|
|
|
21
21
|
attachments: AttachedFiles[];
|
|
22
22
|
recipients: RecipientMenuItem[];
|
|
23
23
|
username: string;
|
|
24
|
-
clear()
|
|
24
|
+
clear: () => void;
|
|
25
25
|
}) => void;
|
|
26
26
|
autoFocus?: boolean;
|
|
27
27
|
/** Array of private recipient options */
|
|
@@ -29,6 +29,7 @@ export interface FeedNewPostProps {
|
|
|
29
29
|
/** Handler for new search on private recipient options */
|
|
30
30
|
onRecipientSearch?: (newSearch: string) => void;
|
|
31
31
|
}
|
|
32
|
+
export declare const StyledTextAreaOverflow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
32
33
|
export declare const StyledFeedNewPost: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
33
34
|
declare const FeedNewPost: FC<ForwardProps & FeedNewPostProps>;
|
|
34
35
|
export default FeedNewPost;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedNewPost.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedNewPost.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"FeedNewPost.d.ts","sourceRoot":"","sources":["../../../src/components/Feed/FeedNewPost.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,EAAE,EAAkC,MAAM,OAAO,CAAC;AAGrE,OAAO,EAcL,YAAY,EAIb,MAAM,yBAAyB,CAAC;AAKjC,OAA4B,EAE1B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAwB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOnE,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;IAC9B,sFAAsF;IACtF,eAAe,EAAE;QACf,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,sGAAsG;IACtG,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;IAChD,yEAAyE;IACzE,MAAM,EAAE,CAAC,KAAK,EAAE;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,aAAa,EAAE,CAAC;QAC7B,UAAU,EAAE,iBAAiB,EAAE,CAAC;QAChC,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,IAAI,CAAC;KACnB,KAAK,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,UAAU,CAAC,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC7C,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,sBAAsB,yGAajC,CAAC;AAIH,eAAO,MAAM,iBAAiB,yGAU5B,CAAC;AAQH,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,YAAY,GAAG,gBAAgB,CA2JpD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useContext } from 'react';
|
|
2
3
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import { Avatar, Button, CardContent, Flex, Icon, StyledIcon, StyledCard, StyledPopover, defaultThemeProp, useAutoResize, useElement, useOuterEvent, useI18n, ExpandCollapse } from '@pega/cosmos-react-core';
|
|
4
|
+
import { Avatar, Button, CardContent, Flex, Icon, registerIcon, StyledIcon, StyledCard, StyledPopover, defaultThemeProp, useAutoResize, useElement, useOuterEvent, useI18n, ExpandCollapse, useAfterInitialEffect } from '@pega/cosmos-react-core';
|
|
5
|
+
import { StyledRichTextEditor } from '@pega/cosmos-react-rte';
|
|
6
|
+
import * as timesIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/times.icon';
|
|
7
|
+
import * as paperClipIcon from '@pega/cosmos-react-core/lib/components/Icon/icons/paper-clip.icon';
|
|
4
8
|
import FeedNewPostTypeMenu from './FeedNewPostTypeMenu';
|
|
5
9
|
import FeedAttachments from './FeedAttachments';
|
|
6
10
|
import FeedButton from './FeedButton';
|
|
7
11
|
import FeedRichText from './FeedRichText';
|
|
8
12
|
import { FeedContext } from './Feed.context';
|
|
9
|
-
|
|
13
|
+
registerIcon(timesIcon, paperClipIcon);
|
|
14
|
+
export const StyledTextAreaOverflow = styled.div(({ theme }) => {
|
|
10
15
|
return css `
|
|
11
16
|
overflow-y: hidden;
|
|
12
17
|
margin-top: ${theme.base.spacing};
|
|
18
|
+
min-height: 1rem;
|
|
13
19
|
width: 100%;
|
|
20
|
+
|
|
21
|
+
${StyledRichTextEditor} {
|
|
22
|
+
&:focus-within {
|
|
23
|
+
box-shadow: none;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
14
26
|
`;
|
|
15
27
|
});
|
|
16
28
|
StyledTextAreaOverflow.defaultProps = defaultThemeProp;
|
|
@@ -30,10 +42,11 @@ const HiddenFileInput = styled.input `
|
|
|
30
42
|
display: none;
|
|
31
43
|
`;
|
|
32
44
|
const FeedNewPost = (props) => {
|
|
33
|
-
var _a;
|
|
34
45
|
const { id, attachments = [], interactionInfo, onPost, onFilesAdded, autoFocus, recipients, onRecipientSearch, ...restProps } = props;
|
|
35
46
|
const rteRef = useRef();
|
|
36
47
|
const { textAreaPlaceholder, postLabel } = interactionInfo;
|
|
48
|
+
const { setShowSearchResults } = useContext(FeedContext);
|
|
49
|
+
const { avatarSrc, fullname, username } = useContext(FeedContext).userInfo;
|
|
37
50
|
const [emptyText, setEmptyText] = useState(true);
|
|
38
51
|
const [hasFocus, setHasFocus] = useState(autoFocus);
|
|
39
52
|
const [postType, setPostType] = useState('post');
|
|
@@ -42,67 +55,54 @@ const FeedNewPost = (props) => {
|
|
|
42
55
|
const [attachmentEl, setAttachmentEl] = useElement();
|
|
43
56
|
const [newPostEl, setNewPostEl] = useElement();
|
|
44
57
|
const [textAreaRef, resizeTextArea] = useAutoResize();
|
|
45
|
-
const { avatarSrc, fullname, username } = useContext(FeedContext).userInfo;
|
|
46
58
|
useOuterEvent('mousedown', [newPostEl], () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
(_b = rteRef.current) === null || _b === void 0 ? void 0 : _b.clear();
|
|
59
|
+
if (emptyText)
|
|
60
|
+
rteRef.current?.clear();
|
|
50
61
|
});
|
|
51
62
|
const t = useI18n();
|
|
52
63
|
const handlePost = () => {
|
|
53
|
-
|
|
54
|
-
if (!emptyText || attachments.length > 0) {
|
|
64
|
+
setShowSearchResults?.(false);
|
|
65
|
+
if ((!emptyText || attachments.length > 0) && attachments.every(x => !x.error)) {
|
|
55
66
|
onPost({
|
|
56
67
|
newPostId: id,
|
|
57
|
-
value:
|
|
68
|
+
value: rteRef.current?.getPlainText() || '',
|
|
58
69
|
attachments: attachments || [],
|
|
59
70
|
recipients: selectedRecipients,
|
|
60
71
|
username,
|
|
61
72
|
clear: () => {
|
|
62
|
-
|
|
63
|
-
(_a = rteRef.current) === null || _a === void 0 ? void 0 : _a.clear();
|
|
73
|
+
rteRef.current?.clear();
|
|
64
74
|
setResetPostTypeMenu(true);
|
|
65
75
|
}
|
|
66
76
|
});
|
|
67
77
|
}
|
|
68
78
|
};
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
const handleClear = () => {
|
|
80
|
+
setShowSearchResults?.(false);
|
|
81
|
+
rteRef.current?.clear();
|
|
82
|
+
};
|
|
83
|
+
useAfterInitialEffect(() => {
|
|
71
84
|
if (postType === 'post') {
|
|
72
|
-
|
|
85
|
+
rteRef.current?.focus();
|
|
73
86
|
}
|
|
74
87
|
if (postType !== 'private') {
|
|
75
88
|
setSelectedRecipients([]);
|
|
76
89
|
}
|
|
77
90
|
}, [postType]);
|
|
78
|
-
return (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
React.createElement(HiddenFileInput, { ref: setAttachmentEl, type: 'file', multiple: true, onChange: () => {
|
|
94
|
-
if (attachmentEl === null || attachmentEl === void 0 ? void 0 : attachmentEl.files) {
|
|
95
|
-
onFilesAdded === null || onFilesAdded === void 0 ? void 0 : onFilesAdded(Array.from(attachmentEl === null || attachmentEl === void 0 ? void 0 : attachmentEl.files));
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
// Must trick input to believe there is no value when activated so that the same file may be added consecutively.
|
|
99
|
-
onClick: (event) => {
|
|
100
|
-
event.target.value = '';
|
|
101
|
-
} }),
|
|
102
|
-
React.createElement(FeedAttachments, { attachments: attachments }),
|
|
103
|
-
React.createElement(ExpandCollapse, { collapsed: !hasFocus && emptyText && !attachments.length },
|
|
104
|
-
React.createElement(Flex, { container: { justify: 'end' } },
|
|
105
|
-
React.createElement(Button, { variant: 'primary', disabled: emptyText && attachments.length === 0, onClick: handlePost }, postLabel))))));
|
|
91
|
+
return (_jsx(StyledCard, { ref: setNewPostEl, as: StyledFeedNewPost, ...restProps, children: _jsxs(CardContent, { children: [onRecipientSearch && (_jsx(FeedNewPostTypeMenu, { recipients: recipients || [], onSetPostType: setPostType, onSelectedRecipientsUpdate: setSelectedRecipients, onRecipientSearch: onRecipientSearch, reset: resetPostTypeMenu, onReset: () => setResetPostTypeMenu(false) }, void 0)), _jsxs(Flex, { container: { alignItems: 'start', gap: 1 }, children: [_jsx(Avatar, { name: fullname, size: 'l', imageSrc: avatarSrc }, void 0), _jsx(StyledTextAreaOverflow, { ref: textAreaRef, children: _jsx(FeedRichText, { label: t('feed_new_post'), labelHidden: true, onChange: () => {
|
|
92
|
+
setEmptyText(rteRef.current?.getPlainText().trim() === '');
|
|
93
|
+
resizeTextArea();
|
|
94
|
+
}, placeholder: textAreaPlaceholder, autoFocus: autoFocus, onSubmit: handlePost, onFocus: () => setHasFocus(true), onBlur: () => setHasFocus(false), ref: rteRef }, void 0) }, void 0), !emptyText && (_jsx(Button, { variant: 'simple', as: FeedButton, onClick: handleClear, icon: true, label: t('feed_cancel_conversation'), children: _jsx(Icon, { name: 'times' }, void 0) }, void 0)), onFilesAdded && (_jsx(Button, { variant: 'simple', as: FeedButton, onClick: () => {
|
|
95
|
+
setShowSearchResults?.(false);
|
|
96
|
+
attachmentEl?.click();
|
|
97
|
+
}, icon: true, label: t('attachment'), children: _jsx(Icon, { name: 'paper-clip' }, void 0) }, void 0))] }, void 0), _jsx(HiddenFileInput, { ref: setAttachmentEl, type: 'file', multiple: true, onChange: () => {
|
|
98
|
+
if (attachmentEl?.files) {
|
|
99
|
+
onFilesAdded?.(Array.from(attachmentEl?.files));
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
// Must trick input to believe there is no value when activated so that the same file may be added consecutively.
|
|
103
|
+
onClick: (event) => {
|
|
104
|
+
event.target.value = '';
|
|
105
|
+
} }, void 0), _jsx(FeedAttachments, { attachments: attachments }, void 0), _jsx(ExpandCollapse, { collapsed: !hasFocus && emptyText && !attachments.length, children: _jsx(Flex, { container: { justify: 'end' }, children: _jsx(Button, { variant: 'primary', disabled: (emptyText && attachments.length === 0) || attachments.some(x => x.error), onClick: handlePost, children: postLabel }, void 0) }, void 0) }, void 0)] }, void 0) }, void 0));
|
|
106
106
|
};
|
|
107
107
|
export default FeedNewPost;
|
|
108
108
|
//# sourceMappingURL=FeedNewPost.js.map
|