@selfcommunity/react-ui 0.7.9-alpha.3 → 0.7.9-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
  2. package/lib/cjs/components/Composer/Attributes/Attributes.js +7 -0
  3. package/lib/cjs/components/Composer/Composer.d.ts +2 -1
  4. package/lib/cjs/components/Composer/Composer.js +40 -11
  5. package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  6. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
  7. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +35 -13
  8. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  9. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
  10. package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
  11. package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  12. package/lib/cjs/components/EditGroupButton/EditGroupButton.js +57 -0
  13. package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
  14. package/lib/cjs/components/EditGroupButton/index.js +5 -0
  15. package/lib/cjs/components/Group/Group.d.ts +4 -3
  16. package/lib/cjs/components/Group/Group.js +2 -2
  17. package/lib/cjs/components/Group/Skeleton.js +1 -1
  18. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  19. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
  20. package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
  21. package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
  22. package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
  23. package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
  24. package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
  25. package/lib/cjs/components/{CreateGroup → GroupForm}/constants.js +1 -1
  26. package/lib/cjs/components/GroupForm/index.d.ts +3 -0
  27. package/lib/cjs/components/GroupForm/index.js +5 -0
  28. package/lib/cjs/components/GroupHeader/GroupHeader.js +4 -2
  29. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
  30. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +5 -4
  31. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +18 -16
  32. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
  33. package/lib/cjs/components/Groups/Groups.d.ts +1 -1
  34. package/lib/cjs/components/Groups/Groups.js +16 -19
  35. package/lib/cjs/components/Groups/Skeleton.d.ts +14 -2
  36. package/lib/cjs/components/Groups/Skeleton.js +12 -5
  37. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  38. package/lib/cjs/index.d.ts +4 -3
  39. package/lib/cjs/index.js +7 -5
  40. package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
  41. package/lib/esm/components/Composer/Attributes/Attributes.js +7 -0
  42. package/lib/esm/components/Composer/Composer.d.ts +2 -1
  43. package/lib/esm/components/Composer/Composer.js +40 -11
  44. package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  45. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
  46. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +34 -13
  47. package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  48. package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
  49. package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
  50. package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  51. package/lib/esm/components/EditGroupButton/EditGroupButton.js +54 -0
  52. package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
  53. package/lib/esm/components/EditGroupButton/index.js +2 -0
  54. package/lib/esm/components/Group/Group.d.ts +4 -3
  55. package/lib/esm/components/Group/Group.js +2 -2
  56. package/lib/esm/components/Group/Skeleton.js +1 -1
  57. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  58. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
  59. package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
  60. package/lib/esm/components/GroupAutocomplete/index.js +2 -0
  61. package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
  62. package/lib/esm/components/GroupForm/GroupForm.js +236 -0
  63. package/lib/esm/components/GroupForm/constants.d.ts +1 -0
  64. package/lib/esm/components/GroupForm/constants.js +1 -0
  65. package/lib/esm/components/GroupForm/index.d.ts +3 -0
  66. package/lib/esm/components/GroupForm/index.js +2 -0
  67. package/lib/esm/components/GroupHeader/GroupHeader.js +4 -2
  68. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
  69. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +5 -4
  70. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +19 -17
  71. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
  72. package/lib/esm/components/Groups/Groups.d.ts +1 -1
  73. package/lib/esm/components/Groups/Groups.js +17 -20
  74. package/lib/esm/components/Groups/Skeleton.d.ts +14 -2
  75. package/lib/esm/components/Groups/Skeleton.js +13 -5
  76. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  77. package/lib/esm/index.d.ts +4 -3
  78. package/lib/esm/index.js +3 -2
  79. package/lib/umd/react-ui.js +1 -1
  80. package/package.json +6 -6
  81. package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
  82. package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
  83. package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
  84. package/lib/cjs/components/CreateGroup/index.js +0 -5
  85. package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
  86. package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
  87. package/lib/esm/components/CreateGroup/constants.js +0 -1
  88. package/lib/esm/components/CreateGroup/index.d.ts +0 -3
  89. package/lib/esm/components/CreateGroup/index.js +0 -2
