@selfcommunity/react-ui 0.7.9-alpha.1 → 0.7.9-alpha.10
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 +203 -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 +128 -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 +200 -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 +125 -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,57 @@
|
|
|
1
|
+
export interface ChangeGroupPictureProps {
|
|
2
|
+
/**
|
|
3
|
+
* Id of the group. It is optional only for group creation modal.
|
|
4
|
+
* @default null
|
|
5
|
+
*/
|
|
6
|
+
groupId?: number;
|
|
7
|
+
/**
|
|
8
|
+
* On change function.
|
|
9
|
+
* @default null
|
|
10
|
+
*/
|
|
11
|
+
onChange?: (cover: any) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Hides this component
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
autoHide?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Overrides or extends the styles applied to the component.
|
|
19
|
+
* @default null
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Prop to handle avatar loading in the create group modal.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
isCreationMode?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Any other properties
|
|
29
|
+
*/
|
|
30
|
+
[p: string]: any;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* > API documentation for the Community-JS Change Group Picture component. Learn about the available props and the CSS API.
|
|
34
|
+
*
|
|
35
|
+
*
|
|
36
|
+
* This component renders a button that allows admins to manage their group pictures.
|
|
37
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/ChangeGroupPicture)
|
|
38
|
+
|
|
39
|
+
#### Import
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
import {ChangeGroupPicture} from '@selfcommunity/react-ui';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Component Name
|
|
46
|
+
|
|
47
|
+
The name `SCChangeGroupPictureButton` can be used when providing style overrides in the theme.
|
|
48
|
+
|
|
49
|
+
#### CSS
|
|
50
|
+
|
|
51
|
+
|Rule Name|Global class|Description|
|
|
52
|
+
|---|---|---|
|
|
53
|
+
|root|.SCChangeGroupPictureButton-root|Styles applied to the root element.|
|
|
54
|
+
|
|
55
|
+
* @param inProps
|
|
56
|
+
*/
|
|
57
|
+
export default function ChangeGroupPicture(inProps: ChangeGroupPictureProps): JSX.Element;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useContext, useRef, useState } from 'react';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { Alert } from '@mui/material';
|
|
5
|
+
import Icon from '@mui/material/Icon';
|
|
6
|
+
import { SCUserContext } from '@selfcommunity/react-core';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import { useThemeProps } from '@mui/system';
|
|
9
|
+
import { PREFIX } from './constants';
|
|
10
|
+
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
11
|
+
import { GroupService } from '@selfcommunity/api-services';
|
|
12
|
+
import { Logger } from '@selfcommunity/utils';
|
|
13
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
14
|
+
import { LoadingButton } from '@mui/lab';
|
|
15
|
+
const messages = defineMessages({
|
|
16
|
+
errorLoadImage: {
|
|
17
|
+
id: 'ui.changeGroupPicture.alert',
|
|
18
|
+
defaultMessage: 'ui.changeGroupPicture.alert'
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const classes = {
|
|
22
|
+
root: `${PREFIX}-root`
|
|
23
|
+
};
|
|
24
|
+
const Root = styled(LoadingButton, {
|
|
25
|
+
name: PREFIX,
|
|
26
|
+
slot: 'Root'
|
|
27
|
+
})(() => ({}));
|
|
28
|
+
/**
|
|
29
|
+
* > API documentation for the Community-JS Change Group Picture component. Learn about the available props and the CSS API.
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* This component renders a button that allows admins to manage their group pictures.
|
|
33
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/ChangeGroupPicture)
|
|
34
|
+
|
|
35
|
+
#### Import
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import {ChangeGroupPicture} from '@selfcommunity/react-ui';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### Component Name
|
|
42
|
+
|
|
43
|
+
The name `SCChangeGroupPictureButton` can be used when providing style overrides in the theme.
|
|
44
|
+
|
|
45
|
+
#### CSS
|
|
46
|
+
|
|
47
|
+
|Rule Name|Global class|Description|
|
|
48
|
+
|---|---|---|
|
|
49
|
+
|root|.SCChangeGroupPictureButton-root|Styles applied to the root element.|
|
|
50
|
+
|
|
51
|
+
* @param inProps
|
|
52
|
+
*/
|
|
53
|
+
export default function ChangeGroupPicture(inProps) {
|
|
54
|
+
//PROPS
|
|
55
|
+
const props = useThemeProps({
|
|
56
|
+
props: inProps,
|
|
57
|
+
name: PREFIX
|
|
58
|
+
});
|
|
59
|
+
const { groupId, onChange, autoHide, className, isCreationMode = false } = props, rest = __rest(props, ["groupId", "onChange", "autoHide", "className", "isCreationMode"]);
|
|
60
|
+
//STATE
|
|
61
|
+
const [loading, setLoading] = useState(false);
|
|
62
|
+
const [alert, setAlert] = useState(null);
|
|
63
|
+
let fileInput = useRef(null);
|
|
64
|
+
//CONTEXT
|
|
65
|
+
const scUserContext = useContext(SCUserContext);
|
|
66
|
+
// INTL
|
|
67
|
+
const intl = useIntl();
|
|
68
|
+
// Anonymous
|
|
69
|
+
if (!scUserContext.user) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Handles avatar upload
|
|
74
|
+
* @param event
|
|
75
|
+
*/
|
|
76
|
+
function handleUpload(event) {
|
|
77
|
+
const fileInput = event.target.files[0];
|
|
78
|
+
if (fileInput) {
|
|
79
|
+
const reader = new FileReader();
|
|
80
|
+
reader.onload = (e) => {
|
|
81
|
+
const img = new Image();
|
|
82
|
+
img.onload = () => {
|
|
83
|
+
if (img.width < 600 && img.height < 600) {
|
|
84
|
+
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
isCreationMode ? onChange && onChange(fileInput) : handleSave();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
img.src = e.target.result;
|
|
93
|
+
};
|
|
94
|
+
reader.readAsDataURL(fileInput);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// ui.changeGroupPicture.alert
|
|
98
|
+
/**
|
|
99
|
+
* Performs save avatar after upload
|
|
100
|
+
*/
|
|
101
|
+
function handleSave() {
|
|
102
|
+
setLoading(true);
|
|
103
|
+
const formData = new FormData();
|
|
104
|
+
formData.append('image_original', fileInput);
|
|
105
|
+
GroupService.changeGroupAvatarOrCover(groupId, formData, { headers: { 'Content-Type': 'multipart/form-data' } })
|
|
106
|
+
.then((data) => {
|
|
107
|
+
setLoading(false);
|
|
108
|
+
onChange && onChange(data.image_bigger);
|
|
109
|
+
})
|
|
110
|
+
.catch((error) => {
|
|
111
|
+
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
112
|
+
setLoading(false);
|
|
113
|
+
Logger.error(SCOPE_SC_UI, error);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* If there is an error
|
|
118
|
+
*/
|
|
119
|
+
if (alert) {
|
|
120
|
+
return (React.createElement(Alert, { color: "error", onClose: () => setAlert(null) }, alert));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Renders the component (if not hidden by autoHide prop)
|
|
124
|
+
*/
|
|
125
|
+
if (!autoHide) {
|
|
126
|
+
return (React.createElement(React.Fragment, null,
|
|
127
|
+
React.createElement("input", { type: "file", onChange: handleUpload, ref: fileInput, hidden: true, accept: ".gif,.png,.jpg,.jpeg" }),
|
|
128
|
+
React.createElement(Root, Object.assign({ className: classNames(classes.root, className), size: "small", variant: "contained", disabled: loading, onClick: () => fileInput.current.click(), loading: loading }, rest),
|
|
129
|
+
React.createElement(Icon, null, "photo_camera"))));
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCChangeGroupPictureButton";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PREFIX = 'SCChangeGroupPictureButton';
|
|
@@ -16,7 +16,7 @@ export interface AttributesProps extends Omit<BoxProps, 'value' | 'onChange' | '
|
|
|
16
16
|
* @param value
|
|
17
17
|
* @default empty object
|
|
18
18
|
*/
|
|
19
|
-
onClick?: (attribute: 'categories' | 'addressing' | 'location') => void;
|
|
19
|
+
onClick?: (attribute: 'categories' | 'group' | 'addressing' | 'location') => void;
|
|
20
20
|
}
|
|
21
21
|
declare const _default: (props: AttributesProps) => JSX.Element;
|
|
22
22
|
export default _default;
|
|
@@ -23,6 +23,12 @@ export default (props) => {
|
|
|
23
23
|
const handleClickCategory = useCallback(() => {
|
|
24
24
|
onClick && onClick('categories');
|
|
25
25
|
}, [onClick]);
|
|
26
|
+
const handleDeleteGroup = useCallback(() => {
|
|
27
|
+
onChange && onChange(Object.assign(Object.assign({}, value), { group: null }));
|
|
28
|
+
}, [value, onChange]);
|
|
29
|
+
const handleClickGroup = useCallback(() => {
|
|
30
|
+
onClick && onClick('group');
|
|
31
|
+
}, [onClick]);
|
|
26
32
|
const handleDeleteTag = useCallback((id) => () => {
|
|
27
33
|
onChange && onChange(Object.assign(Object.assign({}, value), { addressing: value.addressing.filter((tag) => tag.id !== id) }));
|
|
28
34
|
}, [value, onChange]);
|
|
@@ -38,6 +44,7 @@ export default (props) => {
|
|
|
38
44
|
return (React.createElement(Root, { className: classNames(classes.root, className) },
|
|
39
45
|
((_a = value === null || value === void 0 ? void 0 : value.categories) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
40
46
|
(value === null || value === void 0 ? void 0 : value.categories.map((c) => (React.createElement(Chip, { key: c.id, label: c.name, onDelete: handleDeleteCategory(c.id), icon: React.createElement(Icon, null, "category"), onClick: handleClickCategory })))),
|
|
47
|
+
(value === null || value === void 0 ? void 0 : value.group) && (React.createElement(Chip, { key: value === null || value === void 0 ? void 0 : value.group.id, label: value === null || value === void 0 ? void 0 : value.group.name, onDelete: handleDeleteGroup, icon: React.createElement(Icon, null, "groups"), onClick: handleClickGroup })),
|
|
41
48
|
((_b = value === null || value === void 0 ? void 0 : value.addressing) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
|
|
42
49
|
(value === null || value === void 0 ? void 0 : value.addressing.map((t) => (React.createElement(TagChip, { key: t.id, tag: t, onDelete: handleDeleteTag(t.id), icon: React.createElement(Icon, null, "label"), onClick: handleClickTag })))),
|
|
43
50
|
(value === null || value === void 0 ? void 0 : value.location) && (React.createElement(Chip, { icon: React.createElement(Icon, null, "add_location_alt"), label: value === null || value === void 0 ? void 0 : value.location.location, onDelete: handleDeleteLocation, onClick: handleClickLocation }))));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SyntheticEvent } from 'react';
|
|
2
|
-
import { SCCategoryType, SCContributionType, SCFeedDiscussionType, SCFeedPostType, SCFeedStatusType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
|
|
2
|
+
import { SCCategoryType, SCContributionType, SCFeedDiscussionType, SCFeedPostType, SCFeedStatusType, SCGroupType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
|
|
3
3
|
import { DialogProps } from '@mui/material';
|
|
4
4
|
import { EditorProps } from '../Editor';
|
|
5
5
|
import { SCMediaObjectType } from '../../types/media';
|
|
@@ -27,6 +27,7 @@ export interface ComposerProps extends Omit<DialogProps, 'defaultValue' | 'scrol
|
|
|
27
27
|
title?: string;
|
|
28
28
|
text?: string;
|
|
29
29
|
categories?: SCCategoryType[];
|
|
30
|
+
group?: SCGroupType;
|
|
30
31
|
audience?: string;
|
|
31
32
|
addressing?: SCTagType[];
|
|
32
33
|
medias?: SCMediaType[];
|
|
@@ -57,7 +57,9 @@ const COMPOSER_INITIAL_STATE = {
|
|
|
57
57
|
html: '',
|
|
58
58
|
htmlError: null,
|
|
59
59
|
categories: [],
|
|
60
|
+
group: null,
|
|
60
61
|
categoriesError: null,
|
|
62
|
+
groupsError: null,
|
|
61
63
|
addressing: null,
|
|
62
64
|
addressingError: null,
|
|
63
65
|
medias: [],
|
|
@@ -131,7 +133,7 @@ export default function Composer(inProps) {
|
|
|
131
133
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
132
134
|
const [layer, setLayer] = useState();
|
|
133
135
|
const [state, dispatch] = useReducer(reducer, Object.assign(Object.assign(Object.assign({}, COMPOSER_INITIAL_STATE), defaultValue), { key: random() }));
|
|
134
|
-
const { key, id, type, title, titleError, html, categories, addressing, audience, medias, poll, pollError, location, error } = state;
|
|
136
|
+
const { key, id, type, title, titleError, html, categories, group, addressing, audience, medias, poll, pollError, location, error } = state;
|
|
135
137
|
const destructureFeedObject = (_feedObject) => {
|
|
136
138
|
if (_feedObject.type === SCContributionType.POST) {
|
|
137
139
|
_feedObject = _feedObject;
|
|
@@ -151,6 +153,7 @@ export default function Composer(inProps) {
|
|
|
151
153
|
title: _feedObject.title,
|
|
152
154
|
html: _feedObject.html,
|
|
153
155
|
categories: _feedObject.categories,
|
|
156
|
+
group: _feedObject.group,
|
|
154
157
|
addressing: _feedObject.addressing,
|
|
155
158
|
medias: _feedObject.medias,
|
|
156
159
|
poll: _feedObject.poll,
|
|
@@ -302,18 +305,23 @@ export default function Composer(inProps) {
|
|
|
302
305
|
}
|
|
303
306
|
}), [handleAddLayer, handleRemoveLayer, handleChangeCategories, categories]);
|
|
304
307
|
const handleChangeAudience = useCallback((value) => {
|
|
305
|
-
|
|
308
|
+
if (group || typeof value === 'object') {
|
|
309
|
+
dispatch({ type: 'group', value });
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
dispatch({ type: 'addressing', value });
|
|
313
|
+
}
|
|
306
314
|
setLayer(null);
|
|
307
|
-
}, []);
|
|
315
|
+
}, [group]);
|
|
308
316
|
const handleAddAudienceLayer = useCallback(() => handleAddLayer({
|
|
309
317
|
name: 'audience',
|
|
310
318
|
Component: AudienceLayer,
|
|
311
319
|
ComponentProps: {
|
|
312
320
|
onClose: handleRemoveLayer,
|
|
313
321
|
onSave: handleChangeAudience,
|
|
314
|
-
defaultValue: addressing
|
|
322
|
+
defaultValue: group || typeof addressing === 'object' ? group : addressing
|
|
315
323
|
}
|
|
316
|
-
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing]);
|
|
324
|
+
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing, group]);
|
|
317
325
|
const handleChangeLocation = useCallback((value) => {
|
|
318
326
|
dispatch({ type: 'location', value });
|
|
319
327
|
setLayer(null);
|
|
@@ -404,6 +412,9 @@ export default function Composer(inProps) {
|
|
|
404
412
|
if (features.includes(SCFeatureName.TAGGING) && addressing !== null) {
|
|
405
413
|
data.addressing = addressing.map((t) => t.id);
|
|
406
414
|
}
|
|
415
|
+
if (features.includes(SCFeatureName.GROUPING) && group !== null) {
|
|
416
|
+
data.group = group.id;
|
|
417
|
+
}
|
|
407
418
|
setIsSubmitting(true);
|
|
408
419
|
// Finding right url
|
|
409
420
|
const _type = type === COMPOSER_TYPE_POLL ? SCContributionType.POST : type;
|
|
@@ -431,7 +442,7 @@ export default function Composer(inProps) {
|
|
|
431
442
|
dispatch({ type: 'multiple', value: formatHttpErrorCode(error) });
|
|
432
443
|
})
|
|
433
444
|
.then(() => setIsSubmitting(false));
|
|
434
|
-
}, [scUserContext.user, feedObjectType, id, type, title, html, categories, addressing, audience, medias, poll, location, hasPoll]);
|
|
445
|
+
}, [scUserContext.user, feedObjectType, id, type, title, html, categories, group, addressing, audience, medias, poll, location, hasPoll]);
|
|
435
446
|
//edited here
|
|
436
447
|
const handleClose = useCallback((event, reason) => {
|
|
437
448
|
if (unloadRef.current) {
|
|
@@ -486,13 +497,29 @@ export default function Composer(inProps) {
|
|
|
486
497
|
}
|
|
487
498
|
switch (type) {
|
|
488
499
|
case COMPOSER_TYPE_POLL:
|
|
489
|
-
return (React.createElement(ContentPoll, { key: key, onChange: handleChangePoll, value: { html,
|
|
500
|
+
return (React.createElement(ContentPoll, { key: key, onChange: handleChangePoll, value: { html, group, addressing, medias, poll, location }, error: pollError, disabled: isSubmitting }));
|
|
490
501
|
case SCContributionType.DISCUSSION:
|
|
491
|
-
return (React.createElement(ContentDiscussion, { key: key, value: { title, html, categories, addressing, medias, poll, location }, error: { titleError, error }, onChange: handleChangeDiscussion, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: true, uploadImage: true }, EditorProps) }));
|
|
502
|
+
return (React.createElement(ContentDiscussion, { key: key, value: { title, html, categories, group, addressing, medias, poll, location }, error: { titleError, error }, onChange: handleChangeDiscussion, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: true, uploadImage: true }, EditorProps) }));
|
|
492
503
|
default:
|
|
493
|
-
return (React.createElement(ContentPost, { key: key, value: { html, categories, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
|
|
504
|
+
return (React.createElement(ContentPost, { key: key, value: { html, categories, group, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
|
|
494
505
|
}
|
|
495
|
-
}, [
|
|
506
|
+
}, [
|
|
507
|
+
key,
|
|
508
|
+
type,
|
|
509
|
+
title,
|
|
510
|
+
html,
|
|
511
|
+
categories,
|
|
512
|
+
group,
|
|
513
|
+
addressing,
|
|
514
|
+
medias,
|
|
515
|
+
poll,
|
|
516
|
+
pollError,
|
|
517
|
+
location,
|
|
518
|
+
error,
|
|
519
|
+
handleChangePoll,
|
|
520
|
+
handleChangePost,
|
|
521
|
+
isSubmitting
|
|
522
|
+
]);
|
|
496
523
|
if (!scUserContext.user && !(scUserContext.loading && open)) {
|
|
497
524
|
return null;
|
|
498
525
|
}
|
|
@@ -504,7 +531,7 @@ export default function Composer(inProps) {
|
|
|
504
531
|
React.createElement(LoadingButton, { size: "small", type: "submit", color: "secondary", variant: "contained", disabled: !canSubmit, loading: isSubmitting },
|
|
505
532
|
React.createElement(FormattedMessage, { id: "ui.composer.submit", defaultMessage: "ui.composer.submit" }))),
|
|
506
533
|
React.createElement(DialogContent, { className: classes.content },
|
|
507
|
-
React.createElement(Attributes, { value: { categories, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
|
|
534
|
+
React.createElement(Attributes, { value: { categories, group, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
|
|
508
535
|
content,
|
|
509
536
|
medias && medias.length > 0 && (React.createElement(Box, { className: classes.medias }, mediaObjectTypes.map((mediaObjectType) => {
|
|
510
537
|
if (mediaObjectType.previewComponent) {
|
|
@@ -524,7 +551,7 @@ export default function Composer(inProps) {
|
|
|
524
551
|
}),
|
|
525
552
|
React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddCategoryLayer },
|
|
526
553
|
React.createElement(Icon, null, "category")),
|
|
527
|
-
React.createElement(IconButton, { disabled: isSubmitting || !features.includes(SCFeatureName.TAGGING), onClick: handleAddAudienceLayer }, addressing === null || addressing.length === 0 ? React.createElement(Icon, null, "public") : React.createElement(Icon, null, "label")),
|
|
554
|
+
React.createElement(IconButton, { disabled: isSubmitting || !features.includes(SCFeatureName.TAGGING), onClick: handleAddAudienceLayer }, addressing === null || addressing.length === 0 ? (React.createElement(Icon, null, "public")) : typeof addressing === 'object' ? (React.createElement(Icon, null, "groups")) : (React.createElement(Icon, null, "label"))),
|
|
528
555
|
preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED].value && (React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddLocationLayer, color: location !== null ? 'primary' : 'default' },
|
|
529
556
|
React.createElement(Icon, null, "add_location_alt"))))),
|
|
530
557
|
layer && (React.createElement(LayerTransitionRoot, { className: classes.layerTransitionRoot, in: true, container: dialogRef.current, direction: "left" },
|
|
@@ -23,6 +23,7 @@ const Root = styled(Box, {
|
|
|
23
23
|
const DEFAULT_DISCUSSION = {
|
|
24
24
|
title: '',
|
|
25
25
|
categories: [],
|
|
26
|
+
group: null,
|
|
26
27
|
medias: [],
|
|
27
28
|
html: '',
|
|
28
29
|
addressing: []
|
|
@@ -42,9 +43,12 @@ export default (props) => {
|
|
|
42
43
|
}, [value]);
|
|
43
44
|
// RENDER
|
|
44
45
|
return (React.createElement(Root, { className: classNames(classes.root, className) },
|
|
45
|
-
generalError && React.createElement(Typography, { className: classes.generalError },
|
|
46
|
-
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` })),
|
|
47
|
-
React.createElement(TextField, { className: classes.title, placeholder: intl.formatMessage({
|
|
46
|
+
generalError && (React.createElement(Typography, { className: classes.generalError },
|
|
47
|
+
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }))),
|
|
48
|
+
React.createElement(TextField, { className: classes.title, placeholder: intl.formatMessage({
|
|
49
|
+
id: 'ui.composer.content.discussion.title.label',
|
|
50
|
+
defaultMessage: 'ui.composer.content.discussion.title.label'
|
|
51
|
+
}), autoFocus: true, fullWidth: true, variant: "outlined", value: value.title, multiline: true, onChange: handleChangeTitle, InputProps: {
|
|
48
52
|
endAdornment: React.createElement(Typography, { variant: "body2" }, COMPOSER_TITLE_MAX_LENGTH - value.title.length)
|
|
49
53
|
}, error: Boolean(titleError), helperText: titleError, disabled: disabled }),
|
|
50
54
|
React.createElement(Editor, Object.assign({}, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, defaultValue: value.html }))));
|
|
@@ -22,7 +22,8 @@ const DEFAULT_POST = {
|
|
|
22
22
|
categories: [],
|
|
23
23
|
medias: [],
|
|
24
24
|
html: '',
|
|
25
|
-
addressing: []
|
|
25
|
+
addressing: [],
|
|
26
|
+
group: null
|
|
26
27
|
};
|
|
27
28
|
export default (props) => {
|
|
28
29
|
// PROPS
|
|
@@ -40,7 +41,7 @@ export default (props) => {
|
|
|
40
41
|
}, [value]);
|
|
41
42
|
// RENDER
|
|
42
43
|
return (React.createElement(Root, { className: classNames(classes.root, className) },
|
|
43
|
-
generalError && React.createElement(Typography, { className: classes.generalError },
|
|
44
|
-
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` })),
|
|
44
|
+
generalError && (React.createElement(Typography, { className: classes.generalError },
|
|
45
|
+
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }))),
|
|
45
46
|
React.createElement(Editor, Object.assign({ ref: editorRef }, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, defaultValue: value.html }))));
|
|
46
47
|
};
|
|
@@ -3,8 +3,14 @@ import { TextFieldProps } from '@mui/material/TextField';
|
|
|
3
3
|
import { BoxProps } from '@mui/material';
|
|
4
4
|
import { SCTagType } from '@selfcommunity/types/src/index';
|
|
5
5
|
import { ComposerLayerProps } from '../../../../types/composer';
|
|
6
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
7
|
+
export declare enum AudienceTypes {
|
|
8
|
+
AUDIENCE_ALL = "all",
|
|
9
|
+
AUDIENCE_TAG = "tag",
|
|
10
|
+
AUDIENCE_GROUP = "group"
|
|
11
|
+
}
|
|
6
12
|
export interface AudienceLayerProps extends Omit<BoxProps, 'defaultValue'>, ComposerLayerProps {
|
|
7
|
-
defaultValue: SCTagType[];
|
|
13
|
+
defaultValue: SCTagType[] | SCGroupType;
|
|
8
14
|
TextFieldProps?: TextFieldProps;
|
|
9
15
|
}
|
|
10
16
|
declare const AudienceLayer: React.ForwardRefExoticComponent<Pick<AudienceLayerProps, "p" | "slot" | "style" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform" | "component" | "sx" | "classes" | "onClose" | "TextFieldProps" | "onSave"> & React.RefAttributes<unknown>>;
|
|
@@ -12,8 +12,13 @@ import Icon from '@mui/material/Icon';
|
|
|
12
12
|
import DialogContent from '@mui/material/DialogContent';
|
|
13
13
|
import { useSCFetchAddressingTagList } from '@selfcommunity/react-core';
|
|
14
14
|
import { PREFIX } from '../../constants';
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import GroupAutocomplete from '../../../GroupAutocomplete';
|
|
16
|
+
export var AudienceTypes;
|
|
17
|
+
(function (AudienceTypes) {
|
|
18
|
+
AudienceTypes["AUDIENCE_ALL"] = "all";
|
|
19
|
+
AudienceTypes["AUDIENCE_TAG"] = "tag";
|
|
20
|
+
AudienceTypes["AUDIENCE_GROUP"] = "group";
|
|
21
|
+
})(AudienceTypes || (AudienceTypes = {}));
|
|
17
22
|
const classes = {
|
|
18
23
|
root: `${PREFIX}-layer-audience-root`,
|
|
19
24
|
title: `${PREFIX}-layer-title`,
|
|
@@ -27,23 +32,36 @@ const Root = styled(Box, {
|
|
|
27
32
|
})(() => ({}));
|
|
28
33
|
const AudienceLayer = React.forwardRef((props, ref) => {
|
|
29
34
|
// Props
|
|
30
|
-
const { className, onClose, onSave, defaultValue = [], TextFieldProps = {
|
|
35
|
+
const { className, onClose, onSave, defaultValue = AudienceTypes.AUDIENCE_TAG ? [] : null, TextFieldProps = {
|
|
31
36
|
variant: 'outlined',
|
|
32
37
|
label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tags.label", defaultMessage: "ui.composer.layer.audience.tags.label" })
|
|
33
38
|
} } = props, rest = __rest(props, ["className", "onClose", "onSave", "defaultValue", "TextFieldProps"]);
|
|
34
39
|
// STATE
|
|
35
40
|
const [autocompleteOpen, setAutocompleteOpen] = useState(false);
|
|
36
|
-
const [audience, setAudience] = useState(
|
|
41
|
+
const [audience, setAudience] = useState(
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
defaultValue === null || defaultValue.length === 0
|
|
45
|
+
? AudienceTypes.AUDIENCE_ALL
|
|
46
|
+
: typeof defaultValue === 'object'
|
|
47
|
+
? AudienceTypes.AUDIENCE_GROUP
|
|
48
|
+
: AudienceTypes.AUDIENCE_TAG);
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
|
+
// @ts-ignore
|
|
37
51
|
const [value, setValue] = useState(defaultValue || undefined);
|
|
38
52
|
// HOOKS
|
|
39
53
|
const { scAddressingTags } = useSCFetchAddressingTagList({ fetch: autocompleteOpen });
|
|
40
54
|
// HANDLERS
|
|
41
|
-
const handleSave = useCallback(
|
|
55
|
+
const handleSave = useCallback(
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
() => (typeof defaultValue === 'object' ? onSave(value) : onSave((value === null || value === void 0 ? void 0 : value.length) && (value === null || value === void 0 ? void 0 : value.length) > 0 ? value : null)), [value, onSave]);
|
|
42
59
|
const handleChange = useCallback((event, tags) => setValue(tags), []);
|
|
60
|
+
const handleGroupChange = useCallback((group) => setValue(group), []);
|
|
43
61
|
const handleChangeAudience = useCallback((event, data) => setAudience(data), []);
|
|
44
62
|
const handleAutocompleteOpen = useCallback(() => setAutocompleteOpen(true), []);
|
|
45
63
|
const handleAutocompleteClose = useCallback(() => setAutocompleteOpen(false), []);
|
|
46
|
-
return React.createElement(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest),
|
|
64
|
+
return (React.createElement(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest),
|
|
47
65
|
React.createElement(DialogTitle, { className: classes.title },
|
|
48
66
|
React.createElement(IconButton, { onClick: onClose },
|
|
49
67
|
React.createElement(Icon, null, "arrow_back")),
|
|
@@ -53,12 +71,26 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
53
71
|
React.createElement(FormattedMessage, { id: "ui.composer.layer.save", defaultMessage: "ui.composer.layer.save" }))),
|
|
54
72
|
React.createElement(DialogContent, { className: classes.content },
|
|
55
73
|
React.createElement(Tabs, { value: audience, onChange: handleChangeAudience, "aria-label": "audience type" },
|
|
56
|
-
React.createElement(Tab, { value: AUDIENCE_ALL, icon: React.createElement(Icon, null, "public"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
|
|
57
|
-
React.createElement(Tab
|
|
74
|
+
React.createElement(Tab, { value: AudienceTypes.AUDIENCE_ALL, icon: React.createElement(Icon, null, "public"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
|
|
75
|
+
React.createElement(Tab
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
, {
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
disabled: defaultValue && defaultValue.length !== 0, value: AudienceTypes.AUDIENCE_GROUP, icon: React.createElement(Icon, null, "groups"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group", defaultMessage: "ui.composer.layer.audience.group" }) }),
|
|
82
|
+
React.createElement(Tab
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
, {
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
disabled: typeof defaultValue === 'object', value: AudienceTypes.AUDIENCE_TAG, icon: React.createElement(Icon, null, "label"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) })),
|
|
58
89
|
React.createElement(Typography, { className: classes.message },
|
|
59
|
-
audience === AUDIENCE_ALL && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
|
|
60
|
-
audience ===
|
|
61
|
-
|
|
90
|
+
audience === AudienceTypes.AUDIENCE_ALL && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
|
|
91
|
+
audience === AudienceTypes.AUDIENCE_GROUP && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group.message", defaultMessage: "ui.composer.audience.layer.group.message" })),
|
|
92
|
+
audience === AudienceTypes.AUDIENCE_TAG && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag.message", defaultMessage: "ui.composer.audience.layer.tag.message" }))),
|
|
93
|
+
audience === AudienceTypes.AUDIENCE_TAG && (React.createElement(Autocomplete, { className: classes.autocomplete, open: autocompleteOpen, onOpen: handleAutocompleteOpen, onClose: handleAutocompleteClose, multiple: true, options: scAddressingTags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderTags: (value, getTagProps) => {
|
|
62
94
|
return value.map((option, index) => React.createElement(TagChip, Object.assign({ key: option.id, tag: option }, getTagProps({ index }))));
|
|
63
95
|
}, renderOption: (props, option, { selected, inputValue }) => {
|
|
64
96
|
const matches = match(option.name, inputValue);
|
|
@@ -67,6 +99,7 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
67
99
|
React.createElement(TagChip, { key: option.id, tag: option, label: React.createElement(React.Fragment, null, parts.map((part, index) => (React.createElement("span", { key: index, style: { fontWeight: part.highlight ? 700 : 400 } }, part.text)))) })));
|
|
68
100
|
}, renderInput: (params) => {
|
|
69
101
|
return (React.createElement(TextField, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'addressing', endAdornment: React.createElement(React.Fragment, null, params.InputProps.endAdornment) }) })));
|
|
70
|
-
} }))
|
|
102
|
+
} })),
|
|
103
|
+
audience === AudienceTypes.AUDIENCE_GROUP && React.createElement(GroupAutocomplete, { onChange: handleGroupChange, defaultValue: defaultValue }))));
|
|
71
104
|
});
|
|
72
105
|
export default AudienceLayer;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ButtonProps } from '@mui/material/Button/Button';
|
|
2
|
+
import { GroupFormProps } from '../GroupForm';
|
|
3
|
+
export interface CreateGroupButtonProps extends ButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Overrides or extends the styles applied to the component.
|
|
6
|
+
* @default null
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Props to spread to CreateGroup component
|
|
11
|
+
* @default empty object
|
|
12
|
+
*/
|
|
13
|
+
GroupFormProps?: GroupFormProps;
|
|
14
|
+
/**
|
|
15
|
+
* Any other properties
|
|
16
|
+
*/
|
|
17
|
+
[p: string]: any;
|
|
18
|
+
}
|
|
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: CreateGroupButtonProps): JSX.Element;
|