@selfcommunity/react-ui 0.7.50-events.44 → 0.7.50-events.47

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.
Files changed (133) hide show
  1. package/lib/cjs/components/CreateEventButton/CreateEventButton.js +6 -4
  2. package/lib/cjs/components/CreateEventWidget/CreateEventWidget.d.ts +14 -0
  3. package/lib/cjs/components/CreateEventWidget/CreateEventWidget.js +63 -0
  4. package/lib/cjs/components/CreateEventWidget/Skeleton.d.ts +1 -0
  5. package/lib/cjs/components/CreateEventWidget/Skeleton.js +25 -0
  6. package/lib/cjs/components/CreateEventWidget/constants.d.ts +1 -0
  7. package/lib/cjs/components/CreateEventWidget/constants.js +4 -0
  8. package/lib/cjs/components/CreateEventWidget/index.d.ts +4 -0
  9. package/lib/cjs/components/CreateEventWidget/index.js +8 -0
  10. package/lib/cjs/components/Event/Event.d.ts +28 -0
  11. package/lib/cjs/components/Event/Event.js +64 -8
  12. package/lib/cjs/components/Event/Skeleton.d.ts +9 -3
  13. package/lib/cjs/components/Event/Skeleton.js +48 -6
  14. package/lib/cjs/components/EventHeader/EventHeader.js +10 -3
  15. package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +2 -1
  16. package/lib/cjs/components/EventInfoWidget/Skeleton.js +1 -1
  17. package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +8 -3
  18. package/lib/cjs/components/EventPartecipantsButton/EventPartecipantsButton.js +7 -8
  19. package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +3 -2
  20. package/lib/cjs/components/Events/Events.d.ts +6 -1
  21. package/lib/cjs/components/Events/Events.js +3 -3
  22. package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +1 -1
  23. package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +1 -1
  24. package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +19 -10
  25. package/lib/cjs/components/MyEventsWidget/Skeleton.js +6 -26
  26. package/lib/cjs/components/Notification/Event/Event.d.ts +15 -0
  27. package/lib/cjs/components/Notification/Event/Event.js +71 -0
  28. package/lib/cjs/components/Notification/Event/index.d.ts +3 -0
  29. package/lib/cjs/components/Notification/Event/index.js +5 -0
  30. package/lib/cjs/components/Notification/Notification.js +26 -0
  31. package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
  32. package/lib/cjs/components/SuggestedEventsWidget/Skeleton.d.ts +2 -0
  33. package/lib/cjs/components/SuggestedEventsWidget/Skeleton.js +28 -0
  34. package/lib/cjs/components/SuggestedEventsWidget/SuggestedEventsWidget.d.ts +14 -0
  35. package/lib/cjs/components/SuggestedEventsWidget/SuggestedEventsWidget.js +80 -0
  36. package/lib/cjs/components/SuggestedEventsWidget/constants.d.ts +1 -0
  37. package/lib/cjs/components/SuggestedEventsWidget/constants.js +4 -0
  38. package/lib/cjs/components/SuggestedEventsWidget/index.d.ts +4 -0
  39. package/lib/cjs/components/SuggestedEventsWidget/index.js +8 -0
  40. package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
  41. package/lib/cjs/constants/EventActionsMenu.d.ts +6 -0
  42. package/lib/cjs/constants/EventActionsMenu.js +9 -0
  43. package/lib/cjs/constants/Media.d.ts +2 -0
  44. package/lib/cjs/constants/Media.js +3 -1
  45. package/lib/cjs/index.d.ts +4 -1
  46. package/lib/cjs/index.js +12 -4
  47. package/lib/cjs/shared/Calendar/index.js +1 -1
  48. package/lib/cjs/shared/EventActionsMenu/index.d.ts +49 -0
  49. package/lib/cjs/shared/EventActionsMenu/index.js +154 -0
  50. package/lib/cjs/shared/EventInfoDetails/index.d.ts +12 -0
  51. package/lib/cjs/shared/EventInfoDetails/index.js +3 -3
  52. package/lib/cjs/shared/Media/Event/DisplayComponent.d.ts +15 -0
  53. package/lib/cjs/shared/Media/Event/DisplayComponent.js +31 -0
  54. package/lib/cjs/shared/Media/Event/constants.d.ts +1 -0
  55. package/lib/cjs/shared/Media/Event/constants.js +4 -0
  56. package/lib/cjs/shared/Media/Event/filter.d.ts +3 -0
  57. package/lib/cjs/shared/Media/Event/filter.js +4 -0
  58. package/lib/cjs/shared/Media/Event/index.d.ts +3 -0
  59. package/lib/cjs/shared/Media/Event/index.js +14 -0
  60. package/lib/cjs/shared/Media/Link/PreviewComponent.js +1 -1
  61. package/lib/cjs/shared/Media/index.d.ts +2 -1
  62. package/lib/cjs/shared/Media/index.js +3 -1
  63. package/lib/cjs/types/event.d.ts +5 -0
  64. package/lib/cjs/types/event.js +9 -0
  65. package/lib/esm/components/CreateEventButton/CreateEventButton.js +6 -4
  66. package/lib/esm/components/CreateEventWidget/CreateEventWidget.d.ts +14 -0
  67. package/lib/esm/components/CreateEventWidget/CreateEventWidget.js +60 -0
  68. package/lib/esm/components/CreateEventWidget/Skeleton.d.ts +1 -0
  69. package/lib/esm/components/CreateEventWidget/Skeleton.js +21 -0
  70. package/lib/esm/components/CreateEventWidget/constants.d.ts +1 -0
  71. package/lib/esm/components/CreateEventWidget/constants.js +1 -0
  72. package/lib/esm/components/CreateEventWidget/index.d.ts +4 -0
  73. package/lib/esm/components/CreateEventWidget/index.js +4 -0
  74. package/lib/esm/components/Event/Event.d.ts +28 -0
  75. package/lib/esm/components/Event/Event.js +66 -10
  76. package/lib/esm/components/Event/Skeleton.d.ts +9 -3
  77. package/lib/esm/components/Event/Skeleton.js +50 -7
  78. package/lib/esm/components/EventHeader/EventHeader.js +11 -4
  79. package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +2 -1
  80. package/lib/esm/components/EventInfoWidget/Skeleton.js +1 -1
  81. package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +8 -3
  82. package/lib/esm/components/EventPartecipantsButton/EventPartecipantsButton.js +8 -9
  83. package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +3 -2
  84. package/lib/esm/components/Events/Events.d.ts +6 -1
  85. package/lib/esm/components/Events/Events.js +3 -3
  86. package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +1 -1
  87. package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +2 -2
  88. package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +23 -14
  89. package/lib/esm/components/MyEventsWidget/Skeleton.js +7 -27
  90. package/lib/esm/components/Notification/Event/Event.d.ts +15 -0
  91. package/lib/esm/components/Notification/Event/Event.js +68 -0
  92. package/lib/esm/components/Notification/Event/index.d.ts +3 -0
  93. package/lib/esm/components/Notification/Event/index.js +2 -0
  94. package/lib/esm/components/Notification/Notification.js +26 -0
  95. package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
  96. package/lib/esm/components/SuggestedEventsWidget/Skeleton.d.ts +2 -0
  97. package/lib/esm/components/SuggestedEventsWidget/Skeleton.js +24 -0
  98. package/lib/esm/components/SuggestedEventsWidget/SuggestedEventsWidget.d.ts +14 -0
  99. package/lib/esm/components/SuggestedEventsWidget/SuggestedEventsWidget.js +77 -0
  100. package/lib/esm/components/SuggestedEventsWidget/constants.d.ts +1 -0
  101. package/lib/esm/components/SuggestedEventsWidget/constants.js +1 -0
  102. package/lib/esm/components/SuggestedEventsWidget/index.d.ts +4 -0
  103. package/lib/esm/components/SuggestedEventsWidget/index.js +4 -0
  104. package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
  105. package/lib/esm/constants/EventActionsMenu.d.ts +6 -0
  106. package/lib/esm/constants/EventActionsMenu.js +6 -0
  107. package/lib/esm/constants/Media.d.ts +2 -0
  108. package/lib/esm/constants/Media.js +2 -0
  109. package/lib/esm/index.d.ts +4 -1
  110. package/lib/esm/index.js +6 -3
  111. package/lib/esm/shared/Calendar/index.js +1 -1
  112. package/lib/esm/shared/EventActionsMenu/index.d.ts +49 -0
  113. package/lib/esm/shared/EventActionsMenu/index.js +151 -0
  114. package/lib/esm/shared/EventInfoDetails/index.d.ts +12 -0
  115. package/lib/esm/shared/EventInfoDetails/index.js +3 -3
  116. package/lib/esm/shared/Media/Event/DisplayComponent.d.ts +15 -0
  117. package/lib/esm/shared/Media/Event/DisplayComponent.js +29 -0
  118. package/lib/esm/shared/Media/Event/constants.d.ts +1 -0
  119. package/lib/esm/shared/Media/Event/constants.js +1 -0
  120. package/lib/esm/shared/Media/Event/filter.d.ts +3 -0
  121. package/lib/esm/shared/Media/Event/filter.js +2 -0
  122. package/lib/esm/shared/Media/Event/index.d.ts +3 -0
  123. package/lib/esm/shared/Media/Event/index.js +11 -0
  124. package/lib/esm/shared/Media/Link/PreviewComponent.js +1 -1
  125. package/lib/esm/shared/Media/index.d.ts +2 -1
  126. package/lib/esm/shared/Media/index.js +2 -1
  127. package/lib/esm/types/event.d.ts +5 -0
  128. package/lib/esm/types/event.js +6 -0
  129. package/lib/umd/224.js +2 -0
  130. package/lib/umd/react-ui.js +1 -1
  131. package/package.json +7 -7
  132. package/lib/umd/84.js +0 -2
  133. /package/lib/umd/{84.js.LICENSE.txt → 224.js.LICENSE.txt} +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Share = exports.Link = exports.File = void 0;
