@selfcommunity/react-ui 0.7.9-alpha.0 → 0.7.9-alpha.2

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 (174) hide show
  1. package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
  2. package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +117 -0
  3. package/lib/cjs/components/ChangeGroupCover/constants.d.ts +1 -0
  4. package/lib/cjs/components/ChangeGroupCover/constants.js +4 -0
  5. package/lib/cjs/components/ChangeGroupCover/index.d.ts +3 -0
  6. package/lib/cjs/components/ChangeGroupCover/index.js +5 -0
  7. package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.d.ts +57 -0
  8. package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +117 -0
  9. package/lib/cjs/components/ChangeGroupPicture/constants.d.ts +1 -0
  10. package/lib/cjs/components/ChangeGroupPicture/constants.js +4 -0
  11. package/lib/cjs/components/ChangeGroupPicture/index.d.ts +3 -0
  12. package/lib/cjs/components/ChangeGroupPicture/index.js +5 -0
  13. package/lib/cjs/components/CreateGroup/CreateGroup.d.ts +48 -0
  14. package/lib/cjs/components/CreateGroup/CreateGroup.js +187 -0
  15. package/lib/cjs/components/CreateGroup/constants.d.ts +1 -0
  16. package/lib/cjs/components/CreateGroup/constants.js +4 -0
  17. package/lib/cjs/components/CreateGroup/index.d.ts +3 -0
  18. package/lib/cjs/components/CreateGroup/index.js +5 -0
  19. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
  20. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +73 -0
  21. package/lib/cjs/components/CreateGroupButton/index.d.ts +3 -0
  22. package/lib/cjs/components/CreateGroupButton/index.js +5 -0
  23. package/lib/cjs/components/Group/Group.d.ts +67 -0
  24. package/lib/cjs/components/Group/Group.js +96 -0
  25. package/lib/cjs/components/Group/Skeleton.d.ts +22 -0
  26. package/lib/cjs/components/Group/Skeleton.js +42 -0
  27. package/lib/cjs/components/Group/constants.d.ts +1 -0
  28. package/lib/cjs/components/Group/constants.js +4 -0
  29. package/lib/cjs/components/Group/index.d.ts +4 -0
  30. package/lib/cjs/components/Group/index.js +8 -0
  31. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +83 -0
  32. package/lib/cjs/components/GroupHeader/GroupHeader.js +137 -0
  33. package/lib/cjs/components/GroupHeader/Skeleton.d.ts +27 -0
  34. package/lib/cjs/components/GroupHeader/Skeleton.js +56 -0
  35. package/lib/cjs/components/GroupHeader/constants.d.ts +1 -0
  36. package/lib/cjs/components/GroupHeader/constants.js +4 -0
  37. package/lib/cjs/components/GroupHeader/index.d.ts +4 -0
  38. package/lib/cjs/components/GroupHeader/index.js +8 -0
  39. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.d.ts +52 -0
  40. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +100 -0
  41. package/lib/cjs/components/GroupInfoWidget/Skeleton.d.ts +21 -0
  42. package/lib/cjs/components/GroupInfoWidget/Skeleton.js +38 -0
  43. package/lib/cjs/components/GroupInfoWidget/constants.d.ts +1 -0
  44. package/lib/cjs/components/GroupInfoWidget/constants.js +4 -0
  45. package/lib/cjs/components/GroupInfoWidget/index.d.ts +4 -0
  46. package/lib/cjs/components/GroupInfoWidget/index.js +8 -0
  47. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.d.ts +57 -0
  48. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +259 -0
  49. package/lib/cjs/components/GroupInviteButton/index.d.ts +3 -0
  50. package/lib/cjs/components/GroupInviteButton/index.js +5 -0
  51. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +46 -0
  52. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +135 -0
  53. package/lib/cjs/components/GroupMembersButton/index.d.ts +3 -0
  54. package/lib/cjs/components/GroupMembersButton/index.js +5 -0
  55. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.d.ts +79 -0
  56. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +194 -0
  57. package/lib/cjs/components/GroupMembersWidget/Skeleton.d.ts +22 -0
  58. package/lib/cjs/components/GroupMembersWidget/Skeleton.js +38 -0
  59. package/lib/cjs/components/GroupMembersWidget/constants.d.ts +1 -0
  60. package/lib/cjs/components/GroupMembersWidget/constants.js +4 -0
  61. package/lib/cjs/components/GroupMembersWidget/index.d.ts +4 -0
  62. package/lib/cjs/components/GroupMembersWidget/index.js +8 -0
  63. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +79 -0
  64. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +194 -0
  65. package/lib/cjs/components/GroupRequestsWidget/Skeleton.d.ts +22 -0
  66. package/lib/cjs/components/GroupRequestsWidget/Skeleton.js +38 -0
  67. package/lib/cjs/components/GroupRequestsWidget/constants.d.ts +1 -0
  68. package/lib/cjs/components/GroupRequestsWidget/constants.js +4 -0
  69. package/lib/cjs/components/GroupRequestsWidget/index.d.ts +4 -0
  70. package/lib/cjs/components/GroupRequestsWidget/index.js +8 -0
  71. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +51 -0
  72. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +117 -0
  73. package/lib/cjs/components/GroupSubscribeButton/index.d.ts +3 -0
  74. package/lib/cjs/components/GroupSubscribeButton/index.js +5 -0
  75. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +4 -0
  76. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +2 -3
  77. package/lib/cjs/components/NavigationMenuIconButton/index.d.ts +2 -1
  78. package/lib/cjs/components/NavigationMenuIconButton/index.js +3 -0
  79. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
  80. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -2
  81. package/lib/cjs/components/User/User.d.ts +12 -0
  82. package/lib/cjs/components/User/User.js +5 -3
  83. package/lib/cjs/constants/Group.d.ts +2 -0
  84. package/lib/cjs/constants/Group.js +5 -0
  85. package/lib/cjs/index.d.ts +14 -2
  86. package/lib/cjs/index.js +34 -5
  87. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
  88. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +114 -0
  89. package/lib/esm/components/ChangeGroupCover/constants.d.ts +1 -0
  90. package/lib/esm/components/ChangeGroupCover/constants.js +1 -0
  91. package/lib/esm/components/ChangeGroupCover/index.d.ts +3 -0
  92. package/lib/esm/components/ChangeGroupCover/index.js +2 -0
  93. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.d.ts +57 -0
  94. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +114 -0
  95. package/lib/esm/components/ChangeGroupPicture/constants.d.ts +1 -0
  96. package/lib/esm/components/ChangeGroupPicture/constants.js +1 -0
  97. package/lib/esm/components/ChangeGroupPicture/index.d.ts +3 -0
  98. package/lib/esm/components/ChangeGroupPicture/index.js +2 -0
  99. package/lib/esm/components/CreateGroup/CreateGroup.d.ts +48 -0
  100. package/lib/esm/components/CreateGroup/CreateGroup.js +184 -0
  101. package/lib/esm/components/CreateGroup/constants.d.ts +1 -0
  102. package/lib/esm/components/CreateGroup/constants.js +1 -0
  103. package/lib/esm/components/CreateGroup/index.d.ts +3 -0
  104. package/lib/esm/components/CreateGroup/index.js +2 -0
  105. package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
  106. package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +70 -0
  107. package/lib/esm/components/CreateGroupButton/index.d.ts +3 -0
  108. package/lib/esm/components/CreateGroupButton/index.js +2 -0
  109. package/lib/esm/components/Group/Group.d.ts +67 -0
  110. package/lib/esm/components/Group/Group.js +93 -0
  111. package/lib/esm/components/Group/Skeleton.d.ts +22 -0
  112. package/lib/esm/components/Group/Skeleton.js +38 -0
  113. package/lib/esm/components/Group/constants.d.ts +1 -0
  114. package/lib/esm/components/Group/constants.js +1 -0
  115. package/lib/esm/components/Group/index.d.ts +4 -0
  116. package/lib/esm/components/Group/index.js +4 -0
  117. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +83 -0
  118. package/lib/esm/components/GroupHeader/GroupHeader.js +134 -0
  119. package/lib/esm/components/GroupHeader/Skeleton.d.ts +27 -0
  120. package/lib/esm/components/GroupHeader/Skeleton.js +53 -0
  121. package/lib/esm/components/GroupHeader/constants.d.ts +1 -0
  122. package/lib/esm/components/GroupHeader/constants.js +1 -0
  123. package/lib/esm/components/GroupHeader/index.d.ts +4 -0
  124. package/lib/esm/components/GroupHeader/index.js +4 -0
  125. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.d.ts +52 -0
  126. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +97 -0
  127. package/lib/esm/components/GroupInfoWidget/Skeleton.d.ts +21 -0
  128. package/lib/esm/components/GroupInfoWidget/Skeleton.js +34 -0
  129. package/lib/esm/components/GroupInfoWidget/constants.d.ts +1 -0
  130. package/lib/esm/components/GroupInfoWidget/constants.js +1 -0
  131. package/lib/esm/components/GroupInfoWidget/index.d.ts +4 -0
  132. package/lib/esm/components/GroupInfoWidget/index.js +4 -0
  133. package/lib/esm/components/GroupInviteButton/GroupInviteButton.d.ts +57 -0
  134. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +256 -0
  135. package/lib/esm/components/GroupInviteButton/index.d.ts +3 -0
  136. package/lib/esm/components/GroupInviteButton/index.js +2 -0
  137. package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +46 -0
  138. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +132 -0
  139. package/lib/esm/components/GroupMembersButton/index.d.ts +3 -0
  140. package/lib/esm/components/GroupMembersButton/index.js +2 -0
  141. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.d.ts +79 -0
  142. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +191 -0
  143. package/lib/esm/components/GroupMembersWidget/Skeleton.d.ts +22 -0
  144. package/lib/esm/components/GroupMembersWidget/Skeleton.js +34 -0
  145. package/lib/esm/components/GroupMembersWidget/constants.d.ts +1 -0
  146. package/lib/esm/components/GroupMembersWidget/constants.js +1 -0
  147. package/lib/esm/components/GroupMembersWidget/index.d.ts +4 -0
  148. package/lib/esm/components/GroupMembersWidget/index.js +4 -0
  149. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +79 -0
  150. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +191 -0
  151. package/lib/esm/components/GroupRequestsWidget/Skeleton.d.ts +22 -0
  152. package/lib/esm/components/GroupRequestsWidget/Skeleton.js +34 -0
  153. package/lib/esm/components/GroupRequestsWidget/constants.d.ts +1 -0
  154. package/lib/esm/components/GroupRequestsWidget/constants.js +1 -0
  155. package/lib/esm/components/GroupRequestsWidget/index.d.ts +4 -0
  156. package/lib/esm/components/GroupRequestsWidget/index.js +4 -0
  157. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +51 -0
  158. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +114 -0
  159. package/lib/esm/components/GroupSubscribeButton/index.d.ts +3 -0
  160. package/lib/esm/components/GroupSubscribeButton/index.js +2 -0
  161. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +4 -0
  162. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +3 -4
  163. package/lib/esm/components/NavigationMenuIconButton/index.d.ts +2 -1
  164. package/lib/esm/components/NavigationMenuIconButton/index.js +2 -0
  165. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
  166. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +3 -3
  167. package/lib/esm/components/User/User.d.ts +12 -0
  168. package/lib/esm/components/User/User.js +5 -3
  169. package/lib/esm/constants/Group.d.ts +2 -0
  170. package/lib/esm/constants/Group.js +2 -0
  171. package/lib/esm/index.d.ts +14 -2
  172. package/lib/esm/index.js +41 -29
  173. package/lib/umd/react-ui.js +1 -1
  174. package/package.json +6 -6