@@ -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
- const AUDIENCE_ALL = 'all';
16
- const AUDIENCE_TAG = 'tag';
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, defaultType = AudienceTypes.AUDIENCE_TAG, 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
- } } = props, rest = __rest(props, ["className", "onClose", "onSave", "defaultValue", "TextFieldProps"]);
38
+ } } = props, rest = __rest(props, ["className", "onClose", "onSave", "defaultType", "defaultValue", "TextFieldProps"]);
34
39
  // STATE
35
40
  const [autocompleteOpen, setAutocompleteOpen] = useState(false);
36
- const [audience, setAudience] = useState(defaultValue === null || defaultValue.length === 0 ? AUDIENCE_ALL : AUDIENCE_TAG);
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
+ : defaultType === AudienceTypes.AUDIENCE_GROUP
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(() => onSave((value === null || value === void 0 ? void 0 : value.length) && (value === null || value === void 0 ? void 0 : value.length) > 0 ? value : null), [value, onSave]);
55
+ const handleSave = useCallback(
56
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
57
+ // @ts-ignore
58
+ () => (defaultType === AudienceTypes.AUDIENCE_GROUP ? 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,14 @@ 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, { value: AUDIENCE_TAG, icon: React.createElement(Icon, null, "label"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) })),
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, { disabled: defaultType === AudienceTypes.AUDIENCE_TAG, 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" }) }),
76
+ React.createElement(Tab, { disabled: defaultType === AudienceTypes.AUDIENCE_GROUP, 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
77
  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 === AUDIENCE_TAG && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag.message", defaultMessage: "ui.composer.audience.layer.tag.message" }))),
61
- audience === 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) => {
78
+ audience === AudienceTypes.AUDIENCE_ALL && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
79
+ audience === AudienceTypes.AUDIENCE_GROUP && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group.message", defaultMessage: "ui.composer.audience.layer.group.message" })),
80
+ audience === AudienceTypes.AUDIENCE_TAG && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag.message", defaultMessage: "ui.composer.audience.layer.tag.message" }))),
81
+ 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
82
  return value.map((option, index) => React.createElement(TagChip, Object.assign({ key: option.id, tag: option }, getTagProps({ index }))));
63
83
  }, renderOption: (props, option, { selected, inputValue }) => {
64
84
  const matches = match(option.name, inputValue);
@@ -67,6 +87,7 @@ const AudienceLayer = React.forwardRef((props, ref) => {
67
87
  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
88
  }, renderInput: (params) => {
69
89
  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
- } })));
90
+ } })),
91
+ audience === AudienceTypes.AUDIENCE_GROUP && React.createElement(GroupAutocomplete, { onChange: handleGroupChange, defaultValue: defaultValue }))));
71
92
  });
72
93
  export default AudienceLayer;
@@ -1,5 +1,5 @@
1
1
  import { ButtonProps } from '@mui/material/Button/Button';