3
+ exports.Event = exports.Share = exports.Link = exports.File = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const File_1 = tslib_1.__importDefault(require("./File"));
6
6
  exports.File = File_1.default;
@@ -8,3 +8,5 @@ const Link_1 = tslib_1.__importDefault(require("./Link"));
8
8
  exports.Link = Link_1.default;
9
9
  const Share_1 = tslib_1.__importDefault(require("./Share"));
10
10
  exports.Share = Share_1.default;
11
+ const Event_1 = tslib_1.__importDefault(require("./Event"));
12
+ exports.Event = Event_1.default;
@@ -0,0 +1,5 @@
1
+ export declare enum SCEventTemplateType {
2
+ DETAIL = "detail",
3
+ SNIPPET = "snippet",
4
+ PREVIEW = "preview"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SCEventTemplateType = void 0;
4
+ var SCEventTemplateType;
5
+ (function (SCEventTemplateType) {
6
+ SCEventTemplateType["DETAIL"] = "detail";
7
+ SCEventTemplateType["SNIPPET"] = "snippet";
8
+ SCEventTemplateType["PREVIEW"] = "preview";
9
+ })(SCEventTemplateType = exports.SCEventTemplateType || (exports.SCEventTemplateType = {}));
@@ -8,6 +8,7 @@ import classNames from 'classnames';
8
8
  import React, { useContext, useMemo } from 'react';
9
9
  import { FormattedMessage } from 'react-intl';
10
10
  import EventForm from '../EventForm';
11
+ import { SCFeatureName } from '@selfcommunity/types';
11
12
  const PREFIX = 'SCCreateEventButton';
12
13
  const classes = {
13
14
  root: `${PREFIX}-root`
@@ -50,11 +51,12 @@ export default function CreateEventButton(inProps) {
50
51
  const [open, setOpen] = React.useState(false);
51
52
  // CONST
52
53
  const authUserId = scUserContext.user ? scUserContext.user.id : null;
53
- const preferences = useSCPreferences();
54
- const onlyStaffEnabled = useMemo(() => preferences.preferences[SCPreferences.CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED].value, [preferences.preferences]);
54
+ const { preferences, features } = useSCPreferences();
55
+ const eventsEnabled = useMemo(() => features && features.includes(SCFeatureName.EVENT) && features.includes(SCFeatureName.TAGGING), [features]);
56
+ const onlyStaffEnabled = useMemo(() => preferences[SCPreferences.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED].value, [preferences]);
55
57
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
56
58
  // @ts-ignore
57
- const canCreateEvent = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_group; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
59
+ const canCreateEvent = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_event; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
58
60
  /**
59
61
  * Handle click on button
60
62
  */
@@ -64,7 +66,7 @@ export default function CreateEventButton(inProps) {
64
66
  /**
65
67
  * If there's no authUserId, component is hidden.
66
68
  */
67
- if ((!canCreateEvent && onlyStaffEnabled) || !authUserId) {
69
+ if (!eventsEnabled || (!canCreateEvent && onlyStaffEnabled) || !authUserId) {
68
70
  return null;
69
71
  }
70
72
  /**
@@ -0,0 +1,14 @@
1
+ import { CreateEventButtonProps } from '../CreateEventButton';
2
+ import { WidgetProps } from '../Widget';
3
+ export interface CreateEventWidgetProps extends WidgetProps {
4
+ /**
5
+ * Props to spread to CreateEventButton component
6
+ * @default {}
7
+ */
8
+ CreateEventButtonComponentProps?: CreateEventButtonProps;
9
+ /**
10
+ * Other props
11
+ */
12
+ [p: string]: any;
13
+ }
14
+ export default function CreateEventWidget(inProps: CreateEventWidgetProps): JSX.Element;
@@ -0,0 +1,60 @@
1
+ import { __rest } from "tslib";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Box, CardActions, CardContent, CardMedia, Divider, Icon, styled, Typography, useThemeProps } from '@mui/material';
4
+ import { SCPreferences, SCUserContext, useSCPreferences } from '@selfcommunity/react-core';
5
+ import { useContext, useEffect, useMemo, useState } from 'react';
6
+ import { FormattedMessage } from 'react-intl';
7
+ import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
8
+ import CreateEventButton from '../CreateEventButton';
9
+ import Widget from '../Widget';
10
+ import { PREFIX } from './constants';
11
+ import Skeleton from './Skeleton';
12
+ import { SCFeatureName } from '@selfcommunity/types';
13
+ const classes = {
14
+ root: `${PREFIX}-root`,
15
+ image: `${PREFIX}-image`,
16
+ calendar: `${PREFIX}-calendar`,
17
+ content: `${PREFIX}-content`,
18
+ title: `${PREFIX}-title`,
19
+ spaging: `${PREFIX}-spacing`,
20
+ actions: `${PREFIX}-actions`
21
+ };
22
+ const Root = styled(Widget, {
23
+ name: PREFIX,
24
+ slot: 'Root',
25
+ overridesResolver: (_props, styles) => styles.root
26
+ })(() => ({}));
27
+ export default function CreateEventWidget(inProps) {
28
+ var _a;
29
+ // PROPS
30
+ const props = useThemeProps({
31
+ props: inProps,
32
+ name: PREFIX
33
+ });
34
+ const { CreateEventButtonComponentProps = {} } = props, rest = __rest(props, ["CreateEventButtonComponentProps"]);
35
+ // STATE
36
+ const [loading, setLoading] = useState(true);
37
+ // CONTEXT
38
+ const scUserContext = useContext(SCUserContext);
39
+ // HOOK
40
+ const { preferences, features } = useSCPreferences();
41
+ const eventsEnabled = useMemo(() => features && features.includes(SCFeatureName.EVENT) && features.includes(SCFeatureName.TAGGING), [features]);
42
+ const authUserId = scUserContext.user ? scUserContext.user.id : null;
43
+ const onlyStaffEnabled = useMemo(() => preferences[SCPreferences.CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED].value, [preferences]);
44
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
45
+ // @ts-ignore
46
+ const canCreateEvent = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_group; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
47
+ useEffect(() => {
48
+ setLoading(false);
49
+ }, []);
50
+ if (loading) {
51
+ return _jsx(Skeleton, {});
52
+ }
53
+ /**
54
+ * If there's no authUserId, component is hidden.
55
+ */
56
+ if (!eventsEnabled || (!canCreateEvent && onlyStaffEnabled) || !authUserId) {
57
+ return _jsx(HiddenPlaceholder, {});
58
+ }
59
+ return (_jsxs(Root, Object.assign({ className: classes.root }, rest, { children: [_jsxs(Box, Object.assign({ position: "relative" }, { children: [_jsx(CardMedia, { component: "img", image: `${preferences[SCPreferences.IMAGES_USER_DEFAULT_COVER].value}`, alt: "placeholder image", className: classes.image }), _jsx(Icon, Object.assign({ className: classes.calendar, fontSize: "large" }, { children: "CalendarIcon" }))] })), _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.title }, { children: _jsx(FormattedMessage, { id: "ui.createEvent.title", defaultMessage: "ui.createEvent.title" }) })), _jsx(Typography, Object.assign({ variant: "body1", className: classes.spaging }, { children: _jsx(FormattedMessage, { id: "ui.createEvent.description", defaultMessage: "ui.createEvent.description" }) })), _jsx(Divider, { className: classes.spaging })] })), _jsx(CardActions, Object.assign({ className: classes.actions }, { children: _jsx(CreateEventButton, Object.assign({}, CreateEventButtonComponentProps)) }))] })));
60
+ }
@@ -0,0 +1 @@
1
+ export default function CreateEventWidgetSkeleton(): JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, CardActions, CardContent, Divider } from '@mui/material';
3
+ import Skeleton from '@mui/material/Skeleton';
4
+ import { styled } from '@mui/material/styles';
5
+ import Widget from '../Widget';
6
+ import { PREFIX } from './constants';
7
+ const classes = {
8
+ root: `${PREFIX}-skeleton-root`,
9
+ calendar: `${PREFIX}-calendar`,
10
+ content: `${PREFIX}-content`,
11
+ title: `${PREFIX}-title`,
12
+ spacing: `${PREFIX}-spacing`,
13
+ actions: `${PREFIX}-actions`
14
+ };
15
+ const Root = styled(Widget, {
16
+ name: PREFIX,
17
+ slot: 'SkeletonRoot'
18
+ })(() => ({}));
19
+ export default function CreateEventWidgetSkeleton() {
20
+ return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [_jsxs(Box, Object.assign({ position: "relative" }, { children: [_jsx(Skeleton, { variant: "rectangular", animation: "wave", width: "100%", height: "110px" }), _jsx(Skeleton, { className: classes.calendar, variant: "rounded", animation: "wave", width: "50px", height: "50px" })] })), _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsx(Skeleton, { className: classes.title, animation: "wave", width: "26%", height: "30px" }), _jsx(Skeleton, { className: classes.spacing, animation: "wave", width: "100%", height: "20px" }), _jsx(Divider, { className: classes.spacing })] })), _jsx(CardActions, Object.assign({ className: classes.actions }, { children: _jsx(Skeleton, { animation: "wave", variant: "rounded", width: "138px", height: "36px" }) }))] })));
21
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCCreateEventWidget";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCCreateEventWidget';
@@ -0,0 +1,4 @@
1
+ import CreateEventWidget, { CreateEventWidgetProps } from './CreateEventWidget';
2
+ import CreateEventWidgetSkeleton from './Skeleton';
3
+ export default CreateEventWidget;
4
+ export { CreateEventWidgetSkeleton, CreateEventWidgetProps, type CreateEventWidget };
@@ -0,0 +1,4 @@
1
+ import CreateEventWidget from './CreateEventWidget';
2
+ import CreateEventWidgetSkeleton from './Skeleton';
3
+ export default CreateEventWidget;
4
+ export { CreateEventWidgetSkeleton };
@@ -1,5 +1,8 @@
1
+ import React from 'react';
1
2
  import { SCEventType } from '@selfcommunity/types';
