@selfcommunity/react-ui 0.7.9-alpha.3 → 0.7.9-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
  2. package/lib/cjs/components/Composer/Attributes/Attributes.js +7 -0
  3. package/lib/cjs/components/Composer/Composer.d.ts +2 -1
  4. package/lib/cjs/components/Composer/Composer.js +40 -11
  5. package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  6. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
  7. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +35 -13
  8. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  9. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
  10. package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
  11. package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  12. package/lib/cjs/components/EditGroupButton/EditGroupButton.js +57 -0
  13. package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
  14. package/lib/cjs/components/EditGroupButton/index.js +5 -0
  15. package/lib/cjs/components/Group/Group.d.ts +4 -3
  16. package/lib/cjs/components/Group/Group.js +2 -2
  17. package/lib/cjs/components/Group/Skeleton.js +1 -1
  18. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  19. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
  20. package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
  21. package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
  22. package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
  23. package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
  24. package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
  25. package/lib/cjs/components/{CreateGroup → GroupForm}/constants.js +1 -1
  26. package/lib/cjs/components/GroupForm/index.d.ts +3 -0
  27. package/lib/cjs/components/GroupForm/index.js +5 -0
  28. package/lib/cjs/components/GroupHeader/GroupHeader.js +4 -2
  29. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
  30. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +5 -4
  31. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +18 -16
  32. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
  33. package/lib/cjs/components/Groups/Groups.d.ts +1 -1
  34. package/lib/cjs/components/Groups/Groups.js +16 -19
  35. package/lib/cjs/components/Groups/Skeleton.d.ts +14 -2
  36. package/lib/cjs/components/Groups/Skeleton.js +12 -5
  37. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  38. package/lib/cjs/index.d.ts +4 -3
  39. package/lib/cjs/index.js +7 -5
  40. package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
  41. package/lib/esm/components/Composer/Attributes/Attributes.js +7 -0
  42. package/lib/esm/components/Composer/Composer.d.ts +2 -1
  43. package/lib/esm/components/Composer/Composer.js +40 -11
  44. package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  45. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
  46. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +34 -13
  47. package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  48. package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
  49. package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
  50. package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  51. package/lib/esm/components/EditGroupButton/EditGroupButton.js +54 -0
  52. package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
  53. package/lib/esm/components/EditGroupButton/index.js +2 -0
  54. package/lib/esm/components/Group/Group.d.ts +4 -3
  55. package/lib/esm/components/Group/Group.js +2 -2
  56. package/lib/esm/components/Group/Skeleton.js +1 -1
  57. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  58. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
  59. package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
  60. package/lib/esm/components/GroupAutocomplete/index.js +2 -0
  61. package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
  62. package/lib/esm/components/GroupForm/GroupForm.js +236 -0
  63. package/lib/esm/components/GroupForm/constants.d.ts +1 -0
  64. package/lib/esm/components/GroupForm/constants.js +1 -0
  65. package/lib/esm/components/GroupForm/index.d.ts +3 -0
  66. package/lib/esm/components/GroupForm/index.js +2 -0
  67. package/lib/esm/components/GroupHeader/GroupHeader.js +4 -2
  68. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
  69. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +5 -4
  70. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +19 -17
  71. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
  72. package/lib/esm/components/Groups/Groups.d.ts +1 -1
  73. package/lib/esm/components/Groups/Groups.js +17 -20
  74. package/lib/esm/components/Groups/Skeleton.d.ts +14 -2
  75. package/lib/esm/components/Groups/Skeleton.js +13 -5
  76. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  77. package/lib/esm/index.d.ts +4 -3
  78. package/lib/esm/index.js +3 -2
  79. package/lib/umd/react-ui.js +1 -1
  80. package/package.json +6 -6
  81. package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
  82. package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
  83. package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
  84. package/lib/cjs/components/CreateGroup/index.js +0 -5
  85. package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
  86. package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
  87. package/lib/esm/components/CreateGroup/constants.js +0 -1
  88. package/lib/esm/components/CreateGroup/index.d.ts +0 -3
  89. package/lib/esm/components/CreateGroup/index.js +0 -2
