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

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 (186) hide show
  1. package/lib/cjs/components/BottomNavigation/BottomNavigation.js +3 -1
  2. package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
  3. package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +117 -0
  4. package/lib/cjs/components/ChangeGroupCover/constants.d.ts +1 -0
  5. package/lib/cjs/components/ChangeGroupCover/constants.js +4 -0
  6. package/lib/cjs/components/ChangeGroupCover/index.d.ts +3 -0
  7. package/lib/cjs/components/ChangeGroupCover/index.js +5 -0
  8. package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.d.ts +57 -0
  9. package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +117 -0
  10. package/lib/cjs/components/ChangeGroupPicture/constants.d.ts +1 -0
  11. package/lib/cjs/components/ChangeGroupPicture/constants.js +4 -0
  12. package/lib/cjs/components/ChangeGroupPicture/index.d.ts +3 -0
  13. package/lib/cjs/components/ChangeGroupPicture/index.js +5 -0
  14. package/lib/cjs/components/CreateGroup/CreateGroup.d.ts +48 -0
  15. package/lib/cjs/components/CreateGroup/CreateGroup.js +187 -0
  16. package/lib/cjs/components/CreateGroup/constants.d.ts +1 -0
  17. package/lib/cjs/components/CreateGroup/constants.js +4 -0
  18. package/lib/cjs/components/CreateGroup/index.d.ts +3 -0
  19. package/lib/cjs/components/CreateGroup/index.js +5 -0
  20. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
  21. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +73 -0
  22. package/lib/cjs/components/CreateGroupButton/index.d.ts +3 -0
  23. package/lib/cjs/components/CreateGroupButton/index.js +5 -0
  24. package/lib/cjs/components/Group/Group.d.ts +67 -0
  25. package/lib/cjs/components/Group/Group.js +96 -0
  26. package/lib/cjs/components/Group/Skeleton.d.ts +22 -0
  27. package/lib/cjs/components/Group/Skeleton.js +42 -0
  28. package/lib/cjs/components/Group/constants.d.ts +1 -0
  29. package/lib/cjs/components/Group/constants.js +4 -0
  30. package/lib/cjs/components/Group/index.d.ts +4 -0
  31. package/lib/cjs/components/Group/index.js +8 -0
  32. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +83 -0
  33. package/lib/cjs/components/GroupHeader/GroupHeader.js +137 -0
  34. package/lib/cjs/components/GroupHeader/Skeleton.d.ts +27 -0
  35. package/lib/cjs/components/GroupHeader/Skeleton.js +56 -0
  36. package/lib/cjs/components/GroupHeader/constants.d.ts +1 -0
  37. package/lib/cjs/components/GroupHeader/constants.js +4 -0
  38. package/lib/cjs/components/GroupHeader/index.d.ts +4 -0
  39. package/lib/cjs/components/GroupHeader/index.js +8 -0
  40. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.d.ts +52 -0
  41. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +100 -0
  42. package/lib/cjs/components/GroupInfoWidget/Skeleton.d.ts +21 -0
  43. package/lib/cjs/components/GroupInfoWidget/Skeleton.js +38 -0
  44. package/lib/cjs/components/GroupInfoWidget/constants.d.ts +1 -0
  45. package/lib/cjs/components/GroupInfoWidget/constants.js +4 -0
  46. package/lib/cjs/components/GroupInfoWidget/index.d.ts +4 -0
  47. package/lib/cjs/components/GroupInfoWidget/index.js +8 -0
  48. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.d.ts +57 -0
  49. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +261 -0
  50. package/lib/cjs/components/GroupInviteButton/index.d.ts +3 -0
  51. package/lib/cjs/components/GroupInviteButton/index.js +5 -0
  52. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +46 -0
  53. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +135 -0
  54. package/lib/cjs/components/GroupMembersButton/index.d.ts +3 -0
  55. package/lib/cjs/components/GroupMembersButton/index.js +5 -0
  56. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.d.ts +79 -0
  57. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +197 -0
  58. package/lib/cjs/components/GroupMembersWidget/Skeleton.d.ts +22 -0
  59. package/lib/cjs/components/GroupMembersWidget/Skeleton.js +38 -0
  60. package/lib/cjs/components/GroupMembersWidget/constants.d.ts +1 -0
  61. package/lib/cjs/components/GroupMembersWidget/constants.js +4 -0
  62. package/lib/cjs/components/GroupMembersWidget/index.d.ts +4 -0
  63. package/lib/cjs/components/GroupMembersWidget/index.js +8 -0
  64. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +79 -0
  65. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +194 -0
  66. package/lib/cjs/components/GroupRequestsWidget/Skeleton.d.ts +22 -0
  67. package/lib/cjs/components/GroupRequestsWidget/Skeleton.js +38 -0
  68. package/lib/cjs/components/GroupRequestsWidget/constants.d.ts +1 -0
  69. package/lib/cjs/components/GroupRequestsWidget/constants.js +4 -0
  70. package/lib/cjs/components/GroupRequestsWidget/index.d.ts +4 -0
  71. package/lib/cjs/components/GroupRequestsWidget/index.js +8 -0
  72. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +51 -0
  73. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +117 -0
  74. package/lib/cjs/components/GroupSubscribeButton/index.d.ts +3 -0
  75. package/lib/cjs/components/GroupSubscribeButton/index.js +5 -0
  76. package/lib/cjs/components/Groups/Groups.d.ts +65 -0
  77. package/lib/cjs/components/Groups/Groups.js +184 -0
  78. package/lib/cjs/components/Groups/Skeleton.d.ts +22 -0
  79. package/lib/cjs/components/Groups/Skeleton.js +38 -0
  80. package/lib/cjs/components/Groups/constants.d.ts +1 -0
  81. package/lib/cjs/components/Groups/constants.js +4 -0
  82. package/lib/cjs/components/Groups/index.d.ts +4 -0
  83. package/lib/cjs/components/Groups/index.js +8 -0
  84. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +4 -0
  85. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +2 -3
  86. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +5 -1
  87. package/lib/cjs/components/User/User.d.ts +12 -0
  88. package/lib/cjs/components/User/User.js +5 -3
  89. package/lib/cjs/constants/Group.d.ts +2 -0
  90. package/lib/cjs/constants/Group.js +5 -0
  91. package/lib/cjs/index.d.ts +14 -1
  92. package/lib/cjs/index.js +34 -2
  93. package/lib/esm/components/BottomNavigation/BottomNavigation.js +3 -1
  94. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
  95. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +114 -0
  96. package/lib/esm/components/ChangeGroupCover/constants.d.ts +1 -0
  97. package/lib/esm/components/ChangeGroupCover/constants.js +1 -0
  98. package/lib/esm/components/ChangeGroupCover/index.d.ts +3 -0
  99. package/lib/esm/components/ChangeGroupCover/index.js +2 -0
  100. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.d.ts +57 -0
  101. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +114 -0
  102. package/lib/esm/components/ChangeGroupPicture/constants.d.ts +1 -0
  103. package/lib/esm/components/ChangeGroupPicture/constants.js +1 -0
  104. package/lib/esm/components/ChangeGroupPicture/index.d.ts +3 -0
  105. package/lib/esm/components/ChangeGroupPicture/index.js +2 -0
  106. package/lib/esm/components/CreateGroup/CreateGroup.d.ts +48 -0
  107. package/lib/esm/components/CreateGroup/CreateGroup.js +184 -0
  108. package/lib/esm/components/CreateGroup/constants.d.ts +1 -0
  109. package/lib/esm/components/CreateGroup/constants.js +1 -0
  110. package/lib/esm/components/CreateGroup/index.d.ts +3 -0
  111. package/lib/esm/components/CreateGroup/index.js +2 -0
  112. package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
  113. package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +70 -0
  114. package/lib/esm/components/CreateGroupButton/index.d.ts +3 -0
  115. package/lib/esm/components/CreateGroupButton/index.js +2 -0
  116. package/lib/esm/components/Group/Group.d.ts +67 -0
  117. package/lib/esm/components/Group/Group.js +93 -0
  118. package/lib/esm/components/Group/Skeleton.d.ts +22 -0
  119. package/lib/esm/components/Group/Skeleton.js +38 -0
  120. package/lib/esm/components/Group/constants.d.ts +1 -0
  121. package/lib/esm/components/Group/constants.js +1 -0
  122. package/lib/esm/components/Group/index.d.ts +4 -0
  123. package/lib/esm/components/Group/index.js +4 -0
  124. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +83 -0
  125. package/lib/esm/components/GroupHeader/GroupHeader.js +134 -0
  126. package/lib/esm/components/GroupHeader/Skeleton.d.ts +27 -0
  127. package/lib/esm/components/GroupHeader/Skeleton.js +53 -0
  128. package/lib/esm/components/GroupHeader/constants.d.ts +1 -0
  129. package/lib/esm/components/GroupHeader/constants.js +1 -0
  130. package/lib/esm/components/GroupHeader/index.d.ts +4 -0
  131. package/lib/esm/components/GroupHeader/index.js +4 -0
  132. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.d.ts +52 -0
  133. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +97 -0
  134. package/lib/esm/components/GroupInfoWidget/Skeleton.d.ts +21 -0
  135. package/lib/esm/components/GroupInfoWidget/Skeleton.js +34 -0
  136. package/lib/esm/components/GroupInfoWidget/constants.d.ts +1 -0
  137. package/lib/esm/components/GroupInfoWidget/constants.js +1 -0
  138. package/lib/esm/components/GroupInfoWidget/index.d.ts +4 -0
  139. package/lib/esm/components/GroupInfoWidget/index.js +4 -0
  140. package/lib/esm/components/GroupInviteButton/GroupInviteButton.d.ts +57 -0
  141. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +258 -0
  142. package/lib/esm/components/GroupInviteButton/index.d.ts +3 -0
  143. package/lib/esm/components/GroupInviteButton/index.js +2 -0
  144. package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +46 -0
  145. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +132 -0
  146. package/lib/esm/components/GroupMembersButton/index.d.ts +3 -0
  147. package/lib/esm/components/GroupMembersButton/index.js +2 -0
  148. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.d.ts +79 -0
  149. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +194 -0
  150. package/lib/esm/components/GroupMembersWidget/Skeleton.d.ts +22 -0
  151. package/lib/esm/components/GroupMembersWidget/Skeleton.js +34 -0
  152. package/lib/esm/components/GroupMembersWidget/constants.d.ts +1 -0
  153. package/lib/esm/components/GroupMembersWidget/constants.js +1 -0
  154. package/lib/esm/components/GroupMembersWidget/index.d.ts +4 -0
  155. package/lib/esm/components/GroupMembersWidget/index.js +4 -0
  156. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +79 -0
  157. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +191 -0
  158. package/lib/esm/components/GroupRequestsWidget/Skeleton.d.ts +22 -0
  159. package/lib/esm/components/GroupRequestsWidget/Skeleton.js +34 -0
  160. package/lib/esm/components/GroupRequestsWidget/constants.d.ts +1 -0
  161. package/lib/esm/components/GroupRequestsWidget/constants.js +1 -0
  162. package/lib/esm/components/GroupRequestsWidget/index.d.ts +4 -0
  163. package/lib/esm/components/GroupRequestsWidget/index.js +4 -0
  164. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +51 -0
  165. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +114 -0
  166. package/lib/esm/components/GroupSubscribeButton/index.d.ts +3 -0
  167. package/lib/esm/components/GroupSubscribeButton/index.js +2 -0
  168. package/lib/esm/components/Groups/Groups.d.ts +65 -0
  169. package/lib/esm/components/Groups/Groups.js +181 -0
  170. package/lib/esm/components/Groups/Skeleton.d.ts +22 -0
  171. package/lib/esm/components/Groups/Skeleton.js +34 -0
  172. package/lib/esm/components/Groups/constants.d.ts +1 -0
  173. package/lib/esm/components/Groups/constants.js +1 -0
  174. package/lib/esm/components/Groups/index.d.ts +4 -0
  175. package/lib/esm/components/Groups/index.js +4 -0
  176. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +4 -0
  177. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +3 -4
  178. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +5 -1
  179. package/lib/esm/components/User/User.d.ts +12 -0
  180. package/lib/esm/components/User/User.js +5 -3
  181. package/lib/esm/constants/Group.d.ts +2 -0
  182. package/lib/esm/constants/Group.js +2 -0
  183. package/lib/esm/index.d.ts +14 -1
  184. package/lib/esm/index.js +14 -1
  185. package/lib/umd/react-ui.js +1 -1
  186. package/package.json +6 -6
