@selfcommunity/react-ui 0.8.0-live.80 → 0.8.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.
Files changed (139) hide show
  1. package/lib/cjs/assets/onBoarding/android.d.ts +1 -1
  2. package/lib/cjs/assets/onBoarding/android.js +1 -1
  3. package/lib/cjs/components/CategoryFollowersButton/CategoryFollowersButton.d.ts +2 -2
  4. package/lib/cjs/components/CategoryFollowersButton/CategoryFollowersButton.js +20 -15
  5. package/lib/cjs/components/CommentObject/CommentObject.js +6 -3
  6. package/lib/cjs/components/CommentObjectReply/CommentObjectReply.js +4 -1
  7. package/lib/cjs/components/CreateEventButton/CreateEventButton.d.ts +1 -1
  8. package/lib/cjs/components/CreateEventButton/CreateEventButton.js +1 -1
  9. package/lib/cjs/components/EditEventButton/EditEventButton.js +2 -2
  10. package/lib/cjs/components/Editor/plugins/AutoLinkPlugin.js +7 -1
  11. package/lib/cjs/components/Event/Event.js +4 -4
  12. package/lib/cjs/components/EventForm/EventAddress.js +5 -8
  13. package/lib/cjs/components/EventForm/EventForm.js +32 -25
  14. package/lib/cjs/components/EventForm/constants.d.ts +4 -4
  15. package/lib/cjs/components/EventForm/constants.js +4 -4
  16. package/lib/cjs/components/EventForm/utils.d.ts +3 -3
  17. package/lib/cjs/components/EventForm/utils.js +8 -5
  18. package/lib/cjs/components/EventHeader/EventHeader.js +4 -35
  19. package/lib/cjs/components/EventInviteButton/EventInviteButton.js +5 -5
  20. package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +3 -7
  21. package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +1 -1
  22. package/lib/cjs/components/EventParticipantsButton/EventParticipantsButton.js +9 -5
  23. package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
  24. package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +14 -16
  25. package/lib/cjs/components/Events/Events.js +12 -35
  26. package/lib/cjs/components/Events/PastEventsFilter.js +2 -12
  27. package/lib/cjs/components/FeedObject/Actions/Share/Share.js +1 -1
  28. package/lib/cjs/components/FeedObject/FeedObject.js +5 -6
  29. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +2 -2
  30. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +20 -15
  31. package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.js +6 -1
  32. package/lib/cjs/components/NavigationMenuIconButton/DefaultDrawerContent.js +24 -2
  33. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +1 -1
  34. package/lib/cjs/components/Notification/Comment/Comment.js +2 -2
  35. package/lib/cjs/components/Notification/Notification.js +1 -1
  36. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +2 -2
  37. package/lib/cjs/components/OnBoardingWidget/Steps/App/App.js +2 -1
  38. package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/Appearance.js +65 -104
  39. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +4 -7
  40. package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +3 -2
  41. package/lib/cjs/components/Skeleton/AvatarGroupSkeleton.js +4 -4
  42. package/lib/cjs/components/SuggestedEventsWidget/Arrow.js +2 -1
  43. package/lib/cjs/components/TagAutocomplete/TagAutocomplete.d.ts +44 -0
  44. package/lib/cjs/components/TagAutocomplete/TagAutocomplete.js +92 -0
  45. package/lib/cjs/components/TagAutocomplete/index.d.ts +3 -0
  46. package/lib/cjs/components/TagAutocomplete/index.js +5 -0
  47. package/lib/cjs/components/UserActionIconButton/UserActionIconButton.js +24 -2
  48. package/lib/cjs/components/UserProfileEdit/Section/PublicInfo.js +1 -1
  49. package/lib/cjs/components/UserProfileEdit/UserProfileEdit.d.ts +1 -1
  50. package/lib/cjs/components/UserProfileEdit/UserProfileEdit.js +1 -1
  51. package/lib/cjs/components/UserSocialAssociation/UserSocialAssociation.js +16 -4
  52. package/lib/cjs/constants/SocialShare.d.ts +12 -0
  53. package/lib/cjs/constants/SocialShare.js +15 -2
  54. package/lib/cjs/index.d.ts +3 -2
  55. package/lib/cjs/index.js +6 -2
  56. package/lib/cjs/shared/CopyTextArea/index.d.ts +10 -0
  57. package/lib/cjs/shared/CopyTextArea/index.js +77 -0
  58. package/lib/cjs/utils/buttonCounters.d.ts +1 -0
  59. package/lib/cjs/utils/buttonCounters.js +15 -0
  60. package/lib/cjs/utils/contribution.d.ts +7 -0
  61. package/lib/cjs/utils/contribution.js +13 -1
  62. package/lib/cjs/utils/string.js +1 -1
  63. package/lib/esm/assets/onBoarding/android.d.ts +1 -1
  64. package/lib/esm/assets/onBoarding/android.js +1 -1
  65. package/lib/esm/components/CategoryFollowersButton/CategoryFollowersButton.d.ts +2 -2
  66. package/lib/esm/components/CategoryFollowersButton/CategoryFollowersButton.js +20 -15
  67. package/lib/esm/components/CommentObject/CommentObject.js +8 -5
  68. package/lib/esm/components/CommentObjectReply/CommentObjectReply.js +5 -2
  69. package/lib/esm/components/CreateEventButton/CreateEventButton.d.ts +1 -1
  70. package/lib/esm/components/CreateEventButton/CreateEventButton.js +1 -1
  71. package/lib/esm/components/EditEventButton/EditEventButton.js +2 -2
  72. package/lib/esm/components/Editor/plugins/AutoLinkPlugin.js +7 -1
  73. package/lib/esm/components/Event/Event.js +4 -4
  74. package/lib/esm/components/EventForm/EventAddress.js +6 -9
  75. package/lib/esm/components/EventForm/EventForm.js +32 -25
  76. package/lib/esm/components/EventForm/constants.d.ts +4 -4
  77. package/lib/esm/components/EventForm/constants.js +4 -4
  78. package/lib/esm/components/EventForm/utils.d.ts +3 -3
  79. package/lib/esm/components/EventForm/utils.js +8 -5
  80. package/lib/esm/components/EventHeader/EventHeader.js +5 -36
  81. package/lib/esm/components/EventInviteButton/EventInviteButton.js +5 -5
  82. package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +5 -9
  83. package/lib/esm/components/EventMembersWidget/TabContentComponent.js +1 -1
  84. package/lib/esm/components/EventParticipantsButton/EventParticipantsButton.js +9 -5
  85. package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
  86. package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +16 -18
  87. package/lib/esm/components/Events/Events.js +11 -34
  88. package/lib/esm/components/Events/PastEventsFilter.js +2 -12
  89. package/lib/esm/components/FeedObject/Actions/Share/Share.js +1 -1
  90. package/lib/esm/components/FeedObject/FeedObject.js +5 -6
  91. package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +2 -2
  92. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +20 -15
  93. package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.js +8 -3
  94. package/lib/esm/components/NavigationMenuIconButton/DefaultDrawerContent.js +27 -5
  95. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +1 -1
  96. package/lib/esm/components/Notification/Comment/Comment.js +2 -2
  97. package/lib/esm/components/Notification/Notification.js +1 -1
  98. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +2 -2
  99. package/lib/esm/components/OnBoardingWidget/Steps/App/App.js +2 -1
  100. package/lib/esm/components/OnBoardingWidget/Steps/Appearance/Appearance.js +67 -106
  101. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +4 -7
  102. package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +3 -2
  103. package/lib/esm/components/Skeleton/AvatarGroupSkeleton.js +4 -4
  104. package/lib/esm/components/SuggestedEventsWidget/Arrow.js +2 -1
  105. package/lib/esm/components/TagAutocomplete/TagAutocomplete.d.ts +44 -0
  106. package/lib/esm/components/TagAutocomplete/TagAutocomplete.js +90 -0
  107. package/lib/esm/components/TagAutocomplete/index.d.ts +3 -0
  108. package/lib/esm/components/TagAutocomplete/index.js +2 -0
  109. package/lib/esm/components/UserActionIconButton/UserActionIconButton.js +24 -2
  110. package/lib/esm/components/UserProfileEdit/Section/PublicInfo.js +1 -1
  111. package/lib/esm/components/UserProfileEdit/UserProfileEdit.d.ts +1 -1
  112. package/lib/esm/components/UserProfileEdit/UserProfileEdit.js +1 -1
  113. package/lib/esm/components/UserSocialAssociation/UserSocialAssociation.js +18 -6
  114. package/lib/esm/constants/SocialShare.d.ts +12 -0
  115. package/lib/esm/constants/SocialShare.js +13 -0
  116. package/lib/esm/index.d.ts +3 -2
  117. package/lib/esm/index.js +3 -2
  118. package/lib/esm/shared/CopyTextArea/index.d.ts +10 -0
  119. package/lib/esm/shared/CopyTextArea/index.js +74 -0
  120. package/lib/esm/utils/buttonCounters.d.ts +1 -0
  121. package/lib/esm/utils/buttonCounters.js +11 -0
  122. package/lib/esm/utils/contribution.d.ts +7 -0
  123. package/lib/esm/utils/contribution.js +11 -0
  124. package/lib/esm/utils/string.js +1 -1
  125. package/lib/umd/2aa155858f48b8f3911a.eot +0 -0
  126. package/lib/umd/36f3af7f155d916c26ff.woff2 +0 -0
  127. package/lib/umd/749.js +2 -0
  128. package/lib/umd/80884d7cc0fcb1a47982.svg +1 -0
  129. package/lib/umd/a221d3aba0f6753cfbb7.ttf +0 -0
  130. package/lib/umd/assets/icons.svg +251 -0
  131. package/lib/umd/c3528e120c4e831db2ae.woff +0 -0
  132. package/lib/umd/react-ui.js +1 -1
  133. package/package.json +9 -8
  134. package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/reducer.d.ts +0 -15
  135. package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/reducer.js +0 -42
  136. package/lib/esm/components/OnBoardingWidget/Steps/Appearance/reducer.d.ts +0 -15
  137. package/lib/esm/components/OnBoardingWidget/Steps/Appearance/reducer.js +0 -37
  138. package/lib/umd/32.js +0 -2
  139. /package/lib/umd/{32.js.LICENSE.txt → 749.js.LICENSE.txt} +0 -0
