@selfcommunity/react-ui 0.7.9-alpha.2 → 0.7.9-alpha.4

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 (101) hide show
  1. package/lib/cjs/components/BottomNavigation/BottomNavigation.js +3 -1
  2. package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
  3. package/lib/cjs/components/Composer/Attributes/Attributes.js +7 -0
  4. package/lib/cjs/components/Composer/Composer.d.ts +2 -1
  5. package/lib/cjs/components/Composer/Composer.js +40 -11
  6. package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  7. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
  8. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +35 -13
  9. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  10. package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
  11. package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
  12. package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  13. package/lib/cjs/components/EditGroupButton/EditGroupButton.js +57 -0
  14. package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
  15. package/lib/cjs/components/EditGroupButton/index.js +5 -0
  16. package/lib/cjs/components/Group/Group.d.ts +4 -3
  17. package/lib/cjs/components/Group/Group.js +2 -2
  18. package/lib/cjs/components/Group/Skeleton.js +1 -1
  19. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  20. package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
  21. package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
  22. package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
  23. package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
  24. package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
  25. package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
  26. package/lib/cjs/components/{CreateGroup → GroupForm}/constants.js +1 -1
  27. package/lib/cjs/components/GroupForm/index.d.ts +3 -0
  28. package/lib/cjs/components/GroupForm/index.js +5 -0
  29. package/lib/cjs/components/GroupHeader/GroupHeader.js +4 -2
  30. package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
  31. package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +6 -4
  32. package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +19 -14
  33. package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
  34. package/lib/cjs/components/Groups/Groups.d.ts +65 -0
  35. package/lib/cjs/components/Groups/Groups.js +181 -0
  36. package/lib/cjs/components/Groups/Skeleton.d.ts +34 -0
  37. package/lib/cjs/components/Groups/Skeleton.js +45 -0
  38. package/lib/cjs/components/Groups/constants.d.ts +1 -0
  39. package/lib/cjs/components/Groups/constants.js +4 -0
  40. package/lib/cjs/components/Groups/index.d.ts +4 -0
  41. package/lib/cjs/components/Groups/index.js +8 -0
  42. package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  43. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +5 -1
  44. package/lib/cjs/index.d.ts +5 -3
  45. package/lib/cjs/index.js +10 -4
  46. package/lib/esm/components/BottomNavigation/BottomNavigation.js +3 -1
  47. package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
  48. package/lib/esm/components/Composer/Attributes/Attributes.js +7 -0
  49. package/lib/esm/components/Composer/Composer.d.ts +2 -1
  50. package/lib/esm/components/Composer/Composer.js +40 -11
  51. package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
  52. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
  53. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +34 -13
  54. package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
  55. package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
  56. package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
  57. package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
  58. package/lib/esm/components/EditGroupButton/EditGroupButton.js +54 -0
  59. package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
  60. package/lib/esm/components/EditGroupButton/index.js +2 -0
  61. package/lib/esm/components/Group/Group.d.ts +4 -3
  62. package/lib/esm/components/Group/Group.js +2 -2
  63. package/lib/esm/components/Group/Skeleton.js +1 -1
  64. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
  65. package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
  66. package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
  67. package/lib/esm/components/GroupAutocomplete/index.js +2 -0
  68. package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
  69. package/lib/esm/components/GroupForm/GroupForm.js +236 -0
  70. package/lib/esm/components/GroupForm/constants.d.ts +1 -0
  71. package/lib/esm/components/GroupForm/constants.js +1 -0
  72. package/lib/esm/components/GroupForm/index.d.ts +3 -0
  73. package/lib/esm/components/GroupForm/index.js +2 -0
  74. package/lib/esm/components/GroupHeader/GroupHeader.js +4 -2
  75. package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
  76. package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +6 -4
  77. package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +20 -15
  78. package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
  79. package/lib/esm/components/Groups/Groups.d.ts +65 -0
  80. package/lib/esm/components/Groups/Groups.js +178 -0
  81. package/lib/esm/components/Groups/Skeleton.d.ts +34 -0
  82. package/lib/esm/components/Groups/Skeleton.js +42 -0
  83. package/lib/esm/components/Groups/constants.d.ts +1 -0
  84. package/lib/esm/components/Groups/constants.js +1 -0
  85. package/lib/esm/components/Groups/index.d.ts +4 -0
  86. package/lib/esm/components/Groups/index.js +4 -0
  87. package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
  88. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +5 -1
  89. package/lib/esm/index.d.ts +5 -3
  90. package/lib/esm/index.js +4 -2
  91. package/lib/umd/react-ui.js +1 -1
  92. package/package.json +6 -6
  93. package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
  94. package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
  95. package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
  96. package/lib/cjs/components/CreateGroup/index.js +0 -5
  97. package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
  98. package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
  99. package/lib/esm/components/CreateGroup/constants.js +0 -1
  100. package/lib/esm/components/CreateGroup/index.d.ts +0 -3
  101. package/lib/esm/components/CreateGroup/index.js +0 -2
