@selfcommunity/react-ui 0.9.2-alpha.0 → 0.10.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/CategoryFollowersButton/CategoryFollowersButton.d.ts +2 -2
- package/lib/cjs/components/CategoryFollowersButton/CategoryFollowersButton.js +14 -12
- package/lib/cjs/components/EventParticipantsButton/EventParticipantsButton.js +5 -3
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +2 -2
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +16 -14
- package/lib/cjs/utils/buttonCounters.d.ts +1 -0
- package/lib/cjs/utils/buttonCounters.js +15 -0
- package/lib/esm/components/CategoryFollowersButton/CategoryFollowersButton.d.ts +2 -2
- package/lib/esm/components/CategoryFollowersButton/CategoryFollowersButton.js +14 -12
- package/lib/esm/components/EventParticipantsButton/EventParticipantsButton.js +5 -3
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +2 -2
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +16 -14
- package/lib/esm/utils/buttonCounters.d.ts +1 -0
- package/lib/esm/utils/buttonCounters.js +11 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +2 -2
|
@@ -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
|
|
9
|
-
const
|
|
10
|
-
const
|
|
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
|
|
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`,
|
|
@@ -122,9 +123,10 @@ function CategoryFollowersButton(inProps) {
|
|
|
122
123
|
const handleToggleDialogOpen = (0, react_1.useMemo)(() => () => {
|
|
123
124
|
setOpen((prev) => !prev);
|
|
124
125
|
}, [setOpen]);
|
|
126
|
+
const renderSurplus = (0, react_1.useCallback)(() => (0, buttonCounters_1.numberFormatter)(scCategory.followers_counter), [scCategory]);
|
|
125
127
|
// RENDER
|
|
126
128
|
const theme = (0, material_1.useTheme)();
|
|
127
129
|
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))) }) })) })))] }));
|
|
130
|
+
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, 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
131
|
}
|
|
130
132
|
exports.default = CategoryFollowersButton;
|
|
@@ -16,6 +16,7 @@ const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
|
16
16
|
const Errors_1 = require("../../constants/Errors");
|
|
17
17
|
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
18
18
|
const InfiniteScroll_1 = tslib_1.__importDefault(require("../../shared/InfiniteScroll"));
|
|
19
|
+
const buttonCounters_1 = require("../../utils/buttonCounters");
|
|
19
20
|
const AvatarGroupSkeleton_1 = tslib_1.__importDefault(require("../Skeleton/AvatarGroupSkeleton"));
|
|
20
21
|
const User_1 = tslib_1.__importStar(require("../User"));
|
|
21
22
|
const PREFIX = 'SCEventParticipantsButton';
|
|
@@ -73,8 +74,8 @@ function EventParticipantsButton(inProps) {
|
|
|
73
74
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
74
75
|
// HOOKS
|
|
75
76
|
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
76
|
-
const participantsAvailable = (0, react_1.useMemo)(() => scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC ||
|
|
77
|
-
[types_1.SCEventSubscriptionStatusType.SUBSCRIBED, types_1.SCEventSubscriptionStatusType.GOING, types_1.SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent.subscription_status) > -1, [scEvent]);
|
|
77
|
+
const participantsAvailable = (0, react_1.useMemo)(() => (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === types_1.SCEventPrivacyType.PUBLIC ||
|
|
78
|
+
[types_1.SCEventSubscriptionStatusType.SUBSCRIBED, types_1.SCEventSubscriptionStatusType.GOING, types_1.SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1, [scEvent]);
|
|
78
79
|
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
79
80
|
setFollowers([]);
|
|
80
81
|
setLoading(true);
|
|
@@ -125,12 +126,13 @@ function EventParticipantsButton(inProps) {
|
|
|
125
126
|
.catch((error) => utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error))
|
|
126
127
|
.then(() => setLoading(false));
|
|
127
128
|
}, [followers, scEvent, next]);
|
|
129
|
+
const renderSurplus = (0, react_1.useCallback)(() => (0, buttonCounters_1.numberFormatter)(followers.length), [followers]);
|
|
128
130
|
/**
|
|
129
131
|
* Opens dialog votes
|
|
130
132
|
*/
|
|
131
133
|
const handleToggleDialogOpen = (0, react_1.useCallback)(() => {
|
|
132
134
|
setOpen((prev) => !prev);
|
|
133
135
|
}, [setOpen]);
|
|
134
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scEvent || scEvent.goings_counter === 0 }, rest, { children: [!hideCaption && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.participants, variant: "caption" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.participants", id: "ui.eventParticipantsButton.participants" }) }))), !followers.length && (loading || !scEvent) ? ((0, jsx_runtime_1.jsx)(AvatarGroupSkeleton_1.default, Object.assign({}, rest, (!participantsAvailable && { skeletonsAnimation: false })))) : ((0, jsx_runtime_1.jsx)(material_1.AvatarGroup, Object.assign({ total: followers.length }, { children: followers.map((c) => ((0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: c.username, src: c.avatar, className: classes.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.eventParticipantsButton.dialogTitle", id: "ui.eventParticipantsButton.dialogTitle", values: { total: scEvent.goings_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 }), className: classes.infiniteScroll, 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.eventParticipantsButton.noOtherParticipants", defaultMessage: "ui.eventParticipantsButton.noOtherParticipants" }) })) }, { 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))) }) })) })))] }));
|
|
136
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scEvent || scEvent.goings_counter === 0 }, rest, { children: [!hideCaption && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.participants, variant: "caption" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.participants", id: "ui.eventParticipantsButton.participants" }) }))), !followers.length && (loading || !scEvent) ? ((0, jsx_runtime_1.jsx)(AvatarGroupSkeleton_1.default, Object.assign({}, rest, (!participantsAvailable && { skeletonsAnimation: false })))) : ((0, jsx_runtime_1.jsx)(material_1.AvatarGroup, Object.assign({ total: followers.length, renderSurplus: renderSurplus }, { children: followers.map((c) => ((0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: c.username, src: c.avatar, className: classes.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.eventParticipantsButton.dialogTitle", id: "ui.eventParticipantsButton.dialogTitle", values: { total: scEvent.goings_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 }), className: classes.infiniteScroll, 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.eventParticipantsButton.noOtherParticipants", defaultMessage: "ui.eventParticipantsButton.noOtherParticipants" }) })) }, { 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))) }) })) })))] }));
|
|
135
137
|
}
|
|
136
138
|
exports.default = EventParticipantsButton;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
2
|
-
import { SCGroupType } from '@selfcommunity/types';
|
|
3
1
|
import { ButtonProps } from '@mui/material/Button/Button';
|
|
2
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
+
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
4
4
|
export interface GroupMembersButtonProps extends Pick<ButtonProps, Exclude<keyof ButtonProps, 'onClick' | 'disabled'>> {
|
|
5
5
|
/**
|
|
6
6
|
* Group Object
|
|
@@ -2,23 +2,24 @@
|
|
|
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
|
|
9
|
-
const
|
|
10
|
-
const
|
|
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
11
|
const types_1 = require("@selfcommunity/types");
|
|
15
|
-
const AvatarGroupSkeleton_1 = tslib_1.__importDefault(require("../Skeleton/AvatarGroupSkeleton"));
|
|
16
|
-
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
17
|
-
const system_1 = require("@mui/system");
|
|
18
|
-
const useMediaQuery_1 = tslib_1.__importDefault(require("@mui/material/useMediaQuery"));
|
|
19
12
|
const utils_1 = require("@selfcommunity/utils");
|
|
20
|
-
const
|
|
13
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
14
|
+
const react_1 = require("react");
|
|
15
|
+
const react_intl_1 = require("react-intl");
|
|
21
16
|
const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
17
|
+
const Errors_1 = require("../../constants/Errors");
|
|
18
|
+
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
19
|
+
const InfiniteScroll_1 = tslib_1.__importDefault(require("../../shared/InfiniteScroll"));
|
|
20
|
+
const buttonCounters_1 = require("../../utils/buttonCounters");
|
|
21
|
+
const AvatarGroupSkeleton_1 = tslib_1.__importDefault(require("../Skeleton/AvatarGroupSkeleton"));
|
|
22
|
+
const User_1 = tslib_1.__importStar(require("../User"));
|
|
22
23
|
const PREFIX = 'SCGroupMembersButton';
|
|
23
24
|
const classes = {
|
|
24
25
|
root: `${PREFIX}-root`,
|
|
@@ -28,12 +29,12 @@ const classes = {
|
|
|
28
29
|
const Root = (0, styles_1.styled)(material_1.Button, {
|
|
29
30
|
name: PREFIX,
|
|
30
31
|
slot: 'Root',
|
|
31
|
-
overridesResolver: (
|
|
32
|
+
overridesResolver: (_props, styles) => styles.root
|
|
32
33
|
})(() => ({}));
|
|
33
34
|
const DialogRoot = (0, styles_1.styled)(BaseDialog_1.default, {
|
|
34
35
|
name: PREFIX,
|
|
35
36
|
slot: 'Root',
|
|
36
|
-
overridesResolver: (
|
|
37
|
+
overridesResolver: (_props, styles) => styles.dialogRoot
|
|
37
38
|
})(() => ({}));
|
|
38
39
|
/**
|
|
39
40
|
*> API documentation for the Community-JS Group Members Button component. Learn about the available props and the CSS API.
|
|
@@ -127,9 +128,10 @@ function GroupMembersButton(inProps) {
|
|
|
127
128
|
const handleToggleDialogOpen = (0, react_1.useMemo)(() => () => {
|
|
128
129
|
setOpen((prev) => !prev);
|
|
129
130
|
}, [setOpen]);
|
|
131
|
+
const renderSurplus = (0, react_1.useCallback)(() => (0, buttonCounters_1.numberFormatter)(scGroup.subscribers_counter), [scGroup]);
|
|
130
132
|
// RENDER
|
|
131
133
|
const theme = (0, material_1.useTheme)();
|
|
132
134
|
const isMobile = (0, useMediaQuery_1.default)(theme.breakpoints.down('md'));
|
|
133
|
-
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 || !scGroup || scGroup.subscribers_counter === 0 }, rest, { children: loading || !scGroup ? ((0, jsx_runtime_1.jsx)(AvatarGroupSkeleton_1.default, Object.assign({}, rest))) : ((0, jsx_runtime_1.jsx)(material_1.AvatarGroup, Object.assign({ total: scGroup.subscribers_counter }, { children: members.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.groupMembersButton.dialogTitle", id: "ui.groupMembersButton.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: (0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ dataLength: members.length, next: fetchMembers, 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.groupMembersButton.noOtherMembers", defaultMessage: "ui.groupMembersButton.noOtherMembers" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: members.map((member) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, { elevation: 0, user: member, onClick: handleToggleDialogOpen }) }, member.id))) }) })) })))] }));
|
|
135
|
+
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 || !scGroup || scGroup.subscribers_counter === 0 }, rest, { children: loading || !scGroup ? ((0, jsx_runtime_1.jsx)(AvatarGroupSkeleton_1.default, Object.assign({}, rest))) : ((0, jsx_runtime_1.jsx)(material_1.AvatarGroup, Object.assign({ total: scGroup.subscribers_counter, renderSurplus: renderSurplus }, { children: members.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.groupMembersButton.dialogTitle", id: "ui.groupMembersButton.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: (0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ dataLength: members.length, next: fetchMembers, 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.groupMembersButton.noOtherMembers", defaultMessage: "ui.groupMembersButton.noOtherMembers" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: members.map((member) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, { elevation: 0, user: member, onClick: handleToggleDialogOpen }) }, member.id))) }) })) })))] }));
|
|
134
136
|
}
|
|
135
137
|
exports.default = GroupMembersButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function numberFormatter(num: number): JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.numberFormatter = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
function numberFormatter(num) {
|
|
6
|
+
const surplus = num - 3;
|
|
7
|
+
if (surplus > 999999) {
|
|
8
|
+
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", (Math.abs(surplus) / 1000000).toFixed(1), "M"] });
|
|
9
|
+
}
|
|
10
|
+
else if (num > 999) {
|
|
11
|
+
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", (Math.abs(surplus) / 1000).toFixed(1), "K"] });
|
|
12
|
+
}
|
|
13
|
+
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", surplus] });
|
|
14
|
+
}
|
|
15
|
+
exports.numberFormatter = numberFormatter;
|
|
@@ -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`,
|
|
@@ -120,8 +121,9 @@ export default function CategoryFollowersButton(inProps) {
|
|
|
120
121
|
const handleToggleDialogOpen = useMemo(() => () => {
|
|
121
122
|
setOpen((prev) => !prev);
|
|
122
123
|
}, [setOpen]);
|
|
124
|
+
const renderSurplus = useCallback(() => numberFormatter(scCategory.followers_counter), [scCategory]);
|
|
123
125
|
// RENDER
|
|
124
126
|
const theme = useTheme();
|
|
125
127
|
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 }, rest, { children: loading || !scCategory ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest))) : (_jsx(AvatarGroup, Object.assign({ total: scCategory.followers_counter }, { 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))) }) })) })))] }));
|
|
128
|
+
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scCategory || scCategory.followers_counter === 0 }, 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
129
|
}
|
|
@@ -14,6 +14,7 @@ import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
|
|
|
14
14
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
15
15
|
import BaseDialog from '../../shared/BaseDialog';
|
|
16
16
|
import InfiniteScroll from '../../shared/InfiniteScroll';
|
|
17
|
+
import { numberFormatter } from '../../utils/buttonCounters';
|
|
17
18
|
import AvatarGroupSkeleton from '../Skeleton/AvatarGroupSkeleton';
|
|
18
19
|
import User, { UserSkeleton } from '../User';
|
|
19
20
|
const PREFIX = 'SCEventParticipantsButton';
|
|
@@ -71,8 +72,8 @@ export default function EventParticipantsButton(inProps) {
|
|
|
71
72
|
const [open, setOpen] = useState(false);
|
|
72
73
|
// HOOKS
|
|
73
74
|
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
74
|
-
const participantsAvailable = useMemo(() => scEvent.privacy === SCEventPrivacyType.PUBLIC ||
|
|
75
|
-
[SCEventSubscriptionStatusType.SUBSCRIBED, SCEventSubscriptionStatusType.GOING, SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent.subscription_status) > -1, [scEvent]);
|
|
75
|
+
const participantsAvailable = useMemo(() => (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === SCEventPrivacyType.PUBLIC ||
|
|
76
|
+
[SCEventSubscriptionStatusType.SUBSCRIBED, SCEventSubscriptionStatusType.GOING, SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1, [scEvent]);
|
|
76
77
|
useDeepCompareEffectNoCheck(() => {
|
|
77
78
|
setFollowers([]);
|
|
78
79
|
setLoading(true);
|
|
@@ -123,11 +124,12 @@ export default function EventParticipantsButton(inProps) {
|
|
|
123
124
|
.catch((error) => Logger.error(SCOPE_SC_UI, error))
|
|
124
125
|
.then(() => setLoading(false));
|
|
125
126
|
}, [followers, scEvent, next]);
|
|
127
|
+
const renderSurplus = useCallback(() => numberFormatter(followers.length), [followers]);
|
|
126
128
|
/**
|
|
127
129
|
* Opens dialog votes
|
|
128
130
|
*/
|
|
129
131
|
const handleToggleDialogOpen = useCallback(() => {
|
|
130
132
|
setOpen((prev) => !prev);
|
|
131
133
|
}, [setOpen]);
|
|
132
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scEvent || scEvent.goings_counter === 0 }, rest, { children: [!hideCaption && (_jsx(Typography, Object.assign({ className: classes.participants, variant: "caption" }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.participants", id: "ui.eventParticipantsButton.participants" }) }))), !followers.length && (loading || !scEvent) ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest, (!participantsAvailable && { skeletonsAnimation: false })))) : (_jsx(AvatarGroup, Object.assign({ total: followers.length }, { children: followers.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar, className: classes.avatar }, c.id))) })))] })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.dialogTitle", id: "ui.eventParticipantsButton.dialogTitle", values: { total: scEvent.goings_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 }), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventParticipantsButton.noOtherParticipants", defaultMessage: "ui.eventParticipantsButton.noOtherParticipants" }) })) }, { children: _jsx(List, { children: followers.map((follower) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: follower }) }, follower.id))) }) })) })))] }));
|
|
134
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scEvent || scEvent.goings_counter === 0 }, rest, { children: [!hideCaption && (_jsx(Typography, Object.assign({ className: classes.participants, variant: "caption" }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.participants", id: "ui.eventParticipantsButton.participants" }) }))), !followers.length && (loading || !scEvent) ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest, (!participantsAvailable && { skeletonsAnimation: false })))) : (_jsx(AvatarGroup, Object.assign({ total: followers.length, renderSurplus: renderSurplus }, { children: followers.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar, className: classes.avatar }, c.id))) })))] })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.dialogTitle", id: "ui.eventParticipantsButton.dialogTitle", values: { total: scEvent.goings_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 }), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventParticipantsButton.noOtherParticipants", defaultMessage: "ui.eventParticipantsButton.noOtherParticipants" }) })) }, { children: _jsx(List, { children: followers.map((follower) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: follower }) }, follower.id))) }) })) })))] }));
|
|
133
135
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
2
|
-
import { SCGroupType } from '@selfcommunity/types';
|
|
3
1
|
import { ButtonProps } from '@mui/material/Button/Button';
|
|
2
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
+
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
4
4
|
export interface GroupMembersButtonProps extends Pick<ButtonProps, Exclude<keyof ButtonProps, 'onClick' | 'disabled'>> {
|
|
5
5
|
/**
|
|
6
6
|
* Group Object
|
|
@@ -1,22 +1,23 @@
|
|
|
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 { Endpoints, GroupService, http } from '@selfcommunity/api-services';
|
|
11
8
|
import { useSCFetchGroup } from '@selfcommunity/react-core';
|
|
12
9
|
import { SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
|
|
13
|
-
import AvatarGroupSkeleton from '../Skeleton/AvatarGroupSkeleton';
|
|
14
|
-
import classNames from 'classnames';
|
|
15
|
-
import { useThemeProps } from '@mui/system';
|
|
16
|
-
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
17
10
|
import { Logger } from '@selfcommunity/utils';
|
|
18
|
-
import
|
|
11
|
+
import classNames from 'classnames';
|
|
12
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
13
|
+
import { FormattedMessage } from 'react-intl';
|
|
19
14
|
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
|
|
15
|
+
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
16
|
+
import BaseDialog from '../../shared/BaseDialog';
|
|
17
|
+
import InfiniteScroll from '../../shared/InfiniteScroll';
|
|
18
|
+
import { numberFormatter } from '../../utils/buttonCounters';
|
|
19
|
+
import AvatarGroupSkeleton from '../Skeleton/AvatarGroupSkeleton';
|
|
20
|
+
import User, { UserSkeleton } from '../User';
|
|
20
21
|
const PREFIX = 'SCGroupMembersButton';
|
|
21
22
|
const classes = {
|
|
22
23
|
root: `${PREFIX}-root`,
|
|
@@ -26,12 +27,12 @@ const classes = {
|
|
|
26
27
|
const Root = styled(Button, {
|
|
27
28
|
name: PREFIX,
|
|
28
29
|
slot: 'Root',
|
|
29
|
-
overridesResolver: (
|
|
30
|
+
overridesResolver: (_props, styles) => styles.root
|
|
30
31
|
})(() => ({}));
|
|
31
32
|
const DialogRoot = styled(BaseDialog, {
|
|
32
33
|
name: PREFIX,
|
|
33
34
|
slot: 'Root',
|
|
34
|
-
overridesResolver: (
|
|
35
|
+
overridesResolver: (_props, styles) => styles.dialogRoot
|
|
35
36
|
})(() => ({}));
|
|
36
37
|
/**
|
|
37
38
|
*> API documentation for the Community-JS Group Members Button component. Learn about the available props and the CSS API.
|
|
@@ -125,8 +126,9 @@ export default function GroupMembersButton(inProps) {
|
|
|
125
126
|
const handleToggleDialogOpen = useMemo(() => () => {
|
|
126
127
|
setOpen((prev) => !prev);
|
|
127
128
|
}, [setOpen]);
|
|
129
|
+
const renderSurplus = useCallback(() => numberFormatter(scGroup.subscribers_counter), [scGroup]);
|
|
128
130
|
// RENDER
|
|
129
131
|
const theme = useTheme();
|
|
130
132
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
131
|
-
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scGroup || scGroup.subscribers_counter === 0 }, rest, { children: loading || !scGroup ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest))) : (_jsx(AvatarGroup, Object.assign({ total: scGroup.subscribers_counter }, { children: members.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.groupMembersButton.dialogTitle", id: "ui.groupMembersButton.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: members.length, next: fetchMembers, 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.groupMembersButton.noOtherMembers", defaultMessage: "ui.groupMembersButton.noOtherMembers" }) })) }, { children: _jsx(List, { children: members.map((member) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: member, onClick: handleToggleDialogOpen }) }, member.id))) }) })) })))] }));
|
|
133
|
+
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scGroup || scGroup.subscribers_counter === 0 }, rest, { children: loading || !scGroup ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest))) : (_jsx(AvatarGroup, Object.assign({ total: scGroup.subscribers_counter, renderSurplus: renderSurplus }, { children: members.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.groupMembersButton.dialogTitle", id: "ui.groupMembersButton.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: members.length, next: fetchMembers, 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.groupMembersButton.noOtherMembers", defaultMessage: "ui.groupMembersButton.noOtherMembers" }) })) }, { children: _jsx(List, { children: members.map((member) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: member, onClick: handleToggleDialogOpen }) }, member.id))) }) })) })))] }));
|
|
132
134
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function numberFormatter(num: number): JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function numberFormatter(num) {
|
|
3
|
+
const surplus = num - 3;
|
|
4
|
+
if (surplus > 999999) {
|
|
5
|
+
return _jsxs(_Fragment, { children: ["+", (Math.abs(surplus) / 1000000).toFixed(1), "M"] });
|
|
6
|
+
}
|
|
7
|
+
else if (num > 999) {
|
|
8
|
+
return _jsxs(_Fragment, { children: ["+", (Math.abs(surplus) / 1000).toFixed(1), "K"] });
|
|
9
|
+
}
|
|
10
|
+
return _jsxs(_Fragment, { children: ["+", surplus] });
|
|
11
|
+
}
|