@@ -1,6 +1,6 @@
1
- import { BaseDialogProps } from '../../shared/BaseDialog';
2
- import { SCCategoryType } from '@selfcommunity/types';
3
1
  import { ButtonProps } from '@mui/material/Button/Button';
2
+ import { SCCategoryType } from '@selfcommunity/types';
3
+ import { BaseDialogProps } from '../../shared/BaseDialog';
4
4
  export interface CategoryFollowersButtonProps extends Pick<ButtonProps, Exclude<keyof ButtonProps, 'onClick' | 'disabled'>> {
5
5
  /**
6
6
  * Category Object
@@ -2,22 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const styles_1 = require("@mui/material/styles");
7
5
  const material_1 = require("@mui/material");
8
- const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
9
- const react_intl_1 = require("react-intl");
10
- const InfiniteScroll_1 = tslib_1.__importDefault(require("../../shared/InfiniteScroll"));
11
- const User_1 = tslib_1.__importStar(require("../User"));
6
+ const styles_1 = require("@mui/material/styles");
7
+ const useMediaQuery_1 = tslib_1.__importDefault(require("@mui/material/useMediaQuery"));
8
+ const system_1 = require("@mui/system");
12
9
  const api_services_1 = require("@selfcommunity/api-services");
13
10
  const react_core_1 = require("@selfcommunity/react-core");
14
- const AvatarGroupSkeleton_1 = tslib_1.__importDefault(require("../Skeleton/AvatarGroupSkeleton"));
15
- const classnames_1 = tslib_1.__importDefault(require("classnames"));
16
- const system_1 = require("@mui/system");
17
- const useMediaQuery_1 = tslib_1.__importDefault(require("@mui/material/useMediaQuery"));
18
11
  const utils_1 = require("@selfcommunity/utils");
19
- const Errors_1 = require("../../constants/Errors");
12
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
13
+ const react_1 = require("react");
14
+ const react_intl_1 = require("react-intl");
20
15
  const use_deep_compare_effect_1 = require("use-deep-compare-effect");
16
+ const Errors_1 = require("../../constants/Errors");
17
+ const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
18
+ const InfiniteScroll_1 = tslib_1.__importDefault(require("../../shared/InfiniteScroll"));
19
+ const buttonCounters_1 = require("../../utils/buttonCounters");
20
+ const AvatarGroupSkeleton_1 = tslib_1.__importDefault(require("../Skeleton/AvatarGroupSkeleton"));
21
+ const User_1 = tslib_1.__importStar(require("../User"));
21
22
  const PREFIX = 'SCCategoryFollowersButton';
22
23
  const classes = {
23
24
  root: `${PREFIX}-root`,
@@ -27,12 +28,13 @@ const classes = {
27
28
  const Root = (0, styles_1.styled)(material_1.Button, {
28
29
  name: PREFIX,
29
30
  slot: 'Root',
30
- overridesResolver: (props, styles) => styles.root
31
+ overridesResolver: (_props, styles) => styles.root,
32
+ shouldForwardProp: (prop) => prop !== 'followers'
31
33
  })(() => ({}));
32
34
  const DialogRoot = (0, styles_1.styled)(BaseDialog_1.default, {
33
35
  name: PREFIX,
34
- slot: 'Root',
35
- overridesResolver: (props, styles) => styles.dialogRoot
36
+ slot: 'DialogRoot',
37
+ overridesResolver: (_props, styles) => styles.dialogRoot
36
38
  })(() => ({}));
37
39
  /**
38
40
  *> API documentation for the Community-JS Category Followers Button component. Learn about the available props and the CSS API.
@@ -122,9 +124,12 @@ function CategoryFollowersButton(inProps) {
122
124
  const handleToggleDialogOpen = (0, react_1.useMemo)(() => () => {
123
125
  setOpen((prev) => !prev);
124
126
  }, [setOpen]);
127
+ const renderSurplus = (0, react_1.useCallback)(() => (0, buttonCounters_1.numberFormatter)(scCategory.followers_counter), [scCategory]);
125
128
  // RENDER
126
129
  const theme = (0, material_1.useTheme)();
127
130
  const isMobile = (0, useMediaQuery_1.default)(theme.breakpoints.down('md'));
128
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scCategory || scCategory.followers_counter === 0 }, rest, { children: loading || !scCategory ? ((0, jsx_runtime_1.jsx)(AvatarGroupSkeleton_1.default, Object.assign({}, rest))) : ((0, jsx_runtime_1.jsx)(material_1.AvatarGroup, Object.assign({ total: scCategory.followers_counter }, { children: followers.map((c) => ((0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: c.username, src: c.avatar }, c.id))) }))) })), open && ((0, jsx_runtime_1.jsx)(DialogRoot, Object.assign({ className: classes.dialogRoot, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.categoryFollowersButton.dialogTitle", id: "ui.categoryFollowersButton.dialogTitle", values: { total: scCategory.followers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: (0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ dataLength: followers.length, next: fetchFollowers, hasMoreNext: next !== null || loading, loaderNext: (0, jsx_runtime_1.jsx)(User_1.UserSkeleton, { elevation: 0 }), height: isMobile ? '100%' : 400, endMessage: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.categoryFollowersButton.noOtherFollowers", defaultMessage: "ui.categoryFollowersButton.noOtherFollowers" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: followers.map((follower) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, { elevation: 0, user: follower }) }, follower.id))) }) })) })))] }));
131
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scCategory || scCategory.followers_counter === 0,
132
+ // @ts-expect-error this is needed to use followers into SCCategoryFollowersButton
133
+ followers: scCategory === null || scCategory === void 0 ? void 0 : scCategory.followers_counter }, rest, { children: loading || !scCategory ? ((0, jsx_runtime_1.jsx)(AvatarGroupSkeleton_1.default, Object.assign({}, rest))) : ((0, jsx_runtime_1.jsx)(material_1.AvatarGroup, Object.assign({ total: scCategory.followers_counter, renderSurplus: renderSurplus }, { children: followers.map((c) => ((0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: c.username, src: c.avatar }, c.id))) }))) })), open && ((0, jsx_runtime_1.jsx)(DialogRoot, Object.assign({ className: classes.dialogRoot, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.categoryFollowersButton.dialogTitle", id: "ui.categoryFollowersButton.dialogTitle", values: { total: scCategory.followers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: (0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ dataLength: followers.length, next: fetchFollowers, hasMoreNext: next !== null || loading, loaderNext: (0, jsx_runtime_1.jsx)(User_1.UserSkeleton, { elevation: 0 }), height: isMobile ? '100%' : 400, endMessage: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.categoryFollowersButton.noOtherFollowers", defaultMessage: "ui.categoryFollowersButton.noOtherFollowers" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: followers.map((follower) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, { elevation: 0, user: follower }) }, follower.id))) }) })) })))] }));
129
134
  }
130
135
  exports.default = CategoryFollowersButton;
@@ -44,7 +44,9 @@ const classes = {
44
44
  vote: `${constants_1.PREFIX}-vote`,
45
45
  voteAudience: `${constants_1.PREFIX}-vote-audience`,
46
46
  reply: `${constants_1.PREFIX}-reply`,
47
- contentSubSection: `${constants_1.PREFIX}-comment-sub-section`
47
+ contentSubSection: `${constants_1.PREFIX}-comment-sub-section`,
48
+ collapsed: `${constants_1.PREFIX}-collapsed`,
49
+ flagChip: `${constants_1.PREFIX}-flag-chip`
48
50
  };
49
51
  const Root = (0, styles_1.styled)(material_1.Box, {
50
52
  name: constants_1.PREFIX,
@@ -103,6 +105,7 @@ function CommentObject(inProps) {
103
105
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
104
106
  // STATE
105
107
  const { obj, setObj } = (0, react_core_1.useSCFetchCommentObject)({ id: commentObjectId, commentObject, cacheStrategy });
108
+ const [collapsed, setCollapsed] = (0, react_1.useState)(obj === null || obj === void 0 ? void 0 : obj.collapsed);
106
109
  const [replyComment, setReplyComment] = (0, react_1.useState)(commentReply);
107
110
  const [isReplying, setIsReplying] = (0, react_1.useState)(false);
108
111
  const [isSavingComment, setIsSavingComment] = (0, react_1.useState)(false);
@@ -300,8 +303,8 @@ function CommentObject(inProps) {
300
303
  }
301
304
  const summaryHtmlTruncated = 'summary_truncated' in comment ? comment.summary_truncated : false;
302
305
  const commentHtml = 'summary_html' in comment && truncateContent && summaryHtmlTruncated ? comment.summary_html : comment.html;
303
- const summaryHtml = (0, contribution_1.getContributionHtml)(commentHtml, scRoutingContext.url);
304
- return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [editComment && editComment.id === comment.id ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.comment }, { children: (0, jsx_runtime_1.jsx)(CommentObjectReply_1.default, Object.assign({ text: comment.html, autoFocus: true, id: `edit-${comment.id}`, onSave: handleSave, onCancel: handleCancel, editable: !isReplying || !isSavingComment }, CommentObjectReplyProps)) }))) : ((0, jsx_runtime_1.jsx)(BaseItem_1.default, { elevation: 0, className: classes.comment, image: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!comment.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, comment.author) }), { onClick: comment.author.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !obj.author.community_badge }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: obj.author.username, variant: "circular", src: comment.author.avatar, className: classes.avatar }) })) })), disableTypography: true, primary: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Widget_1.default, Object.assign({ className: classes.content, elevation: elevation }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: (0, classnames_1.default)({ [classes.deleted]: obj && obj.deleted }) }, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ className: classes.author }, (!comment.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, comment.author) }), { onClick: comment.author.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "span" }, { children: comment.author.username })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, { className: classes.textContent, variant: "body2", gutterBottom: true, dangerouslySetInnerHTML: { __html: summaryHtml } }), summaryHtmlTruncated && truncateContent && ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.COMMENT_ROUTE_NAME, (0, contribution_1.getRouteData)(comment)), className: classes.showMoreContent }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.showMore", defaultMessage: "ui.commentObject.showMore" }) })))] })), scUserContext.user && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.commentActionsMenu }, { children: (0, jsx_runtime_1.jsx)(ContributionActionsMenu_1.default, { commentObject: comment, onRestoreContribution: handleRestore, onHideContribution: handleHide, onDeleteContribution: handleDelete, onEditContribution: handleEdit }) })))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ component: "span", className: classes.contentSubSection }, { children: [renderTimeAgo(comment), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(VoteButton_1.default, { size: "small", className: classes.vote, contributionId: comment.id, contributionType: types_1.SCContributionType.COMMENT, contribution: comment, onVote: handleVoteSuccess }), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), renderActionReply(comment), (0, jsx_runtime_1.jsx)(VoteAudienceButton_1.default, { size: "small", className: classes.voteAudience, contributionId: comment.id, contributionType: types_1.SCContributionType.COMMENT, contribution: comment })] }))] }) })), comment.comment_count > 0 && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.nestedComments }, { children: renderLatestComment(comment) })), scUserContext.user && replyComment && (replyComment.id === comment.id || replyComment.parent === comment.id) && !comment.parent && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.nestedComments }, { children: (0, jsx_runtime_1.jsx)(CommentObjectReply_1.default, Object.assign({ text: `@${replyComment.author.username}, `, autoFocus: true, id: `reply-${replyComment.id}`, onReply: handleReply, editable: !isReplying }, CommentObjectReplyProps), `reply-${replyComment.id}`) })))] }, comment.id));
306
+ const summaryHtml = (0, contribution_1.getCommentContributionHtml)(commentHtml, scRoutingContext.url);
307
+ return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [collapsed ? ((0, jsx_runtime_1.jsx)(BaseItem_1.default, { elevation: 0, className: classes.comment, disableTypography: true, primary: (0, jsx_runtime_1.jsxs)(Widget_1.default, Object.assign({ className: (0, classnames_1.default)(classes.content, classes.collapsed), elevation: elevation }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.CardContent, Object.assign({ className: (0, classnames_1.default)({ [classes.deleted]: obj && obj.deleted }) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.collapsed", defaultMessage: "ui.commentObject.collapsed" }) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.commentActionsMenu }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => setCollapsed(!collapsed) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "visibility" }) })) }))] })) })) : editComment && editComment.id === comment.id ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.comment }, { children: (0, jsx_runtime_1.jsx)(CommentObjectReply_1.default, Object.assign({ text: comment.html, autoFocus: true, id: `edit-${comment.id}`, onSave: handleSave, onCancel: handleCancel, editable: !isReplying || !isSavingComment }, CommentObjectReplyProps)) }))) : ((0, jsx_runtime_1.jsx)(BaseItem_1.default, { elevation: 0, className: classes.comment, image: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!comment.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, comment.author) }), { onClick: comment.author.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !obj.author.community_badge }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: obj.author.username, variant: "circular", src: comment.author.avatar, className: classes.avatar }) })) })), disableTypography: true, primary: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Widget_1.default, Object.assign({ className: classes.content, elevation: elevation }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: (0, classnames_1.default)({ [classes.deleted]: obj && obj.deleted }) }, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ className: classes.author }, (!comment.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, comment.author) }), { onClick: comment.author.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "span" }, { children: comment.author.username })) })), comment.collapsed && ((0, jsx_runtime_1.jsx)(material_1.Chip, { className: classes.flagChip, color: "error", size: "small", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.flag", defaultMessage: "ui.commentObject.flag" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, { className: classes.textContent, variant: "body2", gutterBottom: true, dangerouslySetInnerHTML: { __html: summaryHtml } }), summaryHtmlTruncated && truncateContent && ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.COMMENT_ROUTE_NAME, (0, contribution_1.getRouteData)(comment)), className: classes.showMoreContent }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.commentObject.showMore", defaultMessage: "ui.commentObject.showMore" }) })))] })), scUserContext.user && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.commentActionsMenu }, { children: (0, jsx_runtime_1.jsx)(ContributionActionsMenu_1.default, { commentObject: comment, onRestoreContribution: handleRestore, onHideContribution: handleHide, onDeleteContribution: handleDelete, onEditContribution: handleEdit }) })))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ component: "span", className: classes.contentSubSection }, { children: [renderTimeAgo(comment), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(VoteButton_1.default, { size: "small", className: classes.vote, contributionId: comment.id, contributionType: types_1.SCContributionType.COMMENT, contribution: comment, onVote: handleVoteSuccess }), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), renderActionReply(comment), (0, jsx_runtime_1.jsx)(VoteAudienceButton_1.default, { size: "small", className: classes.voteAudience, contributionId: comment.id, contributionType: types_1.SCContributionType.COMMENT, contribution: comment })] }))] }) })), comment.comment_count > 0 && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.nestedComments }, { children: renderLatestComment(comment) })), scUserContext.user && replyComment && (replyComment.id === comment.id || replyComment.parent === comment.id) && !comment.parent && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.nestedComments }, { children: (0, jsx_runtime_1.jsx)(CommentObjectReply_1.default, Object.assign({ text: `@${replyComment.author.username}, `, autoFocus: true, id: `reply-${replyComment.id}`, onReply: handleReply, editable: !isReplying }, CommentObjectReplyProps), `reply-${replyComment.id}`) })))] }, comment.id));
305
308
  }
306
309
  /**
307
310
  * Render Latest Comment
@@ -69,6 +69,9 @@ function CommentObjectReply(inProps) {
69
69
  const scUserContext = (0, react_core_1.useSCUser)();
70
70
  // RETRIEVE OBJECTS
71
71
  const [html, setHtml] = (0, react_1.useState)(text);
72
+ // HOOKS
73
+ const theme = (0, material_1.useTheme)();
74
+ const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
72
75
  // REFS
73
76
  let editor = (0, react_1.useRef)();
74
77
  /**
@@ -82,7 +85,7 @@ function CommentObjectReply(inProps) {
82
85
  * Focus on editor
83
86
  */
84
87
  const handleEditorFocus = () => {
85
- if (editor.current) {
88
+ if (!isMobile && editor.current) {
86
89
  editor.current.focus();
87
90
  }
88
91
  };
@@ -1,4 +1,4 @@
1
- import { ButtonProps } from '@mui/material/Button/Button';
1
+ import { ButtonProps } from '@mui/material';
2
2
  import { EventFormDialogProps } from '../EventFormDialog';
3
3
  export interface CreateEventButtonProps extends ButtonProps {
4
4
  /**
@@ -6,11 +6,11 @@ const material_1 = require("@mui/material");
6
6
  const styles_1 = require("@mui/material/styles");
7
7
  const system_1 = require("@mui/system");
8
8
  const react_core_1 = require("@selfcommunity/react-core");
9
+ const types_1 = require("@selfcommunity/types");
9
10
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
10
11
  const react_1 = tslib_1.__importStar(require("react"));
11
12
  const react_intl_1 = require("react-intl");
12
13
  const EventFormDialog_1 = tslib_1.__importDefault(require("../EventFormDialog"));
13
- const types_1 = require("@selfcommunity/types");
14
14
  const PREFIX = 'SCCreateEventButton';
15
15
  const classes = {
16
16
  root: `${PREFIX}-root`
@@ -15,8 +15,8 @@ const classes = {
15
15
  const Root = (0, styles_1.styled)(CreateEventButton_1.default, {
16
16
  name: PREFIX,
17
17
  slot: 'Root',
18
- overridesResolver: (props, styles) => styles.root
19
- })(({ theme }) => ({}));
18
+ overridesResolver: (_props, styles) => styles.root
19
+ })(() => ({}));
20
20
  /**
21
21
  *> API documentation for the Community-JS Create Event Button component. Learn about the available props and the CSS API.
22
22
  *
@@ -4,6 +4,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
4
4
  const LexicalAutoLinkPlugin_1 = require("@lexical/react/LexicalAutoLinkPlugin");
5
5
  const URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
6
6
  const EMAIL_MATCHER = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
7
+ const normalizeURL = (url) => {
8
+ if (!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('mailto:')) {
9
+ return `https://${url}`;
10
+ }
11
+ return url;
12
+ };
7
13
  const MATCHERS = [
8
14
  (text) => {
9
15
  const match = URL_MATCHER.exec(text);
@@ -11,7 +17,7 @@ const MATCHERS = [
11
17
  index: match.index,
12
18
  length: match[0].length,
13
19
  text: match[0],
14
- url: match[0]
20
+ url: normalizeURL(match[0])
15
21
  });
16
22
  },
17
23
  (text) => {
@@ -51,22 +51,22 @@ const classes = {
51
51
  const Root = (0, styles_1.styled)(Widget_1.default, {
52
52
  name: constants_1.PREFIX,
53
53
  slot: 'Root',
54
- overridesResolver: (props, styles) => styles.root
54
+ overridesResolver: (_props, styles) => styles.root
55
55
  })(() => ({}));
56
56
  const DetailRoot = (0, styles_1.styled)(material_1.Box, {
57
57
  name: constants_1.PREFIX,
58
58
  slot: 'DetailRoot',
59
- overridesResolver: (props, styles) => styles.detailRoot
59
+ overridesResolver: (_props, styles) => styles.detailRoot
60
60
  })(() => ({}));
61
61
  const PreviewRoot = (0, styles_1.styled)(material_1.Box, {
62
62
  name: constants_1.PREFIX,
63
63
  slot: 'PreviewRoot',
64
- overridesResolver: (props, styles) => styles.previewRoot
64
+ overridesResolver: (_props, styles) => styles.previewRoot
65
65
  })(() => ({}));
66
66
  const SnippetRoot = (0, styles_1.styled)(BaseItem_1.default, {
67
67
  name: constants_1.PREFIX,
68
68
  slot: 'SnippetRoot',
69
- overridesResolver: (props, styles) => styles.snippetRoot
69
+ overridesResolver: (_props, styles) => styles.snippetRoot
70
70
  })(() => ({}));
71
71
  /**
72
72
  * > API documentation for the Community-JS Event component. Learn about the available props and the CSS API.
@@ -6,7 +6,6 @@ const material_1 = require("@mui/material");
6
6
  const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
7
7
  const styles_1 = require("@mui/material/styles");
8
8
  const system_1 = require("@mui/system");
9
- const api_1 = require("@react-google-maps/api");
10
9
  const react_core_1 = require("@selfcommunity/react-core");
11
10
  const types_1 = require("@selfcommunity/types");
12
11
  const axios_1 = tslib_1.__importDefault(require("axios"));
@@ -20,6 +19,7 @@ const LiveStreamFormSettings_1 = tslib_1.__importDefault(require("../LiveStreamF
20
19
  const liveStream_1 = require("../../types/liveStream");
21
20
  const constants_2 = require("../LiveStreamForm/constants");
22
21
  const utils_1 = require("./utils");
22
+ const react_core_2 = require("@selfcommunity/react-core");
23
23
  const messages = (0, react_intl_1.defineMessages)({
24
24
  virtualPlaceholder: {
25
25
  id: 'ui.eventForm.address.online.placeholder',
@@ -69,11 +69,6 @@ function EventAddress(inProps) {
69
69
  const scContext = (0, react_core_1.useSCContext)();
70
70
  const scUserContext = (0, react_core_1.useSCUser)();
71
71
  const { preferences } = (0, react_core_1.useSCPreferences)();
72
- const geocodingApiKey = (0, react_1.useMemo)(() => scContext.settings.integrations && scContext.settings.integrations.geocoding.apiKey, [scContext.settings.integrations]);
73
- const { isLoaded } = (0, api_1.useLoadScript)({
74
- googleMapsApiKey: scContext.settings.integrations.geocoding.apiKey,
75
- libraries: ['places', 'geocoding']
76
- });
77
72
  const isFreeTrialTier = (0, react_1.useMemo)(() => preferences &&
78
73
  react_core_1.SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER in preferences &&
79
74
  preferences[react_core_1.SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value &&
@@ -91,6 +86,8 @@ function EventAddress(inProps) {
91
86
  (!isFreeTrialTier || (isFreeTrialTier && (scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) && (scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user.id) === 1)) &&
92
87
  (((_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_live_stream) || event.live_stream);
93
88
  }, [(_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.permission, event]);
89
+ // HOOKS
90
+ const { isLoaded, geocodingApiKey } = (0, react_core_2.useSCGoogleApiLoader)();
94
91
  // HANDLERS
95
92
  const handleChange = (_event, newValue) => {
96
93
  setLocation(newValue);
@@ -109,7 +106,7 @@ function EventAddress(inProps) {
109
106
  setGeoLocation(newValue);
110
107
  forwardGeolocationData({
111
108
  location,
112
- geolocation: place.formatted_address,
109
+ geolocation: newValue.description.split(',')[0] + '. ' + place.formatted_address,
113
110
  lat: place.geometry.location.lat,
114
111
  lng: place.geometry.location.lng
115
112
  });
@@ -157,7 +154,7 @@ function EventAddress(inProps) {
157
154
  if (!isInPersonTabActive && !isOnlineTabActive && !isLiveTabActive) {
158
155
  return null;
159
156
  }
160
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [isInPersonTabActive && ((0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) })), isOnlineTabActive && ((0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "play_circle_outline" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) })), isLiveTabActive && canViewLiveTab && ((0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.LIVESTREAM, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "photo_camera" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.liveStream.label", defaultMessage: "ui.eventForm.address.liveStream.label" }) }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.tabContent }, { children: [isInPersonTabActive && location === types_1.SCEventLocationType.PERSON && ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), isOnlineTabActive && location === types_1.SCEventLocationType.ONLINE && ((0, jsx_runtime_1.jsx)(UrlTextField_1.default, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
157
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [isInPersonTabActive && ((0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) })), isOnlineTabActive && ((0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "play_circle_outline" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) })), isLiveTabActive && canViewLiveTab && ((0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.LIVESTREAM, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "photo_camera" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.liveStream.label", defaultMessage: "ui.eventForm.address.liveStream.label" }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.tabContent }, { children: [isInPersonTabActive && location === types_1.SCEventLocationType.PERSON && ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { disabled: !geocodingApiKey, size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), isOnlineTabActive && location === types_1.SCEventLocationType.ONLINE && ((0, jsx_runtime_1.jsx)(UrlTextField_1.default, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
161
158
  endAdornment: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "play_circle_outline" })
162
159
  }, onChange: handleLinkChange })), isLiveTabActive && canViewLiveTab && location === types_1.SCEventLocationType.LIVESTREAM && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(LiveStream_1.default, { template: liveStream_1.SCLiveStreamTemplateType.SNIPPET, liveStream: liveStream, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}) }), (0, jsx_runtime_1.jsx)(LiveStreamFormSettings_1.default, { settings: liveStream.settings || constants_2.LIVESTREAM_DEFAULT_SETTINGS, onChange: handleLiveStreamSettingsChange })] }))] }))] })));
163
160
  }
@@ -116,7 +116,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
116
116
  * @param inProps
117
117
  */
118
118
  function EventForm(inProps) {
119
- var _a, _b, _c, _d, _e;
119
+ var _a, _b, _c, _d;
120
120
  //PROPS
121
121
  const props = (0, system_1.useThemeProps)({
122
122
  props: inProps,
@@ -153,7 +153,7 @@ function EventForm(inProps) {
153
153
  link: (event === null || event === void 0 ? void 0 : event.link) || '',
154
154
  liveStreamSettings: (event === null || event === void 0 ? void 0 : event.live_stream) ? event === null || event === void 0 ? void 0 : event.live_stream.settings : null,
155
155
  recurring: (event === null || event === void 0 ? void 0 : event.recurring) || types_1.SCEventRecurrenceType.NEVER,
156
- isPublic: (_b = (event === null || event === void 0 ? void 0 : event.privacy) === types_1.SCEventPrivacyType.PUBLIC) !== null && _b !== void 0 ? _b : true,
156
+ isPublic: (event === null || event === void 0 ? void 0 : event.privacy) === types_1.SCEventPrivacyType.PUBLIC || true,
157
157
  isSubmitting: false
158
158
  };
159
159
  // STATE
@@ -250,9 +250,7 @@ function EventForm(inProps) {
250
250
  })
251
251
  .catch((e) => {
252
252
  const _error = (0, api_services_1.formatHttpErrorCode)(e);
253
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
254
- // @ts-ignore
255
- if (Object.values(_error)[0].error === 'unique') {
253
+ if (Object.values(_error)[0]['error'] === 'unique') {
256
254
  setError(Object.assign(Object.assign({}, error), { ['nameError']: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.name.error.unique", defaultMessage: "ui.eventForm.name.error.unique" }) }));
257
255
  }
258
256
  else {
@@ -271,7 +269,7 @@ function EventForm(inProps) {
271
269
  utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
272
270
  onError === null || onError === void 0 ? void 0 : onError(e);
273
271
  });
274
- }, [field, privateEnabled, visibilityEnabled, onSuccess, onError]);
272
+ }, [field, privateEnabled, visibilityEnabled, onSuccess, onError, notifyChanges]);
275
273
  const handleChange = (0, react_1.useCallback)((event) => {
276
274
  const { name, value } = event.target;
277
275
  setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
@@ -280,7 +278,7 @@ function EventForm(inProps) {
280
278
  setError(error);
281
279
  }
282
280
  setGenericError(null);
283
- }, [error, setGenericError]);
281
+ }, [error, setField, setGenericError]);
284
282
  const handleChangeDateTime = (0, react_1.useCallback)((value, name) => {
285
283
  setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
286
284
  if (error[`${name}Error`]) {
@@ -292,29 +290,26 @@ function EventForm(inProps) {
292
290
  setError(error);
293
291
  }
294
292
  setGenericError(null);
295
- }, [error, setGenericError]);
296
- const shouldDisabledDate = (0, react_1.useCallback)((date) => {
293
+ }, [error, setField, setGenericError]);
294
+ const shouldDisableDate = (0, react_1.useCallback)((date) => {
297
295
  let disabled = false;
298
296
  switch (field.recurring) {
299
297
  case types_1.SCEventRecurrenceType.DAILY:
300
- disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.DAILY_LATER_DAYS).getTime();
298
+ disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.DAILY_LATER_DAYS, field.startDate).getTime();
301
299
  break;
302
300
  case types_1.SCEventRecurrenceType.WEEKLY:
303
- disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.WEEKLY_LATER_DAYS).getTime();
301
+ disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.WEEKLY_LATER_DAYS, field.startDate).getTime();
304
302
  break;
305
303
  case types_1.SCEventRecurrenceType.MONTHLY:
306
- disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.MONTHLY_LATER_DAYS).getTime();
304
+ disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.MONTHLY_LATER_DAYS, field.startDate).getTime();
307
305
  break;
308
306
  case types_1.SCEventRecurrenceType.NEVER:
309
307
  default:
310
- disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.NEVER_LATER_DAYS).getTime();
311
- }
312
- if (field.startDate.getDate() > date.getDate()) {
313
- disabled = true;
308
+ disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.NEVER_LATER_DAYS, field.startDate).getTime();
314
309
  }
