@selfcommunity/react-ui 0.7.0-alpha.317 → 0.7.0-alpha.318
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.
|
@@ -59,6 +59,11 @@ export interface FeedObjectProps extends CardProps, VirtualScrollerItemProps {
|
|
|
59
59
|
* @default false
|
|
60
60
|
*/
|
|
61
61
|
hideFollowAction?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Show all summary initially (otherwise it will be truncated)
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
summaryExpanded?: boolean;
|
|
62
67
|
/**
|
|
63
68
|
* Show activities as default
|
|
64
69
|
* @default false
|
|
@@ -133,7 +133,7 @@ function FeedObject(inProps) {
|
|
|
133
133
|
props: inProps,
|
|
134
134
|
name: PREFIX
|
|
135
135
|
});
|
|
136
|
-
const { id = `feed_object_${props.feedObjectId ? props.feedObjectId : props.feedObject ? props.feedObject.id : ''}`, className = null, feedObjectId = null, feedObject = null, feedObjectType = types_1.SCContributionType.DISCUSSION, feedObjectActivities = null, cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, markRead = false, template = feedObject_1.SCFeedObjectTemplateType.PREVIEW, hideFollowAction = false, activitiesExpanded = true, activitiesExpandedType, hideParticipantsPreview = false, pollVisible = false, FollowButtonProps = {}, FeedObjectSkeletonProps = { elevation: 0 }, ActionsProps = {}, CommentObjectReplyComponent = CommentObjectReply_1.default, CommentObjectReplyComponentProps = { WidgetProps: { variant: 'outlined' } }, CommentComponentProps = { variant: 'outlined' }, CommentObjectSkeletonProps = { elevation: 0, WidgetProps: { variant: 'outlined' } }, ContributionActionsMenuProps = {}, MediasPreviewProps = {}, ActivitiesProps = { cacheStrategy }, PollObjectProps = { elevation: 0 }, ContributorsFeedObjectProps = {}, onReply, onHeightChange, onStateChange } = props, rest = tslib_1.__rest(props, ["id", "className", "feedObjectId", "feedObject", "feedObjectType", "feedObjectActivities", "cacheStrategy", "markRead", "template", "hideFollowAction", "activitiesExpanded", "activitiesExpandedType", "hideParticipantsPreview", "pollVisible", "FollowButtonProps", "FeedObjectSkeletonProps", "ActionsProps", "CommentObjectReplyComponent", "CommentObjectReplyComponentProps", "CommentComponentProps", "CommentObjectSkeletonProps", "ContributionActionsMenuProps", "MediasPreviewProps", "ActivitiesProps", "PollObjectProps", "ContributorsFeedObjectProps", "onReply", "onHeightChange", "onStateChange"]);
|
|
136
|
+
const { id = `feed_object_${props.feedObjectId ? props.feedObjectId : props.feedObject ? props.feedObject.id : ''}`, className = null, feedObjectId = null, feedObject = null, feedObjectType = types_1.SCContributionType.DISCUSSION, feedObjectActivities = null, cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, markRead = false, template = feedObject_1.SCFeedObjectTemplateType.PREVIEW, hideFollowAction = false, summaryExpanded = false, activitiesExpanded = true, activitiesExpandedType, hideParticipantsPreview = false, pollVisible = false, FollowButtonProps = {}, FeedObjectSkeletonProps = { elevation: 0 }, ActionsProps = {}, CommentObjectReplyComponent = CommentObjectReply_1.default, CommentObjectReplyComponentProps = { WidgetProps: { variant: 'outlined' } }, CommentComponentProps = { variant: 'outlined' }, CommentObjectSkeletonProps = { elevation: 0, WidgetProps: { variant: 'outlined' } }, ContributionActionsMenuProps = {}, MediasPreviewProps = {}, ActivitiesProps = { cacheStrategy }, PollObjectProps = { elevation: 0 }, ContributorsFeedObjectProps = {}, onReply, onHeightChange, onStateChange } = props, rest = tslib_1.__rest(props, ["id", "className", "feedObjectId", "feedObject", "feedObjectType", "feedObjectActivities", "cacheStrategy", "markRead", "template", "hideFollowAction", "summaryExpanded", "activitiesExpanded", "activitiesExpandedType", "hideParticipantsPreview", "pollVisible", "FollowButtonProps", "FeedObjectSkeletonProps", "ActionsProps", "CommentObjectReplyComponent", "CommentObjectReplyComponentProps", "CommentComponentProps", "CommentObjectSkeletonProps", "ContributionActionsMenuProps", "MediasPreviewProps", "ActivitiesProps", "PollObjectProps", "ContributorsFeedObjectProps", "onReply", "onHeightChange", "onStateChange"]);
|
|
137
137
|
// CONTEXT
|
|
138
138
|
const scContext = (0, react_core_1.useSCContext)();
|
|
139
139
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
@@ -155,7 +155,7 @@ function FeedObject(inProps) {
|
|
|
155
155
|
const [comments, setComments] = (0, react_1.useState)([]);
|
|
156
156
|
const [isReplying, setIsReplying] = (0, react_1.useState)(false);
|
|
157
157
|
const [selectedActivities, setSelectedActivities] = (0, react_1.useState)(getInitialSelectedActivitiesType());
|
|
158
|
-
const [expanded, setExpanded] = (0, react_1.useState)(
|
|
158
|
+
const [expanded, setExpanded] = (0, react_1.useState)(summaryExpanded);
|
|
159
159
|
// INTL
|
|
160
160
|
const intl = (0, react_intl_1.useIntl)();
|
|
161
161
|
/**
|
|
@@ -207,6 +207,13 @@ function FeedObject(inProps) {
|
|
|
207
207
|
const handleTogglePollVisibility = (0, react_1.useCallback)((visible) => {
|
|
208
208
|
notifyFeedChanges({ pollVisible: visible });
|
|
209
209
|
}, [pollVisible, notifyFeedChanges]);
|
|
210
|
+
/**
|
|
211
|
+
* Handle toggle summary
|
|
212
|
+
*/
|
|
213
|
+
const handleToggleSummary = (0, react_1.useCallback)(() => {
|
|
214
|
+
setExpanded(!expanded);
|
|
215
|
+
notifyFeedChanges({ summaryExpanded: !expanded });
|
|
216
|
+
}, [expanded, notifyFeedChanges]);
|
|
210
217
|
/**
|
|
211
218
|
* Render header action
|
|
212
219
|
* if author = authenticated user -> render edit action
|
|
@@ -384,7 +391,7 @@ function FeedObject(inProps) {
|
|
|
384
391
|
react_1.default.createElement(material_1.Typography, { component: "div", className: classes.text, variant: "body2", gutterBottom: true, dangerouslySetInnerHTML: {
|
|
385
392
|
__html: summaryHtml
|
|
386
393
|
} })),
|
|
387
|
-
!expanded && summaryHtmlTruncated && (react_1.default.createElement(material_1.Button, { size: "small", variant: "text", color: "inherit", onClick:
|
|
394
|
+
!expanded && summaryHtmlTruncated && (react_1.default.createElement(material_1.Button, { size: "small", variant: "text", color: "inherit", onClick: handleToggleSummary },
|
|
388
395
|
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.feedObject.content.showMore", defaultMessage: "ui.feedObject.content.showMore" })))));
|
|
389
396
|
}
|
|
390
397
|
else if (template === feedObject_1.SCFeedObjectTemplateType.DETAIL) {
|
|
@@ -397,7 +404,7 @@ function FeedObject(inProps) {
|
|
|
397
404
|
react_1.default.createElement(material_1.Typography, { component: "span", dangerouslySetInnerHTML: {
|
|
398
405
|
__html: summaryHtml
|
|
399
406
|
} }),
|
|
400
|
-
!expanded && summaryHtmlTruncated && (react_1.default.createElement(material_1.Button, { size: "small", variant: "text", color: "inherit", onClick:
|
|
407
|
+
!expanded && summaryHtmlTruncated && (react_1.default.createElement(material_1.Button, { size: "small", variant: "text", color: "inherit", onClick: handleToggleSummary },
|
|
401
408
|
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.feedObject.content.showMore", defaultMessage: "ui.feedObject.content.showMore" })))));
|
|
402
409
|
}
|
|
403
410
|
}, [obj, template, expanded]);
|
|
@@ -59,6 +59,11 @@ export interface FeedObjectProps extends CardProps, VirtualScrollerItemProps {
|
|
|
59
59
|
* @default false
|
|
60
60
|
*/
|
|
61
61
|
hideFollowAction?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Show all summary initially (otherwise it will be truncated)
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
summaryExpanded?: boolean;
|
|
62
67
|
/**
|
|
63
68
|
* Show activities as default
|
|
64
69
|
* @default false
|
|
@@ -131,7 +131,7 @@ export default function FeedObject(inProps) {
|
|
|
131
131
|
props: inProps,
|
|
132
132
|
name: PREFIX
|
|
133
133
|
});
|
|
134
|
-
const { id = `feed_object_${props.feedObjectId ? props.feedObjectId : props.feedObject ? props.feedObject.id : ''}`, className = null, feedObjectId = null, feedObject = null, feedObjectType = SCContributionType.DISCUSSION, feedObjectActivities = null, cacheStrategy = CacheStrategies.CACHE_FIRST, markRead = false, template = SCFeedObjectTemplateType.PREVIEW, hideFollowAction = false, activitiesExpanded = true, activitiesExpandedType, hideParticipantsPreview = false, pollVisible = false, FollowButtonProps = {}, FeedObjectSkeletonProps = { elevation: 0 }, ActionsProps = {}, CommentObjectReplyComponent = CommentObjectReply, CommentObjectReplyComponentProps = { WidgetProps: { variant: 'outlined' } }, CommentComponentProps = { variant: 'outlined' }, CommentObjectSkeletonProps = { elevation: 0, WidgetProps: { variant: 'outlined' } }, ContributionActionsMenuProps = {}, MediasPreviewProps = {}, ActivitiesProps = { cacheStrategy }, PollObjectProps = { elevation: 0 }, ContributorsFeedObjectProps = {}, onReply, onHeightChange, onStateChange } = props, rest = __rest(props, ["id", "className", "feedObjectId", "feedObject", "feedObjectType", "feedObjectActivities", "cacheStrategy", "markRead", "template", "hideFollowAction", "activitiesExpanded", "activitiesExpandedType", "hideParticipantsPreview", "pollVisible", "FollowButtonProps", "FeedObjectSkeletonProps", "ActionsProps", "CommentObjectReplyComponent", "CommentObjectReplyComponentProps", "CommentComponentProps", "CommentObjectSkeletonProps", "ContributionActionsMenuProps", "MediasPreviewProps", "ActivitiesProps", "PollObjectProps", "ContributorsFeedObjectProps", "onReply", "onHeightChange", "onStateChange"]);
|
|
134
|
+
const { id = `feed_object_${props.feedObjectId ? props.feedObjectId : props.feedObject ? props.feedObject.id : ''}`, className = null, feedObjectId = null, feedObject = null, feedObjectType = SCContributionType.DISCUSSION, feedObjectActivities = null, cacheStrategy = CacheStrategies.CACHE_FIRST, markRead = false, template = SCFeedObjectTemplateType.PREVIEW, hideFollowAction = false, summaryExpanded = false, activitiesExpanded = true, activitiesExpandedType, hideParticipantsPreview = false, pollVisible = false, FollowButtonProps = {}, FeedObjectSkeletonProps = { elevation: 0 }, ActionsProps = {}, CommentObjectReplyComponent = CommentObjectReply, CommentObjectReplyComponentProps = { WidgetProps: { variant: 'outlined' } }, CommentComponentProps = { variant: 'outlined' }, CommentObjectSkeletonProps = { elevation: 0, WidgetProps: { variant: 'outlined' } }, ContributionActionsMenuProps = {}, MediasPreviewProps = {}, ActivitiesProps = { cacheStrategy }, PollObjectProps = { elevation: 0 }, ContributorsFeedObjectProps = {}, onReply, onHeightChange, onStateChange } = props, rest = __rest(props, ["id", "className", "feedObjectId", "feedObject", "feedObjectType", "feedObjectActivities", "cacheStrategy", "markRead", "template", "hideFollowAction", "summaryExpanded", "activitiesExpanded", "activitiesExpandedType", "hideParticipantsPreview", "pollVisible", "FollowButtonProps", "FeedObjectSkeletonProps", "ActionsProps", "CommentObjectReplyComponent", "CommentObjectReplyComponentProps", "CommentComponentProps", "CommentObjectSkeletonProps", "ContributionActionsMenuProps", "MediasPreviewProps", "ActivitiesProps", "PollObjectProps", "ContributorsFeedObjectProps", "onReply", "onHeightChange", "onStateChange"]);
|
|
135
135
|
// CONTEXT
|
|
136
136
|
const scContext = useSCContext();
|
|
137
137
|
const scRoutingContext = useSCRouting();
|
|
@@ -153,7 +153,7 @@ export default function FeedObject(inProps) {
|
|
|
153
153
|
const [comments, setComments] = useState([]);
|
|
154
154
|
const [isReplying, setIsReplying] = useState(false);
|
|
155
155
|
const [selectedActivities, setSelectedActivities] = useState(getInitialSelectedActivitiesType());
|
|
156
|
-
const [expanded, setExpanded] = useState(
|
|
156
|
+
const [expanded, setExpanded] = useState(summaryExpanded);
|
|
157
157
|
// INTL
|
|
158
158
|
const intl = useIntl();
|
|
159
159
|
/**
|
|
@@ -205,6 +205,13 @@ export default function FeedObject(inProps) {
|
|
|
205
205
|
const handleTogglePollVisibility = useCallback((visible) => {
|
|
206
206
|
notifyFeedChanges({ pollVisible: visible });
|
|
207
207
|
}, [pollVisible, notifyFeedChanges]);
|
|
208
|
+
/**
|
|
209
|
+
* Handle toggle summary
|
|
210
|
+
*/
|
|
211
|
+
const handleToggleSummary = useCallback(() => {
|
|
212
|
+
setExpanded(!expanded);
|
|
213
|
+
notifyFeedChanges({ summaryExpanded: !expanded });
|
|
214
|
+
}, [expanded, notifyFeedChanges]);
|
|
208
215
|
/**
|
|
209
216
|
* Render header action
|
|
210
217
|
* if author = authenticated user -> render edit action
|
|
@@ -382,7 +389,7 @@ export default function FeedObject(inProps) {
|
|
|
382
389
|
React.createElement(Typography, { component: "div", className: classes.text, variant: "body2", gutterBottom: true, dangerouslySetInnerHTML: {
|
|
383
390
|
__html: summaryHtml
|
|
384
391
|
} })),
|
|
385
|
-
!expanded && summaryHtmlTruncated && (React.createElement(Button, { size: "small", variant: "text", color: "inherit", onClick:
|
|
392
|
+
!expanded && summaryHtmlTruncated && (React.createElement(Button, { size: "small", variant: "text", color: "inherit", onClick: handleToggleSummary },
|
|
386
393
|
React.createElement(FormattedMessage, { id: "ui.feedObject.content.showMore", defaultMessage: "ui.feedObject.content.showMore" })))));
|
|
387
394
|
}
|
|
388
395
|
else if (template === SCFeedObjectTemplateType.DETAIL) {
|
|
@@ -395,7 +402,7 @@ export default function FeedObject(inProps) {
|
|
|
395
402
|
React.createElement(Typography, { component: "span", dangerouslySetInnerHTML: {
|
|
396
403
|
__html: summaryHtml
|
|
397
404
|
} }),
|
|
398
|
-
!expanded && summaryHtmlTruncated && (React.createElement(Button, { size: "small", variant: "text", color: "inherit", onClick:
|
|
405
|
+
!expanded && summaryHtmlTruncated && (React.createElement(Button, { size: "small", variant: "text", color: "inherit", onClick: handleToggleSummary },
|
|
399
406
|
React.createElement(FormattedMessage, { id: "ui.feedObject.content.showMore", defaultMessage: "ui.feedObject.content.showMore" })))));
|
|
400
407
|
}
|
|
401
408
|
}, [obj, template, expanded]);
|