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