@selfcommunity/react-ui 0.8.0-embeds.17 → 0.8.1-alpha.0

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 (79) hide show
  1. package/lib/cjs/components/Categories/Categories.js +22 -0
  2. package/lib/cjs/components/CategoriesPopularWidget/CategoriesPopularWidget.js +21 -0
  3. package/lib/cjs/components/CategoriesSuggestionWidget/CategoriesSuggestionWidget.js +21 -0
  4. package/lib/cjs/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.js +1 -1
  5. package/lib/cjs/components/Events/Events.js +15 -5
  6. package/lib/cjs/components/Events/LocationEventsFilter.d.ts +14 -0
  7. package/lib/cjs/components/Events/LocationEventsFilter.js +45 -0
  8. package/lib/cjs/components/Events/PastEventsFilter.js +1 -2
  9. package/lib/cjs/components/Feed/Feed.js +3 -2
  10. package/lib/cjs/components/GroupActionsMenu/index.d.ts +57 -0
  11. package/lib/cjs/components/GroupActionsMenu/index.js +157 -0
  12. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -0
  13. package/lib/cjs/components/GroupHeader/GroupHeader.js +8 -4
  14. package/lib/cjs/components/Groups/Groups.js +26 -0
  15. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +31 -0
  16. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +35 -0
  17. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +9 -20
  18. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +4 -20
  19. package/lib/cjs/components/NavigationMenuIconButton/index.d.ts +2 -1
  20. package/lib/cjs/components/NavigationMenuIconButton/index.js +3 -1
  21. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.d.ts +5 -0
  22. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +2 -2
  23. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.d.ts +5 -1
  24. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +55 -7
  25. package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/Appearance.js +8 -4
  26. package/lib/cjs/components/OnBoardingWidget/Steps/Invite/Invite.js +56 -12
  27. package/lib/cjs/components/PlatformWidget/constants.d.ts +0 -4
  28. package/lib/cjs/components/PlatformWidget/constants.js +1 -5
  29. package/lib/cjs/constants/GroupActionsMenu.d.ts +5 -0
  30. package/lib/cjs/constants/GroupActionsMenu.js +8 -0
  31. package/lib/cjs/constants/PubSub.d.ts +8 -1
  32. package/lib/cjs/constants/PubSub.js +9 -1
  33. package/lib/cjs/index.d.ts +4 -2
  34. package/lib/cjs/index.js +11 -5
  35. package/lib/cjs/shared/EventInfoDetails/index.js +3 -3
  36. package/lib/cjs/shared/InfiniteScroll/index.js +4 -4
  37. package/lib/cjs/shared/Media/Link/DisplayComponent.js +5 -5
  38. package/lib/esm/components/Categories/Categories.js +23 -1
  39. package/lib/esm/components/CategoriesPopularWidget/CategoriesPopularWidget.js +22 -1
  40. package/lib/esm/components/CategoriesSuggestionWidget/CategoriesSuggestionWidget.js +22 -1
  41. package/lib/esm/components/Composer/TypeSwitchButtonGroup/TypeSwitchButtonGroup.js +2 -2
  42. package/lib/esm/components/Events/Events.js +16 -6
  43. package/lib/esm/components/Events/LocationEventsFilter.d.ts +14 -0
  44. package/lib/esm/components/Events/LocationEventsFilter.js +41 -0
  45. package/lib/esm/components/Events/PastEventsFilter.js +1 -2
  46. package/lib/esm/components/Feed/Feed.js +4 -3
  47. package/lib/esm/components/GroupActionsMenu/index.d.ts +57 -0
  48. package/lib/esm/components/GroupActionsMenu/index.js +154 -0
  49. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -0
  50. package/lib/esm/components/GroupHeader/GroupHeader.js +9 -5
  51. package/lib/esm/components/Groups/Groups.js +27 -1
  52. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +31 -0
  53. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +32 -0
  54. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +9 -20
  55. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +6 -22
  56. package/lib/esm/components/NavigationMenuIconButton/index.d.ts +2 -1
  57. package/lib/esm/components/NavigationMenuIconButton/index.js +2 -1
  58. package/lib/esm/components/NavigationToolbar/NavigationToolbar.d.ts +5 -0
  59. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +2 -2
  60. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.d.ts +5 -1
  61. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +57 -9
  62. package/lib/esm/components/OnBoardingWidget/Steps/Appearance/Appearance.js +9 -5
  63. package/lib/esm/components/OnBoardingWidget/Steps/Invite/Invite.js +59 -14
  64. package/lib/esm/components/PlatformWidget/constants.d.ts +0 -4
  65. package/lib/esm/components/PlatformWidget/constants.js +0 -4
  66. package/lib/esm/constants/GroupActionsMenu.d.ts +5 -0
  67. package/lib/esm/constants/GroupActionsMenu.js +5 -0
  68. package/lib/esm/constants/PubSub.d.ts +8 -1
  69. package/lib/esm/constants/PubSub.js +8 -0
  70. package/lib/esm/index.d.ts +4 -2
  71. package/lib/esm/index.js +5 -3
  72. package/lib/esm/shared/EventInfoDetails/index.js +3 -3
  73. package/lib/esm/shared/InfiniteScroll/index.js +4 -4
  74. package/lib/esm/shared/Media/Link/DisplayComponent.js +5 -5
  75. package/lib/umd/148.js +2 -0
  76. package/lib/umd/react-ui.js +1 -1
  77. package/package.json +9 -9
  78. package/lib/umd/99.js +0 -2
  79. /package/lib/umd/{99.js.LICENSE.txt → 148.js.LICENSE.txt} +0 -0
