@selfcommunity/react-ui 0.7.9-alpha.0 → 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/NavigationMenuIconButton/index.d.ts +2 -1
- package/lib/cjs/components/NavigationMenuIconButton/index.js +3 -0
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +9 -0
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +3 -4
- 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 +18 -2
- package/lib/cjs/index.js +44 -5
- 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/NavigationMenuIconButton/index.d.ts +2 -1
- package/lib/esm/components/NavigationMenuIconButton/index.js +2 -0
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +9 -0
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +4 -5
- 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 +18 -2
- package/lib/esm/index.js +47 -31
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCGroup";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupSkeleton = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Group_1 = tslib_1.__importDefault(require("./Group"));
|
|
6
|
+
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
7
|
+
exports.GroupSkeleton = Skeleton_1.default;
|
|
8
|
+
exports.default = Group_1.default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
2
|
+
import { AutocompleteProps } from '@mui/material';
|
|
3
|
+
import { SCGroupType } from '@selfcommunity/types/src/index';
|
|
4
|
+
export interface GroupAutocompleteProps extends Pick<AutocompleteProps<SCGroupType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCGroupType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | 'clearIcon' | 'noOptionsText' | 'isOptionEqualToValue' | 'renderTags' | 'renderOption' | 'renderInput'>> {
|
|
5
|
+
/**
|
|
6
|
+
* The maximum number of groups that will be visible when not focused.
|
|
7
|
+
* @default 0
|
|
8
|
+
*/
|
|
9
|
+
limitCountGroups?: number;
|
|
10
|
+
/**
|
|
11
|
+
* If checkbox is selected
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
checkboxSelect?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The props applied to text field
|
|
17
|
+
* @default {variant: 'outlined, label: groups_label}
|
|
18
|
+
*/
|
|
19
|
+
TextFieldProps?: TextFieldProps;
|
|
20
|
+
/**
|
|
21
|
+
* Callback for change event on poll object
|
|
22
|
+
* @param value
|
|
23
|
+
*/
|
|
24
|
+
onChange?: (value: any) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* > API documentation for the Community-JS Group Autocomplete component. Learn about the available props and the CSS API.
|
|
28
|
+
*
|
|
29
|
+
*
|
|
30
|
+
* This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
|
|
31
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
|
|
32
|
+
*
|
|
33
|
+
* #### Import
|
|
34
|
+
* ```jsx
|
|
35
|
+
* import {GroupAutocomplete} from '@selfcommunity/react-ui';
|
|
36
|
+
* ```
|
|
37
|
+
* #### Component Name
|
|
38
|
+
* The name `SCGroupAutocomplete` can be used when providing style overrides in the theme.
|
|
39
|
+
*
|
|
40
|
+
* #### CSS
|
|
41
|
+
*
|
|
42
|
+
* |Rule Name|Global class|Description|
|
|
43
|
+
* |---|---|---|
|
|
44
|
+
* |root|.SCGroupAutocomplete-root|Styles applied to the root element.|
|
|
45
|
+
*
|
|
46
|
+
* @param inProps
|
|
47
|
+
*/
|
|
48
|
+
declare const GroupAutocomplete: (inProps: GroupAutocompleteProps) => JSX.Element;
|
|
49
|
+
export default GroupAutocomplete;
|
|
@@ -0,0 +1,101 @@
|
|
|
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 react_intl_1 = require("react-intl");
|
|
6
|
+
const Autocomplete_1 = tslib_1.__importDefault(require("@mui/material/Autocomplete"));
|
|
7
|
+
const TextField_1 = tslib_1.__importDefault(require("@mui/material/TextField"));
|
|
8
|
+
const CircularProgress_1 = tslib_1.__importDefault(require("@mui/material/CircularProgress"));
|
|
9
|
+
const parse_1 = tslib_1.__importDefault(require("autosuggest-highlight/parse"));
|
|
10
|
+
const match_1 = tslib_1.__importDefault(require("autosuggest-highlight/match"));
|
|
11
|
+
const material_1 = require("@mui/material");
|
|
12
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
13
|
+
const styles_1 = require("@mui/material/styles");
|
|
14
|
+
const system_1 = require("@mui/system");
|
|
15
|
+
const PREFIX = 'SCGroupAutocomplete';
|
|
16
|
+
const classes = {
|
|
17
|
+
root: `${PREFIX}-root`
|
|
18
|
+
};
|
|
19
|
+
const Root = (0, styles_1.styled)(Autocomplete_1.default, {
|
|
20
|
+
name: PREFIX,
|
|
21
|
+
slot: 'Root',
|
|
22
|
+
overridesResolver: (props, styles) => styles.root
|
|
23
|
+
})(() => ({}));
|
|
24
|
+
/**
|
|
25
|
+
* > API documentation for the Community-JS Group Autocomplete component. Learn about the available props and the CSS API.
|
|
26
|
+
*
|
|
27
|
+
*
|
|
28
|
+
* This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
|
|
29
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
|
|
30
|
+
*
|
|
31
|
+
* #### Import
|
|
32
|
+
* ```jsx
|
|
33
|
+
* import {GroupAutocomplete} from '@selfcommunity/react-ui';
|
|
34
|
+
* ```
|
|
35
|
+
* #### Component Name
|
|
36
|
+
* The name `SCGroupAutocomplete` can be used when providing style overrides in the theme.
|
|
37
|
+
*
|
|
38
|
+
* #### CSS
|
|
39
|
+
*
|
|
40
|
+
* |Rule Name|Global class|Description|
|
|
41
|
+
* |---|---|---|
|
|
42
|
+
* |root|.SCGroupAutocomplete-root|Styles applied to the root element.|
|
|
43
|
+
*
|
|
44
|
+
* @param inProps
|
|
45
|
+
*/
|
|
46
|
+
const GroupAutocomplete = (inProps) => {
|
|
47
|
+
const props = (0, system_1.useThemeProps)({
|
|
48
|
+
props: inProps,
|
|
49
|
+
name: PREFIX
|
|
50
|
+
});
|
|
51
|
+
// Props
|
|
52
|
+
const { onChange, defaultValue = null, disabled = false, TextFieldProps = {
|
|
53
|
+
variant: 'outlined',
|
|
54
|
+
label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupAutocomplete.label", defaultMessage: "ui.groupAutocomplete.label" })
|
|
55
|
+
} } = props, rest = tslib_1.__rest(props, ["onChange", "defaultValue", "disabled", "TextFieldProps"]);
|
|
56
|
+
// State
|
|
57
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
58
|
+
const [value, setValue] = (0, react_1.useState)(typeof defaultValue === 'string' ? null : defaultValue);
|
|
59
|
+
// HOOKS
|
|
60
|
+
const { groups, isLoading } = (0, react_core_1.useSCFetchGroups)();
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
62
|
+
if (value === null) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
onChange && onChange(value);
|
|
66
|
+
}, [value]);
|
|
67
|
+
(0, react_1.useEffect)(() => {
|
|
68
|
+
if (!isLoading && typeof defaultValue === 'string') {
|
|
69
|
+
setValue(groups.find((g) => g.id === Number(defaultValue)));
|
|
70
|
+
}
|
|
71
|
+
}, [isLoading]);
|
|
72
|
+
// Handlers
|
|
73
|
+
const handleOpen = () => {
|
|
74
|
+
setOpen(true);
|
|
75
|
+
};
|
|
76
|
+
const handleClose = () => {
|
|
77
|
+
setOpen(false);
|
|
78
|
+
};
|
|
79
|
+
const handleChange = (event, value) => {
|
|
80
|
+
setValue(value);
|
|
81
|
+
};
|
|
82
|
+
// Render
|
|
83
|
+
return (react_1.default.createElement(Root, Object.assign({ freeSolo: true, className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: groups || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupAutocomplete.empty", defaultMessage: "ui.groupAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id,
|
|
84
|
+
// renderTags={(value, getTagProps) => {
|
|
85
|
+
// return value.map((option: any, index) => (
|
|
86
|
+
// <Chip key={option.id} id={option.id} label={option.name} color={option.color} {...getTagProps({index})} />
|
|
87
|
+
// ));
|
|
88
|
+
// }}
|
|
89
|
+
renderOption: (props, option, { inputValue }) => {
|
|
90
|
+
const matches = (0, match_1.default)(option.name, inputValue);
|
|
91
|
+
const parts = (0, parse_1.default)(option.name, matches);
|
|
92
|
+
return (react_1.default.createElement(material_1.Box, Object.assign({ component: "li" }, props),
|
|
93
|
+
react_1.default.createElement(material_1.Avatar, { alt: option.name, src: option.image_small, sx: { marginRight: 1 } }),
|
|
94
|
+
react_1.default.createElement(react_1.default.Fragment, null, parts.map((part, index) => (react_1.default.createElement(material_1.Typography, { key: index, sx: { fontWeight: part.highlight ? 700 : 400, marginRight: 0.2 } }, part.text))))));
|
|
95
|
+
}, renderInput: (params) => {
|
|
96
|
+
return (react_1.default.createElement(TextField_1.default, Object.assign({}, params, TextFieldProps, { margin: "dense", InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'groups', endAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
97
|
+
isLoading ? react_1.default.createElement(CircularProgress_1.default, { color: "inherit", size: 20 }) : null,
|
|
98
|
+
params.InputProps.endAdornment)) }) })));
|
|
99
|
+
} }, rest)));
|
|
100
|
+
};
|
|
101
|
+
exports.default = GroupAutocomplete;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
2
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
+
export interface GroupFormProps extends BaseDialogProps {
|
|
4
|
+
/**
|
|
5
|
+
* Overrides or extends the styles applied to the component.
|
|
6
|
+
* @default null
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Open dialog
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
open?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* On dialog close callback function
|
|
16
|
+
* @default null
|
|
17
|
+
*/
|
|
18
|
+
onClose?: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Group Object
|
|
21
|
+
* @default null
|
|
22
|
+
*/
|
|
23
|
+
group?: SCGroupType;
|
|
24
|
+
/**
|
|
25
|
+
* On success callback function
|
|
26
|
+
* @default null
|
|
27
|
+
*/
|
|
28
|
+
onSuccess?: (data: SCGroupType) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Any other properties
|
|
31
|
+
*/
|
|
32
|
+
[p: string]: any;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
*> API documentation for the Community-JS Group Form component. Learn about the available props and the CSS API.
|
|
36
|
+
*
|
|
37
|
+
#### Import
|
|
38
|
+
```jsx
|
|
39
|
+
import {GroupForm} from '@selfcommunity/react-ui';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Component Name
|
|
43
|
+
The name `SCGroupForm` can be used when providing style overrides in the theme.
|
|
44
|
+
|
|
45
|
+
#### CSS
|
|
46
|
+
|
|
47
|
+
|Rule Name|Global class|Description|
|
|
48
|
+
|---|---|---|
|
|
49
|
+
|root|.SCGroupForm-root|Styles applied to the root element.|
|
|
50
|
+
|active|.SCGroupForm-active|Styles applied to the active element.|
|
|
51
|
+
|title|.SCGroupForm-title|Styles applied to the title element.|
|
|
52
|
+
|header|.SCGroupForm-header|Styles applied to the header element.|
|
|
53
|
+
|cover|.SCGroupForm-cover|Styles applied to the cover field.|
|
|
54
|
+
|avatar|.SCGroupForm-avatar|Styles applied to the avatar field.|
|
|
55
|
+
|form|.SCGroupForm-form|Styles applied to the form element.|
|
|
56
|
+
|switch|.SCGroupForm-switch|Styles applied to the switch element.|
|
|
57
|
+
|switchLabel|.SCGroupForm-switch-label|Styles applied to the switchLabel element.|
|
|
58
|
+
|name|.SCGroupForm-name|Styles applied to the name field.|
|
|
59
|
+
|description|.SCGroupForm-description|Styles applied to the description field.|
|
|
60
|
+
|content|.SCGroupForm-content|Styles applied to the element.|
|
|
61
|
+
|privacySection|.SCGroupForm-privacy-section|Styles applied to the privacy section.|
|
|
62
|
+
|privacySectionInfo|.SCGroupForm-privacy-section-info|Styles applied to the privacy info section.|
|
|
63
|
+
|visibilitySection|.SCGroupForm-visibility-section|Styles applied to the visibility section.|
|
|
64
|
+
|visibilitySectionInfo|.SCGroupForm-visibility-section-info|Styles applied to the visibility section info.|
|
|
65
|
+
|inviteSection|.SCGroupForm-invite-section|Styles applied to the invite section.|
|
|
66
|
+
|error|.SCGroupForm-error|Styles applied to the error elements.|
|
|
67
|
+
|
|
68
|
+
* @param inProps
|
|
69
|
+
*/
|
|
70
|
+
export default function GroupForm(inProps: GroupFormProps): JSX.Element;
|
|
@@ -0,0 +1,239 @@
|
|
|
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 constants_1 = require("./constants");
|
|
12
|
+
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
13
|
+
const lab_1 = require("@mui/lab");
|
|
14
|
+
const ChangeGroupPicture_1 = tslib_1.__importDefault(require("../ChangeGroupPicture"));
|
|
15
|
+
const ChangeGroupCover_1 = tslib_1.__importDefault(require("../ChangeGroupCover"));
|
|
16
|
+
const Group_1 = require("../../constants/Group");
|
|
17
|
+
const GroupInviteButton_1 = tslib_1.__importDefault(require("../GroupInviteButton"));
|
|
18
|
+
const types_1 = require("@selfcommunity/types");
|
|
19
|
+
const Errors_1 = require("../../constants/Errors");
|
|
20
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
21
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
22
|
+
const messages = (0, react_intl_1.defineMessages)({
|
|
23
|
+
name: {
|
|
24
|
+
id: 'ui.groupForm.name.placeholder',
|
|
25
|
+
defaultMessage: 'ui.groupForm.name.placeholder'
|
|
26
|
+
},
|
|
27
|
+
description: {
|
|
28
|
+
id: 'ui.groupForm.description.placeholder',
|
|
29
|
+
defaultMessage: 'ui.groupForm.description.placeholder'
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const classes = {
|
|
33
|
+
root: `${constants_1.PREFIX}-root`,
|
|
34
|
+
active: `${constants_1.PREFIX}-active`,
|
|
35
|
+
title: `${constants_1.PREFIX}-title`,
|
|
36
|
+
header: `${constants_1.PREFIX}-header`,
|
|
37
|
+
cover: `${constants_1.PREFIX}-cover`,
|
|
38
|
+
avatar: `${constants_1.PREFIX}-avatar`,
|
|
39
|
+
form: `${constants_1.PREFIX}-form`,
|
|
40
|
+
switch: `${constants_1.PREFIX}-switch`,
|
|
41
|
+
switchLabel: `${constants_1.PREFIX}-switch-label`,
|
|
42
|
+
name: `${constants_1.PREFIX}-name`,
|
|
43
|
+
description: `${constants_1.PREFIX}-description`,
|
|
44
|
+
content: `${constants_1.PREFIX}-content`,
|
|
45
|
+
privacySection: `${constants_1.PREFIX}-privacy-section`,
|
|
46
|
+
privacySectionInfo: `${constants_1.PREFIX}-privacy-section-info`,
|
|
47
|
+
visibilitySection: `${constants_1.PREFIX}-visibility-section`,
|
|
48
|
+
visibilitySectionInfo: `${constants_1.PREFIX}-visibility-section-info`,
|
|
49
|
+
inviteSection: `${constants_1.PREFIX}-invite-section`,
|
|
50
|
+
error: `${constants_1.PREFIX}-error`
|
|
51
|
+
};
|
|
52
|
+
const Root = (0, styles_1.styled)(BaseDialog_1.default, {
|
|
53
|
+
name: constants_1.PREFIX,
|
|
54
|
+
slot: 'Root'
|
|
55
|
+
})(() => ({}));
|
|
56
|
+
/**
|
|
57
|
+
*> API documentation for the Community-JS Group Form component. Learn about the available props and the CSS API.
|
|
58
|
+
*
|
|
59
|
+
#### Import
|
|
60
|
+
```jsx
|
|
61
|
+
import {GroupForm} from '@selfcommunity/react-ui';
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Component Name
|
|
65
|
+
The name `SCGroupForm` can be used when providing style overrides in the theme.
|
|
66
|
+
|
|
67
|
+
#### CSS
|
|
68
|
+
|
|
69
|
+
|Rule Name|Global class|Description|
|
|
70
|
+
|---|---|---|
|
|
71
|
+
|root|.SCGroupForm-root|Styles applied to the root element.|
|
|
72
|
+
|active|.SCGroupForm-active|Styles applied to the active element.|
|
|
73
|
+
|title|.SCGroupForm-title|Styles applied to the title element.|
|
|
74
|
+
|header|.SCGroupForm-header|Styles applied to the header element.|
|
|
75
|
+
|cover|.SCGroupForm-cover|Styles applied to the cover field.|
|
|
76
|
+
|avatar|.SCGroupForm-avatar|Styles applied to the avatar field.|
|
|
77
|
+
|form|.SCGroupForm-form|Styles applied to the form element.|
|
|
78
|
+
|switch|.SCGroupForm-switch|Styles applied to the switch element.|
|
|
79
|
+
|switchLabel|.SCGroupForm-switch-label|Styles applied to the switchLabel element.|
|
|
80
|
+
|name|.SCGroupForm-name|Styles applied to the name field.|
|
|
81
|
+
|description|.SCGroupForm-description|Styles applied to the description field.|
|
|
82
|
+
|content|.SCGroupForm-content|Styles applied to the element.|
|
|
83
|
+
|privacySection|.SCGroupForm-privacy-section|Styles applied to the privacy section.|
|
|
84
|
+
|privacySectionInfo|.SCGroupForm-privacy-section-info|Styles applied to the privacy info section.|
|
|
85
|
+
|visibilitySection|.SCGroupForm-visibility-section|Styles applied to the visibility section.|
|
|
86
|
+
|visibilitySectionInfo|.SCGroupForm-visibility-section-info|Styles applied to the visibility section info.|
|
|
87
|
+
|inviteSection|.SCGroupForm-invite-section|Styles applied to the invite section.|
|
|
88
|
+
|error|.SCGroupForm-error|Styles applied to the error elements.|
|
|
89
|
+
|
|
90
|
+
* @param inProps
|
|
91
|
+
*/
|
|
92
|
+
function GroupForm(inProps) {
|
|
93
|
+
//PROPS
|
|
94
|
+
const props = (0, system_1.useThemeProps)({
|
|
95
|
+
props: inProps,
|
|
96
|
+
name: constants_1.PREFIX
|
|
97
|
+
});
|
|
98
|
+
const { className, open = true, onClose, onSuccess, group = null } = props, rest = tslib_1.__rest(props, ["className", "open", "onClose", "onSuccess", "group"]);
|
|
99
|
+
const initialFieldState = {
|
|
100
|
+
imageOriginal: group ? group.image_medium : '',
|
|
101
|
+
imageOriginalFile: '',
|
|
102
|
+
emotionalImageOriginal: group ? group.emotional_image : '',
|
|
103
|
+
emotionalImageOriginalFile: '',
|
|
104
|
+
name: group ? group.name : '',
|
|
105
|
+
description: group ? group.description : '',
|
|
106
|
+
isPublic: group && group.privacy === types_1.SCGroupPrivacyType.PUBLIC,
|
|
107
|
+
isVisible: group ? group.visible : true,
|
|
108
|
+
invitedUsers: null,
|
|
109
|
+
isSubmitting: false
|
|
110
|
+
};
|
|
111
|
+
// STATE
|
|
112
|
+
const [field, setField] = (0, react_1.useState)(initialFieldState);
|
|
113
|
+
const [error, setError] = (0, react_1.useState)({});
|
|
114
|
+
// INTL
|
|
115
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
116
|
+
// PREFERENCES
|
|
117
|
+
const scPreferences = (0, react_core_1.useSCPreferences)();
|
|
118
|
+
const _backgroundCover = Object.assign({}, (field.emotionalImageOriginal
|
|
119
|
+
? { background: `url('${field.emotionalImageOriginal}') center / cover` }
|
|
120
|
+
: { background: `url('${scPreferences.preferences[react_core_1.SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
|
|
121
|
+
function handleChangeAvatar(avatar) {
|
|
122
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginalFile']: avatar })));
|
|
123
|
+
const reader = new FileReader();
|
|
124
|
+
reader.onloadend = () => {
|
|
125
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginal']: reader.result })));
|
|
126
|
+
};
|
|
127
|
+
reader.readAsDataURL(avatar);
|
|
128
|
+
if (error.imageOriginalError) {
|
|
129
|
+
delete error.imageOriginalError;
|
|
130
|
+
setError(error);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function handleChangeCover(cover) {
|
|
134
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginalFile']: cover })));
|
|
135
|
+
const reader = new FileReader();
|
|
136
|
+
reader.onloadend = () => {
|
|
137
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginal']: reader.result })));
|
|
138
|
+
};
|
|
139
|
+
reader.readAsDataURL(cover);
|
|
140
|
+
if (error.emotionalImageOriginalError) {
|
|
141
|
+
delete error.emotionalImageOriginalError;
|
|
142
|
+
setError(error);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const handleSubmit = () => {
|
|
146
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
|
|
147
|
+
const formData = new FormData();
|
|
148
|
+
formData.append('name', field.name);
|
|
149
|
+
formData.append('description', field.description);
|
|
150
|
+
formData.append('privacy', field.isPublic ? types_1.SCGroupPrivacyType.PUBLIC : types_1.SCGroupPrivacyType.PRIVATE);
|
|
151
|
+
formData.append('visible', field.isVisible);
|
|
152
|
+
if (field.imageOriginalFile) {
|
|
153
|
+
formData.append('image_original', field.imageOriginalFile);
|
|
154
|
+
}
|
|
155
|
+
if (field.emotionalImageOriginalFile) {
|
|
156
|
+
formData.append('emotional_image_original', field.emotionalImageOriginalFile);
|
|
157
|
+
}
|
|
158
|
+
for (const key in field.invitedUsers) {
|
|
159
|
+
formData.append(key, field.invitedUsers[key]);
|
|
160
|
+
}
|
|
161
|
+
let groupService;
|
|
162
|
+
if (group) {
|
|
163
|
+
groupService = api_services_1.GroupService.updateGroup(group.id, formData, { headers: { 'Content-Type': 'multipart/form-data' } });
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
groupService = api_services_1.GroupService.createGroup(formData, { headers: { 'Content-Type': 'multipart/form-data' } });
|
|
167
|
+
}
|
|
168
|
+
groupService
|
|
169
|
+
.then((data) => {
|
|
170
|
+
onSuccess && onSuccess(data);
|
|
171
|
+
onClose && onClose();
|
|
172
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
173
|
+
})
|
|
174
|
+
.catch((e) => {
|
|
175
|
+
setError(Object.assign(Object.assign({}, error), (0, api_services_1.formatHttpErrorCode)(e)));
|
|
176
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
177
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
const handleInviteSection = (data) => {
|
|
181
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['invitedUsers']: data })));
|
|
182
|
+
};
|
|
183
|
+
const handleChange = (event) => {
|
|
184
|
+
const { name, value } = event.target;
|
|
185
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
|
|
186
|
+
if (error[`${name}Error`]) {
|
|
187
|
+
delete error[`${name}Error`];
|
|
188
|
+
setError(error);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Renders root object
|
|
193
|
+
*/
|
|
194
|
+
return (react_1.default.createElement(Root, Object.assign({ DialogContentProps: { dividers: false }, title: group ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.title.edit", defaultMessage: "ui.groupForm.title.edit" })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.title", defaultMessage: "ui.groupForm.title" })), open: open, onClose: onClose, className: (0, classnames_1.default)(classes.root, className), actions: react_1.default.createElement(lab_1.LoadingButton, { loading: field.isSubmitting, disabled: !field.name || Object.keys(error).length !== 0, variant: "contained", onClick: handleSubmit, color: "secondary" }, group ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.button.edit", defaultMessage: "ui.groupForm.button.edit" })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.button.create", defaultMessage: "ui.groupForm.button.create" }))) }, rest),
|
|
195
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
196
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
197
|
+
react_1.default.createElement(material_1.Paper, { style: _backgroundCover, classes: { root: classes.cover } },
|
|
198
|
+
react_1.default.createElement(material_1.Box, { className: classes.avatar },
|
|
199
|
+
react_1.default.createElement(material_1.Avatar, null, field.imageOriginal ? react_1.default.createElement("img", { src: field.imageOriginal, alt: "avatar" }) : react_1.default.createElement(material_1.Icon, null, "icon_image"))),
|
|
200
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
201
|
+
react_1.default.createElement(ChangeGroupPicture_1.default, { isCreationMode: true, onChange: handleChangeAvatar }),
|
|
202
|
+
react_1.default.createElement(ChangeGroupCover_1.default, { isCreationMode: true, onChange: handleChangeCover }))),
|
|
203
|
+
react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.header, { [classes.error]: error.emotionalImageOriginalError || error.imageOriginalError }), align: "center" }, error.emotionalImageOriginalError || error.imageOriginalError ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.header.error", defaultMessage: "ui.groupForm.header.error" })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.header", defaultMessage: "ui.groupForm.header" })))),
|
|
204
|
+
react_1.default.createElement(material_1.FormGroup, { className: classes.form },
|
|
205
|
+
react_1.default.createElement(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
206
|
+
endAdornment: react_1.default.createElement(material_1.Typography, { variant: "body2" }, Group_1.GROUP_TITLE_MAX_LENGTH - field.name.length)
|
|
207
|
+
} }),
|
|
208
|
+
react_1.default.createElement(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
209
|
+
endAdornment: react_1.default.createElement(material_1.Typography, { variant: "body2" }, Group_1.GROUP_DESCRIPTION_MAX_LENGTH - field.description.length)
|
|
210
|
+
} }),
|
|
211
|
+
react_1.default.createElement(material_1.Box, { className: classes.privacySection },
|
|
212
|
+
react_1.default.createElement(material_1.Typography, { variant: "h4" },
|
|
213
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.title", defaultMessage: "ui.groupForm.privacy.title", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })),
|
|
214
|
+
react_1.default.createElement(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
215
|
+
react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) },
|
|
216
|
+
react_1.default.createElement(material_1.Icon, null, "private"),
|
|
217
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
|
|
218
|
+
react_1.default.createElement(material_1.Switch, { className: classes.switch, checked: field.isPublic, onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))) }),
|
|
219
|
+
react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) },
|
|
220
|
+
react_1.default.createElement(material_1.Icon, null, "public"),
|
|
221
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" }))),
|
|
222
|
+
react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.privacySectionInfo }, field.isPublic ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })))),
|
|
223
|
+
react_1.default.createElement(material_1.Box, { className: classes.visibilitySection }, !field.isPublic && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
224
|
+
react_1.default.createElement(material_1.Typography, { variant: "h4" },
|
|
225
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.title", defaultMessage: "ui.groupForm.visibility.title", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })),
|
|
226
|
+
react_1.default.createElement(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
227
|
+
react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isVisible }) },
|
|
228
|
+
react_1.default.createElement(material_1.Icon, null, "visibility_off"),
|
|
229
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
|
|
230
|
+
react_1.default.createElement(material_1.Switch, { className: classes.switch, checked: field.isVisible, onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isVisible']: !field.isVisible }))) }),
|
|
231
|
+
react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isVisible }) },
|
|
232
|
+
react_1.default.createElement(material_1.Icon, null, "visibility"),
|
|
233
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" }))),
|
|
234
|
+
react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.visibilitySectionInfo }, !field.isVisible ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: { b: (chunks) => react_1.default.createElement("strong", null, chunks) } }))))))),
|
|
235
|
+
react_1.default.createElement(material_1.Divider, null),
|
|
236
|
+
react_1.default.createElement(material_1.Box, { className: classes.inviteSection },
|
|
237
|
+
react_1.default.createElement(GroupInviteButton_1.default, { handleInvitations: handleInviteSection })))));
|
|
238
|
+
}
|
|
239
|
+
exports.default = GroupForm;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCGroupForm";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
2
|
+
import { ChangeGroupCoverProps } from '../ChangeGroupCover';
|
|
3
|
+
import { ChangeGroupPictureProps } from '../ChangeGroupPicture';
|
|
4
|
+
import { GroupMembersButtonProps } from '../GroupMembersButton';
|
|
5
|
+
import { GroupSubscribeButtonProps } from '../GroupSubscribeButton';
|
|
6
|
+
export interface GroupHeaderProps {
|
|
7
|
+
/**
|
|
8
|
+
* Id of group object
|
|
9
|
+
* @default null
|
|
10
|
+
*/
|
|
11
|
+
id?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Overrides or extends the styles applied to the component.
|
|
14
|
+
* @default null
|
|
15
|
+
*/
|
|
16
|
+
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Group Object
|
|
19
|
+
* @default null
|
|
20
|
+
*/
|
|
21
|
+
group?: SCGroupType;
|
|
22
|
+
/**
|
|
23
|
+
* Id of the group
|
|
24
|
+
* @default null
|
|
25
|
+
*/
|
|
26
|
+
groupId?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Props to spread change picture button
|
|
29
|
+
* @default {}
|
|
30
|
+
*/
|
|
31
|
+
ChangePictureProps?: ChangeGroupPictureProps;
|
|
32
|
+
/**
|
|
33
|
+
* Props to spread change cover button
|
|
34
|
+
* @default {}
|
|
35
|
+
*/
|
|
36
|
+
ChangeCoverProps?: ChangeGroupCoverProps;
|
|
37
|
+
/**
|
|
38
|
+
* Props to spread category button followed
|
|
39
|
+
* @default {}
|
|
40
|
+
*/
|
|
41
|
+
GroupSubscribeButtonProps?: Pick<GroupSubscribeButtonProps, Exclude<keyof GroupSubscribeButtonProps, 'group' | 'onSubscribe'>>;
|
|
42
|
+
/**
|
|
43
|
+
* Props to spread to the group memebers button
|
|
44
|
+
* @default {}
|
|
45
|
+
*/
|
|
46
|
+
GroupMembersButtonProps?: GroupMembersButtonProps;
|
|
47
|
+
/**
|
|
48
|
+
* Any other properties
|
|
49
|
+
*/
|
|
50
|
+
[p: string]: any;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* > API documentation for the Community-JS Group Header component. Learn about the available props and the CSS API.
|
|
54
|
+
*
|
|
55
|
+
*
|
|
56
|
+
* This component renders the groups top section.
|
|
57
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/UserProfileHeader)
|
|
58
|
+
|
|
59
|
+
#### Import
|
|
60
|
+
|
|
61
|
+
```jsx
|
|
62
|
+
import {UserProfileHeader} from '@selfcommunity/react-ui';
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Component Name
|
|
66
|
+
|
|
67
|
+
The name `SCGroupHeader` can be used when providing style overrides in the theme.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
#### CSS
|
|
71
|
+
|
|
72
|
+
|Rule Name|Global class|Description|
|
|
73
|
+
|---|---|---|
|
|
74
|
+
|root|.SCGroupHeader-root|Styles applied to the root element.|
|
|
75
|
+
|cover|.SCGroupHeader-cover|Styles applied to the cover element.|
|
|
76
|
+
|avatar|.SCGroupHeader-avatar|Styles applied to the avatar element.|
|
|
77
|
+
|info|SCGroupHeader-info|Styles applied to the info section.|
|
|
78
|
+
|name|SCGroupHeader-username|Styles applied to the username element.|
|
|
79
|
+
|changePicture|.SCGroupHeader-change-picture|Styles applied to changePicture element.|
|
|
80
|
+
|changeCover|.SCGroupHeader-change-cover`|Styles applied to changeCover element.|
|
|
81
|
+
|
|
82
|
+
* @param inProps
|
|
83
|
+
*/
|
|
84
|
+
export default function GroupHeader(inProps: GroupHeaderProps): JSX.Element;
|