@@ -0,0 +1,236 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useState } from 'react';
3
+ import { useThemeProps } from '@mui/system';
4
+ import { styled } from '@mui/material/styles';
5
+ import { Avatar, Box, Divider, FormGroup, Icon, Paper, Stack, Switch, TextField, Typography } from '@mui/material';
6
+ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
7
+ import { SCPreferences, useSCPreferences } from '@selfcommunity/react-core';
8
+ import classNames from 'classnames';
9
+ import { PREFIX } from './constants';
10
+ import BaseDialog from '../../shared/BaseDialog';
11
+ import { LoadingButton } from '@mui/lab';
12
+ import ChangeGroupPicture from '../ChangeGroupPicture';
13
+ import ChangeGroupCover from '../ChangeGroupCover';
14
+ import { GROUP_DESCRIPTION_MAX_LENGTH, GROUP_TITLE_MAX_LENGTH } from '../../constants/Group';
15
+ import GroupInviteButton from '../GroupInviteButton';
16
+ import { SCGroupPrivacyType } from '@selfcommunity/types';
17
+ import { SCOPE_SC_UI } from '../../constants/Errors';
18
+ import { formatHttpErrorCode, GroupService } from '@selfcommunity/api-services';
19
+ import { Logger } from '@selfcommunity/utils';
20
+ const messages = defineMessages({
21
+ name: {
22
+ id: 'ui.groupForm.name.placeholder',
23
+ defaultMessage: 'ui.groupForm.name.placeholder'
24
+ },
25
+ description: {
26
+ id: 'ui.groupForm.description.placeholder',
27
+ defaultMessage: 'ui.groupForm.description.placeholder'
28
+ }
29
+ });
30
+ const classes = {
31
+ root: `${PREFIX}-root`,
32
+ active: `${PREFIX}-active`,
33
+ title: `${PREFIX}-title`,
34
+ header: `${PREFIX}-header`,
35
+ cover: `${PREFIX}-cover`,
36
+ avatar: `${PREFIX}-avatar`,
37
+ form: `${PREFIX}-form`,
38
+ switch: `${PREFIX}-switch`,
39
+ switchLabel: `${PREFIX}-switch-label`,
40
+ name: `${PREFIX}-name`,
41
+ description: `${PREFIX}-description`,
42
+ content: `${PREFIX}-content`,
43
+ privacySection: `${PREFIX}-privacy-section`,
44
+ privacySectionInfo: `${PREFIX}-privacy-section-info`,
45
+ visibilitySection: `${PREFIX}-visibility-section`,
46
+ visibilitySectionInfo: `${PREFIX}-visibility-section-info`,
47
+ inviteSection: `${PREFIX}-invite-section`,
48
+ error: `${PREFIX}-error`
49
+ };
50
+ const Root = styled(BaseDialog, {
51
+ name: PREFIX,
52
+ slot: 'Root'
53
+ })(() => ({}));
54
+ /**
55
+ *> API documentation for the Community-JS Group Form component. Learn about the available props and the CSS API.
56
+ *
57
+ #### Import
58
+ ```jsx
59
+ import {GroupForm} from '@selfcommunity/react-ui';
60
+ ```
61
+
62
+ #### Component Name
63
+ The name `SCGroupForm` can be used when providing style overrides in the theme.
64
+
65
+ #### CSS
66
+
67
+ |Rule Name|Global class|Description|
68
+ |---|---|---|
69
+ |root|.SCGroupForm-root|Styles applied to the root element.|
70
+ |active|.SCGroupForm-active|Styles applied to the active element.|
71
+ |title|.SCGroupForm-title|Styles applied to the title element.|
72
+ |header|.SCGroupForm-header|Styles applied to the header element.|
73
+ |cover|.SCGroupForm-cover|Styles applied to the cover field.|
74
+ |avatar|.SCGroupForm-avatar|Styles applied to the avatar field.|
75
+ |form|.SCGroupForm-form|Styles applied to the form element.|
76
+ |switch|.SCGroupForm-switch|Styles applied to the switch element.|
77
+ |switchLabel|.SCGroupForm-switch-label|Styles applied to the switchLabel element.|
78
+ |name|.SCGroupForm-name|Styles applied to the name field.|
79
+ |description|.SCGroupForm-description|Styles applied to the description field.|
80
+ |content|.SCGroupForm-content|Styles applied to the element.|
81
+ |privacySection|.SCGroupForm-privacy-section|Styles applied to the privacy section.|
82
+ |privacySectionInfo|.SCGroupForm-privacy-section-info|Styles applied to the privacy info section.|
83
+ |visibilitySection|.SCGroupForm-visibility-section|Styles applied to the visibility section.|
84
+ |visibilitySectionInfo|.SCGroupForm-visibility-section-info|Styles applied to the visibility section info.|
85
+ |inviteSection|.SCGroupForm-invite-section|Styles applied to the invite section.|
86
+ |error|.SCGroupForm-error|Styles applied to the error elements.|
87
+
88
+ * @param inProps
89
+ */
90
+ export default function GroupForm(inProps) {
91
+ //PROPS
92
+ const props = useThemeProps({
93
+ props: inProps,
94
+ name: PREFIX
95
+ });
96
+ const { className, open = true, onClose, onSuccess, group = null } = props, rest = __rest(props, ["className", "open", "onClose", "onSuccess", "group"]);
97
+ const initialFieldState = {
98
+ imageOriginal: group ? group.image_medium : '',
99
+ imageOriginalFile: '',
100
+ emotionalImageOriginal: group ? group.emotional_image : '',
101
+ emotionalImageOriginalFile: '',
102
+ name: group ? group.name : '',
103
+ description: group ? group.description : '',
104
+ isPublic: group && group.privacy === SCGroupPrivacyType.PUBLIC,
105
+ isVisible: group ? group.visible : true,
106
+ invitedUsers: null,
107
+ isSubmitting: false
108
+ };
109
+ // STATE
110
+ const [field, setField] = useState(initialFieldState);
111
+ const [error, setError] = useState({});
112
+ // INTL
113
+ const intl = useIntl();
114
+ // PREFERENCES
115
+ const scPreferences = useSCPreferences();
116
+ const _backgroundCover = Object.assign({}, (field.emotionalImageOriginal
117
+ ? { background: `url('${field.emotionalImageOriginal}') center / cover` }
118
+ : { background: `url('${scPreferences.preferences[SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
119
+ function handleChangeAvatar(avatar) {
120
+ setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginalFile']: avatar })));
121
+ const reader = new FileReader();
122
+ reader.onloadend = () => {
123
+ setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginal']: reader.result })));
124
+ };
125
+ reader.readAsDataURL(avatar);
126
+ if (error.imageOriginalError) {
127
+ delete error.imageOriginalError;
128
+ setError(error);
129
+ }
130
+ }
131
+ function handleChangeCover(cover) {
132
+ setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginalFile']: cover })));
133
+ const reader = new FileReader();
134
+ reader.onloadend = () => {
135
+ setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginal']: reader.result })));
136
+ };
137
+ reader.readAsDataURL(cover);
138
+ if (error.emotionalImageOriginalError) {
139
+ delete error.emotionalImageOriginalError;
140
+ setError(error);
141
+ }
142
+ }
143
+ const handleSubmit = () => {
144
+ setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
145
+ const formData = new FormData();
146
+ formData.append('name', field.name);
147
+ formData.append('description', field.description);
148
+ formData.append('privacy', field.isPublic ? SCGroupPrivacyType.PUBLIC : SCGroupPrivacyType.PRIVATE);
149
+ formData.append('visible', field.isVisible);
150
+ if (field.imageOriginalFile) {
151
+ formData.append('image_original', field.imageOriginalFile);
152
+ }
153
+ if (field.emotionalImageOriginalFile) {
154
+ formData.append('emotional_image_original', field.emotionalImageOriginalFile);
155
+ }
156
+ for (const key in field.invitedUsers) {
157
+ formData.append(key, field.invitedUsers[key]);
158
+ }
159
+ let groupService;
160
+ if (group) {
161
+ groupService = GroupService.updateGroup(group.id, formData, { headers: { 'Content-Type': 'multipart/form-data' } });
162
+ }
163
+ else {
164
+ groupService = GroupService.createGroup(formData, { headers: { 'Content-Type': 'multipart/form-data' } });
165
+ }
166
+ groupService
167
+ .then((data) => {
168
+ onSuccess && onSuccess(data);
169
+ onClose && onClose();
170
+ setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
171
+ })
172
+ .catch((e) => {
173
+ setError(Object.assign(Object.assign({}, error), formatHttpErrorCode(e)));
174
+ setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
175
+ Logger.error(SCOPE_SC_UI, e);
176
+ });
177
+ };
178
+ const handleInviteSection = (data) => {
179
+ setField((prev) => (Object.assign(Object.assign({}, prev), { ['invitedUsers']: data })));
180
+ };
181
+ const handleChange = (event) => {
182
+ const { name, value } = event.target;
183
+ setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
184
+ if (error[`${name}Error`]) {
185
+ delete error[`${name}Error`];
186
+ setError(error);
187
+ }
188
+ };
189
+ /**
190
+ * Renders root object
191
+ */
192
+ return (React.createElement(Root, Object.assign({ DialogContentProps: { dividers: false }, title: group ? (React.createElement(FormattedMessage, { id: "ui.groupForm.title.edit", defaultMessage: "ui.groupForm.title.edit" })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.title", defaultMessage: "ui.groupForm.title" })), open: open, onClose: onClose, className: classNames(classes.root, className), actions: React.createElement(LoadingButton, { loading: field.isSubmitting, disabled: !field.name || Object.keys(error).length !== 0, variant: "contained", onClick: handleSubmit, color: "secondary" }, group ? (React.createElement(FormattedMessage, { id: "ui.groupForm.button.edit", defaultMessage: "ui.groupForm.button.edit" })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.button.create", defaultMessage: "ui.groupForm.button.create" }))) }, rest),
193
+ React.createElement(React.Fragment, null,
194
+ React.createElement(React.Fragment, null,
195
+ React.createElement(Paper, { style: _backgroundCover, classes: { root: classes.cover } },
196
+ React.createElement(Box, { className: classes.avatar },
197
+ React.createElement(Avatar, null, field.imageOriginal ? React.createElement("img", { src: field.imageOriginal, alt: "avatar" }) : React.createElement(Icon, null, "icon_image"))),
198
+ React.createElement(React.Fragment, null,
199
+ React.createElement(ChangeGroupPicture, { isCreationMode: true, onChange: handleChangeAvatar }),
200
+ React.createElement(ChangeGroupCover, { isCreationMode: true, onChange: handleChangeCover }))),
201
+ React.createElement(Typography, { className: classNames(classes.header, { [classes.error]: error.emotionalImageOriginalError || error.imageOriginalError }), align: "center" }, error.emotionalImageOriginalError || error.imageOriginalError ? (React.createElement(FormattedMessage, { id: "ui.groupForm.header.error", defaultMessage: "ui.groupForm.header.error" })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.header", defaultMessage: "ui.groupForm.header" })))),
202
+ React.createElement(FormGroup, { className: classes.form },
203
+ React.createElement(TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
204
+ endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_TITLE_MAX_LENGTH - field.name.length)
205
+ } }),
206
+ React.createElement(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
207
+ endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_DESCRIPTION_MAX_LENGTH - field.description.length)
208
+ } }),
209
+ React.createElement(Box, { className: classes.privacySection },
210
+ React.createElement(Typography, { variant: "h4" },
211
+ React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.title", defaultMessage: "ui.groupForm.privacy.title", values: { b: (chunks) => React.createElement("strong", null, chunks) } })),
212
+ React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
213
+ React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) },
214
+ React.createElement(Icon, null, "private"),
215
+ React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
216
+ React.createElement(Switch, { className: classes.switch, checked: field.isPublic, onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))) }),
217
+ React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) },
218
+ React.createElement(Icon, null, "public"),
219
+ React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" }))),
220
+ React.createElement(Typography, { variant: "body2", className: classes.privacySectionInfo }, field.isPublic ? (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))),
221
+ React.createElement(Box, { className: classes.visibilitySection }, !field.isPublic && (React.createElement(React.Fragment, null,
222
+ React.createElement(Typography, { variant: "h4" },
223
+ React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.title", defaultMessage: "ui.groupForm.visibility.title", values: { b: (chunks) => React.createElement("strong", null, chunks) } })),
224
+ React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
225
+ React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !field.isVisible }) },
226
+ React.createElement(Icon, null, "visibility_off"),
227
+ React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
228
+ React.createElement(Switch, { className: classes.switch, checked: field.isVisible, onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isVisible']: !field.isVisible }))) }),
229
+ React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: field.isVisible }) },
230
+ React.createElement(Icon, null, "visibility"),
231
+ React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" }))),
232
+ React.createElement(Typography, { variant: "body2", className: classes.visibilitySectionInfo }, !field.isVisible ? (React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))))),
233
+ React.createElement(Divider, null),
234
+ React.createElement(Box, { className: classes.inviteSection },
235
+ React.createElement(GroupInviteButton, { handleInvitations: handleInviteSection })))));
236
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCGroupForm";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCGroupForm';
@@ -0,0 +1,3 @@
1
+ import GroupForm, { GroupFormProps } from './GroupForm';
2
+ export default GroupForm;
3
+ export { GroupFormProps };
@@ -0,0 +1,2 @@
1
+ import GroupForm from './GroupForm';
2
+ export default GroupForm;
@@ -13,6 +13,7 @@ import { FormattedMessage } from 'react-intl';
13
13
  import Bullet from '../../shared/Bullet';
14
14
  import ChangeGroupPicture from '../ChangeGroupPicture';
15
15
  import GroupMembersButton from '../GroupMembersButton';
16
+ import EditGroupButton from '../EditGroupButton';
16
17
  const classes = {
17
18
  root: `${PREFIX}-root`,
18
19
  cover: `${PREFIX}-cover`,
@@ -63,7 +64,7 @@ const Root = styled(Box, {
63
64
  * @param inProps
64
65
  */
65
66
  export default function GroupHeader(inProps) {
66
- var _a, _b;
67
+ var _a;
67
68
  // PROPS
68
69
  const props = useThemeProps({
69
70
  props: inProps,
@@ -77,7 +78,7 @@ export default function GroupHeader(inProps) {
77
78
  // HOOKS
78
79
  const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
79
80
  // CONST
80
- const canEdit = useMemo(() => { var _a, _b; return scUserContext.user && (((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.created_by) === null || _a === void 0 ? void 0 : _a.id) || ((_b = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _b === void 0 ? void 0 : _b.id)) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.created_by) === null || _a === void 0 ? void 0 : _a.id, (_b = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _b === void 0 ? void 0 : _b.id]);
81
+ const canEdit = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
81
82
  /**
82
83
  * Handles Change Avatar
83
84
  * @param avatar
@@ -113,6 +114,7 @@ export default function GroupHeader(inProps) {
113
114
  React.createElement("div", { className: classes.changeCover },
114
115
  React.createElement(ChangeGroupCover, Object.assign({ groupId: scGroup.id, onChange: handleChangeCover }, ChangeCoverProps)))))),
115
116
  React.createElement(Box, { className: classes.info },
117
+ canEdit && React.createElement(EditGroupButton, { group: scGroup, groupId: scGroup.id, onEditSuccess: (data) => setSCGroup(data) }),
116
118
  React.createElement(Typography, { variant: "h5", className: classes.name }, scGroup.name),
117
119
  React.createElement(Box, { className: classes.visibility },
118
120
  scGroup.privacy === SCGroupPrivacyType.PUBLIC ? (React.createElement(Typography, { className: classes.visibilityItem },
@@ -73,25 +73,25 @@ export default function GroupInfoWidget(inProps) {
73
73
  React.createElement(Typography, { component: "div", className: classes.privacy }, scGroup.privacy === SCGroupPrivacyType.PUBLIC ? (React.createElement(React.Fragment, null,
74
74
  React.createElement(Typography, { className: classes.privacyTitle },
75
75
  React.createElement(Icon, null, "public"),
76
- React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.public", defaultMessage: "ui.createGroup.privacy.public" })),
76
+ React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" })),
77
77
  React.createElement(Typography, { variant: "body2" },
78
- React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.public.info", defaultMessage: "ui.createGroup.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
78
+ React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
79
79
  React.createElement(Typography, { className: classes.privacyTitle },
80
80
  React.createElement(Icon, null, "private"),
81
- React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.private", defaultMessage: "ui.createGroup.privacy.private" })),
81
+ React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
82
82
  React.createElement(Typography, { variant: "body2" },
83
- React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.private.info", defaultMessage: "ui.createGroup.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))),
83
+ React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))),
84
84
  scGroup.privacy === SCGroupPrivacyType.PRIVATE && (React.createElement(Typography, { component: "div", className: classes.visibility }, scGroup.visible ? (React.createElement(React.Fragment, null,
85
85
  React.createElement(Typography, { className: classes.visibilityTitle },
86
86
  React.createElement(Icon, null, "visibility"),
87
- React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.visible", defaultMessage: "ui.createGroup.visibility.visible" })),
87
+ React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" })),
88
88
  React.createElement(Typography, { variant: "body2" },
89
- React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.visible.info", defaultMessage: "ui.createGroup.visibility.visible.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
89
+ React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
90
90
  React.createElement(Typography, { className: classes.visibilityTitle },
91
91
  React.createElement(Icon, null, "visibility_off"),
92
- React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.hidden", defaultMessage: "ui.createGroup.visibility.hidden" })),
92
+ React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
93
93
  React.createElement(Typography, { variant: "body2" },
94
- React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.hidden.info", defaultMessage: "ui.createGroup.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))))),
94
+ React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))))),
95
95
  React.createElement(Typography, { variant: "body2", className: classes.date },
96
96
  React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })))));
97
97
  }
@@ -71,6 +71,7 @@ const DialogRoot = styled(BaseDialog, {
71
71
  * @param inProps
72
72
  */
73
73
  export default function GroupInviteButton(inProps) {
74
+ var _a;
74
75
  //PROPS
75
76
  const props = useThemeProps({
76
77
  props: inProps,
@@ -105,10 +106,9 @@ export default function GroupInviteButton(inProps) {
105
106
  }
106
107
  return [invited];
107
108
  }, [invited]);
108
- // CONST
109
- const authUserId = scUserContext.user ? scUserContext.user.id : null;
110
109
  // HOOKS
111
110
  const { scGroup } = useSCFetchGroup({ id: groupId, group });
111
+ const canEdit = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
112
112
  // INTL
113
113
  const intl = useIntl();
114
114
  function fetchResults() {
@@ -179,6 +179,7 @@ export default function GroupInviteButton(inProps) {
179
179
  .then(() => {
180
180
  setIsSending(false);
181
181
  setOpen(false);
182
+ setInvited([]);
182
183
  })
183
184
  .catch((error) => {
184
185
  setOpen(false);
@@ -225,14 +226,14 @@ export default function GroupInviteButton(inProps) {
225
226
  /**
226
227
  * If there's no authUserId, component is hidden.
227
228
  // */
228
- if (!authUserId) {
229
+ if (!canEdit) {
229
230
  return null;
230
231
  }
231
232
  /**
232
233
  * Renders root object
233
234
  */
234
235
  return (React.createElement(React.Fragment, null,
235
- React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose, size: "small", variant: scGroup ? 'contained' : 'outlined', color: scGroup ? 'secondary' : 'inherit', startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest),
236
+ React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose, variant: scGroup ? 'contained' : 'outlined', color: scGroup ? 'secondary' : 'inherit', startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest),
236
237
  React.createElement(FormattedMessage, { id: "ui.groupInviteButton", defaultMessage: "ui.groupInviteButton" })),
237
238
  open && (React.createElement(DialogRoot, { DialogContentProps: { dividers: false }, open: true, className: classes.dialogRoot, title: React.createElement(React.Fragment, null,
238
239
  React.createElement(IconButton, { onClick: handleClose },
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
2
2
  import React, { useEffect, useMemo, useReducer, useState } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import List from '@mui/material/List';
5
- import { Button, CardContent, ListItem, Typography, useMediaQuery, useTheme } from '@mui/material';
5
+ import { Button, CardActions, CardContent, ListItem, Typography, useMediaQuery, useTheme } from '@mui/material';
6
6
  import Widget from '../Widget';
7
7
  import { http, Endpoints, GroupService } from '@selfcommunity/api-services';
8
8
  import { CacheStrategies, isInteger, Logger } from '@selfcommunity/utils';
@@ -22,7 +22,7 @@ import GroupInviteButton from '../GroupInviteButton';
22
22
  const classes = {
23
23
  root: `${PREFIX}-root`,
24
24
  title: `${PREFIX}-title`,
25
- button: `${PREFIX}-button`,
25
+ actions: `${PREFIX}-actions`,
26
26
  noResults: `${PREFIX}-no-results`,
27
27
  showMore: `${PREFIX}-show-more`,
28
28
  dialogRoot: `${PREFIX}-dialog-root`,
@@ -175,20 +175,22 @@ export default function GroupMembersWidget(inProps) {
175
175
  if (!state.initialized) {
176
176
  return React.createElement(Skeleton, null);
177
177
  }
178
- const content = (React.createElement(CardContent, null,
179
- React.createElement(Typography, { className: classes.title, variant: "h5" },
180
- React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.title", defaultMessage: "ui.groupMembersWidget.title" })),
181
- !state.count ? (React.createElement(Typography, { className: classes.noResults, variant: "body2" },
182
- React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.subtitle.noResults", defaultMessage: "" }))) : (React.createElement(React.Fragment, null,
183
- React.createElement(List, null, state.results.slice(0, state.visibleItems).map((user) => (React.createElement(ListItem, { key: user.id },
184
- React.createElement(User, { elevation: 0, actions: React.createElement(React.Fragment, null), user: user, userId: user.id, buttonProps: { onClick: () => console.log(user) } }))))),
185
- state.count > state.visibleItems && (React.createElement(Button, { className: classes.showMore, onClick: handleToggleDialogOpen },
186
- React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.button.showMore", defaultMessage: "ui.groupMembersWidget.button.showMore" }))))),
187
- openDialog && (React.createElement(DialogRoot, Object.assign({ className: classes.dialogRoot, title: React.createElement(FormattedMessage, { defaultMessage: "ui.groupMembersWidget.dialogTitle", id: "ui.groupMembersWidget.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: openDialog }, DialogProps),
188
- React.createElement(InfiniteScroll, { dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: React.createElement(UserSkeleton, Object.assign({ elevation: 0 }, UserProps)), height: isMobile ? '100%' : 400, endMessage: React.createElement(Typography, { className: classes.endMessage },
189
- React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.noMoreResults", defaultMessage: "ui.groupMembersWidget.noMoreResults" })) },
190
- React.createElement(List, null, state.results.map((user) => (React.createElement(ListItem, { key: user.id },
191
- React.createElement(User, { elevation: 0, actions: React.createElement(React.Fragment, null), user: user, userId: user.id, buttonProps: { onClick: () => console.log(user) } })))))))),
192
- React.createElement(GroupInviteButton, { className: classes.button, groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup })));
178
+ const content = (React.createElement(React.Fragment, null,
179
+ React.createElement(CardContent, null,
180
+ React.createElement(Typography, { className: classes.title, variant: "h5" },
181
+ React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.title", defaultMessage: "ui.groupMembersWidget.title" })),
182
+ !state.count ? (React.createElement(Typography, { className: classes.noResults, variant: "body2" },
183
+ React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.subtitle.noResults", defaultMessage: "" }))) : (React.createElement(React.Fragment, null,
184
+ React.createElement(List, null, state.results.slice(0, state.visibleItems).map((user) => (React.createElement(ListItem, { key: user.id },
185
+ React.createElement(User, { elevation: 0, actions: React.createElement(React.Fragment, null), user: user, userId: user.id, buttonProps: { onClick: () => console.log(user) } }))))),
186
+ state.count > state.visibleItems && (React.createElement(Button, { className: classes.showMore, onClick: handleToggleDialogOpen },
187
+ React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.button.showMore", defaultMessage: "ui.groupMembersWidget.button.showMore" }))))),
188
+ openDialog && (React.createElement(DialogRoot, Object.assign({ className: classes.dialogRoot, title: React.createElement(FormattedMessage, { defaultMessage: "ui.groupMembersWidget.dialogTitle", id: "ui.groupMembersWidget.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: openDialog }, DialogProps),
189
+ React.createElement(InfiniteScroll, { dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: React.createElement(UserSkeleton, Object.assign({ elevation: 0 }, UserProps)), height: isMobile ? '100%' : 400, endMessage: React.createElement(Typography, { className: classes.endMessage },
190
+ React.createElement(FormattedMessage, { id: "ui.groupMembersWidget.noMoreResults", defaultMessage: "ui.groupMembersWidget.noMoreResults" })) },
191
+ React.createElement(List, null, state.results.map((user) => (React.createElement(ListItem, { key: user.id },
192
+ React.createElement(User, { elevation: 0, actions: React.createElement(React.Fragment, null), user: user, userId: user.id, buttonProps: { onClick: () => console.log(user) } }))))))))),
193
+ React.createElement(CardActions, { className: classes.actions },
194
+ React.createElement(GroupInviteButton, { groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup }))));
193
195
  return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest), content));
194
196
  }
@@ -79,12 +79,22 @@ export default function GroupSubscribeButton(inProps) {
79
79
  Logger.error(SCOPE_SC_UI, e);
80
80
  });
81
81
  };
82
+ const unsubscribe = () => {
83
+ scGroupsManager
84
+ .unsubscribe(scGroup)
85
+ .then(() => {
86
+ // onJoin && onJoin(scGroup, !joined);
87
+ })
88
+ .catch((e) => {
89
+ Logger.error(SCOPE_SC_UI, e);
90
+ });
91
+ };
82
92
  const handleSubscribeAction = () => {
83
93
  if (!scUserContext.user) {
84
94
  scContext.settings.handleAnonymousAction();
85
95
  }
86
96
  else {
87
- subscribe();
97
+ SCGroupSubscriptionStatusType.SUBSCRIBED ? unsubscribe() : subscribe();
88
98
  }
89
99
  };
90
100
  /**
@@ -22,7 +22,7 @@ export interface GroupsProps {
22
22
  */
23
23
  cacheStrategy?: CacheStrategies;
24
24
  /**
25
- * Props to spread to single user object
25
+ * Props to spread to single group object
26
26
  * @default empty object
27
27
  */
28
28
  GroupProps?: GroupProps;
@@ -1,8 +1,7 @@
1
1
  import { __rest } from "tslib";
2
2
  import React, { useEffect, useMemo, useReducer } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
- import List from '@mui/material/List';
5
- import { Box, Button, ListItem, Typography } from '@mui/material';
4
+ import { Box, Button, Grid, Typography } from '@mui/material';
6
5
  import { http } from '@selfcommunity/api-services';
7
6
  import { CacheStrategies, Logger } from '@selfcommunity/utils';
8
7
  import { SCCache, SCPreferences, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
@@ -17,6 +16,7 @@ import { PREFIX } from './constants';
17
16
  import Group from '../Group';
18
17
  const classes = {
19
18
  root: `${PREFIX}-root`,
19
+ groups: `${PREFIX}-groups`,
20
20
  item: `${PREFIX}-item`,
21
21
  noResults: `${PREFIX}-no-results`,
22
22
  showMore: `${PREFIX}-show-more`,
@@ -63,7 +63,7 @@ export default function Groups(inProps) {
63
63
  props: inProps,
64
64
  name: PREFIX
65
65
  });
66
- const { endpoint, autoHide = false, limit = 5, className, cacheStrategy = CacheStrategies.NETWORK_ONLY, onHeightChange, onStateChange, GroupProps = {} } = props, rest = __rest(props, ["endpoint", "autoHide", "limit", "className", "cacheStrategy", "onHeightChange", "onStateChange", "GroupProps"]);
66
+ const { endpoint, autoHide = false, limit = 6, className, cacheStrategy = CacheStrategies.NETWORK_ONLY, onHeightChange, onStateChange, GroupProps = { variant: 'outlined', ButtonBaseProps: { disableRipple: true, component: Box } } } = props, rest = __rest(props, ["endpoint", "autoHide", "limit", "className", "cacheStrategy", "onHeightChange", "onStateChange", "GroupProps"]);
67
67
  // STATE
68
68
  const [state, dispatch] = useReducer(dataWidgetReducer, {
69
69
  isLoadingNext: false,
@@ -150,20 +150,17 @@ export default function Groups(inProps) {
150
150
  }
151
151
  }, []);
152
152
  // HANDLERS
153
- // const handleNext = useMemo(
154
- // () => (): void => {
155
- // dispatch({type: actionWidgetTypes.LOADING_NEXT});
156
- // http
157
- // .request({
158
- // url: state.next,
159
- // method: endpoint
160
- // })
161
- // .then((res: AxiosResponse<any>) => {
162
- // dispatch({type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: res.data});
163
- // });
164
- // },
165
- // [dispatch, state.next, state.isLoadingNext, state.initialized]
166
- // );
153
+ const handleNext = useMemo(() => () => {
154
+ dispatch({ type: actionWidgetTypes.LOADING_NEXT });
155
+ http
156
+ .request({
157
+ url: state.next,
158
+ method: endpoint.method
159
+ })
160
+ .then((res) => {
161
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: res.data });
162
+ });
163
+ }, [dispatch, state.next, state.isLoadingNext, state.initialized, endpoint.method]);
167
164
  // RENDER
168
165
  if ((autoHide && !state.count && state.initialized) || (!contentAvailability && !scUserContext.user) || !endpoint) {
169
166
  return React.createElement(HiddenPlaceholder, null);
@@ -173,9 +170,9 @@ export default function Groups(inProps) {
173
170
  }
174
171
  const content = (React.createElement(React.Fragment, null, !state.count ? (React.createElement(Typography, { className: classes.noResults, variant: "body2" },
175
172
  React.createElement(FormattedMessage, { id: "ui.groupRequestsWidget.subtitle.noResults", defaultMessage: "" }))) : (React.createElement(React.Fragment, null,
176
- React.createElement(List, null, state.results.slice(0, state.visibleItems).map((group) => (React.createElement(ListItem, { key: group.id, className: classes.item },
177
- React.createElement(Group, Object.assign({ elevation: 1, actions: React.createElement(React.Fragment, null), group: group, groupId: group.id, buttonProps: { onClick: () => console.log(group) } }, GroupProps)))))),
178
- state.count > state.visibleItems && (React.createElement(Button, { className: classes.showMore, onClick: () => console.log('load more') },
173
+ React.createElement(Grid, { container: true, spacing: { xs: 3 }, className: classes.groups }, state.results.slice(0, state.visibleItems).map((group) => (React.createElement(Grid, { item: true, xs: 12, sm: 8, md: 6, key: group.id, className: classes.item },
174
+ React.createElement(Group, Object.assign({ group: group, groupId: group.id }, GroupProps)))))),
175
+ state.count > state.visibleItems && (React.createElement(Button, { className: classes.showMore, onClick: handleNext },
179
176
  React.createElement(FormattedMessage, { id: "ui.groupRequestsWidget.button.showMore", defaultMessage: "ui.groupRequestsWidget.button.showMore" })))))));
180
177
  return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest), content));
181
178
  }
@@ -1,4 +1,15 @@
1
- import { WidgetProps } from '../Widget';
1
+ export interface GroupsSkeletonProps {
2
+ /**
3
+ * Overrides or extends the styles applied to the component.
4
+ * @default null
5
+ */
6
+ className?: string;
7
+ /**
8
+ * Overrides or extends the styles applied to the component.
9
+ * @default null
10
+ */
11
+ GroupSkeletonProps?: any;
12
+ }
2
13
  /**
3
14
  * > API documentation for the Community-JS Groups Skeleton component. Learn about the available props and the CSS API.
4
15
 
@@ -17,6 +28,7 @@ import { WidgetProps } from '../Widget';
17
28
  |Rule Name|Global class|Description|
18
29
  |---|---|---|
19
30
  |root|.SCGroups-skeleton-root|Styles applied to the root element.|
31
+ |groups|.SCGroups-skeleton-groups|Styles applied to the group elements.|
20
32
  *
21
33
  */
22
- export default function GroupsSkeleton(props: WidgetProps): JSX.Element;
34
+ export default function GroupsSkeleton(inProps: GroupsSkeletonProps): JSX.Element;
@@ -1,11 +1,15 @@
1
+ import { __rest } from "tslib";
1
2
  import React from 'react';
2
- import { CategoryTrendingPeopleWidgetSkeleton } from '../CategoryTrendingUsersWidget';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { PREFIX } from './constants';
5
+ import { Box, Grid } from '@mui/material';
6
+ import classNames from 'classnames';
7
+ import { GroupSkeleton } from '../Group';
5
8
  const classes = {
6
- root: `${PREFIX}-skeleton-root`
9
+ root: `${PREFIX}-skeleton-root`,
10
+ groups: `${PREFIX}-groups`
7
11
  };
8
- const Root = styled(CategoryTrendingPeopleWidgetSkeleton, {
12
+ const Root = styled(Box, {
9
13
  name: PREFIX,
10
14
  slot: 'SkeletonRoot'
11
15
  })(() => ({}));
@@ -27,8 +31,12 @@ const Root = styled(CategoryTrendingPeopleWidgetSkeleton, {
27
31
  |Rule Name|Global class|Description|
28
32
  |---|---|---|
29
33
  |root|.SCGroups-skeleton-root|Styles applied to the root element.|
34
+ |groups|.SCGroups-skeleton-groups|Styles applied to the group elements.|
30
35
  *
31
36
  */
32
- export default function GroupsSkeleton(props) {
33
- return React.createElement(Root, Object.assign({ className: classes.root }, props));
37
+ export default function GroupsSkeleton(inProps) {
38
+ const { className, GroupSkeletonProps = {} } = inProps, rest = __rest(inProps, ["className", "GroupSkeletonProps"]);
39
+ return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest),
40
+ React.createElement(Grid, { container: true, spacing: { xs: 3 }, className: classes.groups }, [...Array(15)].map((category, index) => (React.createElement(Grid, { item: true, xs: 12, sm: 8, md: 6, key: index },
41
+ React.createElement(GroupSkeleton, Object.assign({ elevation: 0, variant: 'outlined' }, GroupSkeletonProps))))))));
34
42
  }
@@ -1,4 +1,4 @@
1
- import { SCCategoryType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
1
+ import { SCCategoryType, SCGroupType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
2
2
  import { SCMediaObjectType } from '../../types/media';
3
3
  import { WidgetProps } from '../Widget';
4
4
  export interface InlineComposerWidgetProps extends Omit<WidgetProps, 'defaultValue'> {
@@ -15,6 +15,7 @@ export interface InlineComposerWidgetProps extends Omit<WidgetProps, 'defaultVal
15
15
  title?: string;
16
16
  text?: string;
17
17
  categories?: SCCategoryType[];
18
+ group?: SCGroupType;
18
19
  audience?: string;
19
20
  addressing?: SCTagType[];
20
21
  medias?: SCMediaType[];