@@ -0,0 +1,191 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useEffect, useMemo, useReducer, useState } from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import List from '@mui/material/List';
5
+ import { Button, CardContent, ListItem, Typography, useMediaQuery, useTheme } from '@mui/material';
6
+ import Widget from '../Widget';
7
+ import { http, Endpoints, GroupService } from '@selfcommunity/api-services';
8
+ import { CacheStrategies, isInteger, Logger } from '@selfcommunity/utils';
9
+ import { SCCache, SCPreferences, useSCFetchGroup, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
10
+ import { actionWidgetTypes, dataWidgetReducer, stateWidgetInitializer } from '../../utils/widget';
11
+ import Skeleton from './Skeleton';
12
+ import { FormattedMessage } from 'react-intl';
13
+ import classNames from 'classnames';
14
+ import { SCOPE_SC_UI } from '../../constants/Errors';
15
+ import BaseDialog from '../../shared/BaseDialog';
16
+ import InfiniteScroll from '../../shared/InfiniteScroll';
17
+ import { useThemeProps } from '@mui/system';
18
+ import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
19
+ import { PREFIX } from './constants';
20
+ import User, { UserSkeleton } from '../User';
21
+ const classes = {
22
+ root: `${PREFIX}-root`,
23
+ title: `${PREFIX}-title`,
24
+ noResults: `${PREFIX}-no-results`,
25
+ showMore: `${PREFIX}-show-more`,
26
+ dialogRoot: `${PREFIX}-dialog-root`,
27
+ endMessage: `${PREFIX}-end-message`
28
+ };
29
+ const Root = styled(Widget, {
30
+ name: PREFIX,
31
+ slot: 'Root'
32
+ })(() => ({}));
33
+ const DialogRoot = styled(BaseDialog, {
34
+ name: PREFIX,
35
+ slot: 'DialogRoot'
36
+ })(() => ({}));
37
+ /**
38
+ * > API documentation for the Community-JS Group Requests Widget component. Learn about the available props and the CSS API.
39
+ *
40
+ *
41
+ * This component renders the list of the follows of the given group.
42
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupRequests)
43
+
44
+ #### Import
45
+
46
+ ```jsx
47
+ import {GroupRequestsWidget} from '@selfcommunity/react-ui';
48
+ ```
49
+
50
+ #### Component Name
51
+
52
+ The name `SCGroupRequestsWidget` can be used when providing style overrides in the theme.
53
+
54
+
55
+ #### CSS
56
+
57
+ |Rule Name|Global class|Description|
58
+ |---|---|---|
59
+ |root|.SCGroupRequestsWidget-root|Styles applied to the root element.|
60
+ |title|.SCGroupRequestsWidget-title|Styles applied to the title element.|
61
+ |noResults|.SCGroupRequestsWidget-no-results|Styles applied to no results section.|
62
+ |showMore|.SCGroupRequestsWidget-show-more|Styles applied to show more button element.|
63
+ |dialogRoot|.SCGroupRequestsWidget-dialog-root|Styles applied to the dialog root element.|
64
+ |endMessage|.SCGroupRequestsWidget-end-message|Styles applied to the end message element.|
65
+
66
+ * @param inProps
67
+ */
68
+ export default function GroupRequestsWidget(inProps) {
69
+ // PROPS
70
+ const props = useThemeProps({
71
+ props: inProps,
72
+ name: PREFIX
73
+ });
74
+ const { groupId, group, autoHide = false, limit = 5, className, cacheStrategy = CacheStrategies.NETWORK_ONLY, onHeightChange, onStateChange, UserProps = {}, DialogProps = {} } = props, rest = __rest(props, ["groupId", "group", "autoHide", "limit", "className", "cacheStrategy", "onHeightChange", "onStateChange", "UserProps", "DialogProps"]);
75
+ // STATE
76
+ const [state, dispatch] = useReducer(dataWidgetReducer, {
77
+ isLoadingNext: false,
78
+ next: null,
79
+ cacheKey: SCCache.getWidgetStateCacheKey(SCCache.GROUP_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY, isInteger(groupId) ? groupId : group.id),
80
+ cacheStrategy,
81
+ visibleItems: limit
82
+ }, stateWidgetInitializer);
83
+ const [openDialog, setOpenDialog] = useState(false);
84
+ // CONTEXT
85
+ const scUserContext = useSCUser();
86
+ const scPreferencesContext = useSCPreferences();
87
+ const { scGroup } = useSCFetchGroup({ id: groupId, group });
88
+ // MEMO
89
+ const contentAvailability = useMemo(() => SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY in scPreferencesContext.preferences &&
90
+ scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value, [scPreferencesContext.preferences]);
91
+ // HOOKS
92
+ const theme = useTheme();
93
+ const isMobile = useMediaQuery(theme.breakpoints.down('md'));
94
+ /**
95
+ * Initialize component
96
+ * Fetch data only if the component is not initialized and it is not loading data
97
+ */
98
+ const _initComponent = useMemo(() => () => {
99
+ if (!state.initialized && !state.isLoadingNext) {
100
+ dispatch({ type: actionWidgetTypes.LOADING_NEXT });
101
+ GroupService.getGroupWaitingApprovalSubscribers(scGroup.id, { limit })
102
+ .then((payload) => {
103
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
104
+ })
105
+ .catch((error) => {
106
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
107
+ Logger.error(SCOPE_SC_UI, error);
108
+ });
109
+ }
110
+ }, [state.isLoadingNext, state.initialized, scGroup, limit, dispatch]);
111
+ // EFFECTS
112
+ useEffect(() => {
113
+ var _a;
114
+ let _t;
115
+ if ((contentAvailability || (!contentAvailability && ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id))) && scGroup && scUserContext.user !== undefined) {
116
+ _t = setTimeout(_initComponent);
117
+ return () => {
118
+ _t && clearTimeout(_t);
119
+ };
120
+ }
121
+ }, [scUserContext.user, contentAvailability, scGroup]);
122
+ useEffect(() => {
123
+ if (openDialog && state.next && state.results.length === limit && state.initialized) {
124
+ dispatch({ type: actionWidgetTypes.LOADING_NEXT });
125
+ GroupService.getGroupWaitingApprovalSubscribers(scGroup.id, { offset: limit, limit: 10 })
126
+ .then((payload) => {
127
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: payload });
128
+ })
129
+ .catch((error) => {
130
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
131
+ Logger.error(SCOPE_SC_UI, error);
132
+ });
133
+ }
134
+ }, [openDialog, state.next, state.results.length, state.initialized, limit]);
135
+ /**
136
+ * Virtual feed update
137
+ */
138
+ useEffect(() => {
139
+ onHeightChange && onHeightChange();
140
+ }, [state.results]);
141
+ useEffect(() => {
142
+ if (!scGroup || (!contentAvailability && !scUserContext.user)) {
143
+ return;
144
+ }
145
+ else if (cacheStrategy === CacheStrategies.NETWORK_ONLY) {
146
+ onStateChange && onStateChange({ cacheStrategy: CacheStrategies.CACHE_FIRST });
147
+ }
148
+ }, [scUserContext.user, scGroup, contentAvailability]);
149
+ useEffect(() => {
150
+ if (!scGroup || !scUserContext.user || !state.initialized) {
151
+ return;
152
+ }
153
+ }, []);
154
+ // HANDLERS
155
+ const handleNext = useMemo(() => () => {
156
+ dispatch({ type: actionWidgetTypes.LOADING_NEXT });
157
+ http
158
+ .request({
159
+ url: state.next,
160
+ method: Endpoints.GetGroupWaitingApprovalSubscribers.method
161
+ })
162
+ .then((res) => {
163
+ dispatch({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: res.data });
164
+ });
165
+ }, [dispatch, state.next, state.isLoadingNext, state.initialized]);
166
+ const handleToggleDialogOpen = () => {
167
+ setOpenDialog((prev) => !prev);
168
+ };
169
+ // RENDER
170
+ if ((autoHide && !state.count && state.initialized) || (!contentAvailability && !scUserContext.user) || !scGroup) {
171
+ return React.createElement(HiddenPlaceholder, null);
172
+ }
173
+ if (!state.initialized) {
174
+ return React.createElement(Skeleton, null);
175
+ }
176
+ const content = (React.createElement(CardContent, null,
177
+ React.createElement(Typography, { className: classes.title, variant: "h5" },
178
+ React.createElement(FormattedMessage, { id: "ui.groupRequestsWidget.title", defaultMessage: "ui.groupRequestsWidget.title" })),
179
+ !state.count ? (React.createElement(Typography, { className: classes.noResults, variant: "body2" },
180
+ React.createElement(FormattedMessage, { id: "ui.groupRequestsWidget.subtitle.noResults", defaultMessage: "" }))) : (React.createElement(React.Fragment, null,
181
+ React.createElement(List, null, state.results.slice(0, state.visibleItems).map((user) => (React.createElement(ListItem, { key: user.id },
182
+ React.createElement(User, { elevation: 0, actions: React.createElement(React.Fragment, null), user: user, userId: user.id, buttonProps: { onClick: () => console.log(user) } }))))),
183
+ state.count > state.visibleItems && (React.createElement(Button, { className: classes.showMore, onClick: handleToggleDialogOpen },
184
+ React.createElement(FormattedMessage, { id: "ui.groupRequestsWidget.button.showMore", defaultMessage: "ui.groupRequestsWidget.button.showMore" }))))),
185
+ openDialog && (React.createElement(DialogRoot, Object.assign({ className: classes.dialogRoot, title: React.createElement(FormattedMessage, { defaultMessage: "ui.groupRequestsWidget.dialogTitle", id: "ui.groupRequestsWidget.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: openDialog }, DialogProps),
186
+ 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 },
187
+ React.createElement(FormattedMessage, { id: "ui.groupRequestsWidget.noMoreResults", defaultMessage: "ui.groupRequestsWidget.noMoreResults" })) },
188
+ React.createElement(List, null, state.results.map((user) => (React.createElement(ListItem, { key: user.id },
189
+ React.createElement(User, { elevation: 0, actions: React.createElement(React.Fragment, null), user: user, userId: user.id, buttonProps: { onClick: () => console.log(user) } }))))))))));
190
+ return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest), content));
191
+ }
@@ -0,0 +1,22 @@
1
+ import { WidgetProps } from '../Widget';
2
+ /**
3
+ * > API documentation for the Community-JS Group Requests Widget Skeleton component. Learn about the available props and the CSS API.
4
+
5
+ #### Import
6
+
7
+ ```jsx
8
+ import {GroupRequestsWidgetSkeleton} from '@selfcommunity/react-ui';
9
+ ```
10
+
11
+ #### Component Name
12
+
13
+ The name `SCGroupRequestsWidget-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|.SCGroupRequestsWidget-skeleton-root|Styles applied to the root element.|
20
+ *
21
+ */
22
+ export default function GroupRequestsWidgetSkeleton(props: WidgetProps): JSX.Element;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { CategoryTrendingPeopleWidgetSkeleton } from '../CategoryTrendingUsersWidget';
3
+ import { styled } from '@mui/material/styles';
4
+ import { PREFIX } from './constants';
5
+ const classes = {
6
+ root: `${PREFIX}-skeleton-root`
7
+ };
8
+ const Root = styled(CategoryTrendingPeopleWidgetSkeleton, {
9
+ name: PREFIX,
10
+ slot: 'SkeletonRoot'
11
+ })(() => ({}));
12
+ /**
13
+ * > API documentation for the Community-JS Group Requests Widget Skeleton component. Learn about the available props and the CSS API.
14
+
15
+ #### Import
16
+
17
+ ```jsx
18
+ import {GroupRequestsWidgetSkeleton} from '@selfcommunity/react-ui';
19
+ ```
20
+
21
+ #### Component Name
22
+
23
+ The name `SCGroupRequestsWidget-skeleton-root` can be used when providing style overrides in the theme.
24
+
25
+ #### CSS
26
+
27
+ |Rule Name|Global class|Description|
28
+ |---|---|---|
29
+ |root|.SCGroupRequestsWidget-skeleton-root|Styles applied to the root element.|
30
+ *
31
+ */
32
+ export default function GroupRequestsWidgetSkeleton(props) {
33
+ return React.createElement(Root, Object.assign({ className: classes.root }, props));
34
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCGroupRequestsWidget";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCGroupRequestsWidget';
@@ -0,0 +1,4 @@
1
+ import GroupRequestsWidget, { GroupRequestsWidgetProps } from './GroupRequestsWidget';
2
+ import GroupRequestsWidgetSkeleton from './Skeleton';
3
+ export default GroupRequestsWidget;
4
+ export { GroupRequestsWidgetProps, GroupRequestsWidgetSkeleton };
@@ -0,0 +1,4 @@
1
+ import GroupRequestsWidget from './GroupRequestsWidget';
2
+ import GroupRequestsWidgetSkeleton from './Skeleton';
3
+ export default GroupRequestsWidget;
4
+ export { GroupRequestsWidgetSkeleton };
@@ -0,0 +1,51 @@
1
+ import { SCGroupType } from '@selfcommunity/types';
2
+ export interface GroupSubscribeButtonProps {
3
+ /**
4
+ * Overrides or extends the styles applied to the component.
5
+ * @default null
6
+ */
7
+ className?: string;
8
+ /**
9
+ * Group Object
10
+ * @default null
11
+ */
12
+ group?: SCGroupType;
13
+ /**
14
+ * Id of the group
15
+ * @default null
16
+ */
17
+ groupId?: number;
18
+ /**
19
+ * onJoin callback
20
+ * @param user
21
+ * @param joined
22
+ */
23
+ onJoin?: (group: SCGroupType, member: boolean) => any;
24
+ /**
25
+ * Others properties
26
+ */
27
+ [p: string]: any;
28
+ }
29
+ /**
30
+ * > API documentation for the Community-JS Group Subscribe Button component. Learn about the available props and the CSS API.
31
+
32
+ #### Import
33
+
34
+ ```jsx
35
+ import {GroupSubscribeButton} from '@selfcommunity/react-ui';
36
+ ```
37
+
38
+ #### Component Name
39
+
40
+ The name `SCGroupSubscribeButton` can be used when providing style overrides in the theme.
41
+
42
+
43
+ #### CSS
44
+
45
+ |Rule Name|Global class|Description|
46
+ |---|---|---|
47
+ |root|.SCGroupSubscribeButton-root|Styles applied to the root element.|
48
+
49
+ * @param inProps
50
+ */
51
+ export default function GroupSubscribeButton(inProps: GroupSubscribeButtonProps): JSX.Element;
@@ -0,0 +1,114 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useEffect, useState } from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import { CacheStrategies, Logger } from '@selfcommunity/utils';
5
+ import { useSCContext, useSCFetchGroup, useSCUser } from '@selfcommunity/react-core';
6
+ import { SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
7
+ import { LoadingButton } from '@mui/lab';
8
+ import { FormattedMessage } from 'react-intl';
9
+ import classNames from 'classnames';
10
+ import { useThemeProps } from '@mui/system';
11
+ import { SCOPE_SC_UI } from '../../constants/Errors';
12
+ const PREFIX = 'SCGroupSubscribeButton';
13
+ const classes = {
14
+ root: `${PREFIX}-root`
15
+ };
16
+ const Root = styled(LoadingButton, {
17
+ name: PREFIX,
18
+ slot: 'Root',
19
+ overridesResolver: (props, styles) => styles.root
20
+ })(({ theme }) => ({}));
21
+ /**
22
+ * > API documentation for the Community-JS Group Subscribe Button component. Learn about the available props and the CSS API.
23
+
24
+ #### Import
25
+
26
+ ```jsx
27
+ import {GroupSubscribeButton} from '@selfcommunity/react-ui';
28
+ ```
29
+
30
+ #### Component Name
31
+
32
+ The name `SCGroupSubscribeButton` can be used when providing style overrides in the theme.
33
+
34
+
35
+ #### CSS
36
+
37
+ |Rule Name|Global class|Description|
38
+ |---|---|---|
39
+ |root|.SCGroupSubscribeButton-root|Styles applied to the root element.|
40
+
41
+ * @param inProps
42
+ */
43
+ export default function GroupSubscribeButton(inProps) {
44
+ // PROPS
45
+ const props = useThemeProps({
46
+ props: inProps,
47
+ name: PREFIX
48
+ });
49
+ const { className, groupId, group, onJoin } = props, rest = __rest(props, ["className", "groupId", "group", "onJoin"]);
50
+ // STATE
51
+ const [status, setStatus] = useState(null);
52
+ // CONTEXT
53
+ const scContext = useSCContext();
54
+ const scUserContext = useSCUser();
55
+ const scGroupsManager = scUserContext.managers.groups;
56
+ // CONST
57
+ const authUserId = scUserContext.user ? scUserContext.user.id : null;
58
+ const { scGroup } = useSCFetchGroup({
59
+ id: groupId,
60
+ group,
61
+ cacheStrategy: authUserId ? CacheStrategies.CACHE_FIRST : CacheStrategies.STALE_WHILE_REVALIDATE
62
+ });
63
+ useEffect(() => {
64
+ /**
65
+ * Call scGroupsManager.subscriptionStatus inside an effect
66
+ * to avoid warning rendering child during update parent state
67
+ */
68
+ if (authUserId) {
69
+ setStatus(scGroupsManager.subscriptionStatus(scGroup));
70
+ }
71
+ }, [authUserId, scGroupsManager.subscriptionStatus]);
72
+ const subscribe = () => {
73
+ scGroupsManager
74
+ .subscribe(scGroup)
75
+ .then(() => {
76
+ // onJoin && onJoin(scGroup, !joined);
77
+ })
78
+ .catch((e) => {
79
+ Logger.error(SCOPE_SC_UI, e);
80
+ });
81
+ };
82
+ const handleSubscribeAction = () => {
83
+ if (!scUserContext.user) {
84
+ scContext.settings.handleAnonymousAction();
85
+ }
86
+ else {
87
+ subscribe();
88
+ }
89
+ };
90
+ /**
91
+ * Get current translated status
92
+ */
93
+ const getStatus = () => {
94
+ let _status;
95
+ switch (status) {
96
+ case SCGroupSubscriptionStatusType.REQUESTED:
97
+ _status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupJoinButton.waitingApproval", id: "ui.groupJoinButton.waitingApproval" });
98
+ break;
99
+ case SCGroupSubscriptionStatusType.SUBSCRIBED:
100
+ _status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.exit", id: "ui.groupSubscribeButton.exit" });
101
+ break;
102
+ default:
103
+ scGroup.privacy === SCGroupPrivacyType.PUBLIC
104
+ ? (_status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupSubscribeButton.enter", id: "ui.groupSubscribeButton.enter" }))
105
+ : (_status = React.createElement(FormattedMessage, { defaultMessage: "ui.groupJoinButton.requestAccess", id: "ui.groupJoinButton.requestAccess" }));
106
+ break;
107
+ }
108
+ return _status;
109
+ };
110
+ if (!scGroup || (scGroup && !scGroup.subscription_status)) {
111
+ return null;
112
+ }
113
+ return (React.createElement(Root, Object.assign({ size: "small", variant: "outlined", onClick: handleSubscribeAction, loading: scUserContext.user ? scGroupsManager.isLoading(scGroup) : null, className: classNames(classes.root, className) }, rest), getStatus()));
114
+ }
@@ -0,0 +1,3 @@
1
+ import GroupSubscribeButton, { GroupSubscribeButtonProps } from './GroupSubscribeButton';
2
+ export default GroupSubscribeButton;
3
+ export { GroupSubscribeButtonProps };
@@ -0,0 +1,2 @@
1
+ import GroupSubscribeButton from './GroupSubscribeButton';
2
+ export default GroupSubscribeButton;
@@ -0,0 +1,65 @@
1
+ import { EndpointType } from '@selfcommunity/api-services';
2
+ import { CacheStrategies } from '@selfcommunity/utils';
3
+ import { GroupProps } from '../Group';
4
+ export interface GroupsProps {
5
+ /**
6
+ * Endpoint to call
7
+ */
8
+ endpoint: EndpointType;
9
+ /**
10
+ * Hides this component
11
+ * @default false
12
+ */
13
+ autoHide?: boolean;
14
+ /**
15
+ * Limit the number of users to show
16
+ * @default false
17
+ */
18
+ limit?: number;
19
+ /**
20
+ * Caching strategies
21
+ * @default CacheStrategies.CACHE_FIRST
22
+ */
23
+ cacheStrategy?: CacheStrategies;
24
+ /**
25
+ * Props to spread to single user object
26
+ * @default empty object
27
+ */
28
+ GroupProps?: GroupProps;
29
+ /**
30
+ * Other props
31
+ */
32
+ [p: string]: any;
33
+ }
34
+ /**
35
+ * > API documentation for the Community-JS Groups component. Learn about the available props and the CSS API.
36
+ *
37
+ *
38
+ * This component renders the list of the follows of the given group.
39
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/Groups)
40
+
41
+ #### Import
42
+
43
+ ```jsx
44
+ import {Groups} from '@selfcommunity/react-ui';
45
+ ```
46
+
47
+ #### Component Name
48
+
49
+ The name `SCGroups` can be used when providing style overrides in the theme.
50
+
51
+
52
+ #### CSS
53
+
54
+ |Rule Name|Global class|Description|
55
+ |---|---|---|
56
+ |root|.SCGroups-root|Styles applied to the root element.|
57
+ |title|.SCGroups-title|Styles applied to the title element.|
58
+ |noResults|.SCGroups-no-results|Styles applied to no results section.|
59
+ |showMore|.SCGroups-show-more|Styles applied to show more button element.|
60
+ |dialogRoot|.SCGroups-dialog-root|Styles applied to the dialog root element.|
61
+ |endMessage|.SCGroups-end-message|Styles applied to the end message element.|
62
+
63
+ * @param inProps
64
+ */
65
+ export default function Groups(inProps: GroupsProps): JSX.Element;