@@ -16,6 +16,8 @@ const Errors_1 = require("../../constants/Errors");
16
16
  const utils_1 = require("@selfcommunity/utils");
17
17
  const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
18
18
  const constants_1 = require("./constants");
19
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
20
+ const PubSub_1 = require("../../constants/PubSub");
19
21
  const classes = {
20
22
  root: `${constants_1.PREFIX}-root`,
21
23
  filters: `${constants_1.PREFIX}-filter`,
@@ -73,6 +75,7 @@ function Categories(inProps) {
73
75
  const authUserId = scUserContext.user ? scUserContext.user.id : null;
74
76
  // REFS
75
77
  const isMountedRef = (0, react_core_1.useIsComponentMountedRef)();
78
+ const updatesSubscription = (0, react_1.useRef)(null);
76
79
  /**
77
80
  * Fetches categories list
78
81
  */
@@ -104,6 +107,25 @@ function Categories(inProps) {
104
107
  });
105
108
  }
106
109
  }, [contentAvailability, authUserId, prefetchedCategories.length]);
110
+ /**
111
+ * Subscriber for pubsub callback
112
+ */
113
+ const onEditCategoryHandler = (0, react_1.useCallback)((_msg, edited) => {
114
+ setCategories((prev) => {
115
+ return prev.map((c) => (c.id === edited.id ? Object.assign(Object.assign({}, c), edited) : c));
116
+ });
117
+ }, [categories]);
118
+ /**
119
+ * On mount, subscribe to receive event updates (only edit)
120
+ */
121
+ (0, react_1.useEffect)(() => {
122
+ if (categories) {
123
+ updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.CATEGORY}.${PubSub_1.SCCategoryEventType.EDIT}`, onEditCategoryHandler);
124
+ }
125
+ return () => {
126
+ updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
127
+ };
128
+ }, [categories]);
107
129
  /**
108
130
  * Get categories filtered
109
131
  */
@@ -20,6 +20,8 @@ const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/Hidden
20
20
  const react_core_1 = require("@selfcommunity/react-core");
21
21
  const widget_1 = require("../../utils/widget");
22
22
  const constants_1 = require("./constants");
23
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
24
+ const PubSub_1 = require("../../constants/PubSub");
23
25
  const classes = {
24
26
  root: `${constants_1.PREFIX}-root`,
25
27
  title: `${constants_1.PREFIX}-title`,
@@ -89,6 +91,8 @@ function CategoriesPopularWidget(inProps) {
89
91
  // HOOKS
90
92
  const theme = (0, material_1.useTheme)();
91
93
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
94
+ // REFS
95
+ const updatesSubscription = (0, react_1.useRef)(null);
92
96
  /**
93
97
  * Initialize component
94
98
  * Fetch data only if the component is not initialized and it is not loading data
@@ -106,6 +110,23 @@ function CategoriesPopularWidget(inProps) {
106
110
  });
107
111
  }
108
112
  }, [state.isLoadingNext, state.initialized, limit, dispatch]);
113
+ /**
114
+ * Subscriber for pubsub callback
115
+ */
116
+ const onEditCategoryHandler = (0, react_1.useCallback)((_msg, edited) => {
117
+ const _categories = [...state.results];
118
+ const updatedCategories = _categories.map((c) => (c.id === edited.id ? Object.assign(Object.assign({}, c), edited) : c));
119
+ dispatch({ type: widget_1.actionWidgetTypes.SET_RESULTS, payload: { results: updatedCategories } });
120
+ }, [dispatch]);
121
+ /**
122
+ * On mount, subscribe to receive event updates (only edit)
123
+ */
124
+ (0, react_1.useEffect)(() => {
125
+ updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.CATEGORY}.${PubSub_1.SCCategoryEventType.EDIT}`, onEditCategoryHandler);
126
+ return () => {
127
+ updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
128
+ };
129
+ }, [onEditCategoryHandler]);
109
130
  // EFFECTS