@@ -0,0 +1,184 @@
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 { GroupService } from '@selfcommunity/api-services';
19
+ import { Logger } from '@selfcommunity/utils';
20
+ const messages = defineMessages({
21
+ name: {
22
+ id: 'ui.createGroup.name.placeholder',
23
+ defaultMessage: 'ui.createGroup.name.placeholder'
24
+ },
25
+ description: {
26
+ id: 'ui.createGroup.description.placeholder',
27
+ defaultMessage: 'ui.createGroup.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
+ };
49
+ const Root = styled(BaseDialog, {
50
+ name: PREFIX,
51
+ slot: 'Root'
52
+ })(() => ({}));
53
+ /**
54
+ *> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
55
+ *
56
+ #### Import
57
+ ```jsx
58
+ import {CreateGroupButton} from '@selfcommunity/react-ui';
59
+ ```
60
+
61
+ #### Component Name
62
+ The name `SCCreateGroup` can be used when providing style overrides in the theme.
63
+
64
+ #### CSS
65
+
66
+ |Rule Name|Global class|Description|
67
+ |---|---|---|
68
+ |root|.SCCreateGroup-root|Styles applied to the root element.|
69
+
70
+ * @param inProps
71
+ */
72
+ export default function CreateGroup(inProps) {
73
+ //PROPS
74
+ const props = useThemeProps({
75
+ props: inProps,
76
+ name: PREFIX
77
+ });
78
+ const { className, open = true, onClose, group } = props, rest = __rest(props, ["className", "open", "onClose", "group"]);
79
+ // TODO: fare initial state con tutti i fields per la gestione dell'edit
80
+ // STATE
81
+ const [avatar, setAvatar] = useState('');
82
+ const [cover, setCover] = useState('');
83
+ const [name, setName] = useState('');
84
+ const [invitedUsers, setInvitedUsers] = useState(null);
85
+ const [description, setDescription] = useState('');
86
+ const [isPublic, setIsPublic] = useState(true);
87
+ const [isVisible, setIsVisible] = useState(true);
88
+ const [isSubmitting, setIsSubmitting] = useState(false);
89
+ // INTL
90
+ const intl = useIntl();
91
+ // CONTEXT
92
+ // PREFERENCES
93
+ const scPreferences = useSCPreferences();
94
+ const _backgroundCover = Object.assign({}, (cover
95
+ ? { background: `url('${cover}') center / cover` }
96
+ : { background: `url('${scPreferences.preferences[SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
97
+ function handleChangeAvatar(avatar) {
98
+ const reader = new FileReader();
99
+ reader.onloadend = () => {
100
+ setAvatar(reader.result);
101
+ };
102
+ reader.readAsDataURL(avatar);
103
+ }
104
+ function handleChangeCover(cover) {
105
+ const reader = new FileReader();
106
+ reader.onloadend = () => {
107
+ setCover(reader.result);
108
+ };
109
+ reader.readAsDataURL(cover);
110
+ }
111
+ const handleSubmit = () => {
112
+ setIsSubmitting(true);
113
+ const formData = new FormData();
114
+ formData.append('name', name);
115
+ formData.append('description', description);
116
+ formData.append('privacy', isPublic ? SCGroupPrivacyType.PUBLIC : SCGroupPrivacyType.PRIVATE);
117
+ formData.append('image_original', avatar);
118
+ formData.append('emotional_image_original', cover);
119
+ formData.append('visible', isVisible);
120
+ for (const key in invitedUsers) {
121
+ formData.append(key, invitedUsers[key]);
122
+ }
123
+ GroupService.createGroup(formData, { headers: { 'Content-Type': 'multipart/form-data' } })
124
+ .then((data) => {
125
+ console.log(data);
126
+ setIsSubmitting(false);
127
+ })
128
+ .catch((error) => {
129
+ setIsSubmitting(false);
130
+ Logger.error(SCOPE_SC_UI, error);
131
+ });
132
+ };
133
+ const handleInviteSection = (data) => {
134
+ setInvitedUsers(data);
135
+ };
136
+ /**
137
+ * Renders root object
138
+ */
139
+ return (React.createElement(Root, Object.assign({ DialogContentProps: { dividers: false }, title: group ? (React.createElement(FormattedMessage, { id: "ui.createGroup.title.edit", defaultMessage: "ui.createGroup.title.edit" })) : (React.createElement(FormattedMessage, { id: "ui.createGroup.title", defaultMessage: "ui.createGroup.title" })), open: open, onClose: onClose, className: classNames(classes.root, className), actions: React.createElement(LoadingButton, { loading: isSubmitting, disabled: !name, variant: "contained", onClick: handleSubmit, color: "secondary" }, group ? (React.createElement(FormattedMessage, { id: "ui.createGroup.button.edit", defaultMessage: "ui.createGroup.button.edit" })) : (React.createElement(FormattedMessage, { id: "ui.createGroup.button.create", defaultMessage: "ui.createGroup.button.create" }))) }, rest),
140
+ React.createElement(React.Fragment, null,
141
+ React.createElement(React.Fragment, null,
142
+ React.createElement(Paper, { style: _backgroundCover, classes: { root: classes.cover } },
143
+ React.createElement(Box, { className: classes.avatar },
144
+ React.createElement(Avatar, null, avatar ? React.createElement("img", { src: avatar, alt: "avatar" }) : React.createElement(Icon, null, "icon_image"))),
145
+ React.createElement(React.Fragment, null,
146
+ React.createElement(ChangeGroupPicture, { isCreationMode: true, onChange: handleChangeAvatar }),
147
+ React.createElement(ChangeGroupCover, { isCreationMode: true, onChange: handleChangeCover }))),
148
+ React.createElement(Typography, { className: classes.header, align: "center" },
149
+ React.createElement(FormattedMessage, { id: "ui.createGroup.header", defaultMessage: "ui.createGroup.header" }))),
150
+ React.createElement(FormGroup, { className: classes.form },
151
+ React.createElement(TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: name, onChange: (event) => setName(event.target.value), InputProps: {
152
+ endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_TITLE_MAX_LENGTH - name.length)
153
+ } }),
154
+ React.createElement(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: description, onChange: (event) => setDescription(event.target.value), InputProps: {
155
+ endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_DESCRIPTION_MAX_LENGTH - description.length)
156
+ } }),
157
+ React.createElement(Box, { className: classes.privacySection },
158
+ React.createElement(Typography, { variant: "h4" },
159
+ React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.title", defaultMessage: "ui.createGroup.privacy.title", values: { b: (chunks) => React.createElement("strong", null, chunks) } })),
160
+ React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
161
+ React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !isPublic }) },
162
+ React.createElement(Icon, null, "private"),
163
+ React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.private", defaultMessage: "ui.createGroup.privacy.private" })),
164
+ React.createElement(Switch, { className: classes.switch, checked: isPublic, onClick: () => setIsPublic(!isPublic) }),
165
+ React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: isPublic }) },
166
+ React.createElement(Icon, null, "public"),
167
+ React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.public", defaultMessage: "ui.createGroup.privacy.public" }))),
168
+ React.createElement(Typography, { variant: "body2", className: classes.privacySectionInfo }, isPublic ? (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(FormattedMessage, { id: "ui.createGroup.privacy.private.info", defaultMessage: "ui.createGroup.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))),
169
+ React.createElement(Box, { className: classes.visibilitySection }, !isPublic && (React.createElement(React.Fragment, null,
170
+ React.createElement(Typography, { variant: "h4" },
171
+ React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.title", defaultMessage: "ui.createGroup.visibility.title", values: { b: (chunks) => React.createElement("strong", null, chunks) } })),
172
+ React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
173
+ React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !isVisible }) },
174
+ React.createElement(Icon, null, "visibility_off"),
175
+ React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.hidden", defaultMessage: "ui.createGroup.visibility.hidden" })),
176
+ React.createElement(Switch, { className: classes.switch, checked: isVisible, onClick: () => setIsVisible(!isVisible) }),
177
+ React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: isVisible }) },
178
+ React.createElement(Icon, null, "visibility"),
179
+ React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.visible", defaultMessage: "ui.createGroup.visibility.visible" }))),
180
+ React.createElement(Typography, { variant: "body2", className: classes.visibilitySectionInfo }, !isVisible ? (React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.hidden.info", defaultMessage: "ui.createGroup.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })) : (React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.visible.info", defaultMessage: "ui.createGroup.visibility.visible.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))))),
181
+ React.createElement(Divider, null),
182
+ React.createElement(Box, { className: classes.inviteSection },
183
+ React.createElement(GroupInviteButton, { handleInvitations: handleInviteSection })))));
184
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCCreateGroup";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCCreateGroup';
@@ -0,0 +1,3 @@
1
+ import CreateGroup, { CreateGroupProps } from './CreateGroup';
2
+ export default CreateGroup;
3
+ export { CreateGroupProps };
@@ -0,0 +1,2 @@
1
+ import CreateGroup from './CreateGroup';
2
+ export default CreateGroup;
@@ -0,0 +1,38 @@
1
+ import { ButtonProps } from '@mui/material/Button/Button';
2
+ import { CreateGroupProps } from '../CreateGroup';
3
+ export interface CreateGroupButtonProps extends ButtonProps {
4
+ /**
5
+ * Overrides or extends the styles applied to the component.
6
+ * @default null
7
+ */
8
+ className?: string;
9
+ /**
10
+ * Props to spread to CreateGroup component
11
+ * @default empty object
12
+ */
13
+ CreateGroupProps?: CreateGroupProps;
14
+ /**
15
+ * Any other properties
16
+ */
17
+ [p: string]: any;
18
+ }
19
+ /**
20
+ *> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
21
+ *
22
+ #### Import
23
+ ```jsx
24
+ import {CreateGroupButton} from '@selfcommunity/react-ui';
25
+ ```
26
+
27
+ #### Component Name
28
+ The name `SCCreateGroupButton` can be used when providing style overrides in the theme.
29
+
30
+ #### CSS
31
+
32
+ |Rule Name|Global class|Description|
33
+ |---|---|---|
34
+ |root|.SCCreateGroupButton-root|Styles applied to the root element.|
35
+
36
+ * @param inProps
37
+ */
38
+ export default function CreateGroupButton(inProps: CreateGroupButtonProps): JSX.Element;
@@ -0,0 +1,70 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useContext } from 'react';
3
+ import { useThemeProps } from '@mui/system';
4
+ import { styled } from '@mui/material/styles';
5
+ import { Button, Icon } from '@mui/material';
6
+ import { FormattedMessage } from 'react-intl';
7
+ import { SCUserContext } from '@selfcommunity/react-core';
8
+ import classNames from 'classnames';
9
+ import CreateGroup from '../CreateGroup';
10
+ const PREFIX = 'SCCreateGroupButton';
11
+ const classes = {
12
+ root: `${PREFIX}-root`
13
+ };
14
+ const Root = styled(Button, {
15
+ name: PREFIX,
16
+ slot: 'Root',
17
+ overridesResolver: (props, styles) => styles.root
18
+ })(({ theme }) => ({}));
19
+ /**
20
+ *> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
21
+ *
22
+ #### Import
23
+ ```jsx
24
+ import {CreateGroupButton} from '@selfcommunity/react-ui';
25
+ ```
26
+
27
+ #### Component Name
28
+ The name `SCCreateGroupButton` can be used when providing style overrides in the theme.
29
+
30
+ #### CSS
31
+
32
+ |Rule Name|Global class|Description|
33
+ |---|---|---|
34
+ |root|.SCCreateGroupButton-root|Styles applied to the root element.|
35
+
36
+ * @param inProps
37
+ */
38
+ export default function CreateGroupButton(inProps) {
39
+ //PROPS
40
+ const props = useThemeProps({
41
+ props: inProps,
42
+ name: PREFIX
43
+ });
44
+ const { className, CreateGroupProps = {} } = props, rest = __rest(props, ["className", "CreateGroupProps"]);
45
+ // CONTEXT
46
+ const scUserContext = useContext(SCUserContext);
47
+ // STATE
48
+ const [open, setOpen] = React.useState(false);
49
+ // CONST
50
+ const authUserId = scUserContext.user ? scUserContext.user.id : null;
51
+ /**
52
+ * Handle click on button
53
+ */
54
+ const handleClick = () => {
55
+ setOpen((p) => !p);
56
+ };
57
+ /**
58
+ * If there's no authUserId, component is hidden.
59
+ */
60
+ if (!authUserId) {
61
+ return null;
62
+ }
63
+ /**
64
+ * Renders root object
65
+ */
66
+ return (React.createElement(React.Fragment, null,
67
+ React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClick, size: "small", variant: "contained", startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest),
68
+ React.createElement(FormattedMessage, { id: "ui.createGroupButton", defaultMessage: "ui.createGroupButton" })),
69
+ open && React.createElement(CreateGroup, Object.assign({}, CreateGroupProps, { open: true, onClose: handleClick }))));
70
+ }
@@ -0,0 +1,3 @@
1
+ import CreateGroupButton, { CreateGroupButtonProps } from './CreateGroupButton';
2
+ export default CreateGroupButton;
3
+ export { CreateGroupButtonProps };
@@ -0,0 +1,2 @@
1
+ import CreateGroupButton from './CreateGroupButton';
2
+ export default CreateGroupButton;
@@ -0,0 +1,67 @@
1
+ import { ButtonBaseProps } from '@mui/material';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ import { WidgetProps } from '../Widget';
4
+ export interface GroupProps extends WidgetProps {
5
+ /**
6
+ * Group Object
7
+ * @default null
8
+ */
9
+ group?: SCGroupType;
10
+ /**
11
+ * Id of the group for filter the feed
12
+ * @default null
13
+ */
14
+ groupId?: number;
15
+ /**
16
+ * Handles actions ignore
17
+ * @default null
18
+ */
19
+ handleIgnoreAction?: (u: any) => void;
20
+ /**
21
+ * Badge content to show as group avatar badge if show reaction is true.
22
+ */
23
+ badgeContent?: any;
24
+ /**
25
+ * Prop to hide actions
26
+ * @default false
27
+ */
28
+ hideActions?: boolean;
29
+ /**
30
+ * Props to spread to the button
31
+ * @default {}
32
+ */
33
+ buttonProps?: ButtonBaseProps;
34
+ /**
35
+ * Any other properties
36
+ */
37
+ [p: string]: any;
38
+ }
39
+ /**
40
+ * > API documentation for the Community-JS Group component. Learn about the available props and the CSS API.
41
+ *
42
+ *
43
+ * This component renders a group item.
44
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/User)
45
+
46
+ #### Import
47
+
48
+ ```jsx
49
+ import {group} from '@selfcommunity/react-ui';
50
+ ```
51
+
52
+ #### Component Name
53
+
54
+ The name `SCGroup` can be used when providing style overrides in the theme.
55
+
56
+
57
+ #### CSS
58
+
59
+ |Rule Name|Global class|Description|
60
+ |---|---|---|
61
+ |root|.SCGroup-root|Styles applied to the root element.|
62
+ |avatar|.SCGroup-avatar|Styles applied to the avatar element.|
63
+
64
+ *
65
+ * @param inProps
66
+ */
67
+ export default function Group(inProps: GroupProps): JSX.Element;
@@ -0,0 +1,93 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useState } from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import { Avatar, Icon, Stack } from '@mui/material';
5
+ import { Link, SCRoutes, useSCFetchGroup, useSCRouting } from '@selfcommunity/react-core';
6
+ import { defineMessages, useIntl } from 'react-intl';
7
+ import classNames from 'classnames';
8
+ import { useThemeProps } from '@mui/system';
9
+ import BaseItemButton from '../../shared/BaseItemButton';
10
+ import UserDeletedSnackBar from '../../shared/UserDeletedSnackBar';
11
+ import { PREFIX } from './constants';
12
+ import GroupSkeleton from './Skeleton';
13
+ import GroupSubscribeButton from '../GroupSubscribeButton';
14
+ const messages = defineMessages({
15
+ groupMembers: {
16
+ id: 'ui.group.members',
17
+ defaultMessage: 'ui.group.members'
18
+ }
19
+ });
20
+ const classes = {
21
+ root: `${PREFIX}-root`,
22
+ avatar: `${PREFIX}-avatar`,
23
+ actions: `${PREFIX}-actions`
24
+ };
25
+ const Root = styled(BaseItemButton, {
26
+ name: PREFIX,
27
+ slot: 'Root',
28
+ overridesResolver: (props, styles) => styles.root
29
+ })(({ theme }) => ({}));
30
+ /**
31
+ * > API documentation for the Community-JS Group component. Learn about the available props and the CSS API.
32
+ *
33
+ *
34
+ * This component renders a group item.
35
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/User)
36
+
37
+ #### Import
38
+
39
+ ```jsx
40
+ import {group} from '@selfcommunity/react-ui';
41
+ ```
42
+
43
+ #### Component Name
44
+
45
+ The name `SCGroup` can be used when providing style overrides in the theme.
46
+
47
+
48
+ #### CSS
49
+
50
+ |Rule Name|Global class|Description|
51
+ |---|---|---|
52
+ |root|.SCGroup-root|Styles applied to the root element.|
53
+ |avatar|.SCGroup-avatar|Styles applied to the avatar element.|
54
+
55
+ *
56
+ * @param inProps
57
+ */
58
+ export default function Group(inProps) {
59
+ // PROPS
60
+ const props = useThemeProps({
61
+ props: inProps,
62
+ name: PREFIX
63
+ });
64
+ const { groupId = null, group = null, handleIgnoreAction, className = null, elevation, hideActions = false, buttonProps = {}, visible = true } = props, rest = __rest(props, ["groupId", "group", "handleIgnoreAction", "className", "elevation", "hideActions", "buttonProps", "visible"]);
65
+ // STATE
66
+ const { scGroup } = useSCFetchGroup({ id: groupId, group });
67
+ // CONTEXT
68
+ const scRoutingContext = useSCRouting();
69
+ const [openAlert, setOpenAlert] = useState(false);
70
+ // INTL
71
+ const intl = useIntl();
72
+ /**
73
+ * Render authenticated actions
74
+ * @return {JSX.Element}
75
+ */
76
+ function renderAuthenticatedActions() {
77
+ return (React.createElement(Stack, { className: classes.actions, direction: "row", alignItems: "center", justifyContent: "center", spacing: 2 },
78
+ React.createElement(Icon, null, !visible ? 'private' : 'public'),
79
+ React.createElement(GroupSubscribeButton, { group: group, groupId: groupId })));
80
+ }
81
+ /**
82
+ * Renders group object
83
+ */
84
+ if (!scGroup) {
85
+ return React.createElement(GroupSkeleton, { elevation: elevation });
86
+ }
87
+ /**
88
+ * Renders root object
89
+ */
90
+ return (React.createElement(React.Fragment, null,
91
+ React.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: classNames(classes.root, className), ButtonBaseProps: buttonProps !== null && buttonProps !== void 0 ? buttonProps : { component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: React.createElement(Avatar, { alt: scGroup.name, src: scGroup.image_medium, className: classes.avatar }), primary: scGroup.name, secondary: `${intl.formatMessage(messages.groupMembers, { total: scGroup.subscribers_counter })}`, actions: hideActions ? null : renderAuthenticatedActions() })),
92
+ openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
93
+ }
@@ -0,0 +1,22 @@
1
+ import { WidgetProps } from '../Widget';
2
+ /**
3
+ * > API documentation for the Community-JS Group Skeleton component. Learn about the available props and the CSS API.
4
+
5
+ #### Import
6
+
7
+ ```jsx
8
+ import {GroupSkeleton} from '@selfcommunity/react-ui';
9
+ ```
10
+
11
+ #### Component Name
12
+
13
+ The name `SCGroup-skeleton-root` can be used when providing style overrides in the theme.
14
+
15
+ #### CSS
16
+
17
+ |Rule Name|Global class|Description|
18
+ |---|---|---|
19
+ |root|.SCGroup-skeleton-root|Styles applied to the root element.|
20
+ *
21
+ */
22
+ export default function GroupSkeleton(props: WidgetProps): JSX.Element;
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { Button, useTheme } from '@mui/material';
3
+ import { styled } from '@mui/material/styles';
4
+ import Skeleton from '@mui/material/Skeleton';
5
+ import BaseItem from '../../shared/BaseItem';
6
+ import { PREFIX } from './constants';
7
+ const classes = {
8
+ root: `${PREFIX}-skeleton-root`
9
+ };
10
+ const Root = styled(BaseItem, {
11
+ name: PREFIX,
12
+ slot: 'SkeletonRoot'
13
+ })(() => ({}));
14
+ /**
15
+ * > API documentation for the Community-JS Group Skeleton component. Learn about the available props and the CSS API.
16
+
17
+ #### Import
18
+
19
+ ```jsx
20
+ import {GroupSkeleton} from '@selfcommunity/react-ui';
21
+ ```
22
+
23
+ #### Component Name
24
+
25
+ The name `SCGroup-skeleton-root` can be used when providing style overrides in the theme.
26
+
27
+ #### CSS
28
+
29
+ |Rule Name|Global class|Description|
30
+ |---|---|---|
31
+ |root|.SCGroup-skeleton-root|Styles applied to the root element.|
32
+ *
33
+ */
34
+ export default function GroupSkeleton(props) {
35
+ const theme = useTheme();
36
+ return (React.createElement(Root, Object.assign({ className: classes.root }, props, { image: React.createElement(Skeleton, { animation: "wave", variant: "circular", width: theme.selfcommunity.user.avatar.sizeMedium, height: theme.selfcommunity.user.avatar.sizeMedium }), primary: React.createElement(Skeleton, { animation: "wave", height: 10, width: 120, style: { marginBottom: 10 } }), secondary: React.createElement(Skeleton, { animation: "wave", height: 10, width: 70, style: { marginBottom: 10 } }), actions: React.createElement(Button, { size: "small", variant: "outlined", disabled: true },
37
+ React.createElement(Skeleton, { animation: "wave", height: 10, width: 30, style: { marginTop: 5, marginBottom: 5 } })) })));
38
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCGroup";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCGroup';
@@ -0,0 +1,4 @@
1
+ import Group, { GroupProps } from './Group';
2
+ import GroupSkeleton from './Skeleton';
3
+ export default Group;
4
+ export { GroupProps, GroupSkeleton };
@@ -0,0 +1,4 @@
1
+ import Group from './Group';
2
+ import GroupSkeleton from './Skeleton';
3
+ export default Group;
4
+ export { GroupSkeleton };
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ import { ChangeGroupCoverProps } from '../ChangeGroupCover';
4
+ import { ChangeGroupPictureProps } from '../ChangeGroupPicture';
5
+ import { GroupMembersButtonProps } from '../GroupMembersButton';
6
+ export interface GroupHeaderProps {
7
+ /**
8
+ * Id of group object
9
+ * @default null
10
+ */
11
+ id?: string;
12
+ /**
13
+ * Overrides or extends the styles applied to the component.
14
+ * @default null
15
+ */
16
+ className?: string;
17
+ /**
18
+ * Group Object
19
+ * @default null
20
+ */
21
+ group?: SCGroupType;
22
+ /**
23
+ * Id of the group
24
+ * @default null
25
+ */
26
+ groupId?: number;
27
+ /**
28
+ * Props to spread change picture button
29
+ * @default {}
30
+ */
31
+ ChangePictureProps?: ChangeGroupPictureProps;
32
+ /**
33
+ * Props to spread change cover button
34
+ * @default {}
35
+ */
36
+ ChangeCoverProps?: ChangeGroupCoverProps;
37
+ /**
38
+ * Props to spread to the group memebers button
39
+ * @default {}
40
+ */
41
+ GroupMembersButtonProps?: GroupMembersButtonProps;
42
+ /**
43
+ *
44
+ */
45
+ actions?: React.ReactNode;
46
+ /**
47
+ * Any other properties
48
+ */
49
+ [p: string]: any;
50
+ }
51
+ /**
52
+ * > API documentation for the Community-JS Group Header component. Learn about the available props and the CSS API.
53
+ *
54
+ *
55
+ * This component renders the groups top section.
56
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/UserProfileHeader)
57
+
58
+ #### Import
59
+
60
+ ```jsx
61
+ import {UserProfileHeader} from '@selfcommunity/react-ui';
62
+ ```
63
+
64
+ #### Component Name
65
+
66
+ The name `SCGroupHeader` can be used when providing style overrides in the theme.
67
+
68
+
69
+ #### CSS
70
+
71
+ |Rule Name|Global class|Description|
72
+ |---|---|---|
73
+ |root|.SCGroupHeader-root|Styles applied to the root element.|
74
+ |cover|.SCGroupHeader-cover|Styles applied to the cover element.|
75
+ |avatar|.SCGroupHeader-avatar|Styles applied to the avatar element.|
76
+ |info|SCGroupHeader-info|Styles applied to the info section.|
77
+ |name|SCGroupHeader-username|Styles applied to the username element.|
78
+ |changePicture|.SCGroupHeader-change-picture|Styles applied to changePicture element.|
79
+ |changeCover|.SCGroupHeader-change-cover`|Styles applied to changeCover element.|
80
+
81
+ * @param inProps
82
+ */
83
+ export default function GroupHeader(inProps: GroupHeaderProps): JSX.Element;