2
3
  import { WidgetProps } from '../Widget';
4
+ import { EventSkeletonProps } from './Skeleton';
5
+ import { SCEventTemplateType } from '../../types/event';
3
6
  export interface EventProps extends WidgetProps {
4
7
  /**
5
8
  * Event Object
@@ -11,6 +14,31 @@ export interface EventProps extends WidgetProps {
11
14
  * @default null
12
15
  */
13
16
  eventId?: number;
17
+ /**
18
+ * Event template type
19
+ * @default 'preview'
20
+ */
21
+ template?: SCEventTemplateType;
22
+ /**
23
+ * Actions
24
+ * @default null
25
+ */
26
+ actions?: React.ReactNode;
27
+ /**
28
+ * Hide participants
29
+ * @default false
30
+ */
31
+ hideEventParticipants?: boolean;
32
+ /**
33
+ * Hide event planner
34
+ * @default false
35
+ */
36
+ hideEventPlanner?: boolean;
37
+ /**
38
+ * Props to spread to EventSkeleton component
39
+ * @default {}
40
+ */
41
+ EventSkeletonComponentProps?: EventSkeletonProps;
14
42
  /**
15
43
  * Any other properties
16
44
  */
@@ -1,27 +1,66 @@
1
1
  import { __rest } from "tslib";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { styled } from '@mui/material/styles';
4
- import { Avatar, Button, Typography } from '@mui/material';
4
+ import { Avatar, Box, Button, CardActions, CardContent, CardMedia, Divider, Typography } from '@mui/material';
5
5
  import { SCEventLocationType } from '@selfcommunity/types';
6
6
  import { Link, SCRoutes, useSCFetchEvent, useSCRouting } from '@selfcommunity/react-core';
7
7
  import { FormattedMessage, useIntl } from 'react-intl';
8
8
  import classNames from 'classnames';
9
9
  import { useThemeProps } from '@mui/system';
10
10
  import BaseItem from '../../shared/BaseItem';
11
+ import Widget from '../Widget';
11
12
  import { PREFIX } from './constants';
12
13
  import EventSkeleton from './Skeleton';
14
+ import Calendar from '../../shared/Calendar';
15
+ import EventInfoDetails from '../../shared/EventInfoDetails';
16
+ import User from '../User';
17
+ import EventPartecipantsButton from '../EventPartecipantsButton';
18
+ import { SCEventTemplateType } from '../../types/event';
13
19
  const classes = {
14
20
  root: `${PREFIX}-root`,
15
- avatar: `${PREFIX}-avatar`,
16
- primary: `${PREFIX}-primary`,
17
- secondary: `${PREFIX}-secondary`,
18
- actions: `${PREFIX}-actions`
21
+ detailRoot: `${PREFIX}-detail-root`,
22
+ previewRoot: `${PREFIX}-preview-root`,
23
+ snippetRoot: `${PREFIX}-snippet-root`,
24
+ detailImageWrapper: `${PREFIX}-detail-image-wrapper`,
25
+ detailImage: `${PREFIX}-detail-image`,
26
+ detailNameWrapper: `${PREFIX}-detail-name-wrapper`,
27
+ detailName: `${PREFIX}-detail-name`,
28
+ detailContent: `${PREFIX}-detail-content`,
29
+ detailUser: `${PREFIX}-detail-user`,
30
+ detailFirstDivider: `${PREFIX}-detail-first-divider`,
31
+ detailSecondDivider: `${PREFIX}-detail-second-divider`,
32
+ detailActions: `${PREFIX}-detail-actions`,
33
+ previewImageWrapper: `${PREFIX}-preview-image-wrapper`,
34
+ previewImage: `${PREFIX}-preview-image`,
35
+ previewNameWrapper: `${PREFIX}-preview-name-wrapper`,
36
+ previewName: `${PREFIX}-preview-name`,
37
+ previewContent: `${PREFIX}-preview-content`,
38
+ previewActions: `${PREFIX}-preview-actions`,
39
+ snippetAvatar: `${PREFIX}-snippet-avatar`,
40
+ snippetPrimary: `${PREFIX}-snippet-primary`,
41
+ snippetSecondary: `${PREFIX}-snippet-secondary`,
42
+ snippetActions: `${PREFIX}-snippet-actions`
19
43
  };
20
- const Root = styled(BaseItem, {
44
+ const Root = styled(Widget, {
21
45
  name: PREFIX,
22
46
  slot: 'Root',
23
47
  overridesResolver: (props, styles) => styles.root
24
48
  })(() => ({}));
49
+ const DetailRoot = styled(Box, {
50
+ name: PREFIX,
51
+ slot: 'DetailRoot',
52
+ overridesResolver: (props, styles) => styles.detailRoot
53
+ })(() => ({}));
54
+ const PreviewRoot = styled(Box, {
55
+ name: PREFIX,
56
+ slot: 'PreviewRoot',
57
+ overridesResolver: (props, styles) => styles.previewRoot
58
+ })(() => ({}));
59
+ const SnippetRoot = styled(BaseItem, {
60
+ name: PREFIX,
61
+ slot: 'SnippetRoot',
62
+ overridesResolver: (props, styles) => styles.snippetRoot
63
+ })(() => ({}));
25
64
  /**
26
65
  * > API documentation for the Community-JS Event component. Learn about the available props and the CSS API.
27
66
  *
@@ -60,7 +99,7 @@ export default function Event(inProps) {
60
99
  props: inProps,
61
100
  name: PREFIX
62
101
  });
63
- const { eventId = null, event = null, className = null, elevation = 0 } = props, rest = __rest(props, ["eventId", "event", "className", "elevation"]);
102
+ const { id = `event_object_${props.eventId ? props.eventId : props.event ? props.event.id : ''}`, eventId = null, event = null, className = null, template = SCEventTemplateType.SNIPPET, hideEventParticipants = false, hideEventPlanner = false, actions, EventSkeletonComponentProps = {} } = props, rest = __rest(props, ["id", "eventId", "event", "className", "template", "hideEventParticipants", "hideEventPlanner", "actions", "EventSkeletonComponentProps"]);
64
103
  // STATE
65
104
  const { scEvent } = useSCFetchEvent({ id: eventId, event });
66
105
  // CONTEXT
@@ -71,10 +110,27 @@ export default function Event(inProps) {
71
110
  * Renders event object
72
111
  */
73
112
  if (!scEvent) {
74
- return _jsx(EventSkeleton, { elevation: elevation });
113
+ return _jsx(EventSkeleton, Object.assign({ template: template }, EventSkeletonComponentProps, rest, { actions: actions }));
114
+ }
115
+ /**
116
+ * Renders event object
117
+ */
118
+ let contentObj;
119
+ if (template === SCEventTemplateType.DETAIL) {
120
+ contentObj = (_jsxs(DetailRoot, Object.assign({ className: classes.detailRoot }, { children: [_jsxs(Box, Object.assign({ className: classes.detailImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.detailImage }), _jsx(Calendar, { day: new Date(scEvent.start_date).getDate() })] })), _jsxs(CardContent, Object.assign({ className: classes.detailContent }, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) })), _jsx(EventInfoDetails, { event: scEvent }), !hideEventPlanner && (_jsx(User, { user: scEvent.managed_by, elevation: 0, secondary: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })), actions: _jsx(_Fragment, {}), className: classes.detailUser })), !hideEventParticipants && (_jsxs(_Fragment, { children: [_jsx(Divider, { className: classes.detailFirstDivider }), _jsx(EventPartecipantsButton, { event: scEvent, eventId: scEvent.id })] })), _jsx(Divider, { className: classes.detailSecondDivider })] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.detailActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
121
+ }
122
+ else if (template === SCEventTemplateType.PREVIEW) {
123
+ contentObj = (_jsxs(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [_jsx(Box, Object.assign({ position: "relative", className: classes.previewImageWrapper }, { children: _jsx(CardMedia, { component: "img", height: "100px", image: scEvent.image_medium, alt: scEvent.name, className: classes.previewImage }) })), _jsxs(CardContent, Object.assign({ className: classes.previewContent }, { children: [_jsx(EventInfoDetails, { event: scEvent, hidePrivacyIcon: true, hasLocationInfo: false, beforePrivacyInfo: _jsx(Typography, Object.assign({ variant: "h5" }, { children: scEvent.name })) }), !hideEventParticipants && _jsx(EventPartecipantsButton, { event: scEvent })] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.previewActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
124
+ }
125
+ else {
126
+ contentObj = (_jsx(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: _jsx(Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.snippetAvatar }), primary: _jsxs(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.snippetPrimary }, { children: [_jsx(Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, {
127
+ weekday: 'long',
128
+ month: 'long',
129
+ day: 'numeric'
130
+ })}` })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: scEvent.name }))] })), secondary: _jsxs(Typography, Object.assign({ component: "p", variant: "body2", className: classes.snippetSecondary }, { children: [_jsx(FormattedMessage, { id: `ui.eventForm.privacy.${scEvent.privacy}`, defaultMessage: `ui.eventForm.privacy.${scEvent.privacy}` }), " -", ' ', (scEvent === null || scEvent === void 0 ? void 0 : scEvent.location) === SCEventLocationType.PERSON ? (_jsx(FormattedMessage, { id: `ui.eventForm.address.live.label`, defaultMessage: `ui.eventForm.address.live.label` })) : (_jsx(FormattedMessage, { id: `ui.eventForm.address.online.label`, defaultMessage: `ui.eventForm.address.online.label` }))] })), actions: actions !== null && actions !== void 0 ? actions : (_jsx(Box, Object.assign({ className: classes.snippetActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) }))) }));
75
131
  }
76
132
  /**
77
133
  * Renders root object
78
134
  */
79
- return (_jsx(Root, Object.assign({ elevation: elevation, disableTypography: true }, rest, { className: classNames(classes.root, className), image: _jsx(Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.avatar }), primary: _jsxs(Typography, Object.assign({ component: "div", className: classes.primary }, { children: [_jsx(Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, { weekday: 'long', month: 'long', day: 'numeric' })}` })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: scEvent.name }))] })), secondary: _jsxs(Typography, Object.assign({ component: "p", variant: "body2", className: classes.secondary }, { children: [_jsx(FormattedMessage, { id: `ui.eventForm.privacy.${scEvent.privacy}`, defaultMessage: `ui.eventForm.privacy.${scEvent.privacy}` }), " -", ' ', (scEvent === null || scEvent === void 0 ? void 0 : scEvent.location) === SCEventLocationType.PERSON ? (_jsx(FormattedMessage, { id: `ui.eventForm.address.live.label`, defaultMessage: `ui.eventForm.address.live.label` })) : (_jsx(FormattedMessage, { id: `ui.eventForm.address.online.label`, defaultMessage: `ui.eventForm.address.online.label` }))] })), actions: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })));
135
+ return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`) }, rest, { children: contentObj })));
80
136
  }
@@ -1,15 +1,21 @@
1
1
  import React from 'react';
2
- import { BaseItemProps } from '../../shared/BaseItem';
3
- export interface EventSkeletonProps extends BaseItemProps {
2
+ import { SCEventTemplateType } from '../../types/event';
3
+ import { WidgetProps } from '../Widget';
4
+ export interface EventSkeletonProps extends WidgetProps {
4
5
  /**
5
6
  * Overrides or extends the styles applied to the component.
6
7
  * @default null
7
8
  */
8
9
  className?: string;
10
+ /**
11
+ * Event template type
12
+ * @default 'preview'
13
+ */
14
+ template?: SCEventTemplateType;
9
15
  /**
10
16
  * Prop to pass an action to be rendered next to the skeleton
11
17
  */
12
- action?: React.ReactNode;
18
+ actions?: React.ReactNode;
13
19
  }
14
20
  /**
15
21
  * > API documentation for the Community-JS Event Skeleton component. Learn about the available props and the CSS API.
@@ -1,19 +1,44 @@
1
+ import { __rest } from "tslib";
1
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Box, Button, Icon } from '@mui/material';
3
+ import { AvatarGroup, Box, Button, CardContent, Divider, Icon, Stack } from '@mui/material';
3
4
  import { styled } from '@mui/material/styles';
4
5
  import Skeleton from '@mui/material/Skeleton';
5
6
  import { PREFIX } from './constants';
6
- import classNames from 'classnames';
7
7
  import BaseItem from '../../shared/BaseItem';
8
+ import { SCEventTemplateType } from '../../types/event';
9
+ import Widget from '../Widget';
10
+ import { useThemeProps } from '@mui/system';
11
+ import classNames from 'classnames';
8
12
  const classes = {
9
13
  root: `${PREFIX}-skeleton-root`,
10
- image: `${PREFIX}-skeleton-image`,
11
- action: `${PREFIX}-skeleton-action`
14
+ skeletonDetailRoot: `${PREFIX}-skeleton-detail-root`,
15
+ skeletonPreviewRoot: `${PREFIX}-skeleton-preview-root`,
16
+ skeletonSnippetRoot: `${PREFIX}-skeleton-snippet-root`,
17
+ skeletonDetailCalendar: `${PREFIX}-skeleton-detail-calendar`,
18
+ skeletonDetailContent: `${PREFIX}-skeleton-detail-content`,
19
+ skeletonDetailUser: `${PREFIX}-skeleton-detail-user`,
20
+ skeletonDetailFirstDivider: `${PREFIX}-skeleton-detail-first-divider`,
21
+ skeletonDetailSecondDivider: `${PREFIX}-skeleton-detail-second-divider`,
22
+ skeletonPreviewContent: `${PREFIX}-skeleton-preview-content`,
23
+ skeletonSnippetImage: `${PREFIX}-skeleton-snippet-image`,
24
+ skeletonSnippetAction: `${PREFIX}-skeleton-snippet-action`
12
25
  };
13
- const Root = styled(BaseItem, {
26
+ const Root = styled(Widget, {
14
27
  name: PREFIX,
15
28
  slot: 'SkeletonRoot'
16
29
  })(() => ({}));
30
+ const SkeletonDetailRoot = styled(Box, {
31
+ name: PREFIX,
32
+ slot: 'SkeletonDetailRoot'
33
+ })(() => ({}));
34
+ const SkeletonPreviewRoot = styled(Box, {
35
+ name: PREFIX,
36
+ slot: 'SkeletonPreviewRoot'
37
+ })(() => ({}));
38
+ const SkeletonSnippetRoot = styled(BaseItem, {
39
+ name: PREFIX,
40
+ slot: 'SkeletonSnippetRoot'
41
+ })(() => ({}));
17
42
  /**
18
43
  * > API documentation for the Community-JS Event Skeleton component. Learn about the available props and the CSS API.
19
44
 
@@ -37,6 +62,24 @@ const Root = styled(BaseItem, {
37
62
  *
38
63
  */
39
64
  export default function EventSkeleton(inProps) {
40
- const { className, action } = inProps;
41
- return (_jsx(Root, { elevation: 0, className: classNames(classes.root, className), image: _jsxs(Box, Object.assign({ className: classes.image }, { children: [_jsx(Skeleton, { animation: "wave", variant: "rectangular", width: 100, height: 60 }), " ", _jsx(Icon, Object.assign({ fontSize: "large" }, { children: "CalendarIcon" }))] })), primary: _jsx(Skeleton, { animation: "wave", variant: "rectangular", height: 10, width: 100, style: { marginBottom: 12 } }), secondary: _jsxs(_Fragment, { children: [_jsx(Skeleton, { animation: "wave", variant: "rectangular", height: 10, width: 160, style: { marginBottom: 10 } }), _jsx(Skeleton, { animation: "wave", variant: "rectangular", height: 10, width: 90 })] }), actions: _jsx(_Fragment, { children: action !== null && action !== void 0 ? action : (_jsx(Button, Object.assign({ size: "small", variant: "outlined", disabled: true }, { children: _jsx(Skeleton, { animation: "wave", height: 10, width: 30, style: { marginTop: 5, marginBottom: 5 } }) }))) }) }));
65
+ // PROPS
66
+ const props = useThemeProps({
67
+ props: inProps,
68
+ name: PREFIX
69
+ });
70
+ const { className, template = SCEventTemplateType.SNIPPET, actions } = props, rest = __rest(props, ["className", "template", "actions"]);
71
+ /**
72
+ * Renders event object
73
+ */
74
+ let contentObj;
75
+ if (template === SCEventTemplateType.DETAIL) {
76
+ contentObj = (_jsxs(SkeletonDetailRoot, Object.assign({ className: classes.skeletonDetailRoot }, { children: [_jsxs(Box, Object.assign({ position: "relative" }, { children: [_jsx(Skeleton, { variant: "rectangular", animation: "wave", width: "100%", height: "170px" }), _jsx(Skeleton, { className: classes.skeletonDetailCalendar, variant: "rounded", animation: "wave", width: "60px", height: "60px" })] })), _jsxs(CardContent, Object.assign({ className: classes.skeletonDetailContent }, { children: [_jsx(Skeleton, { animation: "wave", width: "36%", height: "40px" }), _jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px", marginBottom: "9px" }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", width: "50%", height: "20px" })] })), _jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px", marginBottom: "9px" }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", width: "35%", height: "20px" })] })), _jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px", marginBottom: "14px" }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", width: "27%", height: "20px" })] })), _jsxs(Stack, Object.assign({ direction: "row", gap: "8px", className: classes.skeletonDetailUser }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "36px", height: "36px" }), _jsxs(Stack, Object.assign({ gap: "1px" }, { children: [_jsx(Skeleton, { animation: "wave", width: "75px", height: "15px" }), _jsx(Skeleton, { animation: "wave", width: "86px", height: "16px" })] }))] })), _jsx(Divider, { className: classes.skeletonDetailFirstDivider }), _jsxs(Stack, Object.assign({ direction: "row", gap: "8px", alignItems: "center", height: "28px" }, { children: [_jsx(Skeleton, { animation: "wave", width: "68px", height: "20px" }), _jsxs(AvatarGroup, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" })] })] })), _jsx(Divider, { className: classes.skeletonDetailSecondDivider })] }))] })));
77
+ }
78
+ else if (template === SCEventTemplateType.PREVIEW) {
79
+ contentObj = (_jsxs(SkeletonPreviewRoot, Object.assign({ className: classes.skeletonPreviewRoot }, { children: [_jsx(Box, Object.assign({ position: "relative" }, { children: _jsx(Skeleton, { variant: "rectangular", animation: "wave", width: "100%", height: "80px" }) })), _jsxs(CardContent, Object.assign({ className: classes.skeletonPreviewContent }, { children: [_jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px" }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", width: "30%", height: "16px" })] })), _jsx(Skeleton, { animation: "wave", width: "46%", height: "20px" }), _jsx(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px", marginBottom: "14px" }, { children: _jsx(Skeleton, { animation: "wave", width: "27%", height: "16px" }) })), _jsxs(Stack, Object.assign({ direction: "row", gap: "8px", alignItems: "center", height: "28px" }, { children: [_jsxs(AvatarGroup, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" })] }), _jsx(Skeleton, { animation: "wave", width: "10%", height: "20px" })] }))] }))] })));
80
+ }
81
+ else {
82
+ contentObj = (_jsx(SkeletonSnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.skeletonSnippetRoot, image: _jsxs(Box, Object.assign({ className: classes.skeletonSnippetImage }, { children: [_jsx(Skeleton, { animation: "wave", variant: "rectangular", width: 100, height: 60 }), " ", _jsx(Icon, Object.assign({ fontSize: "large" }, { children: "CalendarIcon" }))] })), primary: _jsx(Skeleton, { animation: "wave", variant: "rectangular", height: 10, width: "40%", style: { marginBottom: 12 } }), secondary: _jsxs(_Fragment, { children: [_jsx(Skeleton, { animation: "wave", variant: "rectangular", height: 10, width: "60%", style: { marginBottom: 10, marginRight: 5 } }), _jsx(Skeleton, { animation: "wave", variant: "rectangular", height: 10, width: "35%" })] }), actions: _jsx(_Fragment, { children: actions !== null && actions !== void 0 ? actions : (_jsx(Button, Object.assign({ size: "small", variant: "outlined", disabled: true }, { children: _jsx(Skeleton, { animation: "wave", height: 10, width: 30, style: { marginTop: 5, marginBottom: 5 } }) }))) }) }));
83
+ }
84
+ return (_jsx(Root, Object.assign({ className: classNames(classes.root, className, `${PREFIX}-skeleton-${template}`) }, rest, { children: contentObj })));
42
85
  }
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useCallback, useEffect, useMemo, useRef } from 'react';
4
4
  import { styled } from '@mui/material/styles';
5
- import { Box, Icon, Paper, Typography } from '@mui/material';
5
+ import { Box, Icon, Paper, Typography, useMediaQuery, useTheme } from '@mui/material';
6
6
  import { SCEventLocationType, SCEventPrivacyType } from '@selfcommunity/types';
7
7
  import { SCPreferences, useSCFetchEvent, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
8
8
  import EventHeaderSkeleton from './Skeleton';
@@ -18,6 +18,7 @@ import PubSub from 'pubsub-js';
18
18
  import EditEventButton from '../EditEventButton';
19
19
  import User from '../User';
20
20
  import Calendar from '../../shared/Calendar';
21
+ import EventActionsMenu from '../../shared/EventActionsMenu';
21
22
  const classes = {
22
23
  root: `${PREFIX}-root`,
23
24
  cover: `${PREFIX}-cover`,
@@ -31,7 +32,8 @@ const classes = {
31
32
  };
32
33
  const Root = styled(Box, {
33
34
  name: PREFIX,
34
- slot: 'Root'
35
+ slot: 'Root',
36
+ shouldForwardProp: (prop) => prop !== 'isEventAdmin'
35
37
  })(() => ({}));
36
38
  /**
37
39
  * > API documentation for the Community-JS Event Header component. Learn about the available props and the CSS API.
@@ -86,6 +88,8 @@ export default function EventHeader(inProps) {
86
88
  const updatesSubscription = useRef(null);
87
89
  // CONST
88
90
  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]);
91
+ const theme = useTheme();
92
+ const isMobile = useMediaQuery(theme.breakpoints.down('md'));
89
93
  /**
90
94
  * Subscriber for pubsub callback
91
95
  */
@@ -120,7 +124,10 @@ export default function EventHeader(inProps) {
120
124
  const _backgroundCover = Object.assign({}, (scEvent.image_bigger
121
125
  ? { background: `url('${scEvent.image_bigger}') center / cover` }
122
126
  : { background: `url('${scPreferences.preferences[SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
123
- return (_jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, rest, { children: [_jsx(Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: _jsx(Box, Object.assign({ className: classes.calendar }, { children: _jsx(Calendar, { day: new Date(scEvent.start_date).getDate() }) })) })), _jsxs(Box, Object.assign({ className: classes.info }, { children: [_jsx(Typography, Object.assign({ className: classes.time }, { children: scEvent.end_date && scEvent.end_date !== scEvent.start_date ? (new Date(scEvent.start_date).getDate() !== new Date(scEvent.end_date).getDate() ? (_jsx(FormattedMessage, { id: "ui.eventHeader.startEndTimeDiff", defaultMessage: "ui.eventHeader.startEndTimeDiff", values: {
127
+ return (
128
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
129
+ // @ts-ignore
130
+ _jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className), isEventAdmin: isEventAdmin }, rest, { children: [_jsx(Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: _jsx(Box, Object.assign({ className: classes.calendar }, { children: _jsx(Calendar, { day: new Date(scEvent.start_date).getDate() }) })) })), _jsxs(Box, Object.assign({ className: classes.info }, { children: [_jsx(Typography, Object.assign({ className: classes.time }, { children: scEvent.end_date && scEvent.end_date !== scEvent.start_date ? (new Date(scEvent.start_date).getDate() !== new Date(scEvent.end_date).getDate() ? (_jsx(FormattedMessage, { id: "ui.eventHeader.startEndTimeDiff", defaultMessage: "ui.eventHeader.startEndTimeDiff", values: {
124
131
  startDate: intl.formatDate(scEvent.start_date, {
125
132
  weekday: 'long',
126
133
  day: 'numeric',
@@ -152,5 +159,5 @@ export default function EventHeader(inProps) {
152
159
  month: 'long'
153
160
  }),
154
161
  hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
155
- } })) })), _jsx(Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), _jsxs(Box, Object.assign({ className: classes.visibility }, { children: [_jsx(_Fragment, { children: scEvent.privacy === SCEventPrivacyType.PUBLIC ? (_jsxs(Typography, Object.assign({ className: classes.visibilityItem }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.visibility.public" })] }))) : (_jsxs(Typography, Object.assign({ className: classes.visibilityItem }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), _jsx(Bullet, {}), _jsx(Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === SCEventLocationType.PERSON ? (_jsx(FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : (_jsx(FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.online" })) }))] })), _jsx(User, { userId: (_b = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _b === void 0 ? void 0 : _b.id, elevation: 0, actions: _jsx(_Fragment, { children: isEventAdmin ? (_jsxs(Box, Object.assign({ className: classes.multiActions }, { children: [_jsx(EventInviteButton, { size: "small", event: scEvent, eventId: scEvent.id }), _jsx(EditEventButton, { size: "small", event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data) })] }))) : (_jsx(EventSubscribeButton, Object.assign({ event: scEvent }, EventSubscribeButtonProps))) }) })] }))] })));
162
+ } })) })), _jsx(Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), _jsxs(Box, Object.assign({ className: classes.visibility }, { children: [_jsx(_Fragment, { children: scEvent.privacy === SCEventPrivacyType.PUBLIC ? (_jsxs(Typography, Object.assign({ className: classes.visibilityItem }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.visibility.public" })] }))) : (_jsxs(Typography, Object.assign({ className: classes.visibilityItem }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), _jsx(Bullet, {}), _jsx(Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === SCEventLocationType.PERSON ? (_jsx(FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : (_jsx(FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.online" })) }))] })), _jsx(User, { userId: (_b = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _b === void 0 ? void 0 : _b.id, secondary: _jsx(FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: _jsx(_Fragment, { children: isEventAdmin ? (_jsxs(Box, Object.assign({ className: classes.multiActions }, { children: [_jsx(EventInviteButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id }), _jsxs(Box, { children: [_jsx(EditEventButton, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data) }), _jsx(EventActionsMenu, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })] }))) : (_jsxs(_Fragment, { children: [_jsx(EventSubscribeButton, Object.assign({ event: scEvent }, EventSubscribeButtonProps)), _jsx(EventActionsMenu, { eventId: scEvent === null || scEvent === void 0 ? void 0 : scEvent.id })] })) }) })] }))] })));
156
163
  }
