@selfcommunity/react-ui 0.7.50-events.46 → 0.7.50-events.48
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/CreateEventWidget/CreateEventWidget.d.ts +6 -0
- package/lib/cjs/components/CreateEventWidget/CreateEventWidget.js +5 -4
- package/lib/cjs/components/CreateEventWidget/Skeleton.js +1 -1
- package/lib/cjs/components/Event/Event.d.ts +28 -0
- package/lib/cjs/components/Event/Event.js +64 -8
- package/lib/cjs/components/Event/Skeleton.d.ts +9 -3
- package/lib/cjs/components/Event/Skeleton.js +48 -6
- package/lib/cjs/components/EventHeader/EventHeader.js +10 -3
- package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +2 -1
- package/lib/cjs/components/EventInfoWidget/Skeleton.js +1 -1
- package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +8 -3
- package/lib/cjs/components/EventPartecipantsButton/EventPartecipantsButton.js +7 -8
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +3 -2
- package/lib/cjs/components/Events/Events.d.ts +6 -1
- package/lib/cjs/components/Events/Events.js +3 -3
- package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +1 -1
- package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +1 -1
- package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +11 -9
- package/lib/cjs/components/MyEventsWidget/Skeleton.js +6 -3
- package/lib/cjs/components/Notification/Event/Event.d.ts +15 -0
- package/lib/cjs/components/Notification/Event/Event.js +71 -0
- package/lib/cjs/components/Notification/Event/index.d.ts +3 -0
- package/lib/cjs/components/Notification/Event/index.js +5 -0
- package/lib/cjs/components/Notification/Notification.js +26 -0
- package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/cjs/components/SuggestedEventsWidget/Skeleton.d.ts +2 -0
- package/lib/cjs/components/SuggestedEventsWidget/Skeleton.js +28 -0
- package/lib/cjs/components/SuggestedEventsWidget/SuggestedEventsWidget.d.ts +14 -0
- package/lib/cjs/components/SuggestedEventsWidget/SuggestedEventsWidget.js +80 -0
- package/lib/cjs/components/SuggestedEventsWidget/constants.d.ts +1 -0
- package/lib/cjs/components/SuggestedEventsWidget/constants.js +4 -0
- package/lib/cjs/components/SuggestedEventsWidget/index.d.ts +4 -0
- package/lib/cjs/components/SuggestedEventsWidget/index.js +8 -0
- package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/cjs/constants/EventActionsMenu.d.ts +6 -0
- package/lib/cjs/constants/EventActionsMenu.js +9 -0
- package/lib/cjs/constants/Media.d.ts +2 -0
- package/lib/cjs/constants/Media.js +3 -1
- package/lib/cjs/index.d.ts +3 -1
- package/lib/cjs/index.js +9 -4
- package/lib/cjs/shared/Calendar/index.js +1 -1
- package/lib/cjs/shared/EventActionsMenu/index.d.ts +49 -0
- package/lib/cjs/shared/EventActionsMenu/index.js +154 -0
- package/lib/cjs/shared/EventInfoDetails/index.d.ts +12 -0
- package/lib/cjs/shared/EventInfoDetails/index.js +3 -3
- package/lib/cjs/shared/Media/Event/DisplayComponent.d.ts +15 -0
- package/lib/cjs/shared/Media/Event/DisplayComponent.js +31 -0
- package/lib/cjs/shared/Media/Event/constants.d.ts +1 -0
- package/lib/cjs/shared/Media/Event/constants.js +4 -0
- package/lib/cjs/shared/Media/Event/filter.d.ts +3 -0
- package/lib/cjs/shared/Media/Event/filter.js +4 -0
- package/lib/cjs/shared/Media/Event/index.d.ts +3 -0
- package/lib/cjs/shared/Media/Event/index.js +14 -0
- package/lib/cjs/shared/Media/Link/PreviewComponent.js +1 -1
- package/lib/cjs/shared/Media/index.d.ts +2 -1
- package/lib/cjs/shared/Media/index.js +3 -1
- package/lib/cjs/types/event.d.ts +5 -0
- package/lib/cjs/types/event.js +9 -0
- package/lib/esm/components/CreateEventWidget/CreateEventWidget.d.ts +6 -0
- package/lib/esm/components/CreateEventWidget/CreateEventWidget.js +5 -4
- package/lib/esm/components/CreateEventWidget/Skeleton.js +1 -1
- package/lib/esm/components/Event/Event.d.ts +28 -0
- package/lib/esm/components/Event/Event.js +66 -10
- package/lib/esm/components/Event/Skeleton.d.ts +9 -3
- package/lib/esm/components/Event/Skeleton.js +50 -7
- package/lib/esm/components/EventHeader/EventHeader.js +11 -4
- package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +2 -1
- package/lib/esm/components/EventInfoWidget/Skeleton.js +1 -1
- package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +8 -3
- package/lib/esm/components/EventPartecipantsButton/EventPartecipantsButton.js +8 -9
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +3 -2
- package/lib/esm/components/Events/Events.d.ts +6 -1
- package/lib/esm/components/Events/Events.js +3 -3
- package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +1 -1
- package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +2 -2
- package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +13 -11
- package/lib/esm/components/MyEventsWidget/Skeleton.js +7 -4
- package/lib/esm/components/Notification/Event/Event.d.ts +15 -0
- package/lib/esm/components/Notification/Event/Event.js +68 -0
- package/lib/esm/components/Notification/Event/index.d.ts +3 -0
- package/lib/esm/components/Notification/Event/index.js +2 -0
- package/lib/esm/components/Notification/Notification.js +26 -0
- package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/esm/components/SuggestedEventsWidget/Skeleton.d.ts +2 -0
- package/lib/esm/components/SuggestedEventsWidget/Skeleton.js +24 -0
- package/lib/esm/components/SuggestedEventsWidget/SuggestedEventsWidget.d.ts +14 -0
- package/lib/esm/components/SuggestedEventsWidget/SuggestedEventsWidget.js +77 -0
- package/lib/esm/components/SuggestedEventsWidget/constants.d.ts +1 -0
- package/lib/esm/components/SuggestedEventsWidget/constants.js +1 -0
- package/lib/esm/components/SuggestedEventsWidget/index.d.ts +4 -0
- package/lib/esm/components/SuggestedEventsWidget/index.js +4 -0
- package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/esm/constants/EventActionsMenu.d.ts +6 -0
- package/lib/esm/constants/EventActionsMenu.js +6 -0
- package/lib/esm/constants/Media.d.ts +2 -0
- package/lib/esm/constants/Media.js +2 -0
- package/lib/esm/index.d.ts +3 -1
- package/lib/esm/index.js +4 -2
- package/lib/esm/shared/Calendar/index.js +1 -1
- package/lib/esm/shared/EventActionsMenu/index.d.ts +49 -0
- package/lib/esm/shared/EventActionsMenu/index.js +151 -0
- package/lib/esm/shared/EventInfoDetails/index.d.ts +12 -0
- package/lib/esm/shared/EventInfoDetails/index.js +3 -3
- package/lib/esm/shared/Media/Event/DisplayComponent.d.ts +15 -0
- package/lib/esm/shared/Media/Event/DisplayComponent.js +29 -0
- package/lib/esm/shared/Media/Event/constants.d.ts +1 -0
- package/lib/esm/shared/Media/Event/constants.js +1 -0
- package/lib/esm/shared/Media/Event/filter.d.ts +3 -0
- package/lib/esm/shared/Media/Event/filter.js +2 -0
- package/lib/esm/shared/Media/Event/index.d.ts +3 -0
- package/lib/esm/shared/Media/Event/index.js +11 -0
- package/lib/esm/shared/Media/Link/PreviewComponent.js +1 -1
- package/lib/esm/shared/Media/index.d.ts +2 -1
- package/lib/esm/shared/Media/index.js +2 -1
- package/lib/esm/types/event.d.ts +5 -0
- package/lib/esm/types/event.js +6 -0
- package/lib/umd/224.js +2 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
- package/lib/umd/84.js +0 -2
- /package/lib/umd/{84.js.LICENSE.txt → 224.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { Divider, IconButton, List, ListItemIcon, Menu, MenuItem, SwipeableDrawer, useMediaQuery, useTheme } from '@mui/material';
|
|
6
|
+
import { FormattedMessage } from 'react-intl';
|
|
7
|
+
import Icon from '@mui/material/Icon';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { useThemeProps } from '@mui/system';
|
|
10
|
+
import { SCRoutes, useSCFetchEvent, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
11
|
+
import ConfirmDialog from '../../shared/ConfirmDialog/ConfirmDialog';
|
|
12
|
+
import { EventService } from '@selfcommunity/api-services';
|
|
13
|
+
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
14
|
+
import { ADD_EVENT_TO_CALENDAR, CANCEL_EVENT, GET_EVENT_LINK } from '../../constants/EventActionsMenu';
|
|
15
|
+
import { copyTextToClipboard } from '@selfcommunity/utils';
|
|
16
|
+
import { enqueueSnackbar } from 'notistack';
|
|
17
|
+
import HiddenPlaceholder from '../HiddenPlaceholder';
|
|
18
|
+
const PREFIX = 'SCEventActionsMenu';
|
|
19
|
+
const classes = {
|
|
20
|
+
root: `${PREFIX}-root`,
|
|
21
|
+
drawerRoot: `${PREFIX}-drawer-root`,
|
|
22
|
+
menuRoot: `${PREFIX}-menu-root`,
|
|
23
|
+
paper: `${PREFIX}-paper`,
|
|
24
|
+
item: `${PREFIX}-item`
|
|
25
|
+
};
|
|
26
|
+
const Root = styled(IconButton, {
|
|
27
|
+
name: PREFIX,
|
|
28
|
+
slot: 'Root'
|
|
29
|
+
})(() => ({}));
|
|
30
|
+
const SwipeableDrawerRoot = styled(SwipeableDrawer, {
|
|
31
|
+
name: PREFIX,
|
|
32
|
+
slot: 'DrawerRoot'
|
|
33
|
+
})(() => ({}));
|
|
34
|
+
const MenuRoot = styled(Menu, {
|
|
35
|
+
name: PREFIX,
|
|
36
|
+
slot: 'MenuRoot'
|
|
37
|
+
})(() => ({}));
|
|
38
|
+
/**
|
|
39
|
+
* > API documentation for the Community-JS EventActionsMenu component. Learn about the available props and the CSS API.
|
|
40
|
+
|
|
41
|
+
#### Import
|
|
42
|
+
|
|
43
|
+
```jsx
|
|
44
|
+
import {EventActionsMenu} from '@selfcommunity/react-ui';
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Component Name
|
|
48
|
+
|
|
49
|
+
The name `SCEventActionsMenu` can be used when providing style overrides in the theme.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
#### CSS
|
|
53
|
+
|
|
54
|
+
|Rule Name|Global class|Description|
|
|
55
|
+
|---|---|---|
|
|
56
|
+
|root|.SCEventActionsMenu-root|Styles applied to the root element.|
|
|
57
|
+
|drawerRoot|.SCEventActionsMenu-drawer-root|Styles applied to the drawer root element.|
|
|
58
|
+
|menuRoot|.SCEventActionsMenu-menu-root|Styles applied to the menu root element.|
|
|
59
|
+
|paper|.SCEventActionsMenu-paper|Styles applied to the paper element.|
|
|
60
|
+
|item|.SCEventActionsMenu-item|Styles applied to the item element.|
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
* @param inProps
|
|
64
|
+
*/
|
|
65
|
+
export default function EventActionsMenu(inProps) {
|
|
66
|
+
var _a;
|
|
67
|
+
// PROPS
|
|
68
|
+
const props = useThemeProps({
|
|
69
|
+
props: inProps,
|
|
70
|
+
name: PREFIX
|
|
71
|
+
});
|
|
72
|
+
const { className, event, eventId } = props, rest = __rest(props, ["className", "event", "eventId"]);
|
|
73
|
+
// STATE
|
|
74
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
75
|
+
const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
|
|
76
|
+
// HOOKS
|
|
77
|
+
const theme = useTheme();
|
|
78
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
79
|
+
const scRoutingContext = useSCRouting();
|
|
80
|
+
const scUserContext = useSCUser();
|
|
81
|
+
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
82
|
+
const isEventAdmin = useMemo(() => { var _a; return scUserContext.user && ((_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
83
|
+
// HANDLERS
|
|
84
|
+
const handleOpen = (event) => {
|
|
85
|
+
setAnchorEl(event.currentTarget);
|
|
86
|
+
};
|
|
87
|
+
const handleClose = () => {
|
|
88
|
+
setAnchorEl(null);
|
|
89
|
+
};
|
|
90
|
+
const handleCloseDialog = () => {
|
|
91
|
+
setOpenConfirmDialog(false);
|
|
92
|
+
setAnchorEl(null);
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Handles thread deletion
|
|
96
|
+
*/
|
|
97
|
+
function handleDeleteThread() {
|
|
98
|
+
EventService.deleteEvent(scEvent.id)
|
|
99
|
+
.then(() => {
|
|
100
|
+
handleCloseDialog();
|
|
101
|
+
})
|
|
102
|
+
.catch((error) => {
|
|
103
|
+
setOpenConfirmDialog(false);
|
|
104
|
+
console.log(error);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const createGoogleCalendarLink = (event) => {
|
|
108
|
+
const baseUrl = 'https://www.google.com/calendar/render?action=TEMPLATE';
|
|
109
|
+
return `${baseUrl}&text=${encodeURIComponent(event.name)}&details=${encodeURIComponent(event.description)}&location=${encodeURIComponent(event.geolocation)}&dates=${event.start_date}/${event.end_date}`;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Handles actions
|
|
113
|
+
*/
|
|
114
|
+
function handleAction(action) {
|
|
115
|
+
if (action === GET_EVENT_LINK) {
|
|
116
|
+
copyTextToClipboard(`${location.protocol}//${location.host}${scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent)}`).then(() => {
|
|
117
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.common.permanentLinkCopied", defaultMessage: "ui.common.permanentLinkCopied" }), {
|
|
118
|
+
variant: 'success',
|
|
119
|
+
autoHideDuration: 3000
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
handleClose();
|
|
123
|
+
}
|
|
124
|
+
else if (action === ADD_EVENT_TO_CALENDAR) {
|
|
125
|
+
window.open(createGoogleCalendarLink(scEvent), '_blank', 'noopener,noreferrer');
|
|
126
|
+
handleClose();
|
|
127
|
+
}
|
|
128
|
+
else if (action === CANCEL_EVENT) {
|
|
129
|
+
setOpenConfirmDialog(true);
|
|
130
|
+
handleClose();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
*
|
|
135
|
+
*/
|
|
136
|
+
const renderList = () => {
|
|
137
|
+
return [
|
|
138
|
+
_jsxs(MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(GET_EVENT_LINK) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "link" }) }), _jsx(FormattedMessage, { id: "ui.shared.eventActionsMenu.item.link", defaultMessage: "ui.shared.eventActionsMenu.item.link" })] }), "link"),
|
|
139
|
+
_jsxs(MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(ADD_EVENT_TO_CALENDAR) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "CalendarIcon" }) }), _jsx(FormattedMessage, { id: "ui.shared.eventActionsMenu.item.calendar", defaultMessage: "ui.shared.eventActionsMenu.item.calendar" })] }), "calendar"),
|
|
140
|
+
isEventAdmin && [
|
|
141
|
+
_jsx(Divider, {}, "divider"),
|
|
142
|
+
_jsxs(MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(CANCEL_EVENT) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "close" }) }), _jsx(FormattedMessage, { id: "ui.shared.eventActionsMenu.item.cancel", defaultMessage: "ui.shared.eventActionsMenu.item.cancel" })] }), "cancel")
|
|
143
|
+
]
|
|
144
|
+
];
|
|
145
|
+
};
|
|
146
|
+
if (!scUserContext.user ||
|
|
147
|
+
((scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === SCEventPrivacyType.PRIVATE && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) !== SCEventSubscriptionStatusType.SUBSCRIBED)) {
|
|
148
|
+
return _jsx(HiddenPlaceholder, {});
|
|
149
|
+
}
|
|
150
|
+
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { onClick: handleOpen }, { children: _jsx(Icon, { children: "more_vert" }) })), isMobile ? (_jsx(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, anchor: "bottom", open: Boolean(anchorEl), onClose: handleClose, onOpen: handleOpen, PaperProps: { className: classes.paper }, disableSwipeToOpen: true }, { children: _jsx(List, { children: renderList() }) }))) : (_jsx(MenuRoot, Object.assign({ className: classes.menuRoot, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, PaperProps: { className: classes.paper } }, { children: renderList() }))), openConfirmDialog && (_jsx(ConfirmDialog, { open: openConfirmDialog, title: _jsx(FormattedMessage, { id: "ui.shared.eventActionsMenu.dialog.msg", defaultMessage: "ui.shared.eventActionsMenu.dialog.msg" }), btnConfirm: _jsx(FormattedMessage, { id: "ui.shared.eventActionsMenu.dialog.confirm", defaultMessage: "ui.shared.eventActionsMenu.dialog.confirm" }), onConfirm: handleDeleteThread, onClose: handleCloseDialog }))] }));
|
|
151
|
+
}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { SCEventType } from '@selfcommunity/types';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
export interface EventInfoDetailsProps {
|
|
3
4
|
event: SCEventType;
|
|
5
|
+
hideDateIcon?: boolean;
|
|
6
|
+
hidePrivacyIcon?: boolean;
|
|
7
|
+
hideLocationIcon?: boolean;
|
|
8
|
+
hideCreatedIcon?: boolean;
|
|
9
|
+
hasDateInfo?: boolean;
|
|
10
|
+
hasPrivacyInfo?: boolean;
|
|
11
|
+
hasLocationInfo?: boolean;
|
|
4
12
|
hasCreatedInfo?: boolean;
|
|
13
|
+
beforeDateInfo?: React.ReactNode | null;
|
|
14
|
+
beforePrivacyInfo?: React.ReactNode | null;
|
|
15
|
+
beforeLocationInfo?: React.ReactNode | null;
|
|
16
|
+
beforeCreatedInfo?: React.ReactNode | null;
|
|
5
17
|
}
|
|
6
18
|
export default function EventInfoDetails(inProps: EventInfoDetailsProps): JSX.Element;
|
|
@@ -21,14 +21,14 @@ const Root = styled(Stack, {
|
|
|
21
21
|
name: PREFIX,
|
|
22
22
|
slot: 'Root',
|
|
23
23
|
overridesResolver: (_props, styles) => styles.root
|
|
24
|
-
})();
|
|
24
|
+
})(() => ({}));
|
|
25
25
|
export default function EventInfoDetails(inProps) {
|
|
26
26
|
// PROPS
|
|
27
27
|
const props = useThemeProps({
|
|
28
28
|
props: inProps,
|
|
29
29
|
name: PREFIX
|
|
30
30
|
});
|
|
31
|
-
const { event, hasCreatedInfo } = props;
|
|
31
|
+
const { event, hideDateIcon = false, hidePrivacyIcon = false, hideLocationIcon = false, hideCreatedIcon = false, hasDateInfo = true, hasPrivacyInfo = true, hasLocationInfo = true, hasCreatedInfo = false, beforeDateInfo, beforePrivacyInfo, beforeLocationInfo, beforeCreatedInfo } = props;
|
|
32
32
|
// HOOKS
|
|
33
33
|
const intl = useIntl();
|
|
34
34
|
const privacy = event.privacy === SCEventPrivacyType.PUBLIC ? 'ui.eventInfoDetails.privacy.public' : 'ui.eventInfoDetails.privacy.private';
|
|
@@ -43,5 +43,5 @@ export default function EventInfoDetails(inProps) {
|
|
|
43
43
|
locale: LOCALE_MAP[intl.locale]
|
|
44
44
|
}).replace(/Creato il (\d{1})+ ([a-z]+) (\d{4})/, (_, day, month, year) => `Creato il ${day} ${month.charAt(0).toUpperCase() + month.slice(1)} ${year}`);
|
|
45
45
|
};
|
|
46
|
-
return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "CalendarIcon" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: formatDateEventDate(event.start_date) }))] })), _jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.privacy === SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: location, defaultMessage: location }) }))] })), _jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.location === SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' })), event.location === SCEventLocationType.ONLINE ? (_jsx(Link, Object.assign({ to: event.link, target: "_blank", className: classes.link }, { children: _jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.link })) }))) : (_jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.geolocation })))] })), hasCreatedInfo && (_jsxs(Stack, Object.assign({ className: classes.creationWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "create" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: formatDateCreateDate(event.created_at) }))] })))] })));
|
|
46
|
+
return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [beforeDateInfo, hasDateInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideDateIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "CalendarIcon" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: formatDateEventDate(event.start_date) }))] }))), beforePrivacyInfo, hasPrivacyInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.privacy === SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && (_jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.location === SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), event.location === SCEventLocationType.ONLINE ? (_jsx(Link, Object.assign({ to: event.link, target: "_blank", className: classes.link }, { children: _jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.link })) }))) : (_jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && (_jsxs(Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "create" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: formatDateCreateDate(event.created_at) }))] })))] })));
|
|
47
47
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { SCMediaType } from '@selfcommunity/types/src/types';
|
|
3
|
+
import { BoxProps } from '@mui/material';
|
|
4
|
+
export interface DisplayComponentProps extends BoxProps {
|
|
5
|
+
/**
|
|
6
|
+
* Medias
|
|
7
|
+
*/
|
|
8
|
+
medias: SCMediaType[];
|
|
9
|
+
/**
|
|
10
|
+
* Handles on media click
|
|
11
|
+
*/
|
|
12
|
+
onMediaClick?: (any: any) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: ({ className, medias, onMediaClick, ...rest }: DisplayComponentProps) => ReactElement;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import Box from '@mui/material/Box';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import filter from './filter';
|
|
8
|
+
import Event from '../../../components/Event';
|
|
9
|
+
import { SCEventTemplateType } from '../../../types/event';
|
|
10
|
+
import { PREFIX } from './constants';
|
|
11
|
+
const classes = {
|
|
12
|
+
displayRoot: `${PREFIX}-display-root`,
|
|
13
|
+
eventPreview: `${PREFIX}-event-preview`,
|
|
14
|
+
eventPlaceholder: `${PREFIX}-event-placeholder`
|
|
15
|
+
};
|
|
16
|
+
const Root = styled(Box, {
|
|
17
|
+
name: PREFIX,
|
|
18
|
+
slot: 'DisplayRoot'
|
|
19
|
+
})(({ theme }) => ({}));
|
|
20
|
+
export default (_a) => {
|
|
21
|
+
var { className, medias = [], onMediaClick = null } = _a, rest = __rest(_a, ["className", "medias", "onMediaClick"]);
|
|
22
|
+
// MEMO
|
|
23
|
+
const _medias = useMemo(() => medias.filter(filter), [medias]);
|
|
24
|
+
if (_medias.length === 0) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
console.log(medias);
|
|
28
|
+
return (_jsx(Root, Object.assign({ className: classNames(className, classes.displayRoot) }, rest, { children: _medias.map((media, i) => (_jsx(Box, Object.assign({ className: classes.eventPreview, onClick: onMediaClick }, { children: _jsx(Event, { event: media.embed.metadata, template: SCEventTemplateType.DETAIL, variant: "outlined", square: true, hideEventParticipants: true, hideEventPlanner: true, actions: _jsx(_Fragment, {}) }) }), i))) })));
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCMediaEvent";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PREFIX = 'SCMediaEvent';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DisplayComponent from './DisplayComponent';
|
|
2
|
+
import filter from './filter';
|
|
3
|
+
const Event = {
|
|
4
|
+
name: 'event',
|
|
5
|
+
displayComponent: DisplayComponent,
|
|
6
|
+
triggerButton: null,
|
|
7
|
+
layerComponent: null,
|
|
8
|
+
previewComponent: null,
|
|
9
|
+
filter
|
|
10
|
+
};
|
|
11
|
+
export default Event;
|
|
@@ -30,6 +30,6 @@ const PreviewComponent = React.forwardRef((props, ref) => {
|
|
|
30
30
|
onChange && onChange([...value.filter((media) => medias.findIndex((m) => m.id === media.id) === -1), ...medias]);
|
|
31
31
|
}, [onChange, value]);
|
|
32
32
|
const handleDelete = useCallback((id) => () => onChange && onChange(value.filter((media) => media.id !== id)), [onChange, value]);
|
|
33
|
-
return _jsx(Root, Object.assign({ ref: ref, className: classNames(className, classes.previewRoot) }, rest, { children: medias.length > 0 && (_jsx(ReactSortable, Object.assign({ list: medias, setList: handleSort }, { children: medias.map((media) => (_jsxs(Box, Object.assign({ className: classNames(classes.media, { [classes.video]: media.embed.metadata && media.embed.metadata.type === MEDIA_TYPE_VIDEO }) }, { children: [_jsx(DisplayComponent, { medias: [media] }), _jsx(IconButton, Object.assign({ className: classes.delete, onClick: handleDelete(media.id), size: "small" }, { children: _jsx(Icon, { children: "delete" }) }))] }), media.id))) }))) }));
|
|
33
|
+
return (_jsx(Root, Object.assign({ ref: ref, className: classNames(className, classes.previewRoot) }, rest, { children: medias.length > 0 && (_jsx(ReactSortable, Object.assign({ list: medias, setList: handleSort }, { children: medias.map((media) => (_jsxs(Box, Object.assign({ className: classNames(classes.media, { [classes.video]: media.embed.metadata && media.embed.metadata.type === MEDIA_TYPE_VIDEO }) }, { children: [_jsx(DisplayComponent, { medias: [media] }), _jsx(IconButton, Object.assign({ className: classes.delete, onClick: handleDelete(media.id), size: "small" }, { children: _jsx(Icon, { children: "delete" }) }))] }), media.id))) }))) })));
|
|
34
34
|
});
|
|
35
35
|
export default PreviewComponent;
|