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

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 (167) hide show
  1. package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
  2. package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
  3. package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
  4. package/lib/cjs/components/Composer/Attributes/Attributes.js +9 -2
  5. package/lib/cjs/components/Composer/Composer.d.ts +2 -1
  6. package/lib/cjs/components/Composer/Composer.js +39 -12
  7. package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  8. package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.js +4 -3
  9. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
  10. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +46 -12
  11. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  12. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
  13. package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
  14. package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  15. package/lib/cjs/components/EditGroupButton/EditGroupButton.js +61 -0
  16. package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
  17. package/lib/cjs/components/EditGroupButton/index.js +5 -0
  18. package/lib/cjs/components/FeedObject/Actions/Follow/Follow.js +18 -0
  19. package/lib/cjs/components/FeedObject/Actions/Share/Share.js +18 -0
  20. package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
  21. package/lib/cjs/components/FeedObject/FeedObject.js +43 -9
  22. package/lib/cjs/components/Group/Group.d.ts +4 -3
  23. package/lib/cjs/components/Group/Group.js +5 -4
  24. package/lib/cjs/components/Group/Skeleton.js +1 -1
  25. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  26. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
  27. package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
  28. package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
  29. package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
  30. package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
  31. package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
  32. package/lib/cjs/components/{CreateGroup → GroupForm}/constants.js +1 -1
  33. package/lib/cjs/components/GroupForm/index.d.ts +3 -0
  34. package/lib/cjs/components/GroupForm/index.js +5 -0
  35. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -5
  36. package/lib/cjs/components/GroupHeader/GroupHeader.js +21 -11
  37. package/lib/cjs/components/GroupHeader/Skeleton.d.ts +2 -4
  38. package/lib/cjs/components/GroupHeader/Skeleton.js +10 -10
  39. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +12 -8
  40. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +7 -6
  41. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  42. package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +3 -2
  43. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +36 -16
  44. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +0 -5
  45. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +17 -7
  46. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  47. package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +132 -0
  48. package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
  49. package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
  50. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  51. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +24 -9
  52. package/lib/cjs/components/Groups/Groups.d.ts +16 -16
  53. package/lib/cjs/components/Groups/Groups.js +47 -96
  54. package/lib/cjs/components/Groups/Skeleton.d.ts +14 -2
  55. package/lib/cjs/components/Groups/Skeleton.js +12 -5
  56. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  57. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  58. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
  59. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
  60. package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
  61. package/lib/cjs/components/Notification/Group/Group.js +79 -0
  62. package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
  63. package/lib/cjs/components/Notification/Group/index.js +5 -0
  64. package/lib/cjs/components/Notification/Notification.js +32 -1
  65. package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  66. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  67. package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +10 -7
  68. package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  69. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  70. package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
  71. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  72. package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +45 -20
  73. package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  74. package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
  75. package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
  76. package/lib/cjs/components/VoteButton/VoteButton.js +19 -0
  77. package/lib/cjs/index.d.ts +7 -4
  78. package/lib/cjs/index.js +13 -6
  79. package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
  80. package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
  81. package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
  82. package/lib/esm/components/Composer/Attributes/Attributes.js +9 -2
  83. package/lib/esm/components/Composer/Composer.d.ts +2 -1
  84. package/lib/esm/components/Composer/Composer.js +39 -12
  85. package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  86. package/lib/esm/components/Composer/Content/ContentPost/ContentPost.js +4 -3
  87. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
  88. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +45 -12
  89. package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  90. package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
  91. package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
  92. package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  93. package/lib/esm/components/EditGroupButton/EditGroupButton.js +58 -0
  94. package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
  95. package/lib/esm/components/EditGroupButton/index.js +2 -0
  96. package/lib/esm/components/FeedObject/Actions/Follow/Follow.js +20 -2
  97. package/lib/esm/components/FeedObject/Actions/Share/Share.js +20 -2
  98. package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
  99. package/lib/esm/components/FeedObject/FeedObject.js +45 -11
  100. package/lib/esm/components/Group/Group.d.ts +4 -3
  101. package/lib/esm/components/Group/Group.js +5 -4
  102. package/lib/esm/components/Group/Skeleton.js +1 -1
  103. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  104. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
  105. package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
  106. package/lib/esm/components/GroupAutocomplete/index.js +2 -0
  107. package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
  108. package/lib/esm/components/GroupForm/GroupForm.js +236 -0
  109. package/lib/esm/components/GroupForm/constants.d.ts +1 -0
  110. package/lib/esm/components/GroupForm/constants.js +1 -0
  111. package/lib/esm/components/GroupForm/index.d.ts +3 -0
  112. package/lib/esm/components/GroupForm/index.js +2 -0
  113. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -5
  114. package/lib/esm/components/GroupHeader/GroupHeader.js +21 -11
  115. package/lib/esm/components/GroupHeader/Skeleton.d.ts +2 -4
  116. package/lib/esm/components/GroupHeader/Skeleton.js +10 -10
  117. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +12 -8
  118. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +7 -6
  119. package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
  120. package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +4 -3
  121. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +38 -18
  122. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +0 -5
  123. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +17 -7
  124. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
  125. package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +129 -0
  126. package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
  127. package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
  128. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
  129. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +25 -10
  130. package/lib/esm/components/Groups/Groups.d.ts +16 -16
  131. package/lib/esm/components/Groups/Groups.js +52 -101
  132. package/lib/esm/components/Groups/Skeleton.d.ts +14 -2
  133. package/lib/esm/components/Groups/Skeleton.js +13 -5
  134. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  135. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
  136. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
  137. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
  138. package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
  139. package/lib/esm/components/Notification/Group/Group.js +76 -0
  140. package/lib/esm/components/Notification/Group/index.d.ts +3 -0
  141. package/lib/esm/components/Notification/Group/index.js +2 -0
  142. package/lib/esm/components/Notification/Notification.js +32 -1
  143. package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
  144. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
  145. package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +11 -8
  146. package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
  147. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
  148. package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
  149. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
  150. package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +47 -22
  151. package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
  152. package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
  153. package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
  154. package/lib/esm/components/VoteButton/VoteButton.js +20 -1
  155. package/lib/esm/index.d.ts +7 -4
  156. package/lib/esm/index.js +8 -5
  157. package/lib/umd/react-ui.js +1 -1
  158. package/package.json +6 -6
  159. package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
  160. package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
  161. package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
  162. package/lib/cjs/components/CreateGroup/index.js +0 -5
  163. package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
  164. package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
  165. package/lib/esm/components/CreateGroup/constants.js +0 -1
  166. package/lib/esm/components/CreateGroup/index.d.ts +0 -3
  167. package/lib/esm/components/CreateGroup/index.js +0 -2
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ const system_1 = require("@mui/system");
6
+ const styles_1 = require("@mui/material/styles");
7
+ const react_intl_1 = require("react-intl");
8
+ const react_core_1 = require("@selfcommunity/react-core");
9
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
10
+ const CreateGroupButton_1 = tslib_1.__importDefault(require("../CreateGroupButton"));
11
+ const PREFIX = 'SCEditGroupButton';
12
+ const classes = {
13
+ root: `${PREFIX}-root`
14
+ };
15
+ const Root = (0, styles_1.styled)(CreateGroupButton_1.default, {
16
+ name: PREFIX,
17
+ slot: 'Root',
18
+ overridesResolver: (props, styles) => styles.root
19
+ })(({ theme }) => ({}));
20
+ /**
21
+ *> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
22
+ *
23
+ #### Import
24
+ ```jsx
25
+ import {CreateGroupButton} from '@selfcommunity/react-ui';
26
+ ```
27
+
28
+ #### Component Name
29
+ The name `SCEditGroupButton` can be used when providing style overrides in the theme.
30
+
31
+ #### CSS
32
+
33
+ |Rule Name|Global class|Description|
34
+ |---|---|---|
35
+ |root|.SCEditGroupButton-root|Styles applied to the root element.|
36
+
37
+ * @param inProps
38
+ */
39
+ function EditGroupButton(inProps) {
40
+ //PROPS
41
+ const props = (0, system_1.useThemeProps)({
42
+ props: inProps,
43
+ name: PREFIX
44
+ });
45
+ const { className, groupId, group, onEditSuccess } = props, rest = tslib_1.__rest(props, ["className", "groupId", "group", "onEditSuccess"]);
46
+ const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
47
+ const scUserContext = (0, react_core_1.useSCUser)();
48
+ const handleSuccess = (data) => {
49
+ setSCGroup(data);
50
+ onEditSuccess && onEditSuccess(data);
51
+ };
52
+ if (!scUserContext.user) {
53
+ return null;
54
+ }
55
+ /**
56
+ * Renders root object
57
+ */
58
+ return (react_1.default.createElement(Root, Object.assign({ variant: "outlined", className: (0, classnames_1.default)(classes.root, className), GroupFormProps: { group: scGroup, onSuccess: handleSuccess } }, rest),
59
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.editGroupButton", defaultMessage: "ui.editGroupButton" })));
60
+ }
61
+ exports.default = EditGroupButton;
@@ -0,0 +1,3 @@
1
+ import EditGroupButton, { EditGroupButtonProps } from './EditGroupButton';
2
+ export default EditGroupButton;
3
+ export { EditGroupButtonProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const EditGroupButton_1 = tslib_1.__importDefault(require("./EditGroupButton"));
5
+ exports.default = EditGroupButton_1.default;
@@ -27,15 +27,27 @@ const Root = (0, styles_1.styled)(material_1.Box, {
27
27
  slot: 'ActionFollowRoot'
28
28
  })(() => ({}));
29
29
  function Follow(props) {
30
+ var _a;
30
31
  // PROPS
31
32
  const { className = null, feedObjectId = null, feedObject = null, feedObjectType = types_1.SCContributionType.POST, handleFollow, iconized = true } = props, rest = tslib_1.__rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "handleFollow", "iconized"]);
32
33
  // STATE
33
34
  const { obj, setObj } = (0, react_core_1.useSCFetchFeedObject)({ id: feedObjectId, feedObject, feedObjectType });
34
35
  const [isFollowing, setIsFollowing] = (0, react_1.useState)(false);
36
+ const [status, setStatus] = (0, react_1.useState)(null);
35
37
  // CONTEXT
36
38
  const scContext = (0, react_core_1.useSCContext)();
37
39
  const scUserContext = (0, react_core_1.useSCUser)();
40
+ const scGroupsManager = scUserContext.managers.groups;
38
41
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
42
+ /**
43
+ * If the obj has a group, checks the subscription status for the authenticated user
44
+ */
45
+ (0, react_1.useEffect)(() => {
46
+ var _a;
47
+ if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (obj === null || obj === void 0 ? void 0 : obj.group)) {
48
+ setStatus(scGroupsManager.subscriptionStatus(obj === null || obj === void 0 ? void 0 : obj.group));
49
+ }
50
+ }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, obj === null || obj === void 0 ? void 0 : obj.group]);
39
51
  /**
40
52
  * Perform follow/unfollow
41
53
  * Post, Discussion, Status
@@ -61,6 +73,12 @@ function Follow(props) {
61
73
  if (!scUserContext.user) {
62
74
  scContext.settings.handleAnonymousAction();
63
75
  }
76
+ else if ((obj === null || obj === void 0 ? void 0 : obj.group) && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
77
+ enqueueSnackbar(react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
78
+ variant: 'warning',
79
+ autoHideDuration: 3000
80
+ });
81
+ }
64
82
  else {
65
83
  setIsFollowing(true);
66
84
  performFollow()
@@ -45,6 +45,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
45
45
  slot: 'ActionShareRoot'
46
46
  })(() => ({}));
47
47
  function Share(props) {
48
+ var _a;
48
49
  // PROPS
49
50
  const { className = null, feedObjectId = null, feedObject = null, feedObjectType = types_1.SCContributionType.POST, withAction = true, withAudience = true, inlineAction = false } = props, rest = tslib_1.__rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "withAction", "withAudience", "inlineAction"]);
50
51
  // STATE
@@ -56,6 +57,7 @@ function Share(props) {
56
57
  const [composerShareProps, setComposerShareProps] = (0, react_1.useState)(null);
57
58
  const [openSharesDialog, setOpenSharesDialog] = (0, react_1.useState)(false);
58
59
  const [anchorEl, setAnchorEl] = react_1.default.useState(null);
60
+ const [status, setStatus] = (0, react_1.useState)(null);
59
61
  // CONTEXT
60
62
  const scContext = (0, react_core_1.useSCContext)();
61
63
  const scRoutingContext = (0, react_core_1.useSCRouting)();
@@ -67,6 +69,7 @@ function Share(props) {
67
69
  const linkedinShareEnabled = react_core_1.SCPreferences.ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED in scPreferencesContext.preferences &&
68
70
  scPreferencesContext.preferences[react_core_1.SCPreferences.ADDONS_SHARE_POST_ON_LINKEDIN_ENABLED].value;
69
71
  const scUserContext = (0, react_core_1.useSCUser)();
72
+ const scGroupsManager = scUserContext.managers.groups;
70
73
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
71
74
  const domain = typeof location !== 'undefined' && location.origin ? location.origin : '';
72
75
  const url = domain + scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj));
@@ -99,6 +102,15 @@ function Share(props) {
99
102
  setObj(Object.assign({}, obj, { share_count: obj.share_count + 1 }));
100
103
  handleComposerOnClose();
101
104
  }
105
+ /**
106
+ * If the obj has a group, checks the subscription status for the authenticated user
107
+ */
108
+ (0, react_1.useEffect)(() => {
109
+ var _a;
110
+ if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (obj === null || obj === void 0 ? void 0 : obj.group)) {
111
+ setStatus(scGroupsManager.subscriptionStatus(obj === null || obj === void 0 ? void 0 : obj.group));
112
+ }
113
+ }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, obj === null || obj === void 0 ? void 0 : obj.group]);
102
114
  /**
103
115
  * Performs follow/unfollow
104
116
  * Post, Discussion, Status
@@ -141,6 +153,12 @@ function Share(props) {
141
153
  autoHideDuration: 3000
142
154
  });
143
155
  }
156
+ else if ((obj === null || obj === void 0 ? void 0 : obj.group) && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
157
+ enqueueSnackbar(react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
158
+ variant: 'warning',
159
+ autoHideDuration: 3000
160
+ });
161
+ }
144
162
  else {
145
163
  setIsSharing(true);
146
164
  performCreateMediaShare()
@@ -188,6 +188,7 @@ export interface FeedObjectProps extends CardProps, VirtualScrollerItemProps {
188
188
  |deleted|.SCFeedObject-deleted|Styles applied to the feed obj when is deleted (visible only for admin and moderator).|
189
189
  |header|.SCFeedObject-header|Styles applied to the header of the card.|
190
190
  |category|.SCFeedObject-category|Styles applied to the category element.|
191
+ |group|.SCFeedObject-group|Styles applied to the group element.|
191
192
  |avatar|.SCFeedObject-avatar|Styles applied to the avatar element.|
192
193
  |username|.SCFeedObject-username|Styles applied to the username element.|
193
194
  |activityAt|.SCFeedObject-activity-at|Styles applied to the activity at section.|
@@ -42,6 +42,10 @@ const messages = (0, react_intl_1.defineMessages)({
42
42
  visibleToAll: {
43
43
  id: 'ui.feedObject.visibleToAll',
44
44
  defaultMessage: 'ui.feedObject.visibleToAll'
45
+ },
46
+ visibleToGroup: {
47
+ id: 'ui.feedObject.visibleToGroup',
48
+ defaultMessage: 'ui.feedObject.visibleToGroup'
45
49
  }
46
50
  });
47
51
  const classes = {
@@ -49,6 +53,7 @@ const classes = {
49
53
  deleted: `${constants_1.PREFIX}-deleted`,
50
54
  header: `${constants_1.PREFIX}-header`,
51
55
  category: `${constants_1.PREFIX}-category`,
56
+ group: `${constants_1.PREFIX}-group`,
52
57
  avatar: `${constants_1.PREFIX}-avatar`,
53
58
  username: `${constants_1.PREFIX}-username`,
54
59
  activityAt: `${constants_1.PREFIX}-activity-at`,
@@ -102,6 +107,7 @@ const Root = (0, styles_1.styled)(Widget_1.default, {
102
107
  |deleted|.SCFeedObject-deleted|Styles applied to the feed obj when is deleted (visible only for admin and moderator).|
103
108
  |header|.SCFeedObject-header|Styles applied to the header of the card.|
104
109
  |category|.SCFeedObject-category|Styles applied to the category element.|
110
+ |group|.SCFeedObject-group|Styles applied to the group element.|
105
111
  |avatar|.SCFeedObject-avatar|Styles applied to the avatar element.|
106
112
  |username|.SCFeedObject-username|Styles applied to the username element.|
107
113
  |activityAt|.SCFeedObject-activity-at|Styles applied to the activity at section.|
@@ -127,7 +133,7 @@ const Root = (0, styles_1.styled)(Widget_1.default, {
127
133
  * @param inProps
128
134
  */
