@selfcommunity/react-ui 0.7.9-alpha.1 → 0.7.9-alpha.11
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.
- package/lib/cjs/components/BottomNavigation/BottomNavigation.js +3 -1
- package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
- package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +140 -0
- package/lib/cjs/components/ChangeGroupCover/constants.d.ts +1 -0
- package/lib/cjs/components/ChangeGroupCover/constants.js +4 -0
- package/lib/cjs/components/ChangeGroupCover/index.d.ts +3 -0
- package/lib/cjs/components/ChangeGroupCover/index.js +5 -0
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.d.ts +57 -0
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +135 -0
- package/lib/cjs/components/ChangeGroupPicture/constants.d.ts +1 -0
- package/lib/cjs/components/ChangeGroupPicture/constants.js +4 -0
- package/lib/cjs/components/ChangeGroupPicture/index.d.ts +3 -0
- package/lib/cjs/components/ChangeGroupPicture/index.js +5 -0
- package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/cjs/components/Composer/Attributes/Attributes.js +7 -0
- package/lib/cjs/components/Composer/Composer.d.ts +2 -1
- package/lib/cjs/components/Composer/Composer.js +39 -12
- package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.js +4 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +46 -12
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +72 -0
- package/lib/cjs/components/CreateGroupButton/index.d.ts +3 -0
- package/lib/cjs/components/CreateGroupButton/index.js +5 -0
- package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/cjs/components/EditGroupButton/EditGroupButton.d.ts +43 -0
- package/lib/cjs/components/EditGroupButton/EditGroupButton.js +61 -0
- package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
- package/lib/cjs/components/EditGroupButton/index.js +5 -0
- package/lib/cjs/components/Group/Group.d.ts +68 -0
- package/lib/cjs/components/Group/Group.js +96 -0
- package/lib/cjs/components/Group/Skeleton.d.ts +22 -0
- package/lib/cjs/components/Group/Skeleton.js +42 -0
- package/lib/cjs/components/Group/constants.d.ts +1 -0
- package/lib/cjs/components/Group/constants.js +4 -0
- package/lib/cjs/components/Group/index.d.ts +4 -0
- package/lib/cjs/components/Group/index.js +8 -0
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
- package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
- package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
- package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
- package/lib/cjs/components/GroupForm/constants.js +4 -0
- package/lib/cjs/components/GroupForm/index.d.ts +3 -0
- package/lib/cjs/components/GroupForm/index.js +5 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +84 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.js +147 -0
- package/lib/cjs/components/GroupHeader/Skeleton.d.ts +25 -0
- package/lib/cjs/components/GroupHeader/Skeleton.js +56 -0
- package/lib/cjs/components/GroupHeader/constants.d.ts +1 -0
- package/lib/cjs/components/GroupHeader/constants.js +4 -0
- package/lib/cjs/components/GroupHeader/index.d.ts +4 -0
- package/lib/cjs/components/GroupHeader/index.js +8 -0
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.d.ts +52 -0
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +100 -0
- package/lib/cjs/components/GroupInfoWidget/Skeleton.d.ts +21 -0
- package/lib/cjs/components/GroupInfoWidget/Skeleton.js +38 -0
- package/lib/cjs/components/GroupInfoWidget/constants.d.ts +1 -0
- package/lib/cjs/components/GroupInfoWidget/constants.js +4 -0
- package/lib/cjs/components/GroupInfoWidget/index.d.ts +4 -0
- package/lib/cjs/components/GroupInfoWidget/index.js +8 -0
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.d.ts +57 -0
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +262 -0
- package/lib/cjs/components/GroupInviteButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupInviteButton/index.js +5 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +51 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +136 -0
- package/lib/cjs/components/GroupMembersButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupMembersButton/index.js +5 -0
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.d.ts +79 -0
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +205 -0
- package/lib/cjs/components/GroupMembersWidget/Skeleton.d.ts +22 -0
- package/lib/cjs/components/GroupMembersWidget/Skeleton.js +38 -0
- package/lib/cjs/components/GroupMembersWidget/constants.d.ts +1 -0
- package/lib/cjs/components/GroupMembersWidget/constants.js +4 -0
- package/lib/cjs/components/GroupMembersWidget/index.d.ts +4 -0
- package/lib/cjs/components/GroupMembersWidget/index.js +8 -0
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +74 -0
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +204 -0
- package/lib/cjs/components/GroupRequestsWidget/Skeleton.d.ts +22 -0
- package/lib/cjs/components/GroupRequestsWidget/Skeleton.js +38 -0
- package/lib/cjs/components/GroupRequestsWidget/constants.d.ts +1 -0
- package/lib/cjs/components/GroupRequestsWidget/constants.js +4 -0
- package/lib/cjs/components/GroupRequestsWidget/index.d.ts +4 -0
- package/lib/cjs/components/GroupRequestsWidget/index.js +8 -0
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +56 -0
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +137 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +56 -0
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +132 -0
- package/lib/cjs/components/GroupSubscribeButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupSubscribeButton/index.js +5 -0
- package/lib/cjs/components/Groups/Groups.d.ts +61 -0
- package/lib/cjs/components/Groups/Groups.js +133 -0
- package/lib/cjs/components/Groups/Skeleton.d.ts +34 -0
- package/lib/cjs/components/Groups/Skeleton.js +45 -0
- package/lib/cjs/components/Groups/constants.d.ts +1 -0
- package/lib/cjs/components/Groups/constants.js +4 -0
- package/lib/cjs/components/Groups/index.d.ts +4 -0
- package/lib/cjs/components/Groups/index.js +8 -0
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +6 -1
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +2 -3
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
- package/lib/cjs/components/User/User.d.ts +12 -0
- package/lib/cjs/components/User/User.js +5 -3
- package/lib/cjs/constants/Group.d.ts +2 -0
- package/lib/cjs/constants/Group.js +5 -0
- package/lib/cjs/index.d.ts +17 -1
- package/lib/cjs/index.js +40 -2
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +3 -1
- package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
- package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +137 -0
- package/lib/esm/components/ChangeGroupCover/constants.d.ts +1 -0
- package/lib/esm/components/ChangeGroupCover/constants.js +1 -0
- package/lib/esm/components/ChangeGroupCover/index.d.ts +3 -0
- package/lib/esm/components/ChangeGroupCover/index.js +2 -0
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.d.ts +57 -0
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +132 -0
- package/lib/esm/components/ChangeGroupPicture/constants.d.ts +1 -0
- package/lib/esm/components/ChangeGroupPicture/constants.js +1 -0
- package/lib/esm/components/ChangeGroupPicture/index.d.ts +3 -0
- package/lib/esm/components/ChangeGroupPicture/index.js +2 -0
- package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/esm/components/Composer/Attributes/Attributes.js +7 -0
- package/lib/esm/components/Composer/Composer.d.ts +2 -1
- package/lib/esm/components/Composer/Composer.js +39 -12
- package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/esm/components/Composer/Content/ContentPost/ContentPost.js +4 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +45 -12
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +69 -0
- package/lib/esm/components/CreateGroupButton/index.d.ts +3 -0
- package/lib/esm/components/CreateGroupButton/index.js +2 -0
- package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/esm/components/EditGroupButton/EditGroupButton.d.ts +43 -0
- package/lib/esm/components/EditGroupButton/EditGroupButton.js +58 -0
- package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
- package/lib/esm/components/EditGroupButton/index.js +2 -0
- package/lib/esm/components/Group/Group.d.ts +68 -0
- package/lib/esm/components/Group/Group.js +93 -0
- package/lib/esm/components/Group/Skeleton.d.ts +22 -0
- package/lib/esm/components/Group/Skeleton.js +38 -0
- package/lib/esm/components/Group/constants.d.ts +1 -0
- package/lib/esm/components/Group/constants.js +1 -0
- package/lib/esm/components/Group/index.d.ts +4 -0
- package/lib/esm/components/Group/index.js +4 -0
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
- package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/esm/components/GroupAutocomplete/index.js +2 -0
- package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/esm/components/GroupForm/GroupForm.js +236 -0
- package/lib/esm/components/GroupForm/constants.d.ts +1 -0
- package/lib/esm/components/GroupForm/constants.js +1 -0
- package/lib/esm/components/GroupForm/index.d.ts +3 -0
- package/lib/esm/components/GroupForm/index.js +2 -0
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +84 -0
- package/lib/esm/components/GroupHeader/GroupHeader.js +144 -0
- package/lib/esm/components/GroupHeader/Skeleton.d.ts +25 -0
- package/lib/esm/components/GroupHeader/Skeleton.js +53 -0
- package/lib/esm/components/GroupHeader/constants.d.ts +1 -0
- package/lib/esm/components/GroupHeader/constants.js +1 -0
- package/lib/esm/components/GroupHeader/index.d.ts +4 -0
- package/lib/esm/components/GroupHeader/index.js +4 -0
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.d.ts +52 -0
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +97 -0
- package/lib/esm/components/GroupInfoWidget/Skeleton.d.ts +21 -0
- package/lib/esm/components/GroupInfoWidget/Skeleton.js +34 -0
- package/lib/esm/components/GroupInfoWidget/constants.d.ts +1 -0
- package/lib/esm/components/GroupInfoWidget/constants.js +1 -0
- package/lib/esm/components/GroupInfoWidget/index.d.ts +4 -0
- package/lib/esm/components/GroupInfoWidget/index.js +4 -0
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.d.ts +57 -0
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +259 -0
- package/lib/esm/components/GroupInviteButton/index.d.ts +3 -0
- package/lib/esm/components/GroupInviteButton/index.js +2 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +51 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +133 -0
- package/lib/esm/components/GroupMembersButton/index.d.ts +3 -0
- package/lib/esm/components/GroupMembersButton/index.js +2 -0
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.d.ts +79 -0
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +202 -0
- package/lib/esm/components/GroupMembersWidget/Skeleton.d.ts +22 -0
- package/lib/esm/components/GroupMembersWidget/Skeleton.js +34 -0
- package/lib/esm/components/GroupMembersWidget/constants.d.ts +1 -0
- package/lib/esm/components/GroupMembersWidget/constants.js +1 -0
- package/lib/esm/components/GroupMembersWidget/index.d.ts +4 -0
- package/lib/esm/components/GroupMembersWidget/index.js +4 -0
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +74 -0
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +201 -0
- package/lib/esm/components/GroupRequestsWidget/Skeleton.d.ts +22 -0
- package/lib/esm/components/GroupRequestsWidget/Skeleton.js +34 -0
- package/lib/esm/components/GroupRequestsWidget/constants.d.ts +1 -0
- package/lib/esm/components/GroupRequestsWidget/constants.js +1 -0
- package/lib/esm/components/GroupRequestsWidget/index.d.ts +4 -0
- package/lib/esm/components/GroupRequestsWidget/index.js +4 -0
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +56 -0
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +134 -0
- package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +56 -0
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +129 -0
- package/lib/esm/components/GroupSubscribeButton/index.d.ts +3 -0
- package/lib/esm/components/GroupSubscribeButton/index.js +2 -0
- package/lib/esm/components/Groups/Groups.d.ts +61 -0
- package/lib/esm/components/Groups/Groups.js +130 -0
- package/lib/esm/components/Groups/Skeleton.d.ts +34 -0
- package/lib/esm/components/Groups/Skeleton.js +42 -0
- package/lib/esm/components/Groups/constants.d.ts +1 -0
- package/lib/esm/components/Groups/constants.js +1 -0
- package/lib/esm/components/Groups/index.d.ts +4 -0
- package/lib/esm/components/Groups/index.js +4 -0
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +6 -1
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +3 -4
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
- package/lib/esm/components/User/User.d.ts +12 -0
- package/lib/esm/components/User/User.js +5 -3
- package/lib/esm/constants/Group.d.ts +2 -0
- package/lib/esm/constants/Group.js +2 -0
- package/lib/esm/index.d.ts +17 -1
- package/lib/esm/index.js +19 -3
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,69 @@
|
|
|
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 GroupForm from '../GroupForm';
|
|
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, GroupFormProps = {}, children } = props, rest = __rest(props, ["className", "GroupFormProps", "children"]);
|
|
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((o) => !o);
|
|
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, variant: "contained", startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest), children !== null && children !== void 0 ? children : React.createElement(FormattedMessage, { id: "ui.createGroupButton", defaultMessage: "ui.createGroupButton" })),
|
|
68
|
+
open && React.createElement(GroupForm, Object.assign({}, GroupFormProps, { open: true, onClose: handleClick }))));
|
|
69
|
+
}
|
|
@@ -23,6 +23,10 @@ export interface CustomAdvProps extends VirtualScrollerItemProps {
|
|
|
23
23
|
* Category ids if the adv must be related to specific categories
|
|
24
24
|
*/
|
|
25
25
|
categoriesId?: Array<number> | null;
|
|
26
|
+
/**
|
|
27
|
+
* Group ids if the adv must be related to specific groups
|
|
28
|
+
*/
|
|
29
|
+
groupsId?: Array<number> | null;
|
|
26
30
|
/**
|
|
27
31
|
* Prefixed height. Usefull to re-mount item on scroll feed.
|
|
28
32
|
*/
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CreateGroupButtonProps } from '../CreateGroupButton';
|
|
2
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
+
export interface EditGroupButtonProps extends CreateGroupButtonProps {
|
|
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
|
+
* On edit success callback function
|
|
16
|
+
* @default null
|
|
17
|
+
*/
|
|
18
|
+
onEditSuccess?: (data: SCGroupType) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Any other properties
|
|
21
|
+
*/
|
|
22
|
+
[p: string]: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
*> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
|
|
26
|
+
*
|
|
27
|
+
#### Import
|
|
28
|
+
```jsx
|
|
29
|
+
import {CreateGroupButton} from '@selfcommunity/react-ui';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Component Name
|
|
33
|
+
The name `SCEditGroupButton` can be used when providing style overrides in the theme.
|
|
34
|
+
|
|
35
|
+
#### CSS
|
|
36
|
+
|
|
37
|
+
|Rule Name|Global class|Description|
|
|
38
|
+
|---|---|---|
|
|
39
|
+
|root|.SCEditGroupButton-root|Styles applied to the root element.|
|
|
40
|
+
|
|
41
|
+
* @param inProps
|
|
42
|
+
*/
|
|
43
|
+
export default function EditGroupButton(inProps: EditGroupButtonProps): JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useThemeProps } from '@mui/system';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { FormattedMessage } from 'react-intl';
|
|
6
|
+
import { useSCFetchGroup, useSCUser } from '@selfcommunity/react-core';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import CreateGroupButton from '../CreateGroupButton';
|
|
9
|
+
const PREFIX = 'SCEditGroupButton';
|
|
10
|
+
const classes = {
|
|
11
|
+
root: `${PREFIX}-root`
|
|
12
|
+
};
|
|
13
|
+
const Root = styled(CreateGroupButton, {
|
|
14
|
+
name: PREFIX,
|
|
15
|
+
slot: 'Root',
|
|
16
|
+
overridesResolver: (props, styles) => styles.root
|
|
17
|
+
})(({ theme }) => ({}));
|
|
18
|
+
/**
|
|
19
|
+
*> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
|
|
20
|
+
*
|
|
21
|
+
#### Import
|
|
22
|
+
```jsx
|
|
23
|
+
import {CreateGroupButton} from '@selfcommunity/react-ui';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### Component Name
|
|
27
|
+
The name `SCEditGroupButton` can be used when providing style overrides in the theme.
|
|
28
|
+
|
|
29
|
+
#### CSS
|
|
30
|
+
|
|
31
|
+
|Rule Name|Global class|Description|
|
|
32
|
+
|---|---|---|
|
|
33
|
+
|root|.SCEditGroupButton-root|Styles applied to the root element.|
|
|
34
|
+
|
|
35
|
+
* @param inProps
|
|
36
|
+
*/
|
|
37
|
+
export default function EditGroupButton(inProps) {
|
|
38
|
+
//PROPS
|
|
39
|
+
const props = useThemeProps({
|
|
40
|
+
props: inProps,
|
|
41
|
+
name: PREFIX
|
|
42
|
+
});
|
|
43
|
+
const { className, groupId, group, onEditSuccess } = props, rest = __rest(props, ["className", "groupId", "group", "onEditSuccess"]);
|
|
44
|
+
const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
|
|
45
|
+
const scUserContext = useSCUser();
|
|
46
|
+
const handleSuccess = (data) => {
|
|
47
|
+
setSCGroup(data);
|
|
48
|
+
onEditSuccess && onEditSuccess(data);
|
|
49
|
+
};
|
|
50
|
+
if (!scUserContext.user) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Renders root object
|
|
55
|
+
*/
|
|
56
|
+
return (React.createElement(Root, Object.assign({ variant: "outlined", className: classNames(classes.root, className), GroupFormProps: { group: scGroup, onSuccess: handleSuccess } }, rest),
|
|
57
|
+
React.createElement(FormattedMessage, { id: "ui.editGroupButton", defaultMessage: "ui.editGroupButton" })));
|
|
58
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ButtonBaseProps } from '@mui/material';
|
|
2
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
+
import { WidgetProps } from '../Widget';
|
|
4
|
+
import { GroupSubscribeButtonProps } from '../GroupSubscribeButton';
|
|
5
|
+
export interface GroupProps extends WidgetProps {
|
|
6
|
+
/**
|
|
7
|
+
* Group Object
|
|
8
|
+
* @default null
|
|
9
|
+
*/
|
|
10
|
+
group?: SCGroupType;
|
|
11
|
+
/**
|
|
12
|
+
* Id of the group for filter the feed
|
|
13
|
+
* @default null
|
|
14
|
+
*/
|
|
15
|
+
groupId?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Props to spread to group subscribe/unsubscribe button
|
|
18
|
+
* @default {}
|
|
19
|
+
*/
|
|
20
|
+
groupSubscribeButtonProps?: GroupSubscribeButtonProps;
|
|
21
|
+
/**
|
|
22
|
+
* Badge content to show as group avatar badge if show reaction is true.
|
|
23
|
+
*/
|
|
24
|
+
badgeContent?: any;
|
|
25
|
+
/**
|
|
26
|
+
* Prop to hide actions
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
hideActions?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Props to spread to the button
|
|
32
|
+
* @default {}
|
|
33
|
+
*/
|
|
34
|
+
buttonProps?: ButtonBaseProps;
|
|
35
|
+
/**
|
|
36
|
+
* Any other properties
|
|
37
|
+
*/
|
|
38
|
+
[p: string]: any;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* > API documentation for the Community-JS Group component. Learn about the available props and the CSS API.
|
|
42
|
+
*
|
|
43
|
+
*
|
|
44
|
+
* This component renders a group item.
|
|
45
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/User)
|
|
46
|
+
|
|
47
|
+
#### Import
|
|
48
|
+
|
|
49
|
+
```jsx
|
|
50
|
+
import {group} from '@selfcommunity/react-ui';
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Component Name
|
|
54
|
+
|
|
55
|
+
The name `SCGroup` can be used when providing style overrides in the theme.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
#### CSS
|
|
59
|
+
|
|
60
|
+
|Rule Name|Global class|Description|
|
|
61
|
+
|---|---|---|
|
|
62
|
+
|root|.SCGroup-root|Styles applied to the root element.|
|
|
63
|
+
|avatar|.SCGroup-avatar|Styles applied to the avatar element.|
|
|
64
|
+
|
|
65
|
+
*
|
|
66
|
+
* @param inProps
|
|
67
|
+
*/
|
|
68
|
+
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, className = null, elevation, hideActions = false, groupSubscribeButtonProps = {}, visible = true } = props, rest = __rest(props, ["groupId", "group", "className", "elevation", "hideActions", "groupSubscribeButtonProps", "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, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps))));
|
|
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: { 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.group.avatar.sizeSmall, height: theme.selfcommunity.group.avatar.sizeSmall }), 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,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,99 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { FormattedMessage } from 'react-intl';
|
|
4
|
+
import Autocomplete from '@mui/material/Autocomplete';
|
|
5
|
+
import TextField from '@mui/material/TextField';
|
|
6
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
7
|
+
import parse from 'autosuggest-highlight/parse';
|
|
8
|
+
import match from 'autosuggest-highlight/match';
|
|
9
|
+
import { Avatar, Box, Typography } from '@mui/material';
|
|
10
|
+
import { useSCFetchGroups } from '@selfcommunity/react-core';
|
|
11
|
+
import { styled } from '@mui/material/styles';
|
|
12
|
+
import { useThemeProps } from '@mui/system';
|
|
13
|
+
const PREFIX = 'SCGroupAutocomplete';
|
|
14
|
+
const classes = {
|
|
15
|
+
root: `${PREFIX}-root`
|
|
16
|
+
};
|
|
17
|
+
const Root = styled(Autocomplete, {
|
|
18
|
+
name: PREFIX,
|
|
19
|
+
slot: 'Root',
|
|
20
|
+
overridesResolver: (props, styles) => styles.root
|
|
21
|
+
})(() => ({}));
|
|
22
|
+
/**
|
|
23
|
+
* > API documentation for the Community-JS Group Autocomplete component. Learn about the available props and the CSS API.
|
|
24
|
+
*
|
|
25
|
+
*
|
|
26
|
+
* This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
|
|
27
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
|
|
28
|
+
*
|
|
29
|
+
* #### Import
|
|
30
|
+
* ```jsx
|
|
31
|
+
* import {GroupAutocomplete} from '@selfcommunity/react-ui';
|
|
32
|
+
* ```
|
|
33
|
+
* #### Component Name
|
|
34
|
+
* The name `SCGroupAutocomplete` can be used when providing style overrides in the theme.
|
|
35
|
+
*
|
|
36
|
+
* #### CSS
|
|
37
|
+
*
|
|
38
|
+
* |Rule Name|Global class|Description|
|
|
39
|
+
* |---|---|---|
|
|
40
|
+
* |root|.SCGroupAutocomplete-root|Styles applied to the root element.|
|
|
41
|
+
*
|
|
42
|
+
* @param inProps
|
|
43
|
+
*/
|
|
44
|
+
const GroupAutocomplete = (inProps) => {
|
|
45
|
+
const props = useThemeProps({
|
|
46
|
+
props: inProps,
|
|
47
|
+
name: PREFIX
|
|
48
|
+
});
|
|
49
|
+
// Props
|
|
50
|
+
const { onChange, defaultValue = null, disabled = false, TextFieldProps = {
|
|
51
|
+
variant: 'outlined',
|
|
52
|
+
label: React.createElement(FormattedMessage, { id: "ui.groupAutocomplete.label", defaultMessage: "ui.groupAutocomplete.label" })
|
|
53
|
+
} } = props, rest = __rest(props, ["onChange", "defaultValue", "disabled", "TextFieldProps"]);
|
|
54
|
+
// State
|
|
55
|
+
const [open, setOpen] = useState(false);
|
|
56
|
+
const [value, setValue] = useState(typeof defaultValue === 'string' ? null : defaultValue);
|
|
57
|
+
// HOOKS
|
|
58
|
+
const { groups, isLoading } = useSCFetchGroups();
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (value === null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
onChange && onChange(value);
|
|
64
|
+
}, [value]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!isLoading && typeof defaultValue === 'string') {
|
|
67
|
+
setValue(groups.find((g) => g.id === Number(defaultValue)));
|
|
68
|
+
}
|
|
69
|
+
}, [isLoading]);
|
|
70
|
+
// Handlers
|
|
71
|
+
const handleOpen = () => {
|
|
72
|
+
setOpen(true);
|
|
73
|
+
};
|
|
74
|
+
const handleClose = () => {
|
|
75
|
+
setOpen(false);
|
|
76
|
+
};
|
|
77
|
+
const handleChange = (event, value) => {
|
|
78
|
+
setValue(value);
|
|
79
|
+
};
|
|
80
|
+
// Render
|
|
81
|
+
return (React.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.createElement(FormattedMessage, { id: "ui.groupAutocomplete.empty", defaultMessage: "ui.groupAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id,
|
|
82
|
+
// renderTags={(value, getTagProps) => {
|
|
83
|
+
// return value.map((option: any, index) => (
|
|
84
|
+
// <Chip key={option.id} id={option.id} label={option.name} color={option.color} {...getTagProps({index})} />
|
|
85
|
+
// ));
|
|
86
|
+
// }}
|
|
87
|
+
renderOption: (props, option, { inputValue }) => {
|
|
88
|
+
const matches = match(option.name, inputValue);
|
|
89
|
+
const parts = parse(option.name, matches);
|
|
90
|
+
return (React.createElement(Box, Object.assign({ component: "li" }, props),
|
|
91
|
+
React.createElement(Avatar, { alt: option.name, src: option.image_small, sx: { marginRight: 1 } }),
|
|
92
|
+
React.createElement(React.Fragment, null, parts.map((part, index) => (React.createElement(Typography, { key: index, sx: { fontWeight: part.highlight ? 700 : 400, marginRight: 0.2 } }, part.text))))));
|
|
93
|
+
}, renderInput: (params) => {
|
|
94
|
+
return (React.createElement(TextField, Object.assign({}, params, TextFieldProps, { margin: "dense", InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'groups', endAdornment: (React.createElement(React.Fragment, null,
|
|
95
|
+
isLoading ? React.createElement(CircularProgress, { color: "inherit", size: 20 }) : null,
|
|
96
|
+
params.InputProps.endAdornment)) }) })));
|
|
97
|
+
} }, rest)));
|
|
98
|
+
};
|
|
99
|
+
export default GroupAutocomplete;
|
|
@@ -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;
|