@@ -14,7 +14,7 @@ const classes = {
14
14
  root: `${PREFIX}-root`,
15
15
  ios: `${PREFIX}-ios`,
16
16
  action: `${PREFIX}-action`,
17
- composer: `${PREFIX}-composer`,
17
+ composer: `${PREFIX}-composer`
18
18
  };
19
19
  const Root = (0, material_1.styled)(material_1.BottomNavigation, {
20
20
  name: PREFIX,
@@ -62,6 +62,7 @@ function BottomNavigation(inProps) {
62
62
  const { preferences, features } = (0, react_core_1.useSCPreferences)();
63
63
  // MEMO
64
64
  const privateMessagingEnabled = (0, react_1.useMemo)(() => features.includes(types_1.SCFeatureName.PRIVATE_MESSAGING), [features]);
65
+ const groupsEnabled = (0, react_1.useMemo)(() => features.includes(types_1.SCFeatureName.GROUPING), [features]);
65
66
  const isIOS = (0, react_1.useMemo)(() => (0, utils_1.iOS)(), []);
66
67
  // RENDER
67
68
  return (react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root, { [classes.ios]: isIOS }) }, rest), children
@@ -71,6 +72,7 @@ function BottomNavigation(inProps) {
71
72
  (scUserContext.user || preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value) &&
72
73
  preferences[react_core_1.SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value ? (react_1.default.createElement(material_1.BottomNavigationAction, { key: "explore", className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EXPLORE_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.EXPLORE_ROUTE_NAME, {}), icon: react_1.default.createElement(material_1.Icon, null, "explore") })) : null,
73
74
  react_1.default.createElement(material_1.BottomNavigationAction, { key: "composer", className: (0, classnames_1.default)(classes.composer, classes.action), component: ComposerIconButton_1.default, disableRipple: true }),
75
+ groupsEnabled && scUserContext.user ? (react_1.default.createElement(material_1.BottomNavigationAction, { key: "groups", className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_ROUTE_NAME, {}), icon: react_1.default.createElement(material_1.Icon, null, "groups") })) : null,
74
76
  scUserContext.user ? (react_1.default.createElement(material_1.BottomNavigationAction, { key: "notifications", className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}), icon: react_1.default.createElement(material_1.Badge, { badgeContent: scUserContext.user.unseen_notification_banners_counter + scUserContext.user.unseen_interactions_counter, color: "secondary" },
75
77
  react_1.default.createElement(material_1.Icon, null, "notifications_active")) })) : null,
