@selfcommunity/react-templates 0.4.0-live.81 → 0.4.0-live.85
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/cjs/components/Event/Event.js +6 -1
- package/lib/cjs/components/EventFeed/EventFeed.js +8 -6
- package/lib/cjs/components/FeedObjectDetail/FeedObjectDetail.js +1 -1
- package/lib/esm/components/Event/Event.js +7 -2
- package/lib/esm/components/EventFeed/EventFeed.js +8 -6
- package/lib/esm/components/FeedObjectDetail/FeedObjectDetail.js +1 -1
- package/lib/umd/2aa155858f48b8f3911a.eot +0 -0
- package/lib/umd/36f3af7f155d916c26ff.woff2 +0 -0
- package/lib/umd/{903.js → 665.js} +2 -2
- package/lib/umd/a221d3aba0f6753cfbb7.ttf +0 -0
- package/lib/umd/c3528e120c4e831db2ae.woff +0 -0
- package/lib/umd/e0b2b8a5f2f737384ae5.svg +251 -0
- package/lib/umd/react-templates.js +1 -1
- package/package.json +6 -6
- /package/lib/umd/{903.js.LICENSE.txt → 665.js.LICENSE.txt} +0 -0
|
@@ -6,6 +6,7 @@ const styles_1 = require("@mui/material/styles");
|
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_ui_1 = require("@selfcommunity/react-ui");
|
|
8
8
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
9
|
+
const types_1 = require("@selfcommunity/types");
|
|
9
10
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
10
11
|
const system_1 = require("@mui/system");
|
|
11
12
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
@@ -54,7 +55,11 @@ function Event(inProps) {
|
|
|
54
55
|
const { id = 'event', className, event, eventId, widgets, FeedObjectProps, FeedSidebarProps, EventFeedProps = {}, EventHeaderProps = {} } = props;
|
|
55
56
|
// HOOKS
|
|
56
57
|
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
57
|
-
|
|
58
|
+
const scUserContext = (0, react_core_1.useSCUser)();
|
|
59
|
+
if (scUserContext.user === undefined ||
|
|
60
|
+
!scEvent ||
|
|
61
|
+
(scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
62
|
+
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED) {
|
|
58
63
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
59
64
|
}
|
|
60
65
|
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.EventHeader, Object.assign({ event: scEvent }, EventHeaderProps)), (0, jsx_runtime_1.jsx)(EventFeed_1.default, Object.assign({ className: classes.feed, event: scEvent, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, EventFeedProps))] })));
|
|
@@ -91,12 +91,12 @@ function EventFeed(inProps) {
|
|
|
91
91
|
// REF
|
|
92
92
|
const feedRef = (0, react_1.useRef)();
|
|
93
93
|
// Hooks
|
|
94
|
-
const { scEvent
|
|
94
|
+
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
95
95
|
// HANDLERS
|
|
96
96
|
const handleComposerSuccess = (feedObject) => {
|
|
97
97
|
var _a;
|
|
98
98
|
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.success", defaultMessage: "ui.composerIconButton.composer.success" }), {
|
|
99
|
-
action: (
|
|
99
|
+
action: () => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], react_ui_1.ContributionUtils.getRouteData(feedObject)) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
100
100
|
variant: 'success',
|
|
101
101
|
autoHideDuration: 7000
|
|
102
102
|
});
|
|
@@ -114,16 +114,19 @@ function EventFeed(inProps) {
|
|
|
114
114
|
// WIDGETS
|
|
115
115
|
const _widgets = (0, react_1.useMemo)(() => widgets.map((w) => {
|
|
116
116
|
if (scEvent) {
|
|
117
|
-
return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), {
|
|
117
|
+
return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), { event: scEvent }) });
|
|
118
118
|
}
|
|
119
119
|
return w;
|
|
120
120
|
}), [widgets, scEvent]);
|
|
121
|
-
if (
|
|
121
|
+
if (scUserContext.user === undefined ||
|
|
122
|
+
!scEvent ||
|
|
123
|
+
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED ||
|
|
124
|
+
(scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
125
|
+
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
|
|
122
126
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
123
127
|
}
|
|
124
128
|
else if (scEvent.privacy === types_1.SCEventPrivacyType.PRIVATE &&
|
|
125
129
|
scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.SUBSCRIBED &&
|
|
126
|
-
scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.INVITED &&
|
|
127
130
|
scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.GOING &&
|
|
128
131
|
scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.NOT_GOING) {
|
|
129
132
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.EventInfoWidget, { className: classes.root, event: scEvent }) })));
|
|
@@ -142,7 +145,6 @@ function EventFeed(inProps) {
|
|
|
142
145
|
((!scUserContext.user && scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC) ||
|
|
143
146
|
(scUserContext.user &&
|
|
144
147
|
(scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.SUBSCRIBED ||
|
|
145
|
-
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED ||
|
|
146
148
|
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.GOING ||
|
|
147
149
|
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.NOT_GOING)))) && ((0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { event: scEvent }, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "templates.eventFeed.composer.label", defaultMessage: "templates.eventFeed.composer.label" }), feedType: types_1.SCFeedTypologyType.EVENT }))] }), CustomAdvProps: { position: types_1.SCCustomAdvPosition.POSITION_FEED, groupsId: [scEvent.id] }, enabledCustomAdvPositions: [
|
|
148
150
|
types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
@@ -97,6 +97,6 @@ function FeedObjectDetail(inProps) {
|
|
|
97
97
|
if (!obj) {
|
|
98
98
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
99
99
|
}
|
|
100
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, Object.assign({ container: true, spacing: 2 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.FeedObject, Object.assign({}, FeedObjectProps, { feedObject: obj, template: react_ui_1.SCFeedObjectTemplateType.DETAIL, onReply: handleReply })), renderAdvertising(), (0, jsx_runtime_1.jsx)(react_ui_1.CommentsFeedObject, Object.assign({ showTitle: true, feedObject: obj, comments: comments }, CommentsFeedObjectProps), `comments_${obj.id}`)] })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: (0, jsx_runtime_1.jsx)(material_1.Hidden, Object.assign({ mdDown: true }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.StickyBox, Object.assign({}, FeedSidebarProps, { children: (0, jsx_runtime_1.jsx)(react_ui_1.RelatedFeedObjectsWidget, Object.assign({ feedObject: obj }, RelatedFeedObjectProps), `related_${obj.id}`) })) })) }))] })) })));
|
|
100
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, Object.assign({ container: true, spacing: 2 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.FeedObject, Object.assign({}, FeedObjectProps, { feedObject: obj, template: react_ui_1.SCFeedObjectTemplateType.DETAIL, onReply: handleReply })), renderAdvertising(), (0, jsx_runtime_1.jsx)(react_ui_1.CommentsFeedObject, Object.assign({ showTitle: true, feedObject: obj, comments: comments }, CommentsFeedObjectProps), `comments_${obj.id}`)] })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: (0, jsx_runtime_1.jsx)(material_1.Hidden, Object.assign({ mdDown: true }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.StickyBox, Object.assign({}, FeedSidebarProps, { children: (0, jsx_runtime_1.jsx)(react_ui_1.RelatedFeedObjectsWidget, Object.assign({ feedObject: obj, feedObjectId: obj.id }, RelatedFeedObjectProps), `related_${obj.id}`) })) })) }))] })) })));
|
|
101
101
|
}
|
|
102
102
|
exports.default = FeedObjectDetail;
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
import { EventHeader } from '@selfcommunity/react-ui';
|
|
5
|
-
import { useSCFetchEvent } from '@selfcommunity/react-core';
|
|
5
|
+
import { useSCFetchEvent, useSCUser } from '@selfcommunity/react-core';
|
|
6
|
+
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
6
7
|
import EventSkeletonTemplate from './Skeleton';
|
|
7
8
|
import { useThemeProps } from '@mui/system';
|
|
8
9
|
import classNames from 'classnames';
|
|
@@ -51,7 +52,11 @@ export default function Event(inProps) {
|
|
|
51
52
|
const { id = 'event', className, event, eventId, widgets, FeedObjectProps, FeedSidebarProps, EventFeedProps = {}, EventHeaderProps = {} } = props;
|
|
52
53
|
// HOOKS
|
|
53
54
|
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
54
|
-
|
|
55
|
+
const scUserContext = useSCUser();
|
|
56
|
+
if (scUserContext.user === undefined ||
|
|
57
|
+
!scEvent ||
|
|
58
|
+
(scEvent.privacy === SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
59
|
+
scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED) {
|
|
55
60
|
return _jsx(EventSkeletonTemplate, {});
|
|
56
61
|
}
|
|
57
62
|
return (_jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: [_jsx(EventHeader, Object.assign({ event: scEvent }, EventHeaderProps)), _jsx(EventFeed, Object.assign({ className: classes.feed, event: scEvent, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, EventFeedProps))] })));
|
|
@@ -88,12 +88,12 @@ export default function EventFeed(inProps) {
|
|
|
88
88
|
// REF
|
|
89
89
|
const feedRef = useRef();
|
|
90
90
|
// Hooks
|
|
91
|
-
const { scEvent
|
|
91
|
+
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
92
92
|
// HANDLERS
|
|
93
93
|
const handleComposerSuccess = (feedObject) => {
|
|
94
94
|
var _a;
|
|
95
95
|
enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.composerIconButton.composer.success", defaultMessage: "ui.composerIconButton.composer.success" }), {
|
|
96
|
-
action: (
|
|
96
|
+
action: () => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], ContributionUtils.getRouteData(feedObject)) }, { children: _jsx(FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
97
97
|
variant: 'success',
|
|
98
98
|
autoHideDuration: 7000
|
|
99
99
|
});
|
|
@@ -111,16 +111,19 @@ export default function EventFeed(inProps) {
|
|
|
111
111
|
// WIDGETS
|
|
112
112
|
const _widgets = useMemo(() => widgets.map((w) => {
|
|
113
113
|
if (scEvent) {
|
|
114
|
-
return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), {
|
|
114
|
+
return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), { event: scEvent }) });
|
|
115
115
|
}
|
|
116
116
|
return w;
|
|
117
117
|
}), [widgets, scEvent]);
|
|
118
|
-
if (
|
|
118
|
+
if (scUserContext.user === undefined ||
|
|
119
|
+
!scEvent ||
|
|
120
|
+
scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED ||
|
|
121
|
+
(scEvent.privacy === SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
122
|
+
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
|
|
119
123
|
return _jsx(EventFeedSkeleton, {});
|
|
120
124
|
}
|
|
121
125
|
else if (scEvent.privacy === SCEventPrivacyType.PRIVATE &&
|
|
122
126
|
scEvent.subscription_status !== SCEventSubscriptionStatusType.SUBSCRIBED &&
|
|
123
|
-
scEvent.subscription_status !== SCEventSubscriptionStatusType.INVITED &&
|
|
124
127
|
scEvent.subscription_status !== SCEventSubscriptionStatusType.GOING &&
|
|
125
128
|
scEvent.subscription_status !== SCEventSubscriptionStatusType.NOT_GOING) {
|
|
126
129
|
return (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(EventInfoWidget, { className: classes.root, event: scEvent }) })));
|
|
@@ -139,7 +142,6 @@ export default function EventFeed(inProps) {
|
|
|
139
142
|
((!scUserContext.user && scEvent.privacy === SCEventPrivacyType.PUBLIC) ||
|
|
140
143
|
(scUserContext.user &&
|
|
141
144
|
(scEvent.subscription_status === SCEventSubscriptionStatusType.SUBSCRIBED ||
|
|
142
|
-
scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED ||
|
|
143
145
|
scEvent.subscription_status === SCEventSubscriptionStatusType.GOING ||
|
|
144
146
|
scEvent.subscription_status === SCEventSubscriptionStatusType.NOT_GOING)))) && (_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { event: scEvent }, label: _jsx(FormattedMessage, { id: "templates.eventFeed.composer.label", defaultMessage: "templates.eventFeed.composer.label" }), feedType: SCFeedTypologyType.EVENT }))] }), CustomAdvProps: { position: SCCustomAdvPosition.POSITION_FEED, groupsId: [scEvent.id] }, enabledCustomAdvPositions: [
|
|
145
147
|
SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
@@ -94,5 +94,5 @@ export default function FeedObjectDetail(inProps) {
|
|
|
94
94
|
if (!obj) {
|
|
95
95
|
return _jsx(FeedObjectDetailSkeleton, {});
|
|
96
96
|
}
|
|
97
|
-
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsxs(Grid, Object.assign({ container: true, spacing: 2 }, { children: [_jsxs(Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: [_jsx(FeedObject, Object.assign({}, FeedObjectProps, { feedObject: obj, template: SCFeedObjectTemplateType.DETAIL, onReply: handleReply })), renderAdvertising(), _jsx(CommentsFeedObject, Object.assign({ showTitle: true, feedObject: obj, comments: comments }, CommentsFeedObjectProps), `comments_${obj.id}`)] })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: _jsx(Hidden, Object.assign({ mdDown: true }, { children: _jsx(StickyBox, Object.assign({}, FeedSidebarProps, { children: _jsx(RelatedFeedObjectsWidget, Object.assign({ feedObject: obj }, RelatedFeedObjectProps), `related_${obj.id}`) })) })) }))] })) })));
|
|
97
|
+
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsxs(Grid, Object.assign({ container: true, spacing: 2 }, { children: [_jsxs(Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: [_jsx(FeedObject, Object.assign({}, FeedObjectProps, { feedObject: obj, template: SCFeedObjectTemplateType.DETAIL, onReply: handleReply })), renderAdvertising(), _jsx(CommentsFeedObject, Object.assign({ showTitle: true, feedObject: obj, comments: comments }, CommentsFeedObjectProps), `comments_${obj.id}`)] })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: _jsx(Hidden, Object.assign({ mdDown: true }, { children: _jsx(StickyBox, Object.assign({}, FeedSidebarProps, { children: _jsx(RelatedFeedObjectsWidget, Object.assign({ feedObject: obj, feedObjectId: obj.id }, RelatedFeedObjectProps), `related_${obj.id}`) })) })) }))] })) })));
|
|
98
98
|
}
|
|
Binary file
|
|
Binary file
|