2
- import { CreateGroupProps } from '../CreateGroup';
2
+ import { GroupFormProps } from '../GroupForm';
3
3
  export interface CreateGroupButtonProps extends ButtonProps {
4
4
  /**
5
5
  * Overrides or extends the styles applied to the component.
@@ -10,7 +10,7 @@ export interface CreateGroupButtonProps extends ButtonProps {
10
10
  * Props to spread to CreateGroup component
11
11
  * @default empty object
12
12
  */
13
- CreateGroupProps?: CreateGroupProps;
13
+ GroupFormProps?: GroupFormProps;
14
14
  /**
15
15
  * Any other properties
16
16
  */
@@ -6,7 +6,7 @@ import { Button, Icon } from '@mui/material';
6
6
  import { FormattedMessage } from 'react-intl';
7
7
  import { SCUserContext } from '@selfcommunity/react-core';
8
8
  import classNames from 'classnames';
9
- import CreateGroup from '../CreateGroup';
9
+ import GroupForm from '../GroupForm';
10
10
  const PREFIX = 'SCCreateGroupButton';
11
11
  const classes = {
12
12
  root: `${PREFIX}-root`
@@ -41,7 +41,7 @@ export default function CreateGroupButton(inProps) {
41
41
  props: inProps,
42
42
  name: PREFIX
43
43
  });
44
- const { className, CreateGroupProps = {} } = props, rest = __rest(props, ["className", "CreateGroupProps"]);
44
+ const { className, GroupFormProps = {}, children } = props, rest = __rest(props, ["className", "GroupFormProps", "children"]);
45
45
  // CONTEXT
46
46
  const scUserContext = useContext(SCUserContext);
47
47
  // STATE
@@ -52,7 +52,7 @@ export default function CreateGroupButton(inProps) {
52
52
  * Handle click on button
53
53
  */
54
54
  const handleClick = () => {
55
- setOpen((p) => !p);
55
+ setOpen((o) => !o);
56
56
  };
57
57
  /**
58
58
  * If there's no authUserId, component is hidden.
@@ -64,7 +64,6 @@ export default function CreateGroupButton(inProps) {
64
64
  * Renders root object
65
65
  */
66
66
  return (React.createElement(React.Fragment, null,
67
- React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClick, size: "small", variant: "contained", startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest),
68
- React.createElement(FormattedMessage, { id: "ui.createGroupButton", defaultMessage: "ui.createGroupButton" })),
69
- open && React.createElement(CreateGroup, Object.assign({}, CreateGroupProps, { open: true, onClose: handleClick }))));
67
+ React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClick, variant: "contained", startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest), children !== null && children !== void 0 ? children : React.createElement(FormattedMessage, { id: "ui.createGroupButton", defaultMessage: "ui.createGroupButton" })),
68
+ open && React.createElement(GroupForm, Object.assign({}, GroupFormProps, { open: true, onClose: handleClick }))));
70
69
  }