129
135
  function FeedObject(inProps) {
130
- var _a;
136
+ var _a, _b;
131
137
  // PROPS
132
138
  const props = (0, system_1.useThemeProps)({
133
139
  props: inProps,
@@ -138,6 +144,7 @@ function FeedObject(inProps) {
138
144
  const scContext = (0, react_core_1.useSCContext)();
139
145
  const scRoutingContext = (0, react_core_1.useSCRouting)();
140
146
  const scUserContext = (0, react_core_1.useSCUser)();
147
+ const scGroupsManager = scUserContext.managers.groups;
141
148
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
142
149
  // OBJECTS
143
150
  const { obj, setObj, error } = (0, react_core_1.useSCFetchFeedObject)({ id: feedObjectId, feedObject, feedObjectType, cacheStrategy });
@@ -156,6 +163,7 @@ function FeedObject(inProps) {
156
163
  const [isReplying, setIsReplying] = (0, react_1.useState)(false);
157
164
  const [selectedActivities, setSelectedActivities] = (0, react_1.useState)(getInitialSelectedActivitiesType());
158
165
  const [expanded, setExpanded] = (0, react_1.useState)(summaryExpanded);
166
+ const [status, setStatus] = (0, react_1.useState)(null);
159
167
  // INTL
160
168
  const intl = (0, react_intl_1.useIntl)();
161
169
  /**
@@ -169,7 +177,7 @@ function FeedObject(inProps) {
169
177
  }, [onStateChange, onHeightChange]);
170
178
  /**
171
179
  * Update state object
172
- * @param obj
180
+ * @param newObj
173
181
  */
174
182
  const updateObject = (newObj) => {
175
183
  setObj(newObj);
@@ -187,6 +195,15 @@ function FeedObject(inProps) {
187
195
  }
188
196
  return feedObject_1.SCFeedObjectActivitiesType.RECENT_COMMENTS;
189
197
  }
198
+ /**
199
+ * If the obj has a group, checks the subscription status for the authenticated user
200
+ */
201
+ (0, react_1.useEffect)(() => {
202
+ var _a;
203
+ if (((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) && (feedObject === null || feedObject === void 0 ? void 0 : feedObject.group)) {
204
+ setStatus(scGroupsManager.subscriptionStatus(feedObject === null || feedObject === void 0 ? void 0 : feedObject.group));
205
+ }
206
+ }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id, scGroupsManager.subscriptionStatus, feedObject === null || feedObject === void 0 ? void 0 : feedObject.group]);
190
207
  /**
191
208
  * Open expanded activities
192
209
  */
@@ -344,6 +361,12 @@ function FeedObject(inProps) {
344
361
  autoHideDuration: 3000
345
362
  });
346
363
  }
364
+ else if ((feedObject === null || feedObject === void 0 ? void 0 : feedObject.group) && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED) {
365
+ enqueueSnackbar(react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.common.group.actions.unsubscribed", defaultMessage: "ui.common.group.actions.unsubscribed" }), {
366
+ variant: 'warning',
367
+ autoHideDuration: 3000
368
+ });
369
+ }
347
370
  else {
348
371
  setIsReplying(true);
349
372
  performReply(comment)
@@ -426,8 +449,13 @@ function FeedObject(inProps) {
426
449
  template === feedObject_1.SCFeedObjectTemplateType.DETAIL ||
427
450
  template === feedObject_1.SCFeedObjectTemplateType.SEARCH) {
428
451
  objElement = (react_1.default.createElement(react_1.default.Fragment, null, obj ? (react_1.default.createElement(material_1.Box, { className: (0, classnames_1.default)({ [classes.deleted]: obj && obj.deleted }) },
429
- obj.categories.length > 0 && (react_1.default.createElement("div", { className: classes.category }, obj.categories.map((c) => (react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, c), key: c.id },
430
- react_1.default.createElement(material_1.Typography, { variant: "overline" }, c.name)))))),
452
+ obj.categories.length > 0 && (react_1.default.createElement("div", { className: classes.category },
453
+ react_1.default.createElement(react_1.default.Fragment, null, obj.group && (react_1.default.createElement("div", { className: classes.group },
454
+ react_1.default.createElement(material_1.Chip, { color: "secondary", size: "small", key: obj.group.id, icon: react_1.default.createElement(Icon_1.default, null, "groups"), component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true })))),
455
+ obj.categories.map((c) => (react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, c), key: c.id },
456
+ react_1.default.createElement(material_1.Typography, { variant: "overline" }, c.name)))))),
457
+ obj.group && !obj.categories.length && (react_1.default.createElement("div", { className: classes.group },
458
+ react_1.default.createElement(material_1.Chip, { color: "secondary", size: "small", key: obj.group.id, icon: react_1.default.createElement(Icon_1.default, null, "groups"), label: obj.group.name, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }))),
431
459
  react_1.default.createElement(material_1.CardHeader, { className: classes.header, avatar: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }),
432
460
  react_1.default.createElement(UserAvatar_1.default, { hide: !obj.author.community_badge },
433
461
  react_1.default.createElement(material_1.Avatar, { "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, obj.author.username))), title: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }), obj.author.username), subheader: react_1.default.createElement(react_1.default.Fragment, null,
@@ -436,10 +464,11 @@ function FeedObject(inProps) {
436
464
  obj.location && (react_1.default.createElement(react_1.default.Fragment, null,
437
465
  react_1.default.createElement(Bullet_1.default, null),
438
466
  react_1.default.createElement(material_1.Box, { className: classes.location },
439
- react_1.default.createElement(Icon_1.default, null, "add_location_alt"), (_a = obj.location) === null || _a === void 0 ? void 0 :
440
- _a.location))),
467
+ react_1.default.createElement(Icon_1.default, null, "add_location_alt"), (_b = obj.location) === null || _b === void 0 ? void 0 :
468
+ _b.location))),
441
469
  react_1.default.createElement(Bullet_1.default, null),
442
- react_1.default.createElement(material_1.Box, { className: classes.tag }, obj.addressing.length > 0 ? (react_1.default.createElement(Tags_1.default, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : (react_1.default.createElement(material_1.Tooltip, { title: `${intl.formatMessage(messages.visibleToAll)}` },
470
+ react_1.default.createElement(material_1.Box, { className: classes.tag }, obj.addressing.length > 0 ? (react_1.default.createElement(Tags_1.default, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (react_1.default.createElement(material_1.Tooltip, { title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` },
471
+ react_1.default.createElement(Icon_1.default, { color: "disabled", fontSize: "small" }, "groups"))) : (react_1.default.createElement(material_1.Tooltip, { title: `${intl.formatMessage(messages.visibleToAll)}` },
443
472
  react_1.default.createElement(Icon_1.default, { color: "disabled", fontSize: "small" }, "public"))))), action: renderHeaderAction() }),
444
473
  react_1.default.createElement(CardContent_1.default, { classes: { root: classes.content } },
445
474
  react_1.default.createElement(material_1.Box, { className: classes.titleSection }, 'title' in obj && (react_1.default.createElement(react_1.default.Fragment, null, template === feedObject_1.SCFeedObjectTemplateType.DETAIL ? (react_1.default.createElement(material_1.Typography, { variant: "body1", gutterBottom: true, className: classes.title }, obj.title)) : (react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj)) },
@@ -468,8 +497,13 @@ function FeedObject(inProps) {
468
497
  }
469
498
  else if (template === feedObject_1.SCFeedObjectTemplateType.SHARE) {
470
499
  objElement = (react_1.default.createElement(react_1.default.Fragment, null, obj ? (react_1.default.createElement(react_1.default.Fragment, null,
471
- obj.categories.length > 0 && (react_1.default.createElement("div", { className: classes.category }, obj.categories.map((c) => (react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, c), key: c.id },
472
- react_1.default.createElement(material_1.Typography, { variant: "overline" }, c.name)))))),
500
+ obj.categories.length > 0 && (react_1.default.createElement("div", { className: classes.category },
501
+ react_1.default.createElement(react_1.default.Fragment, null, obj.group && (react_1.default.createElement("div", { className: classes.group },
502
+ react_1.default.createElement(material_1.Chip, { color: "secondary", size: "small", key: obj.group.id, icon: react_1.default.createElement(Icon_1.default, null, "groups"), component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true })))),
503
+ obj.categories.map((c) => (react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, c), key: c.id },
504
+ react_1.default.createElement(material_1.Typography, { variant: "overline" }, c.name)))))),
505
+ obj.group && !obj.categories.length && (react_1.default.createElement("div", { className: classes.group },
506
+ react_1.default.createElement(material_1.Chip, { color: "secondary", size: "small", key: obj.group.id, icon: react_1.default.createElement(Icon_1.default, null, "groups"), label: obj.group.name, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }))),
473
507
  react_1.default.createElement(material_1.CardHeader, { classes: { root: classes.header }, avatar: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }),
474
508
  react_1.default.createElement(UserAvatar_1.default, { hide: !obj.author.community_badge },
475
509
  react_1.default.createElement(material_1.Avatar, { "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, obj.author.username))), title: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }), obj.author.username), subheader: react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj)), className: classes.activityAt },
@@ -1,6 +1,7 @@
1
1
  import { ButtonBaseProps } from '@mui/material';
2
2
  import { SCGroupType } from '@selfcommunity/types';
3
3
  import { WidgetProps } from '../Widget';
4
+ import { GroupSubscribeButtonProps } from '../GroupSubscribeButton';
4
5
  export interface GroupProps extends WidgetProps {
5
6
  /**
6
7
  * Group Object
@@ -13,10 +14,10 @@ export interface GroupProps extends WidgetProps {
13
14
  */
14
15
  groupId?: number;
15
16
  /**
16
- * Handles actions ignore
17
- * @default null
17
+ * Props to spread to group subscribe/unsubscribe button
18
+ * @default {}
18
19
  */
19
- handleIgnoreAction?: (u: any) => void;
20
+ groupSubscribeButtonProps?: GroupSubscribeButtonProps;
20
21
  /**
21
22
  * Badge content to show as group avatar badge if show reaction is true.
22
23
  */
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const react_1 = tslib_1.__importStar(require("react"));
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  const material_1 = require("@mui/material");
7
+ const types_1 = require("@selfcommunity/types");
7
8
  const react_core_1 = require("@selfcommunity/react-core");
8
9
  const react_intl_1 = require("react-intl");
9
10
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
@@ -63,7 +64,7 @@ function Group(inProps) {
63
64
  props: inProps,
64
65
  name: constants_1.PREFIX
65
66
  });
66
- const { groupId = null, group = null, handleIgnoreAction, className = null, elevation, hideActions = false, buttonProps = {}, visible = true } = props, rest = tslib_1.__rest(props, ["groupId", "group", "handleIgnoreAction", "className", "elevation", "hideActions", "buttonProps", "visible"]);
67
+ const { groupId = null, group = null, className = null, elevation, hideActions = false, groupSubscribeButtonProps = {} } = props, rest = tslib_1.__rest(props, ["groupId", "group", "className", "elevation", "hideActions", "groupSubscribeButtonProps"]);
67
68
  // STATE
68
69
  const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
69
70
  // CONTEXT
@@ -77,8 +78,8 @@ function Group(inProps) {
77
78
  */
78
79
  function renderAuthenticatedActions() {
79
80
  return (react_1.default.createElement(material_1.Stack, { className: classes.actions, direction: "row", alignItems: "center", justifyContent: "center", spacing: 2 },
80
- react_1.default.createElement(material_1.Icon, null, !visible ? 'private' : 'public'),
81
- react_1.default.createElement(GroupSubscribeButton_1.default, { group: group, groupId: groupId })));
81
+ react_1.default.createElement(material_1.Icon, null, (group === null || group === void 0 ? void 0 : group.privacy) === types_1.SCGroupPrivacyType.PRIVATE ? 'private' : 'public'),
82
+ react_1.default.createElement(GroupSubscribeButton_1.default, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps))));
82
83
  }
83
84
  /**
84
85
  * Renders group object
@@ -90,7 +91,7 @@ function Group(inProps) {
90
91
  * Renders root object
91
92
  */
92
93
  return (react_1.default.createElement(react_1.default.Fragment, null,
93
- react_1.default.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps: buttonProps !== null && buttonProps !== void 0 ? buttonProps : { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: react_1.default.createElement(material_1.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() })),
94
+ react_1.default.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps: { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: react_1.default.createElement(material_1.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() })),
94
95
  openAlert && react_1.default.createElement(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })));
95
96
  }
96
97
  exports.default = Group;
@@ -36,7 +36,7 @@ const Root = (0, styles_1.styled)(BaseItem_1.default, {
36
36
  */
37
37
  function GroupSkeleton(props) {
38
38
  const theme = (0, material_1.useTheme)();
39
- return (react_1.default.createElement(Root, Object.assign({ className: classes.root }, props, { image: react_1.default.createElement(Skeleton_1.default, { animation: "wave", variant: "circular", width: theme.selfcommunity.user.avatar.sizeMedium, height: theme.selfcommunity.user.avatar.sizeMedium }), primary: react_1.default.createElement(Skeleton_1.default, { animation: "wave", height: 10, width: 120, style: { marginBottom: 10 } }), secondary: react_1.default.createElement(Skeleton_1.default, { animation: "wave", height: 10, width: 70, style: { marginBottom: 10 } }), actions: react_1.default.createElement(material_1.Button, { size: "small", variant: "outlined", disabled: true },
39
+ return (react_1.default.createElement(Root, Object.assign({ className: classes.root }, props, { image: react_1.default.createElement(Skeleton_1.default, { animation: "wave", variant: "circular", width: theme.selfcommunity.group.avatar.sizeSmall, height: theme.selfcommunity.group.avatar.sizeSmall }), primary: react_1.default.createElement(Skeleton_1.default, { animation: "wave", height: 10, width: 120, style: { marginBottom: 10 } }), secondary: react_1.default.createElement(Skeleton_1.default, { animation: "wave", height: 10, width: 70, style: { marginBottom: 10 } }), actions: react_1.default.createElement(material_1.Button, { size: "small", variant: "outlined", disabled: true },
40
40
  react_1.default.createElement(Skeleton_1.default, { animation: "wave", height: 10, width: 30, style: { marginTop: 5, marginBottom: 5 } })) })));
41
41
  }
42
42
  exports.default = GroupSkeleton;
@@ -0,0 +1,49 @@
1
+ import { TextFieldProps } from '@mui/material/TextField';
2
+ import { AutocompleteProps } from '@mui/material';
3
+ import { SCGroupType } from '@selfcommunity/types/src/index';
4
+ export interface GroupAutocompleteProps extends Pick<AutocompleteProps<SCGroupType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCGroupType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | 'clearIcon' | 'noOptionsText' | 'isOptionEqualToValue' | 'renderTags' | 'renderOption' | 'renderInput'>> {
5
+ /**
6
+ * The maximum number of groups that will be visible when not focused.
7
+ * @default 0
8
+ */
9
+ limitCountGroups?: number;
10
+ /**
11
+ * If checkbox is selected
12
+ * @default false
13
+ */
14
+ checkboxSelect?: boolean;
15
+ /**
16
+ * The props applied to text field
17
+ * @default {variant: 'outlined, label: groups_label}
18
+ */
19
+ TextFieldProps?: TextFieldProps;
20
+ /**
21
+ * Callback for change event on poll object
22
+ * @param value
23
+ */
24
+ onChange?: (value: any) => void;
25
+ }
26
+ /**
27
+ * > API documentation for the Community-JS Group Autocomplete component. Learn about the available props and the CSS API.
28
+ *
29
+ *
30
+ * This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
31
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
32
+ *
33
+ * #### Import
34
+ * ```jsx
35
+ * import {GroupAutocomplete} from '@selfcommunity/react-ui';
36
+ * ```
37
+ * #### Component Name
38
+ * The name `SCGroupAutocomplete` can be used when providing style overrides in the theme.
39
+ *
40
+ * #### CSS
41
+ *
42
+ * |Rule Name|Global class|Description|
43
+ * |---|---|---|
44
+ * |root|.SCGroupAutocomplete-root|Styles applied to the root element.|
45
+ *
46
+ * @param inProps
47
+ */
48
+ declare const GroupAutocomplete: (inProps: GroupAutocompleteProps) => JSX.Element;
49
+ export default GroupAutocomplete;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const react_intl_1 = require("react-intl");
6
+ const Autocomplete_1 = tslib_1.__importDefault(require("@mui/material/Autocomplete"));
7
+ const TextField_1 = tslib_1.__importDefault(require("@mui/material/TextField"));
8
+ const CircularProgress_1 = tslib_1.__importDefault(require("@mui/material/CircularProgress"));
9
+ const parse_1 = tslib_1.__importDefault(require("autosuggest-highlight/parse"));
10
+ const match_1 = tslib_1.__importDefault(require("autosuggest-highlight/match"));
11
+ const material_1 = require("@mui/material");
12
+ const react_core_1 = require("@selfcommunity/react-core");
13
+ const styles_1 = require("@mui/material/styles");
14
+ const system_1 = require("@mui/system");
15
+ const PREFIX = 'SCGroupAutocomplete';
16
+ const classes = {
17
+ root: `${PREFIX}-root`
18
+ };
19
+ const Root = (0, styles_1.styled)(Autocomplete_1.default, {
20
+ name: PREFIX,
21
+ slot: 'Root',
22
+ overridesResolver: (props, styles) => styles.root
23
+ })(() => ({}));
24
+ /**
25
+ * > API documentation for the Community-JS Group Autocomplete component. Learn about the available props and the CSS API.
26
+ *
27
+ *
28
+ * This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
29
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
30
+ *
31
+ * #### Import
32
+ * ```jsx
33
+ * import {GroupAutocomplete} from '@selfcommunity/react-ui';
34
+ * ```
35
+ * #### Component Name
36
+ * The name `SCGroupAutocomplete` can be used when providing style overrides in the theme.
37
+ *
38
+ * #### CSS
39
+ *
40
+ * |Rule Name|Global class|Description|
41
+ * |---|---|---|
42
+ * |root|.SCGroupAutocomplete-root|Styles applied to the root element.|
43
+ *
44
+ * @param inProps
45
+ */
46
+ const GroupAutocomplete = (inProps) => {
47
+ const props = (0, system_1.useThemeProps)({
48
+ props: inProps,
49
+ name: PREFIX
50
+ });
51
+ // Props
52
+ const { onChange, defaultValue = null, disabled = false, TextFieldProps = {
53
+ variant: 'outlined',
54
+ label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupAutocomplete.label", defaultMessage: "ui.groupAutocomplete.label" })
55
+ } } = props, rest = tslib_1.__rest(props, ["onChange", "defaultValue", "disabled", "TextFieldProps"]);
56
+ // State
57
+ const [open, setOpen] = (0, react_1.useState)(false);
58
+ const [value, setValue] = (0, react_1.useState)(typeof defaultValue === 'string' ? null : defaultValue);
59
+ // HOOKS
60
+ const { groups, isLoading } = (0, react_core_1.useSCFetchGroups)();
61
+ (0, react_1.useEffect)(() => {
62
+ if (value === null) {
63
+ return;
64
+ }
65
+ onChange && onChange(value);
66
+ }, [value]);
67
+ (0, react_1.useEffect)(() => {
68
+ if (!isLoading && typeof defaultValue === 'string') {
69
+ setValue(groups.find((g) => g.id === Number(defaultValue)));
70
+ }
71
+ }, [isLoading]);
72
+ // Handlers
73
+ const handleOpen = () => {
74
+ setOpen(true);
75
+ };
76
+ const handleClose = () => {
77
+ setOpen(false);
78
+ };
79
+ const handleChange = (event, value) => {
80
+ setValue(value);
81
+ };
82
+ // Render
83
+ return (react_1.default.createElement(Root, Object.assign({ freeSolo: true, className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: groups || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupAutocomplete.empty", defaultMessage: "ui.groupAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id,
84
+ // renderTags={(value, getTagProps) => {
85
+ // return value.map((option: any, index) => (
86
+ // <Chip key={option.id} id={option.id} label={option.name} color={option.color} {...getTagProps({index})} />
87
+ // ));
88
+ // }}
89
+ renderOption: (props, option, { inputValue }) => {
90
+ const matches = (0, match_1.default)(option.name, inputValue);
91
+ const parts = (0, parse_1.default)(option.name, matches);
92
+ return (react_1.default.createElement(material_1.Box, Object.assign({ component: "li" }, props),
93
+ react_1.default.createElement(material_1.Avatar, { alt: option.name, src: option.image_small, sx: { marginRight: 1 } }),
94
+ react_1.default.createElement(react_1.default.Fragment, null, parts.map((part, index) => (react_1.default.createElement(material_1.Typography, { key: index, sx: { fontWeight: part.highlight ? 700 : 400, marginRight: 0.2 } }, part.text))))));
95
+ }, renderInput: (params) => {
96
+ return (react_1.default.createElement(TextField_1.default, Object.assign({}, params, TextFieldProps, { margin: "dense", InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'groups', endAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
97
+ isLoading ? react_1.default.createElement(CircularProgress_1.default, { color: "inherit", size: 20 }) : null,
98
+ params.InputProps.endAdornment)) }) })));
99
+ } }, rest)));
100
+ };
101
+ exports.default = GroupAutocomplete;
@@ -0,0 +1,3 @@
1
+ import GroupAutocomplete, { GroupAutocompleteProps } from './GroupAutocomplete';
2
+ export default GroupAutocomplete;
3
+ export { GroupAutocompleteProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const GroupAutocomplete_1 = tslib_1.__importDefault(require("./GroupAutocomplete"));
5
+ exports.default = GroupAutocomplete_1.default;
@@ -0,0 +1,70 @@
1
+ import { BaseDialogProps } from '../../shared/BaseDialog';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ export interface GroupFormProps extends BaseDialogProps {
4
+ /**
5
+ * Overrides or extends the styles applied to the component.
6
+ * @default null
7
+ */
8
+ className?: string;
9
+ /**
10
+ * Open dialog
11
+ * @default true
12
+ */
13
+ open?: boolean;
14
+ /**
15
+ * On dialog close callback function
16
+ * @default null
17
+ */
18
+ onClose?: () => void;
19
+ /**
20
+ * Group Object
21
+ * @default null
22
+ */
23
+ group?: SCGroupType;
24
+ /**
25
+ * On success callback function
26
+ * @default null
27
+ */
28
+ onSuccess?: (data: SCGroupType) => void;
29
+ /**
30
+ * Any other properties
31
+ */
32
+ [p: string]: any;
33
+ }
34
+ /**
35
+ *> API documentation for the Community-JS Group Form component. Learn about the available props and the CSS API.
36
+ *
37
+ #### Import
38
+ ```jsx
39
+ import {GroupForm} from '@selfcommunity/react-ui';
40
+ ```
41
+
42
+ #### Component Name
43
+ The name `SCGroupForm` can be used when providing style overrides in the theme.
44
+
45
+ #### CSS
46
+
47
+ |Rule Name|Global class|Description|
48
+ |---|---|---|
49
+ |root|.SCGroupForm-root|Styles applied to the root element.|
50
+ |active|.SCGroupForm-active|Styles applied to the active element.|
51
+ |title|.SCGroupForm-title|Styles applied to the title element.|
52
+ |header|.SCGroupForm-header|Styles applied to the header element.|
53
+ |cover|.SCGroupForm-cover|Styles applied to the cover field.|
54
+ |avatar|.SCGroupForm-avatar|Styles applied to the avatar field.|
55
+ |form|.SCGroupForm-form|Styles applied to the form element.|
56
+ |switch|.SCGroupForm-switch|Styles applied to the switch element.|
57
+ |switchLabel|.SCGroupForm-switch-label|Styles applied to the switchLabel element.|
58
+ |name|.SCGroupForm-name|Styles applied to the name field.|
59
+ |description|.SCGroupForm-description|Styles applied to the description field.|
60
+ |content|.SCGroupForm-content|Styles applied to the element.|
61
+ |privacySection|.SCGroupForm-privacy-section|Styles applied to the privacy section.|
62
+ |privacySectionInfo|.SCGroupForm-privacy-section-info|Styles applied to the privacy info section.|
63
+ |visibilitySection|.SCGroupForm-visibility-section|Styles applied to the visibility section.|
64
+ |visibilitySectionInfo|.SCGroupForm-visibility-section-info|Styles applied to the visibility section info.|
65
+ |inviteSection|.SCGroupForm-invite-section|Styles applied to the invite section.|
66
+ |error|.SCGroupForm-error|Styles applied to the error elements.|
67
+
68
+ * @param inProps
69
+ */
70
+ export default function GroupForm(inProps: GroupFormProps): JSX.Element;