110
131
  (0, react_1.useEffect)(() => {
111
132
  var _a;
@@ -20,6 +20,8 @@ const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"))
20
20
  const Errors_1 = require("../../constants/Errors");
21
21
  const InfiniteScroll_1 = tslib_1.__importDefault(require("../../shared/InfiniteScroll"));
22
22
  const constants_1 = require("./constants");
23
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
24
+ const PubSub_1 = require("../../constants/PubSub");
23
25
  const classes = {
24
26
  root: `${constants_1.PREFIX}-root`,
25
27
  title: `${constants_1.PREFIX}-title`,
@@ -85,6 +87,8 @@ function CategoriesSuggestionWidget(inProps) {
85
87
  // HOOKS
86
88
  const theme = (0, material_1.useTheme)();
87
89
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
90
+ // REFS
91
+ const updatesSubscription = (0, react_1.useRef)(null);
88
92
  /**
89
93
  * Initialize component
90
94
  * Fetch data only if the component is not initialized and it is not loading data
@@ -102,6 +106,23 @@ function CategoriesSuggestionWidget(inProps) {
102
106
  });
103
107
  }
104
108
  }, [state.isLoadingNext, state.initialized, limit, dispatch]);
109
+ /**
110
+ * Subscriber for pubsub callback
111
+ */
112
+ const onEditCategoryHandler = (0, react_1.useCallback)((_msg, edited) => {
113
+ const _categories = [...state.results];
114
+ const updatedCategories = _categories.map((c) => (c.id === edited.id ? Object.assign(Object.assign({}, c), edited) : c));
115
+ dispatch({ type: widget_1.actionWidgetTypes.SET_RESULTS, payload: { results: updatedCategories } });
116
+ }, [dispatch]);
117
+ /**
118
+ * On mount, subscribe to receive event updates (only edit)
119
+ */
120
+ (0, react_1.useEffect)(() => {
121
+ updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.CATEGORY}.${PubSub_1.SCCategoryEventType.EDIT}`, onEditCategoryHandler);
122
+ return () => {
123
+ updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
124
+ };
125
+ }, [onEditCategoryHandler]);
105
126
  // EFFECTS
106
127
  (0, react_1.useEffect)(() => {
107
128
  let _t;
@@ -37,6 +37,6 @@ function ComposerTypeButtonGroup(props) {
37
37
  const handleChange = (0, react_1.useCallback)((event, value) => {
38
38
  onChange && onChange(value);
39
39
  }, [onChange]);
40
- return (0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onChange: handleChange, exclusive: true, value: value }, rest, { children: [hasPostType && (0, jsx_runtime_1.jsx)(material_1.ToggleButton, Object.assign({ value: Composer_1.COMPOSER_TYPE_POST }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.typeSwitch.post", defaultMessage: "ui.composer.typeSwitch.post" }) })), hasDiscussionType && (0, jsx_runtime_1.jsx)(material_1.ToggleButton, Object.assign({ value: Composer_1.COMPOSER_TYPE_DISCUSSION }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.typeSwitch.discussion", defaultMessage: "ui.composer.typeSwitch.discussion" }) })), hasPollType && (0, jsx_runtime_1.jsx)(material_1.ToggleButton, Object.assign({ value: Composer_1.COMPOSER_TYPE_POLL }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.typeSwitch.poll", defaultMessage: "ui.composer.typeSwitch.poll" }) }))] }));
40
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onChange: handleChange, exclusive: true, value: value }, rest, { children: [hasPostType && ((0, jsx_runtime_1.jsx)(material_1.ToggleButton, Object.assign({ value: Composer_1.COMPOSER_TYPE_POST }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.typeSwitch.post", defaultMessage: "ui.composer.typeSwitch.post" }) }))), hasDiscussionType && ((0, jsx_runtime_1.jsx)(material_1.ToggleButton, Object.assign({ value: Composer_1.COMPOSER_TYPE_DISCUSSION }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.typeSwitch.discussion", defaultMessage: "ui.composer.typeSwitch.discussion" }) }))), hasPostType && hasPollType && ((0, jsx_runtime_1.jsx)(material_1.ToggleButton, Object.assign({ value: Composer_1.COMPOSER_TYPE_POLL }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.typeSwitch.poll", defaultMessage: "ui.composer.typeSwitch.poll" }) })))] })));
41
41
  }
42
42
  exports.default = ComposerTypeButtonGroup;
@@ -22,6 +22,7 @@ const constants_1 = require("./constants");
22
22
  const PastEventsFilter_1 = tslib_1.__importDefault(require("./PastEventsFilter"));
23
23
  const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
24
24
  const PubSub_1 = require("../../constants/PubSub");
25
+ const LocationEventsFilter_1 = tslib_1.__importDefault(require("./LocationEventsFilter"));
25
26
  const classes = {
26
27
  root: `${constants_1.PREFIX}-root`,
27
28
  filters: `${constants_1.PREFIX}-filters`,
@@ -89,6 +90,7 @@ function Events(inProps) {
89
90
  const [next, setNext] = (0, react_1.useState)(null);
90
91
  const [query, setQuery] = (0, react_1.useState)('');
91
92
  const [dateSearch, setDateSearch] = (0, react_1.useState)(options[0].value);
93
+ const [location, setLocation] = (0, react_1.useState)(types_1.SCEventLocationFilterType.ANY);
92
94
  const [showFollowed, setShowFollowed] = (0, react_1.useState)(false);
93
95
  const [showPastEvents, setShowPastEvents] = (0, react_1.useState)(false);
94
96
  const [showMyEvents, setShowMyEvents] = (0, react_1.useState)(false);
@@ -128,7 +130,7 @@ function Events(inProps) {
128
130
  url: endpoint.url({}),
129
131
  method: endpoint.method,
130
132
  params: Object.assign(Object.assign({}, endpointQueryParams), (general
131
- ? Object.assign(Object.assign(Object.assign(Object.assign({}, (search && { search: query })), (dateSearch !== types_1.SCEventDateFilterType.ANY && { date_filter: dateSearch })), (showFollowed && { follows: showFollowed })), (showPastEvents && { date_filter: types_1.SCEventDateFilterType.PAST })) : Object.assign(Object.assign({ subscription_status: types_1.SCEventSubscriptionStatusType.GOING }, (showPastEvents && { past: showPastEvents })), (showMyEvents && { created_by: authUserId }))))
133
+ ? Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (search && { search: query })), (dateSearch !== types_1.SCEventDateFilterType.ANY && { date_filter: dateSearch })), (location !== types_1.SCEventLocationFilterType.ANY && { location })), (showFollowed && { follows: showFollowed })), (showPastEvents && { date_filter: types_1.SCEventDateFilterType.PAST })) : Object.assign(Object.assign(Object.assign({ subscription_status: types_1.SCEventSubscriptionStatusType.GOING }, (location !== types_1.SCEventLocationFilterType.ANY && { location })), (showPastEvents && { past: showPastEvents })), (showMyEvents && { created_by: authUserId }))))
132
134
  })
133
135
  .then((res) => {
134
136
  setEvents(res.data.results);
@@ -149,7 +151,7 @@ function Events(inProps) {
149
151
  else {
150
152
  query === '' && fetchEvents();
151
153
  }
152
- }, [contentAvailability, dateSearch, showFollowed, showPastEvents, showMyEvents, query]);
154
+ }, [contentAvailability, dateSearch, location, showFollowed, showPastEvents, showMyEvents, query]);
153
155
  /**
154
156
  * Subscriber for pubsub callback
155
157
  */
@@ -202,10 +204,18 @@ function Events(inProps) {
202
204
  const handleOnChangeTimeFrame = (event) => {
203
205
  setDateSearch(event.target.value);
204
206
  };
207
+ /**
208
+ * Handle change location
209
+ * @param event
210
+ */
211
+ const handleOnChangeLocation = (event) => {
212
+ setLocation(event.target.value);
213
+ };
205
214
  /**
206
215
  * Renders events list
207
216
  */
208
- const c = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showFilters && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(PastEventsFilter_1.default, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, autoHide: !events.length && !showPastEvents, disabled: loading }) })), (events.length !== 0 || (events.length === 0 && showMyEvents)) && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(exports.EventsChipRoot
217
+ console.log(location);
218
+ const c = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showFilters && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(events.length !== 0 || (events.length === 0 && showMyEvents)) && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(exports.EventsChipRoot
209
219
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
210
220
  // @ts-ignore
211
221
  , {
@@ -217,14 +227,14 @@ function Events(inProps) {
217
227
  variant: showMyEvents ? 'filled' : 'outlined', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByCreatedByMe", defaultMessage: "ui.events.filterByCreatedByMe" }), onClick: () => setShowMyEvents(!showMyEvents),
218
228
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
219
229
  // @ts-ignore
220
- showFollowed: showMyEvents, deleteIcon: showMyEvents ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, disabled: loading }) })))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 4 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading || (!events.length && !query), onKeyUp: (e) => {
230
+ showFollowed: showMyEvents, deleteIcon: showMyEvents ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, autoHide: !loading && !events.length, disabled: loading }) }))), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(PastEventsFilter_1.default, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, autoHide: !loading && !events.length && !showPastEvents, disabled: loading }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: (0, jsx_runtime_1.jsx)(LocationEventsFilter_1.default, { value: location, autoHide: !loading && !events.length, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) }))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 3 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading || (!events.length && !query), onKeyUp: (e) => {
221
231
  e.preventDefault();
222
232
  if (e.key === 'Enter') {
223
233
  fetchEvents(true);
224
234
  }
225
235
  }, InputProps: {
226
236
  endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => fetchEvents(true), disabled: loading || (!events.length && !query) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }) }))) : ((0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }), disabled: loading || (!events.length && !query) })) })))
227
- } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ disabled: showPastEvents || loading || (!events.length && dateSearch === types_1.SCEventDateFilterType.ANY), size: 'small', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }), value: dateSearch, onChange: handleOnChangeTimeFrame, renderValue: (selected) => options.find((option) => option.value === selected).label }, { children: options.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: option.value }, { children: [(0, jsx_runtime_1.jsx)(material_1.Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), authUserId && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(exports.EventsChipRoot
237
+ } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ disabled: showPastEvents || loading || (!events.length && dateSearch === types_1.SCEventDateFilterType.ANY), size: 'small', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }), value: dateSearch, onChange: handleOnChangeTimeFrame, renderValue: (selected) => options.find((option) => option.value === selected).label }, { children: options.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: option.value }, { children: [(0, jsx_runtime_1.jsx)(material_1.Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: (0, jsx_runtime_1.jsx)(LocationEventsFilter_1.default, { value: location, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) })), authUserId && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(exports.EventsChipRoot
228
238
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
229
239
  // @ts-ignore
230
240
  , {
@@ -0,0 +1,14 @@
1
+ import { ChipProps } from '@mui/material';
2
+ import { SCEventLocationFilterType } from '@selfcommunity/types';
3
+ export interface LocationEventsFilterProps extends ChipProps {
4
+ /**
5
+ * Overrides or extends the styles applied to the component.
6
+ * @default null
7
+ */
8
+ className?: string;
9
+ value: SCEventLocationFilterType;
10
+ disabled?: boolean;
11
+ autoHide?: boolean;
12
+ handleOnChange: (event: any) => void;
13
+ }
14
+ export default function LocationEventsFilter(inProps: LocationEventsFilterProps): JSX.Element;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const material_1 = require("@mui/material");
6
+ const react_intl_1 = require("react-intl");
7
+ const system_1 = require("@mui/system");
8
+ const constants_1 = require("./constants");
9
+ const styles_1 = require("@mui/material/styles");
10
+ const types_1 = require("@selfcommunity/types");
11
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
12
+ const classes = {
13
+ root: `${constants_1.PREFIX}-root`
14
+ };
15
+ const Root = (0, styles_1.styled)(material_1.FormControl, {
16
+ name: constants_1.PREFIX,
17
+ slot: 'Root'
18
+ })(() => ({}));
19
+ const locationOptions = [
20
+ {
21
+ value: types_1.SCEventLocationFilterType.ANY,
22
+ label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.location.select.any", defaultMessage: "ui.events.location.select.any" })
23
+ },
24
+ {
25
+ value: types_1.SCEventLocationFilterType.PERSON,
26
+ label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.location.inPerson", defaultMessage: "ui.eventInfoDetails.location.inPerson" })
27
+ },
28
+ {
29
+ value: types_1.SCEventLocationFilterType.ONLINE,
30
+ label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.location.virtual", defaultMessage: "ui.eventInfoDetails.location.virtual" })
31
+ }
32
+ ];
33
+ function LocationEventsFilter(inProps) {
34
+ // PROPS
35
+ const props = (0, system_1.useThemeProps)({
36
+ props: inProps,
37
+ name: constants_1.PREFIX
38
+ });
39
+ const { className, value, disabled = false, autoHide = false, handleOnChange } = props;
40
+ if (autoHide) {
41
+ return null;
42
+ }
43
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByLocation", defaultMessage: "ui.events.filterByLocation" }) }), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ disabled: disabled, size: 'small', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.location", defaultMessage: "ui.events.location" }), value: value, onChange: handleOnChange, renderValue: (selected) => locationOptions.find((option) => option.value === selected).label }, { children: locationOptions.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: option.value }, { children: [(0, jsx_runtime_1.jsx)(material_1.Radio, { checked: value === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })));
44
+ }
45
+ exports.default = LocationEventsFilter;
@@ -7,7 +7,6 @@ const react_intl_1 = require("react-intl");
7
7
  const system_1 = require("@mui/system");
8
8
  const constants_1 = require("./constants");
9
9
  const Events_1 = require("./Events");
10
- const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
11
10
  function PastEventsFilter(inProps) {
12
11
  // PROPS
13
12
  const props = (0, system_1.useThemeProps)({
@@ -16,7 +15,7 @@ function PastEventsFilter(inProps) {
16
15
  });
17
16
  const { autoHide = false, showPastEvents, handleClick, handleDeleteClick } = props, rest = tslib_1.__rest(props, ["autoHide", "showPastEvents", "handleClick", "handleDeleteClick"]);
18
17
  if (autoHide) {
19
- return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
18
+ return null;
20
19
  }
21
20
  return ((0, jsx_runtime_1.jsx)(Events_1.EventsChipRoot
22
21
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
@@ -37,6 +37,7 @@ const classes = {
37
37
  left: `${constants_1.PREFIX}-left`,
38
38
  leftItems: `${constants_1.PREFIX}-left-items`,
39
39
  start: `${constants_1.PREFIX}-start`,
40
+ headerItem: `${constants_1.PREFIX}-header-item`,
40
41
  end: `${constants_1.PREFIX}-end`,
41
42
  endMessage: `${constants_1.PREFIX}-end-message`,
42
43
  right: `${constants_1.PREFIX}-right`,
@@ -293,7 +294,7 @@ const Feed = (inProps, ref) => {
293
294
  const renderHeaderComponent = () => {
294
295
  return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.start }, { children: !feedDataObject.previous && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [virtualScrollerMountState.current && HeaderComponent, headData.map((item) => {
295
296
  const _itemId = `item_${itemIdGenerator(item)}`;
296
- return ((0, jsx_runtime_1.jsx)(ItemComponent, Object.assign({ id: _itemId }, itemPropsGenerator(scUserContext.user, item), ItemProps, { sx: { width: '100%' } }), _itemId));
297
+ return ((0, jsx_runtime_1.jsx)(ItemComponent, Object.assign({ className: classes.headerItem, id: _itemId }, itemPropsGenerator(scUserContext.user, item), ItemProps, { sx: { width: '100%' } }), _itemId));
297
298
  })] })) })));
298
299
  };
299
300
  /**
@@ -419,6 +420,6 @@ const Feed = (inProps, ref) => {
419
420
  if (feedDataObject.isLoadingNext && !feedDataLeft.length) {
420
421
  return ((0, jsx_runtime_1.jsx)(Skeleton_2.default, { children: [...Array(3)].map((v, i) => ((0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps), i))) }));
421
422
  }
422
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ container: true, spacing: 2, id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: [advEnabled && !hideAdvs && enabledCustomAdvPositions.includes(types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR) ? ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(CustomAdv_1.default, Object.assign({ position: types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR }, CustomAdvProps)) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: (0, jsx_runtime_1.jsxs)(InfiniteScroll_1.default, Object.assign({ ref: containerRef, className: classes.left, dataLength: feedDataLeft.length, next: getNextPage, previous: getPreviousPage, hasMoreNext: Boolean(feedDataObject.next), hasMorePrevious: Boolean(feedDataObject.previous), header: PreviousPageLink, footer: NextPageLink, loaderNext: (0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps)), loaderPrevious: (0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps)), scrollThreshold: '90%', endMessage: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.end }, { children: [(0, jsx_runtime_1.jsx)(Widget_1.default, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(material_1.CardContent, { children: endMessage }) })), FooterComponent ? (0, jsx_runtime_1.jsx)(FooterComponent, Object.assign({}, FooterComponentProps)) : null] })), refreshFunction: refresh, pullDownToRefresh: true, pullDownToRefreshThreshold: 1000, pullDownToRefreshContent: null, releaseToRefreshContent: (0, jsx_runtime_1.jsx)(Widget_1.default, Object.assign({ variant: "outlined", className: classes.refresh }, { children: (0, jsx_runtime_1.jsx)(material_1.CardContent, { children: refreshMessage }) })), style: { overflow: 'visible' } }, (scrollableTargetId && { scrollableTarget: scrollableTargetId }), { children: [renderHeaderComponent(), feedDataObject.count === 0 && emptyFeedPlaceholder && emptyFeedPlaceholder, (0, jsx_runtime_1.jsx)(VirtualizedScroller_1.default, Object.assign({ className: classes.leftItems, items: feedDataLeft, itemComponent: InnerItem, onMount: onScrollerMount, onScrollerStateChange: onScrollerStateChange, getItemId: getScrollItemId, preserveScrollPosition: true, preserveScrollPositionOnPrependItems: true, cacheScrollStateKey: react_core_1.SCCache.getVirtualizedScrollStateCacheKey(id), cacheScrollerPositionKey: react_core_1.SCCache.getFeedSPCacheKey(id), cacheStrategy: cacheStrategy }, (scrollableTargetId && { getScrollableContainer: () => document.getElementById(scrollableTargetId) }), VirtualizedScrollerProps))] })) })), feedDataRight.length > 0 && !hideAdvs && ((0, jsx_runtime_1.jsx)(material_1.Hidden, Object.assign({ smDown: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: (0, jsx_runtime_1.jsx)(StickyBox_1.default, Object.assign({ className: classes.right }, FeedSidebarProps, { children: (0, jsx_runtime_1.jsx)(react_1.default.Suspense, Object.assign({ fallback: (0, jsx_runtime_1.jsx)(Skeleton_1.GenericSkeleton, {}) }, { children: feedDataRight.map((d, i) => ((0, jsx_runtime_1.jsx)(d.component, Object.assign({}, d.componentProps), i))) })) })) })) })))] })));
423
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ container: true, spacing: 2, id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: [advEnabled && !hideAdvs && enabledCustomAdvPositions.includes(types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR) ? ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(CustomAdv_1.default, Object.assign({ position: types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR }, CustomAdvProps)) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: (0, jsx_runtime_1.jsxs)(InfiniteScroll_1.default, Object.assign({ ref: containerRef, className: classes.left, dataLength: feedDataLeft.length, next: getNextPage, previous: getPreviousPage, hasMoreNext: Boolean(feedDataObject.next), hasMorePrevious: Boolean(feedDataObject.previous), header: PreviousPageLink, footer: NextPageLink, loaderNext: (0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps)), loaderPrevious: (0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps)), scrollThreshold: '90%', endMessage: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.end }, { children: [(0, jsx_runtime_1.jsx)(Widget_1.default, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(material_1.CardContent, { children: endMessage }) })), FooterComponent ? (0, jsx_runtime_1.jsx)(FooterComponent, Object.assign({}, FooterComponentProps)) : null] })), refreshFunction: refresh, pullDownToRefresh: true, pullDownToRefreshThreshold: 1000, pullDownToRefreshContent: null, releaseToRefreshContent: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "secondary", variant: "contained", className: classes.refresh }, { children: refreshMessage })), style: { overflow: 'visible' } }, (scrollableTargetId && { scrollableTarget: scrollableTargetId }), { children: [renderHeaderComponent(), feedDataObject.count === 0 && emptyFeedPlaceholder && emptyFeedPlaceholder, (0, jsx_runtime_1.jsx)(VirtualizedScroller_1.default, Object.assign({ className: classes.leftItems, items: feedDataLeft, itemComponent: InnerItem, onMount: onScrollerMount, onScrollerStateChange: onScrollerStateChange, getItemId: getScrollItemId, preserveScrollPosition: true, preserveScrollPositionOnPrependItems: true, cacheScrollStateKey: react_core_1.SCCache.getVirtualizedScrollStateCacheKey(id), cacheScrollerPositionKey: react_core_1.SCCache.getFeedSPCacheKey(id), cacheStrategy: cacheStrategy }, (scrollableTargetId && { getScrollableContainer: () => document.getElementById(scrollableTargetId) }), VirtualizedScrollerProps))] })) })), feedDataRight.length > 0 && !hideAdvs && ((0, jsx_runtime_1.jsx)(material_1.Hidden, Object.assign({ smDown: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: (0, jsx_runtime_1.jsx)(StickyBox_1.default, Object.assign({ className: classes.right }, FeedSidebarProps, { children: (0, jsx_runtime_1.jsx)(react_1.default.Suspense, Object.assign({ fallback: (0, jsx_runtime_1.jsx)(Skeleton_1.GenericSkeleton, {}) }, { children: feedDataRight.map((d, i) => ((0, jsx_runtime_1.jsx)(d.component, Object.assign({}, d.componentProps), i))) })) })) })) })))] })));
423
424
  };
424
425
  exports.default = (0, react_1.forwardRef)(Feed);
@@ -0,0 +1,57 @@
1
+ import { IconButtonProps } from '@mui/material';
2
+ import { SCGroupType } from '@selfcommunity/types';
3
+ export interface GroupActionsMenuProps extends IconButtonProps {
4
+ /**
5
+ * Overrides or extends the styles applied to the component.
6
+ * @default null
7
+ */
8
+ className?: string;
9
+ /**
10
+ * The group
11
+ */
12
+ group: SCGroupType;
13
+ /**
14
+ * The group id
15
+ */
16
+ groupId?: number;
17
+ /**
18
+ * Handles callback on delete confirm
19
+ */
20
+ onDeleteConfirm?: () => void;
21
+ /**
22
+ * Handles on edit success
23
+ */
24
+ onEditSuccess?: (data: SCGroupType) => any;
25
+ /**
26
+ * Any other properties
27
+ */
28
+ [p: string]: any;
29
+ }
30
+ /**
31
+ * > API documentation for the Community-JS GroupActionsMenu component. Learn about the available props and the CSS API.
32
+
33
+ #### Import
34
+
35
+ ```jsx
36
+ import {GroupActionsMenu} from '@selfcommunity/react-ui';
37
+ ```
38
+
39
+ #### Component Name
40
+
41
+ The name `SCGroupActionsMenu` can be used when providing style overrides in the theme.
42
+
43
+
44
+ #### CSS
45
+
46
+ |Rule Name|Global class|Description|
47
+ |---|---|---|
48
+ |root|.SCGroupActionsMenu-root|Styles applied to the root element.|
49
+ |drawerRoot|.SCGroupActionsMenu-drawer-root|Styles applied to the drawer root element.|
50
+ |menuRoot|.SCGroupActionsMenu-menu-root|Styles applied to the menu root element.|
51
+ |paper|.SCGroupActionsMenu-paper|Styles applied to the paper element.|
52
+ |item|.SCGroupActionsMenu-item|Styles applied to the item element.|
53
+
54
+
55
+ * @param inProps
56
+ */
57
+ export default function GroupActionsMenu(inProps: GroupActionsMenuProps): JSX.Element;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const styles_1 = require("@mui/material/styles");
7
+ const material_1 = require("@mui/material");
8
+ const react_intl_1 = require("react-intl");
9
+ const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
10
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
11
+ const system_1 = require("@mui/system");
12
+ const react_core_1 = require("@selfcommunity/react-core");
13
+ const ConfirmDialog_1 = tslib_1.__importDefault(require("../../shared/ConfirmDialog/ConfirmDialog"));
14
+ const api_services_1 = require("@selfcommunity/api-services");
15
+ const utils_1 = require("@selfcommunity/utils");
16
+ const notistack_1 = require("notistack");
17
+ const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
18
+ const PubSub_1 = require("../../constants/PubSub");
19
+ const GroupForm_1 = tslib_1.__importDefault(require("../../components/GroupForm"));
20
+ const GroupActionsMenu_1 = require("../../constants/GroupActionsMenu");
21
+ const PREFIX = 'SCGroupActionsMenu';
22
+ const classes = {
23
+ root: `${PREFIX}-root`,
24
+ drawerRoot: `${PREFIX}-drawer-root`,
25
+ menuRoot: `${PREFIX}-menu-root`,
26
+ paper: `${PREFIX}-paper`,
27
+ item: `${PREFIX}-item`
28
+ };
29
+ const Root = (0, styles_1.styled)(material_1.IconButton, {
30
+ name: PREFIX,
31
+ slot: 'Root'
32
+ })(() => ({}));
33
+ const SwipeableDrawerRoot = (0, styles_1.styled)(material_1.SwipeableDrawer, {
34
+ name: PREFIX,
35
+ slot: 'DrawerRoot'
36
+ })(() => ({}));
37
+ const MenuRoot = (0, styles_1.styled)(material_1.Menu, {
38
+ name: PREFIX,
39
+ slot: 'MenuRoot'
40
+ })(() => ({}));
41
+ /**
42
+ * > API documentation for the Community-JS GroupActionsMenu component. Learn about the available props and the CSS API.
43
+
44
+ #### Import
45
+
46
+ ```jsx
47
+ import {GroupActionsMenu} from '@selfcommunity/react-ui';
48
+ ```
49
+
50
+ #### Component Name
51
+
52
+ The name `SCGroupActionsMenu` can be used when providing style overrides in the theme.
53
+
54
+
55
+ #### CSS
56
+
57
+ |Rule Name|Global class|Description|
58
+ |---|---|---|
59
+ |root|.SCGroupActionsMenu-root|Styles applied to the root element.|
60
+ |drawerRoot|.SCGroupActionsMenu-drawer-root|Styles applied to the drawer root element.|
61
+ |menuRoot|.SCGroupActionsMenu-menu-root|Styles applied to the menu root element.|
62
+ |paper|.SCGroupActionsMenu-paper|Styles applied to the paper element.|
63
+ |item|.SCGroupActionsMenu-item|Styles applied to the item element.|
64
+
65
+
66
+ * @param inProps
67
+ */
68
+ function GroupActionsMenu(inProps) {
69
+ var _a;
70
+ // PROPS
71
+ const props = (0, system_1.useThemeProps)({
72
+ props: inProps,
73
+ name: PREFIX
74
+ });
75
+ const { className, group, groupId, onDeleteConfirm, onEditSuccess } = props, rest = tslib_1.__rest(props, ["className", "group", "groupId", "onDeleteConfirm", "onEditSuccess"]);
76
+ // STATE
77
+ const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
78
+ const [openConfirmDialog, setOpenConfirmDialog] = (0, react_1.useState)(false);
79
+ const [openEdit, setOpenEdit] = (0, react_1.useState)(false);
80
+ // HOOKS
81
+ const theme = (0, material_1.useTheme)();
82
+ const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
83
+ const scRoutingContext = (0, react_core_1.useSCRouting)();
84
+ const scUserContext = (0, react_core_1.useSCUser)();
85
+ const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
86
+ const isGroupAdmin = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
87
+ // HANDLERS
88
+ const handleOpen = (group) => {
89
+ setAnchorEl(group.currentTarget);
90
+ };
91
+ const handleClose = () => {
92
+ setAnchorEl(null);
93
+ };
94
+ const handleEditClick = () => {
95
+ setOpenEdit((o) => !o);
96
+ };
97
+ const handleCloseDialog = () => {
98
+ setOpenConfirmDialog(false);
99
+ setAnchorEl(null);
100
+ };
101
+ const handleEditSuccess = (data) => {
102
+ setSCGroup(data);
103
+ onEditSuccess && onEditSuccess(data);
104
+ };
105
+ /**
106
+ * Handles thread deletion
107
+ */
108
+ function handleDeleteThread() {
109
+ api_services_1.GroupService.deleteGroup(scGroup.id)
110
+ .then(() => {
111
+ onDeleteConfirm();
112
+ handleCloseDialog();
113
+ pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCGroupEventType.DELETE}`, scGroup.id);
114
+ })
115
+ .catch((error) => {
116
+ setOpenConfirmDialog(false);
117
+ console.log(error);
118
+ });
119
+ }
120
+ /**
121
+ * Handles actions
122
+ */
123
+ function handleAction(action) {
124
+ if (action === GroupActionsMenu_1.GET_GROUP_LINK) {
125
+ (0, utils_1.copyTextToClipboard)(`${location.protocol}//${location.host}${scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, scGroup)}`).then(() => {
126
+ (0, notistack_1.enqueueSnackbar)((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.common.permanentLinkCopied", defaultMessage: "ui.common.permanentLinkCopied" }), {
127
+ variant: 'success',
128
+ autoHideDuration: 3000
129
+ });
130
+ });
131
+ handleClose();
132
+ }
133
+ else if (action === GroupActionsMenu_1.DELETE_GROUP) {
134
+ setOpenConfirmDialog(true);
135
+ handleClose();
136
+ }
137
+ }
138
+ /**
139
+ *
140
+ */
141
+ const renderList = () => {
142
+ return [
143
+ (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(GroupActionsMenu_1.GET_GROUP_LINK) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "link" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.item.link", defaultMessage: "ui.groupActionsMenu.item.link" })] }), "link"),
144
+ isGroupAdmin &&
145
+ scGroup.active && [
146
+ (0, jsx_runtime_1.jsx)(material_1.Divider, {}, "divider"),
147
+ isMobile && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: handleEditClick }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "edit" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.item.edit", defaultMessage: "ui.groupActionsMenu.item.edit" })] }), "edit")),
148
+ (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(GroupActionsMenu_1.DELETE_GROUP) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "delete" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.item.delete", defaultMessage: "ui.groupActionsMenu.item.delete" })] }), "delete")
149
+ ]
150
+ ];
151
+ };
152
+ if (!scGroup) {
153
+ return null;
154
+ }
155
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { onClick: handleOpen }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "more_vert" }) })), isMobile ? ((0, jsx_runtime_1.jsx)(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, anchor: "bottom", open: Boolean(anchorEl), onClose: handleClose, onOpen: handleOpen, PaperProps: { className: classes.paper }, disableSwipeToOpen: true }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: renderList() }) }))) : ((0, jsx_runtime_1.jsx)(MenuRoot, Object.assign({ className: classes.menuRoot, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, PaperProps: { className: classes.paper } }, { children: renderList() }))), openConfirmDialog && ((0, jsx_runtime_1.jsx)(ConfirmDialog_1.default, { open: openConfirmDialog, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.dialog.msg", defaultMessage: "ui.groupActionsMenu.dialog.msg" }), btnConfirm: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.dialog.confirm", defaultMessage: "ui.groupActionsMenu.dialog.confirm" }), onConfirm: handleDeleteThread, onClose: handleCloseDialog })), openEdit && (0, jsx_runtime_1.jsx)(GroupForm_1.default, { onClose: handleEditClick, group: scGroup, onSuccess: handleEditSuccess })] }));
156
+ }
157
+ exports.default = GroupActionsMenu;
@@ -3,6 +3,7 @@ import { ChangeGroupCoverProps } from '../ChangeGroupCover';
3
3
  import { ChangeGroupPictureProps } from '../ChangeGroupPicture';
4
4
  import { GroupMembersButtonProps } from '../GroupMembersButton';
5
5
  import { GroupSubscribeButtonProps } from '../GroupSubscribeButton';
6
+ import { GroupActionsMenuProps } from '../GroupActionsMenu';
6
7
  export interface GroupHeaderProps {
7
8
  /**
8
9
  * Id of group object
@@ -44,6 +45,11 @@ export interface GroupHeaderProps {
44
45
  * @default {}
45
46
  */
46
47
  GroupMembersButtonProps?: GroupMembersButtonProps;
48
+ /**
49
+ * Props to spread event actions menu
50
+ * @default {}
51
+ */
52
+ GroupActionsProps?: Omit<GroupActionsMenuProps, 'group'>;
47
53
  /**
48
54
  * Any other properties
49
55
  */