315
310
  return disabled;
316
311
  }, [field]);
317
- const shouldDisabledTime = (0, react_1.useCallback)((date, _view) => field.startTime.getTime() > date.getTime(), [field]);
312
+ const shouldDisableTime = (0, react_1.useCallback)((date) => field.startTime.getTime() > date.getTime(), [field]);
318
313
  /**
319
314
  * Renders root object
320
315
  */
@@ -341,14 +336,26 @@ function EventForm(inProps) {
341
336
  return (0, jsx_runtime_1.jsx)("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
342
337
  }
343
338
  return ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${selected}.placeholder`, defaultMessage: `ui.eventForm.frequency.${selected}.placeholder` }));
344
- }, startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "frequency" }) }) })) }, { children: Object.values(types_1.SCEventRecurrenceType).map((f) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: f }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, minDate: field.startDate, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
339
+ }, startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "frequency" }) }) })) }, { children: Object.values(types_1.SCEventRecurrenceType).map((f) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: f }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, minDate: field.startDate, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
345
340
  textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endDate)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "calendar_off" }) }) }))) }) })))
346
- }, onChange: (value) => handleChangeDateTime(value, 'endDate'), shouldDisableDate: shouldDisabledDate }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
341
+ }, slotProps: {
342
+ toolbar: {
343
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
344
+ // @ts-ignore
345
+ toolbarTitle: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.title", defaultMessage: "ui.eventForm.date.title" })
346
+ }
347
+ }, onChange: (value) => handleChangeDateTime(value, 'endDate'), shouldDisableDate: shouldDisableDate }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
347
348
  textField: (params) => {
348
349
  var _a;
349
350
  return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }) }) }))) }), error: Boolean(error['endDateError']), helperText: ((_a = error['endDateError']) === null || _a === void 0 ? void 0 : _a.error) ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.error.invalid", defaultMessage: "ui.eventForm.time.end.error.invalid" })) : null })));
350
351
  }
351
- }, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisabledTime })] })) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, Object.assign({ forwardGeolocationData: handleGeoData, forwardLivestreamSettingsData: handleLiveStreamSettingsData, event: Object.assign(Object.assign({}, event), {
352
+ }, slotProps: {
353
+ toolbar: {
354
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
355
+ // @ts-ignore
356
+ toolbarTitle: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.title", defaultMessage: "ui.eventForm.time.title" })
357
+ }
358
+ }, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisableTime })] })) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, Object.assign({ forwardGeolocationData: handleGeoData, forwardLivestreamSettingsData: handleLiveStreamSettingsData, event: Object.assign(Object.assign({}, event), {
352
359
  name: field.name,
353
360
  start_date: field.startDate,
354
361
  location: field.location,
@@ -359,16 +366,16 @@ function EventForm(inProps) {
359
366
  settings: field.liveStreamSettings
360
367
  }
361
368
  }) }, EventAddressComponentProps)), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
362
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
363
- // @ts-ignore
369
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
370
+ // @ts-ignores
364
371
  b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
365
372
  } })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private.info", defaultMessage: "ui.eventForm.private.public.info", values: {
366
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
373
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
367
374
  // @ts-ignore
368
375
  b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
369
376
  } })) }))] }))), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
370
- endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) ? Event_1.EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : Event_1.EVENT_DESCRIPTION_MAX_LENGTH })))
371
- }, error: Boolean(((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null }), genericError && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.genericError }, { children: (0, jsx_runtime_1.jsx)(material_1.Alert, Object.assign({ variant: "filled", severity: "error" }, { children: genericError })) }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.actions }, { children: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
377
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) ? Event_1.EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : Event_1.EVENT_DESCRIPTION_MAX_LENGTH })))
378
+ }, error: Boolean(((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null }), genericError && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.genericError }, { children: (0, jsx_runtime_1.jsx)(material_1.Alert, Object.assign({ variant: "filled", severity: "error" }, { children: genericError })) }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.actions }, { children: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
372
379
  !field.startDate ||
373
380
  !field.startTime ||
374
381
  !field.endDate ||
@@ -1,5 +1,5 @@
1
1
  export declare const PREFIX = "SCEventForm";
2
- export declare const NEVER_LATER_DAYS = 14;
3
- export declare const DAILY_LATER_DAYS = 60;
4
- export declare const WEEKLY_LATER_DAYS = 360;
5
- export declare const MONTHLY_LATER_DAYS = 730;
2
+ export declare const NEVER_LATER_DAYS = 13;
3
+ export declare const DAILY_LATER_DAYS = 59;
4
+ export declare const WEEKLY_LATER_DAYS = 359;
5
+ export declare const MONTHLY_LATER_DAYS = 729;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MONTHLY_LATER_DAYS = exports.WEEKLY_LATER_DAYS = exports.DAILY_LATER_DAYS = exports.NEVER_LATER_DAYS = exports.PREFIX = void 0;
4
4
  exports.PREFIX = 'SCEventForm';
5
- exports.NEVER_LATER_DAYS = 14;
6
- exports.DAILY_LATER_DAYS = 60;
7
- exports.WEEKLY_LATER_DAYS = 360;
8
- exports.MONTHLY_LATER_DAYS = 730;
5
+ exports.NEVER_LATER_DAYS = 13; // 2 weeks less 1 day
6
+ exports.DAILY_LATER_DAYS = 59; // 60 days less 1 day
7
+ exports.WEEKLY_LATER_DAYS = 359; // 360 days less 1 day
8
+ exports.MONTHLY_LATER_DAYS = 729; // 2 years less 1 day
@@ -1,4 +1,4 @@
1
- export declare function getNewDate(date?: string): Date;
2
- export declare function getLaterHoursDate(h: number): Date;
3
- export declare function getLaterDaysDate(d: number): Date;
1
+ export declare function getNewDate(date?: string | Date): Date;
2
+ export declare function getLaterHoursDate(hours: number, date?: Date): Date;
3
+ export declare function getLaterDaysDate(days: number, date?: Date): Date;
4
4
  export declare const combineDateAndTime: (date: Date, time: Date) => string;
@@ -4,17 +4,20 @@ exports.combineDateAndTime = exports.getLaterDaysDate = exports.getLaterHoursDat
4
4
  const date_fns_1 = require("date-fns");
5
5
  function getNewDate(date) {
6
6
  if (date) {
7
- return new Date(date);
7
+ if (typeof date === 'string') {
8
+ return new Date(date);
9
+ }
10
+ return date;
8
11
  }
9
12
  return new Date();
10
13
  }
11
14
  exports.getNewDate = getNewDate;
12
- function getLaterHoursDate(h) {
13
- return (0, date_fns_1.addHours)(getNewDate(), h);
15
+ function getLaterHoursDate(hours, date) {
16
+ return (0, date_fns_1.addHours)(getNewDate(date), hours);
14
17
  }
15
18
  exports.getLaterHoursDate = getLaterHoursDate;
16
- function getLaterDaysDate(d) {
17
- return (0, date_fns_1.addDays)(getNewDate(), d);
19
+ function getLaterDaysDate(days, date) {
20
+ return (0, date_fns_1.addDays)(getNewDate(date), days);
18
21
  }
19
22
  exports.getLaterDaysDate = getLaterDaysDate;
20
23
  const combineDateAndTime = (date, time) => {
@@ -8,10 +8,8 @@ const system_1 = require("@mui/system");
8
8
  const react_core_1 = require("@selfcommunity/react-core");
9
9
  const types_1 = require("@selfcommunity/types");
10
10
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
11
- const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
12
11
  const react_1 = require("react");
13
12
  const react_intl_1 = require("react-intl");
14
- const PubSub_1 = require("../../constants/PubSub");
15
13
  const Bullet_1 = tslib_1.__importDefault(require("../../shared/Bullet"));
16
14
  const Calendar_1 = tslib_1.__importDefault(require("../../shared/Calendar"));
17
15
  const EventActionsMenu_1 = tslib_1.__importDefault(require("../../shared/EventActionsMenu"));
@@ -92,44 +90,15 @@ function EventHeader(inProps) {
92
90
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
93
91
  // INTL
94
92
  const intl = (0, react_intl_1.useIntl)();
95
- // REFS
96
- const updatesSubscription = (0, react_1.useRef)(null);
97
93
  // CONST
98
- const isEventAdmin = (0, react_1.useMemo)(() => scUserContext.user && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id) === scUserContext.user.id, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id]);
94
+ const isEventAdmin = (0, react_1.useMemo)(() => scUserContext.user && scEvent && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id) === scUserContext.user.id, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by]);
99
95
  const isEventFinished = (0, react_1.useMemo)(() => (0, events_1.checkEventFinished)(scEvent), [scEvent]);
100
- /**
101
- * Subscriber for pubsub callback
102
- */
103
- const onChangeEventMembersHandler = (0, react_1.useCallback)((msg, data) => {
104
- var _a;
105
- if (data && ((_a = data === null || data === void 0 ? void 0 : data.event) === null || _a === void 0 ? void 0 : _a.id) === (scEvent === null || scEvent === void 0 ? void 0 : scEvent.id)) {
106
- let _event = Object.assign({}, scEvent);
107
- if (msg === `${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCGroupEventType.ADD_MEMBER}`) {
108
- _event.subscribers_counter = _event.subscribers_counter + 1;
109
- }
110
- else if (msg === `${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCGroupEventType.REMOVE_MEMBER}`) {
111
- _event.subscribers_counter = Math.max(_event.subscribers_counter - 1, 0);
112
- }
113
- setSCEvent(_event);
114
- }
115
- }, [scEvent, setSCEvent]);
116
96
  /**
117
97
  * Handles callback subscribe/unsubscribe event
118
98
  */
119
- const handleSubscribe = (_event, status) => {
120
- setSCEvent(Object.assign({}, scEvent, { subscription_status: status }));
99
+ const handleSubscribe = (event) => {
100
+ setSCEvent(event);
121
101
  };
122
- /**
123
- * On mount, subscribe to receive events updates (only edit)
124
- */
125
- (0, react_1.useEffect)(() => {
126
- if (scEvent) {
127
- updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.MEMBERS}`, onChangeEventMembersHandler);
128
- }
129
- return () => {
130
- updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
131
- };
132
- }, [scEvent]);
133
102
  // RENDER
