@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,52 @@
1
+ import { VirtualScrollerItemProps } from '../../types/virtualScroller';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ export interface GroupInfoWidgetProps extends VirtualScrollerItemProps {
4
+ /**
5
+ * Group Object
6
+ * @default null
7
+ */
8
+ group?: SCGroupType;
9
+ /**
10
+ * Id of the group
11
+ * @default null
12
+ */
13
+ groupId?: number | string;
14
+ /**
15
+ * Overrides or extends the styles applied to the component.
16
+ * @default null
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Other props
21
+ */
22
+ [p: string]: any;
23
+ }
24
+ /**
25
+ * > API documentation for the Community-JS Group Info Widget component. Learn about the available props and the CSS API.
26
+ *
27
+ *
28
+ * This component renders a widget containing the group info.
29
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupInfoWidget)
30
+
31
+ #### Import
32
+
33
+ ```jsx
34
+ import {GroupInfoWidget} from '@selfcommunity/react-ui';
35
+ ```
36
+
37
+ #### Component Name
38
+
39
+ The name `SCGroupInfoWidget` can be used when providing style overrides in the theme.
40
+
41
+
42
+ #### CSS
43
+
44
+ |Rule Name|Global class|Description|
45
+ |---|---|---|
46
+ |root|.SCGroupInfoWidget-root|Styles applied to the root element.|
47
+ |title|.SCGroupInfoWidget-title|Styles applied to the title element.|
48
+
49
+ *
50
+ * @param inProps
51
+ */
52
+ export default function GroupInfoWidget(inProps: GroupInfoWidgetProps): JSX.Element;
@@ -0,0 +1,97 @@
1
+ import { __rest } from "tslib";
2
+ import React from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import { CardContent, Icon, Typography } from '@mui/material';
5
+ import classNames from 'classnames';
6
+ import Widget from '../Widget';
7
+ import { useThemeProps } from '@mui/system';
8
+ import { PREFIX } from './constants';
9
+ import { FormattedMessage, useIntl } from 'react-intl';
10
+ import { SCGroupPrivacyType } from '@selfcommunity/types';
11
+ import { useSCFetchGroup } from '@selfcommunity/react-core';
12
+ const classes = {
13
+ root: `${PREFIX}-root`,
14
+ title: `${PREFIX}-title`,
15
+ description: `${PREFIX}-description`,
16
+ privacy: `${PREFIX}-privacy`,
17
+ privacyTitle: `${PREFIX}-privacy-title`,
18
+ visibility: `${PREFIX}-visibility`,
19
+ visibilityTitle: `${PREFIX}-visibility-title`,
20
+ date: `${PREFIX}-date`
21
+ };
22
+ const Root = styled(Widget, {
23
+ name: PREFIX,
24
+ slot: 'Root'
25
+ })(() => ({}));
26
+ /**
27
+ * > API documentation for the Community-JS Group Info Widget component. Learn about the available props and the CSS API.
28
+ *
29
+ *
30
+ * This component renders a widget containing the group info.
31
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupInfoWidget)
32
+
33
+ #### Import
34
+
35
+ ```jsx
36
+ import {GroupInfoWidget} from '@selfcommunity/react-ui';
37
+ ```
38
+
39
+ #### Component Name
40
+
41
+ The name `SCGroupInfoWidget` can be used when providing style overrides in the theme.
42
+
43
+
44
+ #### CSS
45
+
46
+ |Rule Name|Global class|Description|
47
+ |---|---|---|
48
+ |root|.SCGroupInfoWidget-root|Styles applied to the root element.|
49
+ |title|.SCGroupInfoWidget-title|Styles applied to the title element.|
50
+
51
+ *
52
+ * @param inProps
53
+ */
54
+ export default function GroupInfoWidget(inProps) {
55
+ // PROPS
56
+ const props = useThemeProps({
57
+ props: inProps,
58
+ name: PREFIX
59
+ });
60
+ const { className, group, groupId, onHeightChange, onStateChange } = props, rest = __rest(props, ["className", "group", "groupId", "onHeightChange", "onStateChange"]);
61
+ // HOOKS
62
+ const { scGroup } = useSCFetchGroup({ id: groupId, group });
63
+ // INTL
64
+ const intl = useIntl();
65
+ /**
66
+ * Renders root object
67
+ */
68
+ return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, rest),
69
+ React.createElement(CardContent, null,
70
+ React.createElement(Typography, { variant: "h4", className: classes.title },
71
+ React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.title", defaultMessage: "ui.groupInfoWidget.title" })),
72
+ React.createElement(Typography, { variant: "body1", className: classes.description }, scGroup.description),
73
+ React.createElement(Typography, { component: "div", className: classes.privacy }, scGroup.privacy === SCGroupPrivacyType.PUBLIC ? (React.createElement(React.Fragment, null,
74
+ React.createElement(Typography, { className: classes.privacyTitle },
75
+ React.createElement(Icon, null, "public"),
76
+ React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.public", defaultMessage: "ui.createGroup.privacy.public" })),
77
+ React.createElement(Typography, { variant: "body2" },
78
+ React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.public.info", defaultMessage: "ui.createGroup.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
79
+ React.createElement(Typography, { className: classes.privacyTitle },
80
+ React.createElement(Icon, null, "private"),
81
+ React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.private", defaultMessage: "ui.createGroup.privacy.private" })),
82
+ React.createElement(Typography, { variant: "body2" },
83
+ React.createElement(FormattedMessage, { id: "ui.createGroup.privacy.private.info", defaultMessage: "ui.createGroup.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))),
84
+ scGroup.privacy === SCGroupPrivacyType.PRIVATE && (React.createElement(Typography, { component: "div", className: classes.visibility }, scGroup.visible ? (React.createElement(React.Fragment, null,
85
+ React.createElement(Typography, { className: classes.visibilityTitle },
86
+ React.createElement(Icon, null, "visibility"),
87
+ React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.visible", defaultMessage: "ui.createGroup.visibility.visible" })),
88
+ React.createElement(Typography, { variant: "body2" },
89
+ React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.visible.info", defaultMessage: "ui.createGroup.visibility.visible.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
90
+ React.createElement(Typography, { className: classes.visibilityTitle },
91
+ React.createElement(Icon, null, "visibility_off"),
92
+ React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.hidden", defaultMessage: "ui.createGroup.visibility.hidden" })),
93
+ React.createElement(Typography, { variant: "body2" },
94
+ React.createElement(FormattedMessage, { id: "ui.createGroup.visibility.hidden.info", defaultMessage: "ui.createGroup.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))))),
95
+ React.createElement(Typography, { variant: "body2", className: classes.date },
96
+ React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })))));
97
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * > API documentation for the Community-JS Platform Skeleton component. Learn about the available props and the CSS API.
3
+
4
+ #### Import
5
+
6
+ ```jsx
7
+ import {PlatformWidgetSkeleton} from '@selfcommunity/react-ui';
8
+ ```
9
+
10
+ #### Component Name
11
+
12
+ The name `SCPlatformWidget-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|.SCPlatformWidget-skeleton-root|Styles applied to the root element.|
19
+ *
20
+ */
21
+ export default function PlatformWidgetSkeleton(): JSX.Element;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { GenericSkeleton } from '../Skeleton';
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(GenericSkeleton, {
9
+ name: PREFIX,
10
+ slot: 'SkeletonRoot'
11
+ })(() => ({}));
12
+ /**
13
+ * > API documentation for the Community-JS Platform Skeleton component. Learn about the available props and the CSS API.
14
+
15
+ #### Import
16
+
17
+ ```jsx
18
+ import {PlatformWidgetSkeleton} from '@selfcommunity/react-ui';
19
+ ```
20
+
21
+ #### Component Name
22
+
23
+ The name `SCPlatformWidget-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|.SCPlatformWidget-skeleton-root|Styles applied to the root element.|
30
+ *
31
+ */
32
+ export default function PlatformWidgetSkeleton() {
33
+ return React.createElement(Root, { className: classes.root });
34
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCGroupInfoWidget";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCGroupInfoWidget';
@@ -0,0 +1,4 @@
1
+ import GroupInfoWidget, { GroupInfoWidgetProps } from './GroupInfoWidget';
2
+ import GroupInfoWidgetSkeleton from './Skeleton';
3
+ export default GroupInfoWidget;
4
+ export { GroupInfoWidgetProps, GroupInfoWidgetSkeleton };
@@ -0,0 +1,4 @@
1
+ import GroupInfoWidget from './GroupInfoWidget';
2
+ import GroupInfoWidgetSkeleton from './Skeleton';
3
+ export default GroupInfoWidget;
4
+ export { GroupInfoWidgetSkeleton };
@@ -0,0 +1,57 @@
1
+ import { ButtonProps } from '@mui/material/Button/Button';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ export interface GroupInviteButtonProps extends ButtonProps {
4
+ /**
5
+ * Overrides or extends the styles applied to the component.
6
+ * @default null
7
+ */
8
+ className?: string;
9
+ /**
10
+ * Group Object
11
+ * @default null
12
+ */
13
+ group?: SCGroupType;
14
+ /**
15
+ * Id of the group
16
+ * @default null
17
+ */
18
+ groupId?: number | string;
19
+ /**
20
+ * Functions to handle invitations sending in group creation mode
21
+ * @default null
22
+ */
23
+ handleInvitations?: (data: any) => any;
24
+ /**
25
+ * Any other properties
26
+ */
27
+ [p: string]: any;
28
+ }
29
+ /**
30
+ *> API documentation for the Community-JS Group Invite Button component. Learn about the available props and the CSS API.
31
+ *
32
+ #### Import
33
+ ```jsx
34
+ import {SCGroupInviteButton} from '@selfcommunity/react-ui';
35
+ ```
36
+
37
+ #### Component Name
38
+ The name `SCGroupInviteButton` can be used when providing style overrides in the theme.
39
+
40
+ #### CSS
41
+
42
+ |Rule Name|Global class|Description|
43
+ |---|---|---|
44
+ |root|.SCGroupInviteButton-root|Styles applied to the root element.|
45
+ |dialogRoot|.SCGroupInviteButton-dialog-root|Styles applied to the dialog root.|
46
+ |dialogTitle|.SCGroupInviteButton-dialog-title|Styles applied to the dialog title element.|
47
+ |dialogContent|.SCGroupInviteButton-dialog-content|Styles applied to the dialog content.|
48
+ |autocomplete|.SCGroupInviteButton-autocomplete|Styles applied to the autocomplete element.|
49
+ |icon|.SCGroupInviteButton-icon|Styles applied to the autocomplete icon element.|
50
+ |input|.SCGroupInviteButton-input|Styles applied to the autocomplete input element.|
51
+ |clear|.SCGroupInviteButton-clear|Styles applied to the autocomplete clear icon element.|
52
+ |invitedBox|.SCGroupInviteButton-invited-box|Styles applied to the invited users box.|
53
+ |suggested|.SCGroupInviteButton-suggested|Styles applied to the suggested users box.|
54
+
55
+ * @param inProps
56
+ */
57
+ export default function GroupInviteButton(inProps: GroupInviteButtonProps): JSX.Element;
@@ -0,0 +1,258 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useContext, useEffect, useMemo, useState } from 'react';
3
+ import { useThemeProps } from '@mui/system';
4
+ import { styled } from '@mui/material/styles';
5
+ import { Avatar, Box, Button, Chip, Icon, IconButton, InputAdornment, TextField, Typography } from '@mui/material';
6
+ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
7
+ import { SCUserContext, useSCFetchGroup } from '@selfcommunity/react-core';
8
+ import classNames from 'classnames';
9
+ import BaseDialog from '../../shared/BaseDialog';
10
+ import { LoadingButton } from '@mui/lab';
11
+ import { GroupService } from '@selfcommunity/api-services';
12
+ import Autocomplete from '@mui/material/Autocomplete';
13
+ import User from '../User';
14
+ import { SCOPE_SC_UI } from '../../constants/Errors';
15
+ import { Logger } from '@selfcommunity/utils';
16
+ const messages = defineMessages({
17
+ placeholder: {
18
+ id: 'ui.groupInviteButton.searchBar.placeholder',
19
+ defaultMessage: 'ui.groupInviteButton.searchBar.placeholder'
20
+ }
21
+ });
22
+ const PREFIX = 'SCGroupInviteButton';
23
+ const classes = {
24
+ root: `${PREFIX}-root`,
25
+ dialogRoot: `${PREFIX}-dialog-root`,
26
+ dialogTitle: `${PREFIX}-dialog-title`,
27
+ dialogContent: `${PREFIX}-dialog-content`,
28
+ autocomplete: `${PREFIX}-autocomplete`,
29
+ icon: `${PREFIX}-icon`,
30
+ input: `${PREFIX}-input`,
31
+ clear: `${PREFIX}-clear`,
32
+ invitedBox: `${PREFIX}-invited-box`,
33
+ suggested: `${PREFIX}-suggested`
34
+ };
35
+ const Root = styled(Button, {
36
+ name: PREFIX,
37
+ slot: 'Root',
38
+ overridesResolver: (props, styles) => styles.root
39
+ })(({ theme }) => ({}));
40
+ const DialogRoot = styled(BaseDialog, {
41
+ name: PREFIX,
42
+ slot: 'Root',
43
+ overridesResolver: (props, styles) => styles.dialogRoot
44
+ })(({ theme }) => ({}));
45
+ /**
46
+ *> API documentation for the Community-JS Group Invite Button component. Learn about the available props and the CSS API.
47
+ *
48
+ #### Import
49
+ ```jsx
50
+ import {SCGroupInviteButton} from '@selfcommunity/react-ui';
51
+ ```
52
+
53
+ #### Component Name
54
+ The name `SCGroupInviteButton` can be used when providing style overrides in the theme.
55
+
56
+ #### CSS
57
+
58
+ |Rule Name|Global class|Description|
59
+ |---|---|---|
60
+ |root|.SCGroupInviteButton-root|Styles applied to the root element.|
61
+ |dialogRoot|.SCGroupInviteButton-dialog-root|Styles applied to the dialog root.|
62
+ |dialogTitle|.SCGroupInviteButton-dialog-title|Styles applied to the dialog title element.|
63
+ |dialogContent|.SCGroupInviteButton-dialog-content|Styles applied to the dialog content.|
64
+ |autocomplete|.SCGroupInviteButton-autocomplete|Styles applied to the autocomplete element.|
65
+ |icon|.SCGroupInviteButton-icon|Styles applied to the autocomplete icon element.|
66
+ |input|.SCGroupInviteButton-input|Styles applied to the autocomplete input element.|
67
+ |clear|.SCGroupInviteButton-clear|Styles applied to the autocomplete clear icon element.|
68
+ |invitedBox|.SCGroupInviteButton-invited-box|Styles applied to the invited users box.|
69
+ |suggested|.SCGroupInviteButton-suggested|Styles applied to the suggested users box.|
70
+
71
+ * @param inProps
72
+ */
73
+ export default function GroupInviteButton(inProps) {
74
+ //PROPS
75
+ const props = useThemeProps({
76
+ props: inProps,
77
+ name: PREFIX
78
+ });
79
+ const { className, group, groupId, handleInvitations = null } = props, rest = __rest(props, ["className", "group", "groupId", "handleInvitations"]);
80
+ // CONTEXT
81
+ const scUserContext = useContext(SCUserContext);
82
+ // STATE
83
+ const [open, setOpen] = useState(false);
84
+ const [isSending, setIsSending] = useState(false);
85
+ const [value, setValue] = useState('');
86
+ const [suggested, setSuggested] = useState([]);
87
+ const [list, setList] = useState([]);
88
+ const [loading, setLoading] = useState(false);
89
+ const [invited, setInvited] = useState([]);
90
+ function convertToInvitedUsersObject(data) {
91
+ const invited_users = {};
92
+ data.forEach((user, index) => {
93
+ invited_users[`invited_users[${index}]`] = user.id;
94
+ });
95
+ return invited_users;
96
+ }
97
+ /**
98
+ * Memoized users invited ids
99
+ */
100
+ const ids = useMemo(() => {
101
+ if (invited) {
102
+ return invited.map((u) => {
103
+ return parseInt(u.id, 10);
104
+ });
105
+ }
106
+ return [invited];
107
+ }, [invited]);
108
+ // CONST
109
+ const authUserId = scUserContext.user ? scUserContext.user.id : null;
110
+ // HOOKS
111
+ const { scGroup } = useSCFetchGroup({ id: groupId, group });
112
+ // INTL
113
+ const intl = useIntl();
114
+ function fetchResults() {
115
+ setLoading(true);
116
+ GroupService.getGroupSuggestedUsers(scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, value)
117
+ .then((data) => {
118
+ setLoading(false);
119
+ setSuggested(data.results);
120
+ })
121
+ .catch((error) => {
122
+ setLoading(false);
123
+ Logger.error(SCOPE_SC_UI, error);
124
+ });
125
+ }
126
+ function fetchGeneralResults() {
127
+ setLoading(true);
128
+ GroupService.getGroupsSuggestedUsers(value)
129
+ .then((data) => {
130
+ setLoading(false);
131
+ setSuggested(data.results);
132
+ })
133
+ .catch((error) => {
134
+ setLoading(false);
135
+ Logger.error(SCOPE_SC_UI, error);
136
+ });
137
+ }
138
+ useEffect(() => {
139
+ if (scGroup === null || scGroup === void 0 ? void 0 : scGroup.id) {
140
+ GroupService.getGroupSuggestedUsers(scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, value).then((data) => {
141
+ setLoading(false);
142
+ setList(data.results);
143
+ });
144
+ }
145
+ else {
146
+ GroupService.getGroupsSuggestedUsers(value).then((data) => {
147
+ setLoading(false);
148
+ setList(data.results);
149
+ });
150
+ }
151
+ }, [scGroup === null || scGroup === void 0 ? void 0 : scGroup.id]);
152
+ /**
153
+ * If a value is entered in new message field, it fetches user suggested
154
+ */
155
+ useEffect(() => {
156
+ if (value && !handleInvitations) {
157
+ fetchResults();
158
+ }
159
+ fetchGeneralResults();
160
+ }, [value, handleInvitations]);
161
+ /**
162
+ * Handles dialog close
163
+ */
164
+ const handleClose = () => {
165
+ setOpen((p) => !p);
166
+ };
167
+ /**
168
+ * Handles invitation sending
169
+ */
170
+ const handleSendInvitations = () => {
171
+ if (handleInvitations) {
172
+ handleInvitations(convertToInvitedUsersObject(invited));
173
+ setOpen(false);
174
+ }
175
+ else {
176
+ const data = { users: ids };
177
+ setIsSending(true);
178
+ GroupService.inviteOrAcceptGroupRequest(scGroup.id, data)
179
+ .then(() => {
180
+ setIsSending(false);
181
+ setOpen(false);
182
+ })
183
+ .catch((error) => {
184
+ setOpen(false);
185
+ setLoading(false);
186
+ Logger.error(SCOPE_SC_UI, error);
187
+ });
188
+ }
189
+ };
190
+ // Autocomplete Handlers
191
+ const handleInputChange = (event, value, reason) => {
192
+ switch (reason) {
193
+ case 'input':
194
+ setValue(value);
195
+ !value && setSuggested([]);
196
+ break;
197
+ case 'reset':
198
+ setValue(value);
199
+ break;
200
+ }
201
+ };
202
+ const handleChange = (event, value, reason, details) => {
203
+ event.preventDefault();
204
+ event.stopPropagation();
205
+ switch (reason) {
206
+ case 'selectOption':
207
+ setInvited(value);
208
+ setList((prev) => prev.filter((u) => u.id !== details.option.id));
209
+ break;
210
+ case 'removeOption':
211
+ setInvited(value);
212
+ setList((prev) => [...prev, details.option]);
213
+ break;
214
+ }
215
+ return false;
216
+ };
217
+ const handleUserInvite = (user) => {
218
+ setInvited((prev) => [...prev, user]);
219
+ setList((prev) => prev.filter((u) => u.id !== user.id));
220
+ };
221
+ const handleDelete = (option) => {
222
+ setInvited(invited.filter((v) => v !== option));
223
+ setList((prev) => [...prev, option]);
224
+ };
225
+ /**
226
+ * If there's no authUserId, component is hidden.
227
+ // */
228
+ if (!authUserId) {
229
+ return null;
230
+ }
231
+ /**
232
+ * Renders root object
233
+ */
234
+ return (React.createElement(React.Fragment, null,
235
+ React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose, size: "small", variant: scGroup ? 'contained' : 'outlined', color: scGroup ? 'secondary' : 'inherit', startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest),
236
+ React.createElement(FormattedMessage, { id: "ui.groupInviteButton", defaultMessage: "ui.groupInviteButton" })),
237
+ open && (React.createElement(DialogRoot, { DialogContentProps: { dividers: false }, open: true, className: classes.dialogRoot, title: React.createElement(React.Fragment, null,
238
+ React.createElement(IconButton, { onClick: handleClose },
239
+ React.createElement(Icon, { fontSize: "medium" }, "arrow_back")),
240
+ React.createElement(Typography, { className: classes.dialogTitle },
241
+ React.createElement(FormattedMessage, { id: "ui.groupInviteButton.dialog.title", defaultMessage: "ui.groupInviteButton.dialog.title" })),
242
+ React.createElement(LoadingButton, { size: "small", color: "secondary", variant: "contained", onClick: handleSendInvitations, loading: isSending },
243
+ React.createElement(FormattedMessage, { id: "ui.groupInviteButton.dialog.button.end", defaultMessage: "ui.groupInviteButton.dialog.button.end" }))) },
244
+ React.createElement(Box, { className: classes.dialogContent },
245
+ React.createElement(Autocomplete, { className: classes.autocomplete, loading: loading, size: "small", multiple: true, freeSolo: true, disableClearable: true, options: suggested, onChange: handleChange, onInputChange: handleInputChange, inputValue: value, value: invited, getOptionLabel: (option) => (option ? option.username : '...'), isOptionEqualToValue: (option, value) => (option ? value.id === option.id : false), renderTags: () => null, renderOption: (props, option) => (React.createElement(Box, Object.assign({ component: "li" }, props),
246
+ React.createElement(Avatar, { alt: option.username, src: option.avatar }),
247
+ React.createElement(Typography, { ml: 1 }, option.username))), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { variant: "outlined", placeholder: `${intl.formatMessage(messages.placeholder)}`, InputProps: Object.assign(Object.assign({}, params.InputProps), { className: classes.input, startAdornment: (React.createElement(React.Fragment, null,
248
+ React.createElement(InputAdornment, { position: "start" },
249
+ React.createElement(Icon, { className: classes.icon }, "search")),
250
+ params.InputProps.startAdornment)) }) }))) }),
251
+ React.createElement(Box, { className: classes.invitedBox }, invited.map((option, index) => (React.createElement(Chip, { key: index, avatar: React.createElement(Avatar, { alt: option.username, src: option.avatar }), label: option.username, onDelete: () => {
252
+ handleDelete(option);
253
+ }, style: { marginRight: 8 } })))),
254
+ React.createElement(Box, { className: classes.suggested },
255
+ list.length !== 0 && (React.createElement(Typography, { variant: "h4", fontWeight: "bold" },
256
+ React.createElement(FormattedMessage, { id: "ui.groupInviteButton.dialog.content.list", defaultMessage: "ui.groupInviteButton.dialog.content.list" }))),
257
+ list.slice(0, 5).map((user, index) => (React.createElement(User, { elevation: 0, actions: React.createElement(React.Fragment, null), user: user, userId: user.id, key: index, buttonProps: { onClick: () => handleUserInvite(user) } })))))))));
258
+ }
@@ -0,0 +1,3 @@
1
+ import GroupInviteButton, { GroupInviteButtonProps } from './GroupInviteButton';
2
+ export default GroupInviteButton;
3
+ export { GroupInviteButtonProps };
@@ -0,0 +1,2 @@
1
+ import GroupInviteButton from './GroupInviteButton';
2
+ export default GroupInviteButton;
@@ -0,0 +1,46 @@
1
+ import { BaseDialogProps } from '../../shared/BaseDialog';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ import { ButtonProps } from '@mui/material/Button/Button';
4
+ export interface GroupMembersButtonProps extends Pick<ButtonProps, Exclude<keyof ButtonProps, 'onClick' | 'disabled'>> {
5
+ /**
6
+ * Group Object
7
+ * @default null
8
+ */
9
+ group?: SCGroupType;
10
+ /**
11
+ * Id of the group
12
+ * @default null
13
+ */
14
+ groupId?: number | string;
15
+ /**
16
+ * Props to spread to followedBy dialog
17
+ * @default {}
18
+ */
19
+ DialogProps?: BaseDialogProps;
20
+ /**
21
+ * Any other properties
22
+ */
23
+ [p: string]: any;
24
+ }
25
+ /**
26
+ *> API documentation for the Community-JS Group Members Button component. Learn about the available props and the CSS API.
27
+ *
28
+ #### Import
29
+ ```jsx
30
+ import {GroupMembersButton} from '@selfcommunity/react-ui';
31
+ ```
32
+ #### Component Name
33
+
34
+ The name `SCGroupMembersButton` can be used when providing style overrides in the theme.
35
+
36
+ * #### CSS
37
+ *
38
+ |Rule Name|Global class|Description|
39
+ |---|---|---|
40
+ |root|.SCGroupMembersButton-root|Styles applied to the root element.|
41
+ |dialogRoot|.SCGroupMembersButton-dialog-root|Styles applied to the root element.|
42
+ |endMessage|.SCCategoriesFollowedWidget-end-message|Styles applied to the end message element.|
43
+
44
+ * @param inProps
45
+ */
46
+ export default function GroupMembersButton(inProps: GroupMembersButtonProps): JSX.Element;