@selfcommunity/react-ui 0.7.9-alpha.1 → 0.7.9-alpha.2
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/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
- package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +117 -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 +117 -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/CreateGroup/CreateGroup.d.ts +48 -0
- package/lib/cjs/components/CreateGroup/CreateGroup.js +187 -0
- package/lib/cjs/components/CreateGroup/constants.d.ts +1 -0
- package/lib/cjs/components/CreateGroup/constants.js +4 -0
- package/lib/cjs/components/CreateGroup/index.d.ts +3 -0
- package/lib/cjs/components/CreateGroup/index.js +5 -0
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +73 -0
- package/lib/cjs/components/CreateGroupButton/index.d.ts +3 -0
- package/lib/cjs/components/CreateGroupButton/index.js +5 -0
- package/lib/cjs/components/Group/Group.d.ts +67 -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/GroupHeader/GroupHeader.d.ts +83 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.js +137 -0
- package/lib/cjs/components/GroupHeader/Skeleton.d.ts +27 -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 +259 -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 +46 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +135 -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 +194 -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 +79 -0
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +194 -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/GroupSubscribeButton/GroupSubscribeButton.d.ts +51 -0
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +117 -0
- package/lib/cjs/components/GroupSubscribeButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupSubscribeButton/index.js +5 -0
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +4 -0
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.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 +13 -1
- package/lib/cjs/index.js +30 -2
- package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
- package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +114 -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 +114 -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/CreateGroup/CreateGroup.d.ts +48 -0
- package/lib/esm/components/CreateGroup/CreateGroup.js +184 -0
- package/lib/esm/components/CreateGroup/constants.d.ts +1 -0
- package/lib/esm/components/CreateGroup/constants.js +1 -0
- package/lib/esm/components/CreateGroup/index.d.ts +3 -0
- package/lib/esm/components/CreateGroup/index.js +2 -0
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +70 -0
- package/lib/esm/components/CreateGroupButton/index.d.ts +3 -0
- package/lib/esm/components/CreateGroupButton/index.js +2 -0
- package/lib/esm/components/Group/Group.d.ts +67 -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/GroupHeader/GroupHeader.d.ts +83 -0
- package/lib/esm/components/GroupHeader/GroupHeader.js +134 -0
- package/lib/esm/components/GroupHeader/Skeleton.d.ts +27 -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 +256 -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 +46 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +132 -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 +191 -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 +79 -0
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +191 -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/GroupSubscribeButton/GroupSubscribeButton.d.ts +51 -0
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +114 -0
- package/lib/esm/components/GroupSubscribeButton/index.d.ts +3 -0
- package/lib/esm/components/GroupSubscribeButton/index.js +2 -0
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +4 -0
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +3 -4
- 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 +13 -1
- package/lib/esm/index.js +13 -1
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const Skeleton_1 = tslib_1.__importDefault(require("@mui/material/Skeleton"));
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const classes = {
|
|
10
|
+
root: `${constants_1.PREFIX}-skeleton-root`,
|
|
11
|
+
cover: `${constants_1.PREFIX}-cover`,
|
|
12
|
+
avatar: `${constants_1.PREFIX}-avatar`,
|
|
13
|
+
actions: `${constants_1.PREFIX}-actions`,
|
|
14
|
+
section: `${constants_1.PREFIX}-section`,
|
|
15
|
+
username: `${constants_1.PREFIX}-username`
|
|
16
|
+
};
|
|
17
|
+
const Root = (0, styles_1.styled)(material_1.Box, {
|
|
18
|
+
name: constants_1.PREFIX,
|
|
19
|
+
slot: 'SkeletonRoot'
|
|
20
|
+
})(() => ({}));
|
|
21
|
+
/**
|
|
22
|
+
* > API documentation for the Community-JS Group Headerr Skeleton component. Learn about the available props and the CSS API.
|
|
23
|
+
|
|
24
|
+
#### Import
|
|
25
|
+
|
|
26
|
+
```jsx
|
|
27
|
+
import {GroupHeaderSkeleton} from '@selfcommunity/react-ui';
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### Component Name
|
|
31
|
+
|
|
32
|
+
The name `SCGroupHeader-skeleton-root` can be used when providing style overrides in the theme.
|
|
33
|
+
|
|
34
|
+
#### CSS
|
|
35
|
+
|
|
36
|
+
|Rule Name|Global class|Description|
|
|
37
|
+
|---|---|---|
|
|
38
|
+
|root|.SCGroupHeader-skeleton-root|Styles applied to the root element.|
|
|
39
|
+
|avatar|.SCGroupHeader-avatar|Styles applied to the avatar element.|
|
|
40
|
+
|cover|.SCGroupHeader-cover|Styles applied to the cover element.|
|
|
41
|
+
|actions|.SCGroupHeader-actions|Styles applied to the actions section.|
|
|
42
|
+
|section|.SCGroupHeader-section|Styles applied to the info section.|
|
|
43
|
+
|username|.SCGroupHeader-username|Styles applied to the username element.|
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
function GroupHeaderSkeleton() {
|
|
47
|
+
const theme = (0, material_1.useTheme)();
|
|
48
|
+
return (react_1.default.createElement(Root, { className: classes.root },
|
|
49
|
+
react_1.default.createElement(Skeleton_1.default, { className: classes.cover, animation: "wave", variant: "rectangular" }),
|
|
50
|
+
react_1.default.createElement(material_1.Box, { className: classes.avatar },
|
|
51
|
+
react_1.default.createElement(Skeleton_1.default, { animation: "wave", variant: "circular", width: theme.selfcommunity.group.avatar.sizeLarge, height: theme.selfcommunity.group.avatar.sizeLarge })),
|
|
52
|
+
react_1.default.createElement(material_1.Box, { className: classes.section },
|
|
53
|
+
react_1.default.createElement(material_1.Typography, { variant: "h5", className: classes.username },
|
|
54
|
+
react_1.default.createElement(Skeleton_1.default, { animation: "wave", sx: { height: 30, width: 100 } })))));
|
|
55
|
+
}
|
|
56
|
+
exports.default = GroupHeaderSkeleton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCGroupHeader";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupHeaderSkeleton = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GroupHeader_1 = tslib_1.__importDefault(require("./GroupHeader"));
|
|
6
|
+
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
7
|
+
exports.GroupHeaderSkeleton = Skeleton_1.default;
|
|
8
|
+
exports.default = GroupHeader_1.default;
|
|
@@ -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,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const styles_1 = require("@mui/material/styles");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
8
|
+
const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
9
|
+
const system_1 = require("@mui/system");
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
const react_intl_1 = require("react-intl");
|
|
12
|
+
const types_1 = require("@selfcommunity/types");
|
|
13
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
14
|
+
const classes = {
|
|
15
|
+
root: `${constants_1.PREFIX}-root`,
|
|
16
|
+
title: `${constants_1.PREFIX}-title`,
|
|
17
|
+
description: `${constants_1.PREFIX}-description`,
|
|
18
|
+
privacy: `${constants_1.PREFIX}-privacy`,
|
|
19
|
+
privacyTitle: `${constants_1.PREFIX}-privacy-title`,
|
|
20
|
+
visibility: `${constants_1.PREFIX}-visibility`,
|
|
21
|
+
visibilityTitle: `${constants_1.PREFIX}-visibility-title`,
|
|
22
|
+
date: `${constants_1.PREFIX}-date`
|
|
23
|
+
};
|
|
24
|
+
const Root = (0, styles_1.styled)(Widget_1.default, {
|
|
25
|
+
name: constants_1.PREFIX,
|
|
26
|
+
slot: 'Root'
|
|
27
|
+
})(() => ({}));
|
|
28
|
+
/**
|
|
29
|
+
* > API documentation for the Community-JS Group Info Widget component. Learn about the available props and the CSS API.
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* This component renders a widget containing the group info.
|
|
33
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupInfoWidget)
|
|
34
|
+
|
|
35
|
+
#### Import
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import {GroupInfoWidget} from '@selfcommunity/react-ui';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### Component Name
|
|
42
|
+
|
|
43
|
+
The name `SCGroupInfoWidget` can be used when providing style overrides in the theme.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
#### CSS
|
|
47
|
+
|
|
48
|
+
|Rule Name|Global class|Description|
|
|
49
|
+
|---|---|---|
|
|
50
|
+
|root|.SCGroupInfoWidget-root|Styles applied to the root element.|
|
|
51
|
+
|title|.SCGroupInfoWidget-title|Styles applied to the title element.|
|
|
52
|
+
|
|
53
|
+
*
|
|
54
|
+
* @param inProps
|
|
55
|
+
*/
|
|
56
|
+
function GroupInfoWidget(inProps) {
|
|
57
|
+
// PROPS
|
|
58
|
+
const props = (0, system_1.useThemeProps)({
|
|
59
|
+
props: inProps,
|
|
60
|
+
name: constants_1.PREFIX
|
|
61
|
+
});
|
|
62
|
+
const { className, group, groupId, onHeightChange, onStateChange } = props, rest = tslib_1.__rest(props, ["className", "group", "groupId", "onHeightChange", "onStateChange"]);
|
|
63
|
+
// HOOKS
|
|
64
|
+
const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
65
|
+
// INTL
|
|
66
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
67
|
+
/**
|
|
68
|
+
* Renders root object
|
|
69
|
+
*/
|
|
70
|
+
return (react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest),
|
|
71
|
+
react_1.default.createElement(material_1.CardContent, null,
|
|
72
|
+
react_1.default.createElement(material_1.Typography, { variant: "h4", className: classes.title },
|
|
73
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.title", defaultMessage: "ui.groupInfoWidget.title" })),
|
|
74
|
+
react_1.default.createElement(material_1.Typography, { variant: "body1", className: classes.description }, scGroup.description),
|
|
75
|
+
react_1.default.createElement(material_1.Typography, { component: "div", className: classes.privacy }, scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
76
|
+
react_1.default.createElement(material_1.Typography, { className: classes.privacyTitle },
|
|
77
|
+
react_1.default.createElement(material_1.Icon, null, "public"),
|
|
78
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroup.privacy.public", defaultMessage: "ui.createGroup.privacy.public" })),
|
|
79
|
+
react_1.default.createElement(material_1.Typography, { variant: "body2" },
|
|
80
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroup.privacy.public.info", defaultMessage: "ui.createGroup.privacy.public.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
81
|
+
react_1.default.createElement(material_1.Typography, { className: classes.privacyTitle },
|
|
82
|
+
react_1.default.createElement(material_1.Icon, null, "private"),
|
|
83
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroup.privacy.private", defaultMessage: "ui.createGroup.privacy.private" })),
|
|
84
|
+
react_1.default.createElement(material_1.Typography, { variant: "body2" },
|
|
85
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroup.privacy.private.info", defaultMessage: "ui.createGroup.private.public.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } }))))),
|
|
86
|
+
scGroup.privacy === types_1.SCGroupPrivacyType.PRIVATE && (react_1.default.createElement(material_1.Typography, { component: "div", className: classes.visibility }, scGroup.visible ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
87
|
+
react_1.default.createElement(material_1.Typography, { className: classes.visibilityTitle },
|
|
88
|
+
react_1.default.createElement(material_1.Icon, null, "visibility"),
|
|
89
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroup.visibility.visible", defaultMessage: "ui.createGroup.visibility.visible" })),
|
|
90
|
+
react_1.default.createElement(material_1.Typography, { variant: "body2" },
|
|
91
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroup.visibility.visible.info", defaultMessage: "ui.createGroup.visibility.visible.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
92
|
+
react_1.default.createElement(material_1.Typography, { className: classes.visibilityTitle },
|
|
93
|
+
react_1.default.createElement(material_1.Icon, null, "visibility_off"),
|
|
94
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroup.visibility.hidden", defaultMessage: "ui.createGroup.visibility.hidden" })),
|
|
95
|
+
react_1.default.createElement(material_1.Typography, { variant: "body2" },
|
|
96
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroup.visibility.hidden.info", defaultMessage: "ui.createGroup.visibility.hidden.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })))))),
|
|
97
|
+
react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.date },
|
|
98
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })))));
|
|
99
|
+
}
|
|
100
|
+
exports.default = GroupInfoWidget;
|
|
@@ -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,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const Skeleton_1 = require("../Skeleton");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const classes = {
|
|
9
|
+
root: `${constants_1.PREFIX}-skeleton-root`
|
|
10
|
+
};
|
|
11
|
+
const Root = (0, styles_1.styled)(Skeleton_1.GenericSkeleton, {
|
|
12
|
+
name: constants_1.PREFIX,
|
|
13
|
+
slot: 'SkeletonRoot'
|
|
14
|
+
})(() => ({}));
|
|
15
|
+
/**
|
|
16
|
+
* > API documentation for the Community-JS Platform Skeleton component. Learn about the available props and the CSS API.
|
|
17
|
+
|
|
18
|
+
#### Import
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
import {PlatformWidgetSkeleton} from '@selfcommunity/react-ui';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### Component Name
|
|
25
|
+
|
|
26
|
+
The name `SCPlatformWidget-skeleton-root` can be used when providing style overrides in the theme.
|
|
27
|
+
|
|
28
|
+
#### CSS
|
|
29
|
+
|
|
30
|
+
|Rule Name|Global class|Description|
|
|
31
|
+
|---|---|---|
|
|
32
|
+
|root|.SCPlatformWidget-skeleton-root|Styles applied to the root element.|
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
function PlatformWidgetSkeleton() {
|
|
36
|
+
return react_1.default.createElement(Root, { className: classes.root });
|
|
37
|
+
}
|
|
38
|
+
exports.default = PlatformWidgetSkeleton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCGroupInfoWidget";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupInfoWidgetSkeleton = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GroupInfoWidget_1 = tslib_1.__importDefault(require("./GroupInfoWidget"));
|
|
6
|
+
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
7
|
+
exports.GroupInfoWidgetSkeleton = Skeleton_1.default;
|
|
8
|
+
exports.default = GroupInfoWidget_1.default;
|
|
@@ -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,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const system_1 = require("@mui/system");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
9
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
10
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
11
|
+
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
12
|
+
const lab_1 = require("@mui/lab");
|
|
13
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
14
|
+
const Autocomplete_1 = tslib_1.__importDefault(require("@mui/material/Autocomplete"));
|
|
15
|
+
const User_1 = tslib_1.__importDefault(require("../User"));
|
|
16
|
+
const Errors_1 = require("../../constants/Errors");
|
|
17
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
18
|
+
const messages = (0, react_intl_1.defineMessages)({
|
|
19
|
+
placeholder: {
|
|
20
|
+
id: 'ui.groupInviteButton.searchBar.placeholder',
|
|
21
|
+
defaultMessage: 'ui.groupInviteButton.searchBar.placeholder'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const PREFIX = 'SCGroupInviteButton';
|
|
25
|
+
const classes = {
|
|
26
|
+
root: `${PREFIX}-root`,
|
|
27
|
+
dialogRoot: `${PREFIX}-dialog-root`,
|
|
28
|
+
dialogTitle: `${PREFIX}-dialog-title`,
|
|
29
|
+
dialogContent: `${PREFIX}-dialog-content`,
|
|
30
|
+
autocomplete: `${PREFIX}-autocomplete`,
|
|
31
|
+
icon: `${PREFIX}-icon`,
|
|
32
|
+
input: `${PREFIX}-input`,
|
|
33
|
+
clear: `${PREFIX}-clear`,
|
|
34
|
+
invitedBox: `${PREFIX}-invited-box`,
|
|
35
|
+
suggested: `${PREFIX}-suggested`
|
|
36
|
+
};
|
|
37
|
+
const Root = (0, styles_1.styled)(material_1.Button, {
|
|
38
|
+
name: PREFIX,
|
|
39
|
+
slot: 'Root',
|
|
40
|
+
overridesResolver: (props, styles) => styles.root
|
|
41
|
+
})(({ theme }) => ({}));
|
|
42
|
+
const DialogRoot = (0, styles_1.styled)(BaseDialog_1.default, {
|
|
43
|
+
name: PREFIX,
|
|
44
|
+
slot: 'Root',
|
|
45
|
+
overridesResolver: (props, styles) => styles.dialogRoot
|
|
46
|
+
})(({ theme }) => ({}));
|
|
47
|
+
/**
|
|
48
|
+
*> API documentation for the Community-JS Group Invite Button component. Learn about the available props and the CSS API.
|
|
49
|
+
*
|
|
50
|
+
#### Import
|
|
51
|
+
```jsx
|
|
52
|
+
import {SCGroupInviteButton} from '@selfcommunity/react-ui';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Component Name
|
|
56
|
+
The name `SCGroupInviteButton` can be used when providing style overrides in the theme.
|
|
57
|
+
|
|
58
|
+
#### CSS
|
|
59
|
+
|
|
60
|
+
|Rule Name|Global class|Description|
|
|
61
|
+
|---|---|---|
|
|
62
|
+
|root|.SCGroupInviteButton-root|Styles applied to the root element.|
|
|
63
|
+
|dialogRoot|.SCGroupInviteButton-dialog-root|Styles applied to the dialog root.|
|
|
64
|
+
|dialogTitle|.SCGroupInviteButton-dialog-title|Styles applied to the dialog title element.|
|
|
65
|
+
|dialogContent|.SCGroupInviteButton-dialog-content|Styles applied to the dialog content.|
|
|
66
|
+
|autocomplete|.SCGroupInviteButton-autocomplete|Styles applied to the autocomplete element.|
|
|
67
|
+
|icon|.SCGroupInviteButton-icon|Styles applied to the autocomplete icon element.|
|
|
68
|
+
|input|.SCGroupInviteButton-input|Styles applied to the autocomplete input element.|
|
|
69
|
+
|clear|.SCGroupInviteButton-clear|Styles applied to the autocomplete clear icon element.|
|
|
70
|
+
|invitedBox|.SCGroupInviteButton-invited-box|Styles applied to the invited users box.|
|
|
71
|
+
|suggested|.SCGroupInviteButton-suggested|Styles applied to the suggested users box.|
|
|
72
|
+
|
|
73
|
+
* @param inProps
|
|
74
|
+
*/
|
|
75
|
+
function GroupInviteButton(inProps) {
|
|
76
|
+
//PROPS
|
|
77
|
+
const props = (0, system_1.useThemeProps)({
|
|
78
|
+
props: inProps,
|
|
79
|
+
name: PREFIX
|
|
80
|
+
});
|
|
81
|
+
const { className, group, groupId, handleInvitations = null } = props, rest = tslib_1.__rest(props, ["className", "group", "groupId", "handleInvitations"]);
|
|
82
|
+
// CONTEXT
|
|
83
|
+
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
84
|
+
// STATE
|
|
85
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
86
|
+
const [isSending, setIsSending] = (0, react_1.useState)(false);
|
|
87
|
+
const [value, setValue] = (0, react_1.useState)('');
|
|
88
|
+
const [suggested, setSuggested] = (0, react_1.useState)([]);
|
|
89
|
+
const [list, setList] = (0, react_1.useState)([]);
|
|
90
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
91
|
+
const [invited, setInvited] = (0, react_1.useState)([]);
|
|
92
|
+
function convertToInvitedUsersObject(data) {
|
|
93
|
+
const invited_users = {};
|
|
94
|
+
data.forEach((user, index) => {
|
|
95
|
+
invited_users[`invited_users[${index}]`] = user.id;
|
|
96
|
+
});
|
|
97
|
+
return invited_users;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Memoized users invited ids
|
|
101
|
+
*/
|
|
102
|
+
const ids = (0, react_1.useMemo)(() => {
|
|
103
|
+
if (invited) {
|
|
104
|
+
return invited.map((u) => {
|
|
105
|
+
return parseInt(u.id, 10);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return [invited];
|
|
109
|
+
}, [invited]);
|
|
110
|
+
// CONST
|
|
111
|
+
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
112
|
+
// HOOKS
|
|
113
|
+
const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
114
|
+
// INTL
|
|
115
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
116
|
+
function fetchResults() {
|
|
117
|
+
setLoading(true);
|
|
118
|
+
api_services_1.GroupService.getGroupSuggestedUsers(scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, value)
|
|
119
|
+
.then((data) => {
|
|
120
|
+
setLoading(false);
|
|
121
|
+
setSuggested(data.results);
|
|
122
|
+
})
|
|
123
|
+
.catch((error) => {
|
|
124
|
+
setLoading(false);
|
|
125
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function fetchGeneralResults() {
|
|
129
|
+
setLoading(true);
|
|
130
|
+
api_services_1.GroupService.getGroupsSuggestedUsers(value)
|
|
131
|
+
.then((data) => {
|
|
132
|
+
setLoading(false);
|
|
133
|
+
setSuggested(data.results);
|
|
134
|
+
})
|
|
135
|
+
.catch((error) => {
|
|
136
|
+
setLoading(false);
|
|
137
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
(0, react_1.useEffect)(() => {
|
|
141
|
+
if (scGroup === null || scGroup === void 0 ? void 0 : scGroup.id) {
|
|
142
|
+
api_services_1.GroupService.getGroupSuggestedUsers(scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, value).then((data) => {
|
|
143
|
+
setLoading(false);
|
|
144
|
+
setList(data.results);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
api_services_1.GroupService.getGroupsSuggestedUsers(value).then((data) => {
|
|
149
|
+
setLoading(false);
|
|
150
|
+
setList(data.results);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}, [scGroup === null || scGroup === void 0 ? void 0 : scGroup.id]);
|
|
154
|
+
/**
|
|
155
|
+
* If a value is entered in new message field, it fetches user suggested
|
|
156
|
+
*/
|
|
157
|
+
(0, react_1.useEffect)(() => {
|
|
158
|
+
if (value && !handleInvitations) {
|
|
159
|
+
fetchResults();
|
|
160
|
+
}
|
|
161
|
+
fetchGeneralResults();
|
|
162
|
+
}, [value, handleInvitations]);
|
|
163
|
+
/**
|
|
164
|
+
* Handles dialog close
|
|
165
|
+
*/
|
|
166
|
+
const handleClose = () => {
|
|
167
|
+
setOpen((p) => !p);
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Handles invitation sending
|
|
171
|
+
*/
|
|
172
|
+
const handleSendInvitations = () => {
|
|
173
|
+
if (handleInvitations) {
|
|
174
|
+
handleInvitations(convertToInvitedUsersObject(invited));
|
|
175
|
+
setOpen(false);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const data = { users: ids };
|
|
179
|
+
setIsSending(true);
|
|
180
|
+
api_services_1.GroupService.inviteOrAcceptGroupRequest(scGroup.id, data)
|
|
181
|
+
.then(() => {
|
|
182
|
+
setIsSending(false);
|
|
183
|
+
})
|
|
184
|
+
.catch((error) => {
|
|
185
|
+
setLoading(false);
|
|
186
|
+
utils_1.Logger.error(Errors_1.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_1.default.createElement(react_1.default.Fragment, null,
|
|
235
|
+
react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleClose, size: "small", variant: "outlined", startIcon: react_1.default.createElement(material_1.Icon, { fontSize: "small" }, "add") }, rest),
|
|
236
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInviteButton", defaultMessage: "ui.groupInviteButton" })),
|
|
237
|
+
open && (react_1.default.createElement(DialogRoot, { DialogContentProps: { dividers: false }, open: true, className: classes.dialogRoot, title: react_1.default.createElement(react_1.default.Fragment, null,
|
|
238
|
+
react_1.default.createElement(material_1.IconButton, { onClick: handleClose },
|
|
239
|
+
react_1.default.createElement(material_1.Icon, { fontSize: "medium" }, "arrow_back")),
|
|
240
|
+
react_1.default.createElement(material_1.Typography, { className: classes.dialogTitle },
|
|
241
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInviteButton.dialog.title", defaultMessage: "ui.groupInviteButton.dialog.title" })),
|
|
242
|
+
react_1.default.createElement(lab_1.LoadingButton, { size: "small", color: "secondary", variant: "contained", onClick: handleSendInvitations, loading: isSending },
|
|
243
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInviteButton.dialog.button.end", defaultMessage: "ui.groupInviteButton.dialog.button.end" }))) },
|
|
244
|
+
react_1.default.createElement(material_1.Box, { className: classes.dialogContent },
|
|
245
|
+
react_1.default.createElement(Autocomplete_1.default, { 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_1.default.createElement(material_1.Box, Object.assign({ component: "li" }, props),
|
|
246
|
+
react_1.default.createElement(material_1.Avatar, { alt: option.username, src: option.avatar }),
|
|
247
|
+
react_1.default.createElement(material_1.Typography, { ml: 1 }, option.username))), renderInput: (params) => (react_1.default.createElement(material_1.TextField, Object.assign({}, params, { variant: "outlined", placeholder: `${intl.formatMessage(messages.placeholder)}`, InputProps: Object.assign(Object.assign({}, params.InputProps), { className: classes.input, startAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
248
|
+
react_1.default.createElement(material_1.InputAdornment, { position: "start" },
|
|
249
|
+
react_1.default.createElement(material_1.Icon, { className: classes.icon }, "search")),
|
|
250
|
+
params.InputProps.startAdornment)) }) }))) }),
|
|
251
|
+
react_1.default.createElement(material_1.Box, { className: classes.invitedBox }, invited.map((option, index) => (react_1.default.createElement(material_1.Chip, { key: index, avatar: react_1.default.createElement(material_1.Avatar, { alt: option.username, src: option.avatar }), label: option.username, onDelete: () => {
|
|
252
|
+
handleDelete(option);
|
|
253
|
+
}, style: { marginRight: 8 } })))),
|
|
254
|
+
react_1.default.createElement(material_1.Box, { className: classes.suggested },
|
|
255
|
+
list.length !== 0 && (react_1.default.createElement(material_1.Typography, { variant: "h4", fontWeight: "bold" },
|
|
256
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInviteButton.dialog.content.list", defaultMessage: "ui.groupInviteButton.dialog.content.list" }))),
|
|
257
|
+
list.slice(0, 5).map((user, index) => (react_1.default.createElement(User_1.default, { elevation: 0, actions: react_1.default.createElement(react_1.default.Fragment, null), user: user, userId: user.id, key: index, buttonProps: { onClick: () => handleUserInvite(user) } })))))))));
|
|
258
|
+
}
|
|
259
|
+
exports.default = GroupInviteButton;
|