134
103
  if (!scEvent) {
135
104
  return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
@@ -172,6 +141,6 @@ function EventHeader(inProps) {
172
141
  month: 'long'
173
142
  }),
174
143
  hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
175
- } })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.visibility }, { children: [(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.visibility.public" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === types_1.SCEventLocationType.PERSON ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.online", defaultMessage: "ui.eventHeader.location.online" })) }))] })), (0, jsx_runtime_1.jsx)(User_1.default, { className: classes.planner, userId: scEvent.managed_by.id, secondary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isEventAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.multiActions }, { children: [(0, jsx_runtime_1.jsx)(EventInviteButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, disabled: isEventFinished }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [!isMobile && ((0, jsx_runtime_1.jsx)(EditEventButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data), disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(EventSubscribeButton_1.default, Object.assign({ eventId: scEvent.id, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })) }) })] }))] })));
144
+ } })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.visibility }, { children: [(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.visibility.public" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === types_1.SCEventLocationType.PERSON ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.online", defaultMessage: "ui.eventHeader.location.online" })) }))] })), (0, jsx_runtime_1.jsx)(User_1.default, { className: classes.planner, userId: scEvent.managed_by.id, secondary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isEventAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.multiActions }, { children: [(0, jsx_runtime_1.jsx)(EventInviteButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, disabled: isEventFinished }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [!isMobile && ((0, jsx_runtime_1.jsx)(EditEventButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, onEditSuccess: setSCEvent, disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(EventSubscribeButton_1.default, Object.assign({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: setSCEvent }, EventActionsProps))] })) }) })] }))] })));
176
145
  }
177
146
  exports.default = EventHeader;