@@ -20,7 +20,7 @@ const Root = styled(Widget, {
20
20
  name: PREFIX,
21
21
  slot: 'Root',
22
22
  overridesResolver: (_props, styles) => styles.root
23
- })();
23
+ })(() => ({}));
24
24
  function isTextLongerThanLimit(text, limit = 125) {
25
25
  return text.length > limit;
26
26
  }
@@ -58,6 +58,7 @@ export default function EventInfoWidget(inProps) {
58
58
  const handleToggleSummary = useCallback(() => {
59
59
  setExpanded(!expanded);
60
60
  }, [expanded]);
61
+ // RENDER
61
62
  if (!scEvent && loading) {
62
63
  return _jsx(Skeleton, {});
63
64
  }
@@ -10,7 +10,7 @@ const Root = styled(Widget, {
10
10
  name: PREFIX,
11
11
  slot: 'SkeletonRoot',
12
12
  overridesResolver: (_props, styles) => styles.root
13
- })();
13
+ })(() => ({}));
14
14
  export default function EventInfoWigetSkeleton() {
15
15
  return (_jsx(Root, Object.assign({ className: classes.root }, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px", marginBottom: "8px" }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", width: "184px", height: "21px" })] })), _jsx(Skeleton, { animation: "wave", width: "100%" }), _jsx(Skeleton, { animation: "wave", width: "100%" }), _jsx(Skeleton, { animation: "wave", width: "50%" }), _jsxs(Stack, Object.assign({ gap: "16px", marginTop: "24px" }, { children: [_jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px" }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", width: "223px", height: "21px" })] })), _jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px" }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", width: "223px", height: "21px" })] })), _jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px" }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", width: "223px", height: "21px" })] })), _jsxs(Stack, Object.assign({ direction: "row", alignItems: "center", gap: "8px" }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", width: "21px", height: "21px" }), _jsx(Skeleton, { animation: "wave", width: "223px", height: "21px" })] }))] }))] })) })));
16
16
  }
@@ -70,23 +70,28 @@ export default function EventLocationWidget(inProps) {
70
70
  googleMapsApiKey: scContext.settings.integrations.geocoding.apiKey,
71
71
  libraries: ['maps']
72
72
  });
