@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,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;
@@ -0,0 +1,134 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useMemo } from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import { Avatar, Box, Icon, Paper, Typography } from '@mui/material';
5
+ import { SCGroupPrivacyType } from '@selfcommunity/types';
6
+ import { SCPreferences, useSCFetchGroup, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
7
+ import GroupHeaderSkeleton from './Skeleton';
8
+ import classNames from 'classnames';
9
+ import { useThemeProps } from '@mui/system';
10
+ import { PREFIX } from './constants';
11
+ import ChangeGroupCover from '../ChangeGroupCover';
12
+ import { FormattedMessage } from 'react-intl';
13
+ import Bullet from '../../shared/Bullet';
14
+ import ChangeGroupPicture from '../ChangeGroupPicture';
15
+ import GroupMembersButton from '../GroupMembersButton';
16
+ const classes = {
17
+ root: `${PREFIX}-root`,
18
+ cover: `${PREFIX}-cover`,
19
+ avatar: `${PREFIX}-avatar`,
20
+ info: `${PREFIX}-info`,
21
+ name: `${PREFIX}-name`,
22
+ changePicture: `${PREFIX}-change-picture`,
23
+ changeCover: `${PREFIX}-change-cover`,
24
+ visibility: `${PREFIX}-visibility`,
25
+ visibilityItem: `${PREFIX}-visibility-item`,
26
+ members: `${PREFIX}-members`,
27
+ membersCounter: `${PREFIX}-members-counter`
28
+ };
29
+ const Root = styled(Box, {
30
+ name: PREFIX,
31
+ slot: 'Root'
32
+ })(() => ({}));
33
+ /**
34
+ * > API documentation for the Community-JS Group Header component. Learn about the available props and the CSS API.
35
+ *
36
+ *
37
+ * This component renders the groups top section.
38
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/UserProfileHeader)
39
+
40
+ #### Import
41
+
42
+ ```jsx
43
+ import {UserProfileHeader} from '@selfcommunity/react-ui';
44
+ ```
45
+
46
+ #### Component Name
47
+
48
+ The name `SCGroupHeader` can be used when providing style overrides in the theme.
49
+
50
+
51
+ #### CSS
52
+
53
+ |Rule Name|Global class|Description|
54
+ |---|---|---|
55
+ |root|.SCGroupHeader-root|Styles applied to the root element.|
56
+ |cover|.SCGroupHeader-cover|Styles applied to the cover element.|
57
+ |avatar|.SCGroupHeader-avatar|Styles applied to the avatar element.|
58
+ |info|SCGroupHeader-info|Styles applied to the info section.|
59
+ |name|SCGroupHeader-username|Styles applied to the username element.|
60
+ |changePicture|.SCGroupHeader-change-picture|Styles applied to changePicture element.|
61
+ |changeCover|.SCGroupHeader-change-cover`|Styles applied to changeCover element.|
62
+
63
+ * @param inProps
64
+ */
65
+ export default function GroupHeader(inProps) {
66
+ var _a, _b;
67
+ // PROPS
68
+ const props = useThemeProps({
69
+ props: inProps,
70
+ name: PREFIX
71
+ });
72
+ const { id = null, className = null, group, groupId = null, ChangePictureProps = {}, ChangeCoverProps = {}, GroupMembersButtonProps = {}, actions } = props, rest = __rest(props, ["id", "className", "group", "groupId", "ChangePictureProps", "ChangeCoverProps", "GroupMembersButtonProps", "actions"]);
73
+ // PREFERENCES
74
+ const scPreferences = useSCPreferences();
75
+ // CONTEXT
76
+ const scUserContext = useSCUser();
77
+ // HOOKS
78
+ const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
79
+ // CONST
80
+ const canEdit = useMemo(() => { var _a, _b; return scUserContext.user && (((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.created_by) === null || _a === void 0 ? void 0 : _a.id) || ((_b = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _b === void 0 ? void 0 : _b.id)) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.created_by) === null || _a === void 0 ? void 0 : _a.id, (_b = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _b === void 0 ? void 0 : _b.id]);
81
+ /**
82
+ * Handles Change Avatar
83
+ * @param avatar
84
+ */
85
+ function handleChangeAvatar(avatar) {
86
+ if (canEdit) {
87
+ setSCGroup(Object.assign({}, scGroup, { image_bigger: avatar }));
88
+ }
89
+ }
90
+ /**
91
+ * Handles Change Cover
92
+ * @param cover
93
+ */
94
+ function handleChangeCover(cover) {
95
+ if (canEdit) {
96
+ setSCGroup(Object.assign({}, scGroup, { emotional_image: cover }));
97
+ }
98
+ }
99
+ // RENDER
100
+ if (!scGroup) {
101
+ return React.createElement(GroupHeaderSkeleton, null);
102
+ }
103
+ const _backgroundCover = Object.assign({}, (scGroup.emotional_image
104
+ ? { background: `url('${scGroup.emotional_image}') center / cover` }
105
+ : { background: `url('${scPreferences.preferences[SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
106
+ return (React.createElement(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, rest),
107
+ React.createElement(Paper, { style: _backgroundCover, classes: { root: classes.cover } },
108
+ React.createElement(Box, { className: classes.avatar },
109
+ React.createElement(Avatar, null,
110
+ React.createElement("img", { alt: "group", src: scGroup.image_bigger ? scGroup.image_bigger : '' }))),
111
+ canEdit && (React.createElement(React.Fragment, null,
112
+ React.createElement(ChangeGroupPicture, Object.assign({ groupId: scGroup.id, onChange: handleChangeAvatar, className: classes.changePicture }, ChangePictureProps)),
113
+ React.createElement("div", { className: classes.changeCover },
114
+ React.createElement(ChangeGroupCover, Object.assign({ groupId: scGroup.id, onChange: handleChangeCover }, ChangeCoverProps)))))),
115
+ React.createElement(Box, { className: classes.info },
116
+ React.createElement(Typography, { variant: "h5", className: classes.name }, scGroup.name),
117
+ React.createElement(Box, { className: classes.visibility },
118
+ scGroup.privacy === SCGroupPrivacyType.PUBLIC ? (React.createElement(Typography, { className: classes.visibilityItem },
119
+ React.createElement(Icon, null, "public"),
120
+ React.createElement(FormattedMessage, { id: "ui.groupHeader.visibility.public", defaultMessage: "ui.groupHeader.visibility.public" }))) : (React.createElement(Typography, { className: classes.visibilityItem },
121
+ React.createElement(Icon, null, "private"),
122
+ React.createElement(FormattedMessage, { id: "ui.groupHeader.visibility.private", defaultMessage: "ui.groupHeader.visibility.private" }))),
123
+ React.createElement(Bullet, null),
124
+ scGroup.visible ? (React.createElement(Typography, { className: classes.visibilityItem },
125
+ React.createElement(Icon, null, "visibility"),
126
+ React.createElement(FormattedMessage, { id: "ui.groupHeader.visibility.visible", defaultMessage: "ui.groupHeader.visibility.visible" }))) : (React.createElement(Typography, { className: classes.visibilityItem },
127
+ React.createElement(Icon, null, "visibility_off"),
128
+ React.createElement(FormattedMessage, { id: "ui.groupHeader.visibility.hidden", defaultMessage: "ui.groupHeader.visibility.hidden" })))),
129
+ React.createElement(Box, { className: classes.members },
130
+ React.createElement(Typography, { className: classes.membersCounter, component: "div" },
131
+ React.createElement(FormattedMessage, { id: "ui.groupHeader.members", defaultMessage: "ui.groupHeader.members", values: { total: scGroup.subscribers_counter } })),
132
+ React.createElement(GroupMembersButton, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup }, GroupMembersButtonProps))),
133
+ actions && actions)));
134
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * > API documentation for the Community-JS Group Headerr Skeleton component. Learn about the available props and the CSS API.
3
+
4
+ #### Import
5
+
6
+ ```jsx
7
+ import {GroupHeaderSkeleton} from '@selfcommunity/react-ui';
8
+ ```
9
+
10
+ #### Component Name
11
+
12
+ The name `SCGroupHeader-skeleton-root` can be used when providing style overrides in the theme.
13
+
14
+ #### CSS
15
+
16
+ |Rule Name|Global class|Description|
17
+ |---|---|---|
18
+ |root|.SCGroupHeader-skeleton-root|Styles applied to the root element.|
19
+ |avatar|.SCGroupHeader-avatar|Styles applied to the avatar element.|
20
+ |cover|.SCGroupHeader-cover|Styles applied to the cover element.|
21
+ |actions|.SCGroupHeader-actions|Styles applied to the actions section.|
22
+ |section|.SCGroupHeader-section|Styles applied to the info section.|
23
+ |username|.SCGroupHeader-username|Styles applied to the username element.|
24
+ *
25
+ */
26
+ declare function GroupHeaderSkeleton(): JSX.Element;
27
+ export default GroupHeaderSkeleton;
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import { Box, Typography, useTheme } from '@mui/material';
3
+ import { styled } from '@mui/material/styles';
4
+ import Skeleton from '@mui/material/Skeleton';
5
+ import { PREFIX } from './constants';
6
+ const classes = {
7
+ root: `${PREFIX}-skeleton-root`,
8
+ cover: `${PREFIX}-cover`,
9
+ avatar: `${PREFIX}-avatar`,
10
+ actions: `${PREFIX}-actions`,
11
+ section: `${PREFIX}-section`,
12
+ username: `${PREFIX}-username`
13
+ };
14
+ const Root = styled(Box, {
15
+ name: PREFIX,
16
+ slot: 'SkeletonRoot'
17
+ })(() => ({}));
18
+ /**
19
+ * > API documentation for the Community-JS Group Headerr Skeleton component. Learn about the available props and the CSS API.
20
+
21
+ #### Import
22
+
23
+ ```jsx
24
+ import {GroupHeaderSkeleton} from '@selfcommunity/react-ui';
25
+ ```
26
+
27
+ #### Component Name
28
+
29
+ The name `SCGroupHeader-skeleton-root` can be used when providing style overrides in the theme.
30
+
31
+ #### CSS
32
+
33
+ |Rule Name|Global class|Description|
34
+ |---|---|---|
35
+ |root|.SCGroupHeader-skeleton-root|Styles applied to the root element.|
36
+ |avatar|.SCGroupHeader-avatar|Styles applied to the avatar element.|
37
+ |cover|.SCGroupHeader-cover|Styles applied to the cover element.|
38
+ |actions|.SCGroupHeader-actions|Styles applied to the actions section.|
39
+ |section|.SCGroupHeader-section|Styles applied to the info section.|
40
+ |username|.SCGroupHeader-username|Styles applied to the username element.|
41
+ *
42
+ */
43
+ function GroupHeaderSkeleton() {
44
+ const theme = useTheme();
45
+ return (React.createElement(Root, { className: classes.root },
46
+ React.createElement(Skeleton, { className: classes.cover, animation: "wave", variant: "rectangular" }),
47
+ React.createElement(Box, { className: classes.avatar },
48
+ React.createElement(Skeleton, { animation: "wave", variant: "circular", width: theme.selfcommunity.group.avatar.sizeLarge, height: theme.selfcommunity.group.avatar.sizeLarge })),
49
+ React.createElement(Box, { className: classes.section },
50
+ React.createElement(Typography, { variant: "h5", className: classes.username },
51
+ React.createElement(Skeleton, { animation: "wave", sx: { height: 30, width: 100 } })))));
52
+ }
53
+ export default GroupHeaderSkeleton;
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCGroupHeader";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCGroupHeader';
@@ -0,0 +1,4 @@
1
+ import GroupHeader, { GroupHeaderProps } from './GroupHeader';
2
+ import GroupHeaderSkeleton from './Skeleton';
3
+ export default GroupHeader;
4
+ export { GroupHeaderProps, GroupHeaderSkeleton };
@@ -0,0 +1,4 @@
1
+ import GroupHeader from './GroupHeader';
2
+ import GroupHeaderSkeleton from './Skeleton';
3
+ export default GroupHeader;
4
+ export { GroupHeaderSkeleton };