76
78
  privateMessagingEnabled && scUserContext.user ? (react_1.default.createElement(material_1.BottomNavigationAction, { key: "messages", className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, {}), icon: react_1.default.createElement(material_1.Badge, { badgeContent: 0, color: "secondary" },
@@ -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;
@@ -26,6 +26,12 @@ exports.default = (props) => {
26
26
  const handleClickCategory = (0, react_1.useCallback)(() => {
27
27
  onClick && onClick('categories');
28
28
  }, [onClick]);
29
+ const handleDeleteGroup = (0, react_1.useCallback)(() => {
30
+ onChange && onChange(Object.assign(Object.assign({}, value), { group: null }));
31
+ }, [value, onChange]);
32
+ const handleClickGroup = (0, react_1.useCallback)(() => {
33
+ onClick && onClick('group');
34
+ }, [onClick]);
29
35
  const handleDeleteTag = (0, react_1.useCallback)((id) => () => {
30
36
  onChange && onChange(Object.assign(Object.assign({}, value), { addressing: value.addressing.filter((tag) => tag.id !== id) }));
31
37
  }, [value, onChange]);
@@ -41,6 +47,7 @@ exports.default = (props) => {
41
47
  return (react_1.default.createElement(Root, { className: (0, classnames_1.default)(classes.root, className) },
42
48
  ((_a = value === null || value === void 0 ? void 0 : value.categories) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
43
49
  (value === null || value === void 0 ? void 0 : value.categories.map((c) => (react_1.default.createElement(material_1.Chip, { key: c.id, label: c.name, onDelete: handleDeleteCategory(c.id), icon: react_1.default.createElement(Icon_1.default, null, "category"), onClick: handleClickCategory })))),
50
+ (value === null || value === void 0 ? void 0 : value.group) && (react_1.default.createElement(material_1.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_1.default.createElement(Icon_1.default, null, "groups"), onClick: handleClickGroup })),
44
51
  ((_b = value === null || value === void 0 ? void 0 : value.addressing) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
45
52
  (value === null || value === void 0 ? void 0 : value.addressing.map((t) => (react_1.default.createElement(TagChip_1.default, { key: t.id, tag: t, onDelete: handleDeleteTag(t.id), icon: react_1.default.createElement(Icon_1.default, null, "label"), onClick: handleClickTag })))),
46
53
  (value === null || value === void 0 ? void 0 : value.location) && (react_1.default.createElement(material_1.Chip, { icon: react_1.default.createElement(Icon_1.default, 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[];
@@ -29,6 +29,7 @@ const Attributes_1 = tslib_1.__importDefault(require("./Attributes"));
29
29
  const constants_1 = require("./constants");
30
30
  const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
31
31
  const CloseLayer_1 = tslib_1.__importDefault(require("./Layer/CloseLayer"));
32
+ const AudienceLayer_2 = require("./Layer/AudienceLayer/AudienceLayer");
32
33
  const DialogTransition = (0, react_1.forwardRef)(function Transition(props, ref) {
33
34
  return react_1.default.createElement(material_1.Fade, Object.assign({ ref: ref }, props));
34
35
  });
@@ -59,7 +60,9 @@ const COMPOSER_INITIAL_STATE = {
59
60
  html: '',
60
61
  htmlError: null,
61
62
  categories: [],
63
+ group: null,
62
64
  categoriesError: null,
65
+ groupsError: null,
63
66
  addressing: null,
64
67
  addressingError: null,
65
68
  medias: [],
@@ -133,7 +136,7 @@ function Composer(inProps) {
133
136
  const [isSubmitting, setIsSubmitting] = (0, react_1.useState)(false);
134
137
  const [layer, setLayer] = (0, react_1.useState)();
135
138
  const [state, dispatch] = (0, react_1.useReducer)(reducer, Object.assign(Object.assign(Object.assign({}, COMPOSER_INITIAL_STATE), defaultValue), { key: (0, utils_1.random)() }));
136
- const { key, id, type, title, titleError, html, categories, addressing, audience, medias, poll, pollError, location, error } = state;
139
+ const { key, id, type, title, titleError, html, categories, group, addressing, audience, medias, poll, pollError, location, error } = state;
137
140
  const destructureFeedObject = (_feedObject) => {
138
141
  if (_feedObject.type === types_1.SCContributionType.POST) {
139
142
  _feedObject = _feedObject;
@@ -153,6 +156,7 @@ function Composer(inProps) {
153
156
  title: _feedObject.title,
154
157
  html: _feedObject.html,
155
158
  categories: _feedObject.categories,
159
+ group: _feedObject.group,
156
160
  addressing: _feedObject.addressing,
157
161
  medias: _feedObject.medias,
158
162
  poll: _feedObject.poll,
@@ -304,18 +308,24 @@ function Composer(inProps) {
304
308
  }
305
309
  }), [handleAddLayer, handleRemoveLayer, handleChangeCategories, categories]);
306
310
  const handleChangeAudience = (0, react_1.useCallback)((value) => {
307
- dispatch({ type: 'addressing', value });
311
+ if (group) {
312
+ dispatch({ type: 'group', value });
313
+ }
314
+ else {
315
+ dispatch({ type: 'addressing', value });
316
+ }
308
317
  setLayer(null);
309
- }, []);
318
+ }, [group]);
310
319
  const handleAddAudienceLayer = (0, react_1.useCallback)(() => handleAddLayer({
311
320
  name: 'audience',
312
321
  Component: AudienceLayer_1.default,
313
322
  ComponentProps: {
314
323
  onClose: handleRemoveLayer,
315
324
  onSave: handleChangeAudience,
316
- defaultValue: addressing
325
+ defaultValue: group ? group : addressing,
326
+ defaultType: group ? AudienceLayer_2.AudienceTypes.AUDIENCE_GROUP : addressing ? AudienceLayer_2.AudienceTypes.AUDIENCE_TAG : AudienceLayer_2.AudienceTypes.AUDIENCE_ALL
317
327
  }
318
- }), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing]);
328
+ }), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing, group]);
319
329
  const handleChangeLocation = (0, react_1.useCallback)((value) => {
320
330
  dispatch({ type: 'location', value });
321
331
  setLayer(null);
@@ -406,6 +416,9 @@ function Composer(inProps) {
406
416
  if (features.includes(types_1.SCFeatureName.TAGGING) && addressing !== null) {
407
417
  data.addressing = addressing.map((t) => t.id);
408
418
  }
419
+ if (features.includes(types_1.SCFeatureName.GROUPING) && group !== null) {
420
+ data.group = group.id;
421
+ }
409
422
  setIsSubmitting(true);
410
423
  // Finding right url
411
424
  const _type = type === Composer_1.COMPOSER_TYPE_POLL ? types_1.SCContributionType.POST : type;
@@ -433,7 +446,7 @@ function Composer(inProps) {
433
446
  dispatch({ type: 'multiple', value: (0, api_services_1.formatHttpErrorCode)(error) });
434
447
  })
435
448
  .then(() => setIsSubmitting(false));
436
- }, [scUserContext.user, feedObjectType, id, type, title, html, categories, addressing, audience, medias, poll, location, hasPoll]);
449
+ }, [scUserContext.user, feedObjectType, id, type, title, html, categories, group, addressing, audience, medias, poll, location, hasPoll]);
437
450
  //edited here
438
451
  const handleClose = (0, react_1.useCallback)((event, reason) => {
439
452
  if (unloadRef.current) {
@@ -488,13 +501,29 @@ function Composer(inProps) {
488
501
  }
489
502
  switch (type) {
490
503
  case Composer_1.COMPOSER_TYPE_POLL:
491
- return (react_1.default.createElement(ContentPoll_1.default, { key: key, onChange: handleChangePoll, value: { html, categories, addressing, medias, poll, location }, error: pollError, disabled: isSubmitting }));
504
+ return (react_1.default.createElement(ContentPoll_1.default, { key: key, onChange: handleChangePoll, value: { html, group, addressing, medias, poll, location }, error: pollError, disabled: isSubmitting }));
492
505
  case types_1.SCContributionType.DISCUSSION:
493
- return (react_1.default.createElement(ContentDiscussion_1.default, { 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) }));
506
+ return (react_1.default.createElement(ContentDiscussion_1.default, { 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) }));
494
507
  default:
495
- return (react_1.default.createElement(ContentPost_1.default, { key: key, value: { html, categories, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
508
+ return (react_1.default.createElement(ContentPost_1.default, { key: key, value: { html, categories, group, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
496
509
  }
497
- }, [key, type, title, html, categories, addressing, medias, poll, pollError, location, error, handleChangePoll, handleChangePost, isSubmitting]);
510
+ }, [
511
+ key,
512
+ type,
513
+ title,
514
+ html,
515
+ categories,
516
+ group,
517
+ addressing,
518
+ medias,
519
+ poll,
520
+ pollError,
521
+ location,
522
+ error,
523
+ handleChangePoll,
524
+ handleChangePost,
525
+ isSubmitting
526
+ ]);
498
527
  if (!scUserContext.user && !(scUserContext.loading && open)) {
499
528
  return null;
500
529
  }
@@ -506,7 +535,7 @@ function Composer(inProps) {
506
535
  react_1.default.createElement(LoadingButton_1.default, { size: "small", type: "submit", color: "secondary", variant: "contained", disabled: !canSubmit, loading: isSubmitting },
507
536
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.submit", defaultMessage: "ui.composer.submit" }))),
508
537
  react_1.default.createElement(material_1.DialogContent, { className: classes.content },
509
- react_1.default.createElement(Attributes_1.default, { value: { categories, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
538
+ react_1.default.createElement(Attributes_1.default, { value: { categories, group, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
510
539
  content,
511
540
  medias && medias.length > 0 && (react_1.default.createElement(material_1.Box, { className: classes.medias }, mediaObjectTypes.map((mediaObjectType) => {
512
541
  if (mediaObjectType.previewComponent) {
@@ -26,6 +26,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
26
26
  const DEFAULT_DISCUSSION = {
27
27
  title: '',
28
28
  categories: [],
29
+ group: null,
29
30
  medias: [],
30
31
  html: '',
31
32
  addressing: []
@@ -45,9 +46,12 @@ exports.default = (props) => {
45
46
  }, [value]);
46
47
  // RENDER
47
48
  return (react_1.default.createElement(Root, { className: (0, classnames_1.default)(classes.root, className) },
48
- generalError && react_1.default.createElement(material_1.Typography, { className: classes.generalError },
49
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` })),
50
- react_1.default.createElement(material_1.TextField, { className: classes.title, placeholder: intl.formatMessage({ id: "ui.composer.content.discussion.title.label", defaultMessage: "ui.composer.content.discussion.title.label" }), autoFocus: true, fullWidth: true, variant: "outlined", value: value.title, multiline: true, onChange: handleChangeTitle, InputProps: {
49
+ generalError && (react_1.default.createElement(material_1.Typography, { className: classes.generalError },
50
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }))),
51
+ react_1.default.createElement(material_1.TextField, { className: classes.title, placeholder: intl.formatMessage({
52
+ id: 'ui.composer.content.discussion.title.label',
53
+ defaultMessage: 'ui.composer.content.discussion.title.label'
54
+ }), autoFocus: true, fullWidth: true, variant: "outlined", value: value.title, multiline: true, onChange: handleChangeTitle, InputProps: {
51
55
  endAdornment: react_1.default.createElement(material_1.Typography, { variant: "body2" }, Composer_1.COMPOSER_TITLE_MAX_LENGTH - value.title.length)
52
56
  }, error: Boolean(titleError), helperText: titleError, disabled: disabled }),
53
57
  react_1.default.createElement(Editor_1.default, Object.assign({}, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, defaultValue: value.html }))));
@@ -3,9 +3,16 @@ 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
+ defaultType: AudienceTypes;
14
+ defaultValue: SCTagType[] | SCGroupType;
8
15
  TextFieldProps?: TextFieldProps;
9
16
  }
10
- 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>>;
17
+ 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" | "defaultType" | "onSave"> & React.RefAttributes<unknown>>;
11
18
  export default AudienceLayer;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AudienceTypes = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const react_1 = tslib_1.__importStar(require("react"));
5
6
  const react_intl_1 = require("react-intl");
@@ -14,8 +15,13 @@ const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
14
15
  const DialogContent_1 = tslib_1.__importDefault(require("@mui/material/DialogContent"));
15
16
  const react_core_1 = require("@selfcommunity/react-core");
16
17
  const constants_1 = require("../../constants");
17
- const AUDIENCE_ALL = 'all';
18
- const AUDIENCE_TAG = 'tag';
18
+ const GroupAutocomplete_1 = tslib_1.__importDefault(require("../../../GroupAutocomplete"));
19
+ var AudienceTypes;
20
+ (function (AudienceTypes) {
21
+ AudienceTypes["AUDIENCE_ALL"] = "all";
22
+ AudienceTypes["AUDIENCE_TAG"] = "tag";
23
+ AudienceTypes["AUDIENCE_GROUP"] = "group";
24
+ })(AudienceTypes = exports.AudienceTypes || (exports.AudienceTypes = {}));
19
25
  const classes = {
20
26
  root: `${constants_1.PREFIX}-layer-audience-root`,
21
27
  title: `${constants_1.PREFIX}-layer-title`,
@@ -29,23 +35,36 @@ const Root = (0, styles_1.styled)(material_1.Box, {
29
35
  })(() => ({}));
30
36
  const AudienceLayer = react_1.default.forwardRef((props, ref) => {
31
37
  // Props
32
- const { className, onClose, onSave, defaultValue = [], TextFieldProps = {
38
+ const { className, onClose, onSave, defaultType = AudienceTypes.AUDIENCE_TAG, defaultValue = AudienceTypes.AUDIENCE_TAG ? [] : null, TextFieldProps = {
33
39
  variant: 'outlined',
34
40
  label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tags.label", defaultMessage: "ui.composer.layer.audience.tags.label" })
35
- } } = props, rest = tslib_1.__rest(props, ["className", "onClose", "onSave", "defaultValue", "TextFieldProps"]);
41
+ } } = props, rest = tslib_1.__rest(props, ["className", "onClose", "onSave", "defaultType", "defaultValue", "TextFieldProps"]);
36
42
  // STATE
37
43
  const [autocompleteOpen, setAutocompleteOpen] = (0, react_1.useState)(false);
38
- const [audience, setAudience] = (0, react_1.useState)(defaultValue === null || defaultValue.length === 0 ? AUDIENCE_ALL : AUDIENCE_TAG);
44
+ const [audience, setAudience] = (0, react_1.useState)(
45
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
46
+ // @ts-ignore
47
+ defaultValue === null || defaultValue.length === 0
48
+ ? AudienceTypes.AUDIENCE_ALL
49
+ : defaultType === AudienceTypes.AUDIENCE_GROUP
50
+ ? AudienceTypes.AUDIENCE_GROUP
51
+ : AudienceTypes.AUDIENCE_TAG);
52
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
53
+ // @ts-ignore
39
54
  const [value, setValue] = (0, react_1.useState)(defaultValue || undefined);
40
55
  // HOOKS
41
56
  const { scAddressingTags } = (0, react_core_1.useSCFetchAddressingTagList)({ fetch: autocompleteOpen });
42
57
  // HANDLERS
43
- const handleSave = (0, react_1.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]);
58
+ const handleSave = (0, react_1.useCallback)(
59
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
60
+ // @ts-ignore
61
+ () => (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]);
44
62
  const handleChange = (0, react_1.useCallback)((event, tags) => setValue(tags), []);
63
+ const handleGroupChange = (0, react_1.useCallback)((group) => setValue(group), []);
45
64
  const handleChangeAudience = (0, react_1.useCallback)((event, data) => setAudience(data), []);
46
65
  const handleAutocompleteOpen = (0, react_1.useCallback)(() => setAutocompleteOpen(true), []);
47
66
  const handleAutocompleteClose = (0, react_1.useCallback)(() => setAutocompleteOpen(false), []);
48
- return react_1.default.createElement(Root, Object.assign({ ref: ref, className: (0, classnames_1.default)(className, classes.root) }, rest),
67
+ return (react_1.default.createElement(Root, Object.assign({ ref: ref, className: (0, classnames_1.default)(className, classes.root) }, rest),
49
68
  react_1.default.createElement(material_1.DialogTitle, { className: classes.title },
50
69
  react_1.default.createElement(material_1.IconButton, { onClick: onClose },
51
70
  react_1.default.createElement(Icon_1.default, null, "arrow_back")),
@@ -55,12 +74,14 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
55
74
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.save", defaultMessage: "ui.composer.layer.save" }))),
56
75
  react_1.default.createElement(DialogContent_1.default, { className: classes.content },
57
76
  react_1.default.createElement(material_1.Tabs, { value: audience, onChange: handleChangeAudience, "aria-label": "audience type" },
58
- react_1.default.createElement(material_1.Tab, { value: AUDIENCE_ALL, icon: react_1.default.createElement(Icon_1.default, null, "public"), label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
59
- react_1.default.createElement(material_1.Tab, { value: AUDIENCE_TAG, icon: react_1.default.createElement(Icon_1.default, null, "label"), label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) })),
77
+ react_1.default.createElement(material_1.Tab, { value: AudienceTypes.AUDIENCE_ALL, icon: react_1.default.createElement(Icon_1.default, null, "public"), label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
78
+ react_1.default.createElement(material_1.Tab, { disabled: defaultType === AudienceTypes.AUDIENCE_TAG, value: AudienceTypes.AUDIENCE_GROUP, icon: react_1.default.createElement(Icon_1.default, null, "groups"), label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.group", defaultMessage: "ui.composer.layer.audience.group" }) }),
79
+ react_1.default.createElement(material_1.Tab, { disabled: defaultType === AudienceTypes.AUDIENCE_GROUP, value: AudienceTypes.AUDIENCE_TAG, icon: react_1.default.createElement(Icon_1.default, null, "label"), label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) })),
60
80
  react_1.default.createElement(material_1.Typography, { className: classes.message },
61
- audience === AUDIENCE_ALL && (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
62
- audience === AUDIENCE_TAG && (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tag.message", defaultMessage: "ui.composer.audience.layer.tag.message" }))),
63
- audience === AUDIENCE_TAG && react_1.default.createElement(material_1.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_1.default.createElement(react_intl_1.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) => {
81
+ audience === AudienceTypes.AUDIENCE_ALL && (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
82
+ audience === AudienceTypes.AUDIENCE_GROUP && (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.group.message", defaultMessage: "ui.composer.audience.layer.group.message" })),
83
+ audience === AudienceTypes.AUDIENCE_TAG && (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tag.message", defaultMessage: "ui.composer.audience.layer.tag.message" }))),
84
+ audience === AudienceTypes.AUDIENCE_TAG && (react_1.default.createElement(material_1.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_1.default.createElement(react_intl_1.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) => {
64
85
  return value.map((option, index) => react_1.default.createElement(TagChip_1.default, Object.assign({ key: option.id, tag: option }, getTagProps({ index }))));
65
86
  }, renderOption: (props, option, { selected, inputValue }) => {
66
87
  const matches = (0, match_1.default)(option.name, inputValue);
@@ -69,6 +90,7 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
69
90
  react_1.default.createElement(TagChip_1.default, { key: option.id, tag: option, label: react_1.default.createElement(react_1.default.Fragment, null, parts.map((part, index) => (react_1.default.createElement("span", { key: index, style: { fontWeight: part.highlight ? 700 : 400 } }, part.text)))) })));
70
91
  }, renderInput: (params) => {
71
92
  return (react_1.default.createElement(TextField_1.default, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'addressing', endAdornment: react_1.default.createElement(react_1.default.Fragment, null, params.InputProps.endAdornment) }) })));
72
- } })));
93
+ } })),
94
+ audience === AudienceTypes.AUDIENCE_GROUP && react_1.default.createElement(GroupAutocomplete_1.default, { onChange: handleGroupChange, defaultValue: defaultValue }))));
73
95
  });
74
96
  exports.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
  */
@@ -8,7 +8,7 @@ const material_1 = require("@mui/material");
8
8
  const react_intl_1 = require("react-intl");
9
9
  const react_core_1 = require("@selfcommunity/react-core");
10
10
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
11
- const CreateGroup_1 = tslib_1.__importDefault(require("../CreateGroup"));
11
+ const GroupForm_1 = tslib_1.__importDefault(require("../GroupForm"));
12
12
  const PREFIX = 'SCCreateGroupButton';
13
13
  const classes = {
14
14
  root: `${PREFIX}-root`
@@ -43,7 +43,7 @@ function CreateGroupButton(inProps) {
43
43
  props: inProps,
44
44
  name: PREFIX
45
45
  });
46
- const { className, CreateGroupProps = {} } = props, rest = tslib_1.__rest(props, ["className", "CreateGroupProps"]);
46
+ const { className, GroupFormProps = {}, children } = props, rest = tslib_1.__rest(props, ["className", "GroupFormProps", "children"]);
47
47
  // CONTEXT
48
48
  const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
49
49
  // STATE
@@ -54,7 +54,7 @@ function CreateGroupButton(inProps) {
54
54
  * Handle click on button
55
55
  */
56
56
  const handleClick = () => {
57
- setOpen((p) => !p);
57
+ setOpen((o) => !o);
58
58
  };
59
59
  /**
60
60
  * If there's no authUserId, component is hidden.
@@ -66,8 +66,7 @@ function CreateGroupButton(inProps) {
66
66
  * Renders root object
67
67
  */
68
68
  return (react_1.default.createElement(react_1.default.Fragment, null,
69
- react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleClick, size: "small", variant: "contained", startIcon: react_1.default.createElement(material_1.Icon, { fontSize: "small" }, "add") }, rest),
70
- react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroupButton", defaultMessage: "ui.createGroupButton" })),
71
- open && react_1.default.createElement(CreateGroup_1.default, Object.assign({}, CreateGroupProps, { open: true, onClose: handleClick }))));
69
+ react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleClick, variant: "contained", startIcon: react_1.default.createElement(material_1.Icon, { fontSize: "small" }, "add") }, rest), children !== null && children !== void 0 ? children : react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.createGroupButton", defaultMessage: "ui.createGroupButton" })),
70
+ open && react_1.default.createElement(GroupForm_1.default, Object.assign({}, GroupFormProps, { open: true, onClose: handleClick }))));
72
71
  }
73
72
  exports.default = CreateGroupButton;
@@ -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,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importDefault(require("react"));
5
+ const system_1 = require("@mui/system");
6
+ const styles_1 = require("@mui/material/styles");
7
+ const react_intl_1 = require("react-intl");
8
+ const react_core_1 = require("@selfcommunity/react-core");
9
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
10
+ const CreateGroupButton_1 = tslib_1.__importDefault(require("../CreateGroupButton"));
11
+ const PREFIX = 'SCEditGroupButton';
12
+ const classes = {
13
+ root: `${PREFIX}-root`
14
+ };
15
+ const Root = (0, styles_1.styled)(CreateGroupButton_1.default, {
16
+ name: PREFIX,
17
+ slot: 'Root',
18
+ overridesResolver: (props, styles) => styles.root
19
+ })(({ theme }) => ({}));
20
+ /**
21
+ *> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
22
+ *
23
+ #### Import
24
+ ```jsx
25
+ import {CreateGroupButton} from '@selfcommunity/react-ui';
26
+ ```
27
+
28
+ #### Component Name
29
+ The name `SCEditGroupButton` can be used when providing style overrides in the theme.
30
+
31
+ #### CSS
32
+
33
+ |Rule Name|Global class|Description|
34
+ |---|---|---|
35
+ |root|.SCEditGroupButton-root|Styles applied to the root element.|
36
+
37
+ * @param inProps
38
+ */
39
+ function EditGroupButton(inProps) {
40
+ //PROPS
41
+ const props = (0, system_1.useThemeProps)({
42
+ props: inProps,
43
+ name: PREFIX
44
+ });
45
+ const { className, groupId, group, onEditSuccess } = props, rest = tslib_1.__rest(props, ["className", "groupId", "group", "onEditSuccess"]);
46
+ const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
47
+ const handleSuccess = (data) => {
48
+ setSCGroup(data);
49
+ onEditSuccess && onEditSuccess(data);
50
+ };
51
+ /**
52
+ * Renders root object
53
+ */
54
+ return (react_1.default.createElement(Root, Object.assign({ variant: "outlined", className: (0, classnames_1.default)(classes.root, className), GroupFormProps: { group: scGroup, onSuccess: handleSuccess } }, rest),
55
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.editGroupButton", defaultMessage: "ui.editGroupButton" })));
56
+ }
57
+ exports.default = EditGroupButton;
@@ -0,0 +1,3 @@
1
+ import EditGroupButton, { EditGroupButtonProps } from './EditGroupButton';
2
+ export default EditGroupButton;
3
+ export { EditGroupButtonProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const EditGroupButton_1 = tslib_1.__importDefault(require("./EditGroupButton"));
5
+ exports.default = EditGroupButton_1.default;
@@ -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
  */
@@ -63,7 +63,7 @@ function Group(inProps) {
63
63
  props: inProps,
64
64
  name: constants_1.PREFIX
65
65
  });
66
- const { groupId = null, group = null, handleIgnoreAction, className = null, elevation, hideActions = false, buttonProps = {}, visible = true } = props, rest = tslib_1.__rest(props, ["groupId", "group", "handleIgnoreAction", "className", "elevation", "hideActions", "buttonProps", "visible"]);
66
+ const { groupId = null, group = null, className = null, elevation, hideActions = false, groupSubscribeButtonProps = {}, buttonProps = {}, visible = true } = props, rest = tslib_1.__rest(props, ["groupId", "group", "className", "elevation", "hideActions", "groupSubscribeButtonProps", "buttonProps", "visible"]);
67
67
  // STATE
68
68
  const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
69
69
  // CONTEXT
@@ -78,7 +78,7 @@ function Group(inProps) {
78
78
  function renderAuthenticatedActions() {
79
79
  return (react_1.default.createElement(material_1.Stack, { className: classes.actions, direction: "row", alignItems: "center", justifyContent: "center", spacing: 2 },
80
80
  react_1.default.createElement(material_1.Icon, null, !visible ? 'private' : 'public'),
81
- react_1.default.createElement(GroupSubscribeButton_1.default, { group: group, groupId: groupId })));
81
+ react_1.default.createElement(GroupSubscribeButton_1.default, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps))));
82
82
  }
83
83
  /**
84
84
  * Renders group object