@@ -23,6 +23,10 @@ export interface CustomAdvProps extends VirtualScrollerItemProps {
23
23
  * Category ids if the adv must be related to specific categories
24
24
  */
25
25
  categoriesId?: Array<number> | null;
26
+ /**
27
+ * Group ids if the adv must be related to specific groups
28
+ */
29
+ groupsId?: Array<number> | null;
26
30
  /**
27
31
  * Prefixed height. Usefull to re-mount item on scroll feed.
28
32
  */
@@ -1,26 +1,21 @@
1
- import { BaseDialogProps } from '../../shared/BaseDialog';
1
+ import { CreateGroupButtonProps } from '../CreateGroupButton';
2
2
  import { SCGroupType } from '@selfcommunity/types';
3
- export interface CreateGroupProps extends BaseDialogProps {
3
+ export interface EditGroupButtonProps extends CreateGroupButtonProps {
4
4
  /**
5
- * Overrides or extends the styles applied to the component.
5
+ * Group Object
6
6
  * @default null
7
7
  */
8
- className?: string;
9
- /**
10
- * Open dialog
11
- * @default true
12
- */
13
- open?: boolean;
8
+ group?: SCGroupType;
14
9
  /**
15
- * On dialog close callback function
10
+ * Id of the group
16
11
  * @default null
17
12
  */
18
- onClose?: () => void;
13
+ groupId?: number | string;
19
14
  /**
20
- * Group Object
15
+ * On edit success callback function
21
16
  * @default null
22
17
  */
23
- group?: SCGroupType;
18
+ onEditSuccess?: (data: SCGroupType) => void;
24
19
  /**
25
20
  * Any other properties
26
21
  */
@@ -35,14 +30,14 @@ export interface CreateGroupProps extends BaseDialogProps {
35
30
  ```
36
31
 
37
32
  #### Component Name
38
- The name `SCCreateGroup` can be used when providing style overrides in the theme.
33
+ The name `SCEditGroupButton` can be used when providing style overrides in the theme.
39
34
 
40
35
  #### CSS
41
36
 
42
37
  |Rule Name|Global class|Description|
43
38
  |---|---|---|
44
- |root|.SCCreateGroup-root|Styles applied to the root element.|
39
+ |root|.SCEditGroupButton-root|Styles applied to the root element.|
45
40
 
46
41
  * @param inProps
47
42
  */
48
- export default function CreateGroup(inProps: CreateGroupProps): JSX.Element;
43
+ export default function EditGroupButton(inProps: EditGroupButtonProps): JSX.Element;
@@ -0,0 +1,54 @@
1
+ import { __rest } from "tslib";
2
+ import React from 'react';
3
+ import { useThemeProps } from '@mui/system';
4
+ import { styled } from '@mui/material/styles';
5
+ import { FormattedMessage } from 'react-intl';
6
+ import { useSCFetchGroup } from '@selfcommunity/react-core';
7
+ import classNames from 'classnames';
8
+ import CreateGroupButton from '../CreateGroupButton';
9
+ const PREFIX = 'SCEditGroupButton';
10
+ const classes = {
11
+ root: `${PREFIX}-root`
12
+ };
13
+ const Root = styled(CreateGroupButton, {
14
+ name: PREFIX,
15
+ slot: 'Root',
16
+ overridesResolver: (props, styles) => styles.root
17
+ })(({ theme }) => ({}));
18
+ /**
19
+ *> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
20
+ *
21
+ #### Import
22
+ ```jsx
23
+ import {CreateGroupButton} from '@selfcommunity/react-ui';
24
+ ```
25
+
26
+ #### Component Name
27
+ The name `SCEditGroupButton` can be used when providing style overrides in the theme.
28
+
29
+ #### CSS
30
+
31
+ |Rule Name|Global class|Description|
32
+ |---|---|---|
33
+ |root|.SCEditGroupButton-root|Styles applied to the root element.|
34
+
35
+ * @param inProps
36
+ */
37
+ export default function EditGroupButton(inProps) {
38
+ //PROPS
39
+ const props = useThemeProps({
40
+ props: inProps,
41
+ name: PREFIX
42
+ });
43
+ const { className, groupId, group, onEditSuccess } = props, rest = __rest(props, ["className", "groupId", "group", "onEditSuccess"]);
44
+ const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
45
+ const handleSuccess = (data) => {
46
+ setSCGroup(data);
47
+ onEditSuccess && onEditSuccess(data);
48
+ };
49
+ /**
50
+ * Renders root object
51
+ */
52
+ return (React.createElement(Root, Object.assign({ variant: "outlined", className: classNames(classes.root, className), GroupFormProps: { group: scGroup, onSuccess: handleSuccess } }, rest),
53
+ React.createElement(FormattedMessage, { id: "ui.editGroupButton", defaultMessage: "ui.editGroupButton" })));
54
+ }
@@ -0,0 +1,3 @@
1
+ import EditGroupButton, { EditGroupButtonProps } from './EditGroupButton';
2
+ export default EditGroupButton;
3
+ export { EditGroupButtonProps };
@@ -0,0 +1,2 @@
1
+ import EditGroupButton from './EditGroupButton';
2
+ export default EditGroupButton;
@@ -1,6 +1,7 @@
1
1
  import { ButtonBaseProps } from '@mui/material';
2
2
  import { SCGroupType } from '@selfcommunity/types';
3
3
  import { WidgetProps } from '../Widget';
4
+ import { GroupSubscribeButtonProps } from '../GroupSubscribeButton';
4
5
  export interface GroupProps extends WidgetProps {
5
6
  /**
6
7
  * Group Object
@@ -13,10 +14,10 @@ export interface GroupProps extends WidgetProps {
13
14
  */
14
15
  groupId?: number;
15
16
  /**
16
- * Handles actions ignore
17
- * @default null
17
+ * Props to spread to group subscribe/unsubscribe button
18
+ * @default {}
18
19
  */
19
- handleIgnoreAction?: (u: any) => void;
20
+ groupSubscribeButtonProps?: GroupSubscribeButtonProps;
20
21
  /**
21
22
  * Badge content to show as group avatar badge if show reaction is true.
22
23
  */
@@ -61,7 +61,7 @@ export default function Group(inProps) {
61
61
  props: inProps,
62
62
  name: PREFIX
63
63
  });
64
- const { groupId = null, group = null, handleIgnoreAction, className = null, elevation, hideActions = false, buttonProps = {}, visible = true } = props, rest = __rest(props, ["groupId", "group", "handleIgnoreAction", "className", "elevation", "hideActions", "buttonProps", "visible"]);
64
+ const { groupId = null, group = null, className = null, elevation, hideActions = false, groupSubscribeButtonProps = {}, buttonProps = {}, visible = true } = props, rest = __rest(props, ["groupId", "group", "className", "elevation", "hideActions", "groupSubscribeButtonProps", "buttonProps", "visible"]);
65
65
  // STATE
66
66
  const { scGroup } = useSCFetchGroup({ id: groupId, group });
67
67
  // CONTEXT
@@ -76,7 +76,7 @@ export default function Group(inProps) {
76
76
  function renderAuthenticatedActions() {
77
77
  return (React.createElement(Stack, { className: classes.actions, direction: "row", alignItems: "center", justifyContent: "center", spacing: 2 },
78
78
  React.createElement(Icon, null, !visible ? 'private' : 'public'),
79
- React.createElement(GroupSubscribeButton, { group: group, groupId: groupId })));
79
+ React.createElement(GroupSubscribeButton, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps))));
80
80
  }
81
81
  /**
82
82
  * Renders group object
@@ -33,6 +33,6 @@ const Root = styled(BaseItem, {
33
33
  */
34
34
  export default function GroupSkeleton(props) {
35
35
  const theme = useTheme();
36
- return (React.createElement(Root, Object.assign({ className: classes.root }, props, { image: React.createElement(Skeleton, { animation: "wave", variant: "circular", width: theme.selfcommunity.user.avatar.sizeMedium, height: theme.selfcommunity.user.avatar.sizeMedium }), primary: React.createElement(Skeleton, { animation: "wave", height: 10, width: 120, style: { marginBottom: 10 } }), secondary: React.createElement(Skeleton, { animation: "wave", height: 10, width: 70, style: { marginBottom: 10 } }), actions: React.createElement(Button, { size: "small", variant: "outlined", disabled: true },
36
+ return (React.createElement(Root, Object.assign({ className: classes.root }, props, { image: React.createElement(Skeleton, { animation: "wave", variant: "circular", width: theme.selfcommunity.group.avatar.sizeSmall, height: theme.selfcommunity.group.avatar.sizeSmall }), primary: React.createElement(Skeleton, { animation: "wave", height: 10, width: 120, style: { marginBottom: 10 } }), secondary: React.createElement(Skeleton, { animation: "wave", height: 10, width: 70, style: { marginBottom: 10 } }), actions: React.createElement(Button, { size: "small", variant: "outlined", disabled: true },
37
37
  React.createElement(Skeleton, { animation: "wave", height: 10, width: 30, style: { marginTop: 5, marginBottom: 5 } })) })));
38
38
  }
@@ -0,0 +1,49 @@
1
+ import { TextFieldProps } from '@mui/material/TextField';
2
+ import { AutocompleteProps } from '@mui/material';
3
+ import { SCGroupType } from '@selfcommunity/types/src/index';
4
+ export interface GroupAutocompleteProps extends Pick<AutocompleteProps<SCGroupType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCGroupType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | 'clearIcon' | 'noOptionsText' | 'isOptionEqualToValue' | 'renderTags' | 'renderOption' | 'renderInput'>> {
5
+ /**
6
+ * The maximum number of groups that will be visible when not focused.
7
+ * @default 0
8
+ */
9
+ limitCountGroups?: number;
10
+ /**
11
+ * If checkbox is selected
12
+ * @default false
13
+ */
14
+ checkboxSelect?: boolean;
15
+ /**
16
+ * The props applied to text field
17
+ * @default {variant: 'outlined, label: groups_label}
18
+ */
19
+ TextFieldProps?: TextFieldProps;
20
+ /**
21
+ * Callback for change event on poll object
22
+ * @param value
23
+ */
24
+ onChange?: (value: any) => void;
25
+ }
26
+ /**
27
+ * > API documentation for the Community-JS Group Autocomplete component. Learn about the available props and the CSS API.
28
+ *
29
+ *
30
+ * This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
31
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
32
+ *
33
+ * #### Import
34
+ * ```jsx
35
+ * import {GroupAutocomplete} from '@selfcommunity/react-ui';
36
+ * ```
37
+ * #### Component Name
38
+ * The name `SCGroupAutocomplete` can be used when providing style overrides in the theme.
39
+ *
40
+ * #### CSS
41
+ *
42
+ * |Rule Name|Global class|Description|
43
+ * |---|---|---|
44
+ * |root|.SCGroupAutocomplete-root|Styles applied to the root element.|
45
+ *
46
+ * @param inProps
47
+ */
48
+ declare const GroupAutocomplete: (inProps: GroupAutocompleteProps) => JSX.Element;
49
+ export default GroupAutocomplete;
@@ -0,0 +1,99 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useEffect, useState } from 'react';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import Autocomplete from '@mui/material/Autocomplete';
5
+ import TextField from '@mui/material/TextField';
6
+ import CircularProgress from '@mui/material/CircularProgress';
7
+ import parse from 'autosuggest-highlight/parse';
8
+ import match from 'autosuggest-highlight/match';
9
+ import { Avatar, Box, Typography } from '@mui/material';
10
+ import { useSCFetchGroups } from '@selfcommunity/react-core';
11
+ import { styled } from '@mui/material/styles';
12
+ import { useThemeProps } from '@mui/system';
13
+ const PREFIX = 'SCGroupAutocomplete';
14
+ const classes = {
15
+ root: `${PREFIX}-root`
16
+ };
17
+ const Root = styled(Autocomplete, {
18
+ name: PREFIX,
19
+ slot: 'Root',
20
+ overridesResolver: (props, styles) => styles.root
21
+ })(() => ({}));
22
+ /**
23
+ * > API documentation for the Community-JS Group Autocomplete component. Learn about the available props and the CSS API.
24
+ *
25
+ *
26
+ * This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
27
+ * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
28
+ *
29
+ * #### Import
30
+ * ```jsx
31
+ * import {GroupAutocomplete} from '@selfcommunity/react-ui';
32
+ * ```
33
+ * #### Component Name
34
+ * The name `SCGroupAutocomplete` can be used when providing style overrides in the theme.
35
+ *
36
+ * #### CSS
37
+ *
38
+ * |Rule Name|Global class|Description|
39
+ * |---|---|---|
40
+ * |root|.SCGroupAutocomplete-root|Styles applied to the root element.|
41
+ *
42
+ * @param inProps
43
+ */
44
+ const GroupAutocomplete = (inProps) => {
45
+ const props = useThemeProps({
46
+ props: inProps,
47
+ name: PREFIX
48
+ });
49
+ // Props
50
+ const { onChange, defaultValue = null, disabled = false, TextFieldProps = {
51
+ variant: 'outlined',
52
+ label: React.createElement(FormattedMessage, { id: "ui.groupAutocomplete.label", defaultMessage: "ui.groupAutocomplete.label" })
53
+ } } = props, rest = __rest(props, ["onChange", "defaultValue", "disabled", "TextFieldProps"]);
54
+ // State
55
+ const [open, setOpen] = useState(false);
56
+ const [value, setValue] = useState(typeof defaultValue === 'string' ? null : defaultValue);
57
+ // HOOKS
58
+ const { groups, isLoading } = useSCFetchGroups();
59
+ useEffect(() => {
60
+ if (value === null) {
61
+ return;
62
+ }
63
+ onChange && onChange(value);
64
+ }, [value]);
65
+ useEffect(() => {
66
+ if (!isLoading && typeof defaultValue === 'string') {
67
+ setValue(groups.find((g) => g.id === Number(defaultValue)));
68
+ }
69
+ }, [isLoading]);
70
+ // Handlers
71
+ const handleOpen = () => {
72
+ setOpen(true);
73
+ };
74
+ const handleClose = () => {
75
+ setOpen(false);
76
+ };
77
+ const handleChange = (event, value) => {
78
+ setValue(value);
79
+ };
80
+ // Render
81
+ return (React.createElement(Root, Object.assign({ freeSolo: true, className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: groups || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: React.createElement(FormattedMessage, { id: "ui.groupAutocomplete.empty", defaultMessage: "ui.groupAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id,
82
+ // renderTags={(value, getTagProps) => {
83
+ // return value.map((option: any, index) => (
84
+ // <Chip key={option.id} id={option.id} label={option.name} color={option.color} {...getTagProps({index})} />
85
+ // ));
86
+ // }}
87
+ renderOption: (props, option, { inputValue }) => {
88
+ const matches = match(option.name, inputValue);
89
+ const parts = parse(option.name, matches);
90
+ return (React.createElement(Box, Object.assign({ component: "li" }, props),
91
+ React.createElement(Avatar, { alt: option.name, src: option.image_small, sx: { marginRight: 1 } }),
92
+ React.createElement(React.Fragment, null, parts.map((part, index) => (React.createElement(Typography, { key: index, sx: { fontWeight: part.highlight ? 700 : 400, marginRight: 0.2 } }, part.text))))));
93
+ }, renderInput: (params) => {
94
+ return (React.createElement(TextField, Object.assign({}, params, TextFieldProps, { margin: "dense", InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'groups', endAdornment: (React.createElement(React.Fragment, null,
95
+ isLoading ? React.createElement(CircularProgress, { color: "inherit", size: 20 }) : null,
96
+ params.InputProps.endAdornment)) }) })));
97
+ } }, rest)));
98
+ };
99
+ export default GroupAutocomplete;
@@ -0,0 +1,3 @@
1
+ import GroupAutocomplete, { GroupAutocompleteProps } from './GroupAutocomplete';
2
+ export default GroupAutocomplete;
3
+ export { GroupAutocompleteProps };
@@ -0,0 +1,2 @@
1
+ import GroupAutocomplete from './GroupAutocomplete';
2
+ export default GroupAutocomplete;
@@ -0,0 +1,70 @@
1
+ import { BaseDialogProps } from '../../shared/BaseDialog';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ export interface GroupFormProps extends BaseDialogProps {
4
+ /**
5
+ * Overrides or extends the styles applied to the component.
6
+ * @default null
7
+ */
8
+ className?: string;
9
+ /**
10
+ * Open dialog
11
+ * @default true
12
+ */
13
+ open?: boolean;
14
+ /**
15
+ * On dialog close callback function
16
+ * @default null
17
+ */
18
+ onClose?: () => void;
19
+ /**
20
+ * Group Object
21
+ * @default null
22
+ */
23
+ group?: SCGroupType;
24
+ /**
25
+ * On success callback function
26
+ * @default null
27
+ */
28
+ onSuccess?: (data: SCGroupType) => void;
29
+ /**
30
+ * Any other properties
31
+ */
32
+ [p: string]: any;
33
+ }
34
+ /**
35
+ *> API documentation for the Community-JS Group Form component. Learn about the available props and the CSS API.
36
+ *
37
+ #### Import
38
+ ```jsx
39
+ import {GroupForm} from '@selfcommunity/react-ui';
40
+ ```
41
+
42
+ #### Component Name
43
+ The name `SCGroupForm` can be used when providing style overrides in the theme.
44
+
45
+ #### CSS
46
+
47
+ |Rule Name|Global class|Description|
48
+ |---|---|---|
49
+ |root|.SCGroupForm-root|Styles applied to the root element.|
50
+ |active|.SCGroupForm-active|Styles applied to the active element.|
51
+ |title|.SCGroupForm-title|Styles applied to the title element.|
52
+ |header|.SCGroupForm-header|Styles applied to the header element.|
53
+ |cover|.SCGroupForm-cover|Styles applied to the cover field.|
54
+ |avatar|.SCGroupForm-avatar|Styles applied to the avatar field.|
55
+ |form|.SCGroupForm-form|Styles applied to the form element.|
56
+ |switch|.SCGroupForm-switch|Styles applied to the switch element.|
57
+ |switchLabel|.SCGroupForm-switch-label|Styles applied to the switchLabel element.|
58
+ |name|.SCGroupForm-name|Styles applied to the name field.|
59
+ |description|.SCGroupForm-description|Styles applied to the description field.|
60
+ |content|.SCGroupForm-content|Styles applied to the element.|
61
+ |privacySection|.SCGroupForm-privacy-section|Styles applied to the privacy section.|
62
+ |privacySectionInfo|.SCGroupForm-privacy-section-info|Styles applied to the privacy info section.|
63
+ |visibilitySection|.SCGroupForm-visibility-section|Styles applied to the visibility section.|
64
+ |visibilitySectionInfo|.SCGroupForm-visibility-section-info|Styles applied to the visibility section info.|
65
+ |inviteSection|.SCGroupForm-invite-section|Styles applied to the invite section.|
66
+ |error|.SCGroupForm-error|Styles applied to the error elements.|
67
+
68
+ * @param inProps
69
+ */
70
+ export default function GroupForm(inProps: GroupFormProps): JSX.Element;