73
+ const mapOptions = {
74
+ fullscreenControl: false,
75
+ mapTypeControl: false,
76
+ streetViewControl: false,
77
+ zoomControl: false // Disables the zoom control (+/- buttons)
78
+ };
73
79
  if (!((_c = (_b = (_a = scContext === null || scContext === void 0 ? void 0 : scContext.settings) === null || _a === void 0 ? void 0 : _a.integrations) === null || _b === void 0 ? void 0 : _b.geocoding) === null || _c === void 0 ? void 0 : _c.apiKey) || (scEvent && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.location) === SCEventLocationType.ONLINE)) {
74
80
  return _jsx(HiddenPlaceholder, {});
75
81
  }
76
82
  /**
77
83
  * Loading event
78
84
  */
79
- console.log(isLoaded, scEvent);
80
85
  if (!isLoaded || !scEvent) {
81
86
  return _jsx(EventLocationWidgetSkeleton, {});
82
87
  }
83
88
  /**
84
89
  * Renders root object
85
90
  */
86
- return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsxs(CardContent, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.title }, { children: _jsx(FormattedMessage, { id: "ui.eventLocationWidget.title", defaultMessage: "ui.eventLocationWidget.title" }) })), _jsx(Box, Object.assign({ className: classes.map }, { children: _jsx(GoogleMap, Object.assign({ mapContainerClassName: classes.map, center: {
91
+ return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsxs(CardContent, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.title, gutterBottom: true }, { children: _jsx(FormattedMessage, { id: "ui.eventLocationWidget.title", defaultMessage: "ui.eventLocationWidget.title" }) })), _jsx(Box, Object.assign({ className: classes.map }, { children: _jsx(GoogleMap, Object.assign({ mapContainerClassName: classes.map, center: {
87
92
  lat: scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation_lat,
88
93
  lng: scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation_lng
89
- }, zoom: 15 }, { children: _jsx(MarkerF, { position: {
94
+ }, options: mapOptions, zoom: 15 }, { children: _jsx(MarkerF, { position: {
90
95
  lat: scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation_lat,
91
96
  lng: scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation_lng
92
97
  } }) })) })), _jsx(Typography, Object.assign({ variant: "h4", className: classes.locationTitle }, { children: formatEventLocationGeolocation(scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation, true) })), _jsx(Typography, Object.assign({ variant: "body1", className: classes.address }, { children: formatEventLocationGeolocation(scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation) }))] }) })));