@selfcommunity/react-ui 0.11.0-alpha.4 → 0.11.0-alpha.41

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 (131) hide show
  1. package/lib/cjs/components/CategoryAutocomplete/CategoryAutocomplete.d.ts +5 -0
  2. package/lib/cjs/components/CategoryAutocomplete/CategoryAutocomplete.js +3 -3
  3. package/lib/cjs/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +1 -1
  4. package/lib/cjs/components/Composer/Layer/CategoryLayer/CategoryLayer.js +4 -1
  5. package/lib/cjs/components/ComposerIconButton/ComposerIconButton.js +10 -2
  6. package/lib/cjs/components/CreateEventButton/CreateEventButton.d.ts +1 -1
  7. package/lib/cjs/components/CreateEventButton/CreateEventButton.js +1 -1
  8. package/lib/cjs/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +11 -9
  9. package/lib/cjs/components/CreateLiveStreamDialog/LiveStreamSelector/LiveStreamSelector.js +21 -12
  10. package/lib/cjs/components/Editor/Editor.js +9 -9
  11. package/lib/cjs/components/Editor/nodes/HashtagNode.js +2 -0
  12. package/lib/cjs/components/Editor/nodes/MentionNode.js +2 -0
  13. package/lib/cjs/components/Editor/plugins/HorizontalRulePlugin.d.ts +8 -0
  14. package/lib/cjs/components/Editor/plugins/HorizontalRulePlugin.js +34 -0
  15. package/lib/cjs/components/Editor/plugins/LexicalRichTextPlugin.d.ts +2 -2
  16. package/lib/cjs/components/Editor/plugins/LexicalRichTextPlugin.js +2 -3
  17. package/lib/cjs/components/Editor/plugins/ToolbarPlugin.js +1 -1
  18. package/lib/cjs/components/Event/Event.js +6 -3
  19. package/lib/cjs/components/EventForm/EventForm.js +7 -5
  20. package/lib/cjs/components/EventHeader/EventHeader.js +1 -1
  21. package/lib/cjs/components/EventMediaWidget/EventMediaWidget.js +2 -2
  22. package/lib/cjs/components/EventMembersWidget/EventMembersWidget.js +11 -11
  23. package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +9 -9
  24. package/lib/cjs/components/EventMembersWidget/types.d.ts +4 -5
  25. package/lib/cjs/components/EventMembersWidget/types.js +7 -7
  26. package/lib/cjs/components/EventParticipantsButton/EventParticipantsButton.js +5 -5
  27. package/lib/cjs/components/Events/Events.d.ts +11 -0
  28. package/lib/cjs/components/Events/Events.js +21 -10
  29. package/lib/cjs/components/Events/OngoingEventsFilter.d.ts +8 -0
  30. package/lib/cjs/components/Events/OngoingEventsFilter.js +24 -0
  31. package/lib/cjs/components/FeedObject/Activities/Activities.js +1 -1
  32. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +1 -1
  33. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +1 -1
  34. package/lib/cjs/components/LiveStreamForm/LiveStreamForm.js +65 -6
  35. package/lib/cjs/components/LiveStreamForm/LiveStreamFormSettings.js +8 -3
  36. package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.js +8 -6
  37. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +3 -1
  38. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.d.ts +2 -1
  39. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.js +2 -2
  40. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.d.ts +9 -0
  41. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.js +106 -0
  42. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.d.ts +4 -0
  43. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.js +37 -0
  44. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
  45. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
  46. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +3 -2
  47. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +45 -2
  48. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +60 -5
  49. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.d.ts +1 -1
  50. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +2 -2
  51. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -1
  52. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +4 -4
  53. package/lib/cjs/components/SearchDialog/SearchDialog.d.ts +4 -1
  54. package/lib/cjs/components/SearchDialog/SearchDialog.js +2 -2
  55. package/lib/cjs/constants/LiveStream.d.ts +1 -0
  56. package/lib/cjs/constants/LiveStream.js +2 -1
  57. package/lib/cjs/shared/EventActionsMenu/index.js +5 -1
  58. package/lib/cjs/shared/UpScalingTierBadge/index.js +9 -0
  59. package/lib/cjs/utils/buttonCounters.d.ts +1 -0
  60. package/lib/cjs/utils/buttonCounters.js +4 -3
  61. package/lib/cjs/utils/contribution.js +1 -2
  62. package/lib/cjs/utils/events.d.ts +1 -0
  63. package/lib/cjs/utils/events.js +6 -1
  64. package/lib/esm/components/CategoryAutocomplete/CategoryAutocomplete.d.ts +5 -0
  65. package/lib/esm/components/CategoryAutocomplete/CategoryAutocomplete.js +3 -3
  66. package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +1 -1
  67. package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.js +4 -1
  68. package/lib/esm/components/ComposerIconButton/ComposerIconButton.js +11 -3
  69. package/lib/esm/components/CreateEventButton/CreateEventButton.d.ts +1 -1
  70. package/lib/esm/components/CreateEventButton/CreateEventButton.js +1 -1
  71. package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +11 -9
  72. package/lib/esm/components/CreateLiveStreamDialog/LiveStreamSelector/LiveStreamSelector.js +23 -14
  73. package/lib/esm/components/Editor/Editor.js +8 -8
  74. package/lib/esm/components/Editor/nodes/HashtagNode.js +2 -0
  75. package/lib/esm/components/Editor/nodes/MentionNode.js +2 -0
  76. package/lib/esm/components/Editor/plugins/HorizontalRulePlugin.d.ts +8 -0
  77. package/lib/esm/components/Editor/plugins/HorizontalRulePlugin.js +30 -0
  78. package/lib/esm/components/Editor/plugins/LexicalRichTextPlugin.d.ts +2 -2
  79. package/lib/esm/components/Editor/plugins/LexicalRichTextPlugin.js +1 -1
  80. package/lib/esm/components/Editor/plugins/ToolbarPlugin.js +1 -1
  81. package/lib/esm/components/Event/Event.js +6 -3
  82. package/lib/esm/components/EventForm/EventForm.js +8 -6
  83. package/lib/esm/components/EventHeader/EventHeader.js +1 -1
  84. package/lib/esm/components/EventMediaWidget/EventMediaWidget.js +2 -2
  85. package/lib/esm/components/EventMembersWidget/EventMembersWidget.js +12 -12
  86. package/lib/esm/components/EventMembersWidget/TabContentComponent.js +10 -10
  87. package/lib/esm/components/EventMembersWidget/types.d.ts +4 -5
  88. package/lib/esm/components/EventMembersWidget/types.js +6 -6
  89. package/lib/esm/components/EventParticipantsButton/EventParticipantsButton.js +5 -5
  90. package/lib/esm/components/Events/Events.d.ts +11 -0
  91. package/lib/esm/components/Events/Events.js +22 -11
  92. package/lib/esm/components/Events/OngoingEventsFilter.d.ts +8 -0
  93. package/lib/esm/components/Events/OngoingEventsFilter.js +21 -0
  94. package/lib/esm/components/FeedObject/Activities/Activities.js +1 -1
  95. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +1 -1
  96. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +1 -1
  97. package/lib/esm/components/LiveStreamForm/LiveStreamForm.js +67 -8
  98. package/lib/esm/components/LiveStreamForm/LiveStreamFormSettings.js +8 -3
  99. package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.js +8 -6
  100. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +3 -1
  101. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.d.ts +2 -1
  102. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.js +2 -2
  103. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.d.ts +9 -0
  104. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.js +103 -0
  105. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.d.ts +4 -0
  106. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.js +34 -0
  107. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
  108. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
  109. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +3 -2
  110. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +45 -2
  111. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +64 -9
  112. package/lib/esm/components/NavigationToolbar/NavigationToolbar.d.ts +1 -1
  113. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +2 -2
  114. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -1
  115. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +4 -4
  116. package/lib/esm/components/SearchDialog/SearchDialog.d.ts +4 -1
  117. package/lib/esm/components/SearchDialog/SearchDialog.js +2 -2
  118. package/lib/esm/constants/LiveStream.d.ts +1 -0
  119. package/lib/esm/constants/LiveStream.js +1 -0
  120. package/lib/esm/shared/EventActionsMenu/index.js +6 -2
  121. package/lib/esm/shared/UpScalingTierBadge/index.js +9 -0
  122. package/lib/esm/utils/buttonCounters.d.ts +1 -0
  123. package/lib/esm/utils/buttonCounters.js +3 -2
  124. package/lib/esm/utils/contribution.js +1 -2
  125. package/lib/esm/utils/events.d.ts +1 -0
  126. package/lib/esm/utils/events.js +4 -0
  127. package/lib/umd/239.js +2 -0
  128. package/lib/umd/react-ui.js +1 -1
  129. package/package.json +13 -12
  130. package/lib/umd/653.js +0 -2
  131. /package/lib/umd/{653.js.LICENSE.txt → 239.js.LICENSE.txt} +0 -0
@@ -13,6 +13,12 @@ const ParticipantTileAvatar_1 = tslib_1.__importDefault(require("./ParticipantTi
13
13
  const react_1 = require("react");
14
14
  const TrackToggle_1 = require("./TrackToggle");
15
15
  const LiveStreamProvider_1 = require("./LiveStreamProvider");
16
+ const track_processors_1 = require("@livekit/track-processors");
17
+ const LiveStreamSettingsMenu_1 = tslib_1.__importDefault(require("./LiveStreamSettingsMenu"));
18
+ const utils_1 = require("@selfcommunity/utils");
19
+ const LiveStream_1 = require("../../../constants/LiveStream");
20
+ const react_intl_1 = require("react-intl");
21
+ const notistack_1 = require("notistack");
16
22
  /** @alpha */
17
23
  function usePreviewTracks(options, onError) {
18
24
  const [tracks, setTracks] = React.useState();
@@ -157,7 +163,8 @@ exports.usePreviewDevice = usePreviewDevice;
157
163
  * @public
158
164
  */
159
165
  function PreJoin(_a) {
160
- var { defaults = {}, onValidate, onSubmit, onError, debug, joinLabel = 'Join Room', micLabel = 'Microphone', camLabel = 'Camera', userLabel = 'Username', persistUserChoices = true } = _a, htmlProps = tslib_1.__rest(_a, ["defaults", "onValidate", "onSubmit", "onError", "debug", "joinLabel", "micLabel", "camLabel", "userLabel", "persistUserChoices"]);
166
+ var _b;
167
+ var { defaults = {}, onValidate, onSubmit, onError, debug, joinLabel = 'Join Room', micLabel = 'Microphone', camLabel = 'Camera', userLabel = 'Username', persistUserChoices = true, videoProcessor } = _a, htmlProps = tslib_1.__rest(_a, ["defaults", "onValidate", "onSubmit", "onError", "debug", "joinLabel", "micLabel", "camLabel", "userLabel", "persistUserChoices", "videoProcessor"]);
161
168
  const { liveStream } = (0, LiveStreamProvider_1.useLiveStream)();
162
169
  const scUserContext = (0, react_core_1.useSCUser)();
163
170
  const [userChoices, setUserChoices] = React.useState(components_core_2.defaultUserChoices);
@@ -170,12 +177,16 @@ function PreJoin(_a) {
170
177
  preventSave: !persistUserChoices,
171
178
  preventLoad: !persistUserChoices
172
179
  });
180
+ const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
173
181
  // Initialize device settings
174
182
  const [audioEnabled, setAudioEnabled] = React.useState(initialUserChoices.audioEnabled && canUseAudio);
175
183
  const [videoEnabled, setVideoEnabled] = React.useState(initialUserChoices.videoEnabled && canUseVideo);
176
184
  const [audioDeviceId, setAudioDeviceId] = React.useState(initialUserChoices.audioDeviceId);
177
185
  const [videoDeviceId, setVideoDeviceId] = React.useState(initialUserChoices.videoDeviceId);
178
186
  const [username, setUsername] = React.useState(initialUserChoices.username);
187
+ // Processors
188
+ const [blurEnabled, setBlurEnabled] = React.useState((0, utils_1.isClientSideRendering)() ? ((_b = window === null || window === void 0 ? void 0 : window.localStorage) === null || _b === void 0 ? void 0 : _b.getItem(LiveStream_1.CHOICE_VIDEO_BLUR_EFFECT)) === 'true' : false);
189
+ const [processorPending, setProcessorPending] = React.useState(false);
179
190
  // Save user choices to persistent storage.
180
191
  React.useEffect(() => {
181
192
  saveAudioInputEnabled(audioEnabled && canUseAudio);
@@ -230,6 +241,12 @@ function PreJoin(_a) {
230
241
  ((values.videoEnabled && values.videoDeviceId) || !values.videoEnabled));
231
242
  }
232
243
  }, [onValidate]);
244
+ const handleBlur = React.useCallback(() => {
245
+ var _a;
246
+ const _blur = !blurEnabled;
247
+ setBlurEnabled(_blur);
248
+ (_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.setItem(LiveStream_1.CHOICE_VIDEO_BLUR_EFFECT, _blur.toString());
249
+ }, [setBlurEnabled, blurEnabled]);
233
250
  (0, react_1.useEffect)(() => {
234
251
  const newUserChoices = {
235
252
  username,
@@ -241,6 +258,32 @@ function PreJoin(_a) {
241
258
  setUserChoices(newUserChoices);
242
259
  setIsValid(handleValidation(newUserChoices));
243
260
  }, [username, scUserContext.user, videoEnabled, handleValidation, audioEnabled, audioDeviceId, videoDeviceId]);
261
+ (0, react_1.useEffect)(() => {
262
+ var _a;
263
+ if (videoTrack && videoEnabled) {
264
+ setProcessorPending(true);
265
+ try {
266
+ if (blurEnabled && !videoTrack.getProcessor()) {
267
+ videoTrack.setProcessor((0, track_processors_1.BackgroundBlur)(20));
268
+ }
269
+ else if (!blurEnabled) {
270
+ videoTrack.stopProcessor();
271
+ }
272
+ }
273
+ catch (e) {
274
+ console.log(e);
275
+ setBlurEnabled(false);
276
+ (_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.setItem(LiveStream_1.CHOICE_VIDEO_BLUR_EFFECT, false.toString());
277
+ enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamRoom.errorApplyVideoEffect", defaultMessage: "ui.contributionActionMenu.errorApplyVideoEffect" }), {
278
+ variant: 'warning',
279
+ autoHideDuration: 3000
280
+ });
281
+ }
282
+ finally {
283
+ setProcessorPending(false);
284
+ }
285
+ }
286
+ }, [blurEnabled, videoTrack, videoEnabled]);
244
287
  function handleSubmit(event) {
245
288
  event.preventDefault();
246
289
  if (handleValidation(userChoices)) {
@@ -252,6 +295,6 @@ function PreJoin(_a) {
252
295
  components_core_1.log.warn('Validation failed with: ', userChoices);
253
296
  }
254
297
  }
255
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-prejoin" }, htmlProps, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-video-container" }, { children: [videoTrack && (0, jsx_runtime_1.jsx)("video", { ref: videoEl, width: "1280", height: "720", "data-lk-facing-mode": facingMode }), (!videoTrack || !videoEnabled) && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-camera-off-note" }, { children: (0, jsx_runtime_1.jsx)(ParticipantTileAvatar_1.default, { user: scUserContext.user }) })))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-button-group-container" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-button-group audio" }, { children: [(0, jsx_runtime_1.jsx)(TrackToggle_1.TrackToggle, Object.assign({ disabled: !canUseAudio, initialState: audioEnabled, source: livekit_client_1.Track.Source.Microphone, onChange: (enabled) => setAudioEnabled(enabled) }, { children: micLabel })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-button-group-menu" }, { children: (0, jsx_runtime_1.jsx)(components_react_1.MediaDeviceMenu, { initialSelection: audioDeviceId, kind: "audioinput", disabled: !audioTrack || !canUseAudio || !audioEnabled, tracks: { audioinput: audioTrack }, onActiveDeviceChange: (_, id) => setAudioDeviceId(id) }) }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-button-group video" }, { children: [(0, jsx_runtime_1.jsx)(TrackToggle_1.TrackToggle, Object.assign({ disabled: !canUseVideo, initialState: videoEnabled, source: livekit_client_1.Track.Source.Camera, onChange: (enabled) => setVideoEnabled(enabled) }, { children: camLabel })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-button-group-menu" }, { children: (0, jsx_runtime_1.jsx)(components_react_1.MediaDeviceMenu, { initialSelection: videoDeviceId, kind: "videoinput", disabled: !videoTrack || !canUseVideo || !videoEnabled, tracks: { videoinput: videoTrack }, onActiveDeviceChange: (_, id) => setVideoDeviceId(id) }) }))] }))] })), (0, jsx_runtime_1.jsx)("form", Object.assign({ className: "lk-username-container" }, { children: (0, jsx_runtime_1.jsx)("button", Object.assign({ className: "lk-button lk-join-button", type: "submit", onClick: handleSubmit, disabled: !isValid || error }, { children: joinLabel })) })), debug && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("strong", { children: "User Choices:" }), (0, jsx_runtime_1.jsxs)("ul", Object.assign({ className: "lk-list", style: { overflow: 'hidden', maxWidth: '15rem' } }, { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Username: ", `${userChoices.username}`] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Video Enabled: ", `${userChoices.videoEnabled}`] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Audio Enabled: ", `${userChoices.audioEnabled}`] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Video Device: ", `${userChoices.videoDeviceId}`] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Audio Device: ", `${userChoices.audioDeviceId}`] })] }))] }))] })));
298
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-prejoin" }, htmlProps, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-video-container" }, { children: [videoTrack && (0, jsx_runtime_1.jsx)("video", { ref: videoEl, width: "1280", height: "720", "data-lk-facing-mode": facingMode }), (!videoTrack || !videoEnabled) && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-camera-off-note" }, { children: (0, jsx_runtime_1.jsx)(ParticipantTileAvatar_1.default, { user: scUserContext.user }) })))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-button-group-container" }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-button-group audio" }, { children: [(0, jsx_runtime_1.jsx)(TrackToggle_1.TrackToggle, Object.assign({ disabled: !canUseAudio, initialState: audioEnabled, source: livekit_client_1.Track.Source.Microphone, onChange: (enabled) => setAudioEnabled(enabled) }, { children: micLabel })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-button-group-menu" }, { children: (0, jsx_runtime_1.jsx)(components_react_1.MediaDeviceMenu, { initialSelection: audioDeviceId, kind: "audioinput", disabled: !audioTrack || !canUseAudio || !audioEnabled, tracks: { audioinput: audioTrack }, onActiveDeviceChange: (_, id) => setAudioDeviceId(id) }) }))] })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-button-group video" }, { children: [(0, jsx_runtime_1.jsx)(TrackToggle_1.TrackToggle, Object.assign({ disabled: !canUseVideo, initialState: videoEnabled, source: livekit_client_1.Track.Source.Camera, onChange: (enabled) => setVideoEnabled(enabled) }, { children: camLabel })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-button-group-menu" }, { children: (0, jsx_runtime_1.jsx)(components_react_1.MediaDeviceMenu, { initialSelection: videoDeviceId, kind: "videoinput", disabled: !videoTrack || !canUseVideo || !videoEnabled, tracks: { videoinput: videoTrack }, onActiveDeviceChange: (_, id) => setVideoDeviceId(id) }) }))] })), (0, jsx_runtime_1.jsx)(LiveStreamSettingsMenu_1.default, { actionBlurDisabled: !canUseVideo || !videoEnabled, blurEnabled: blurEnabled, handleBlur: handleBlur })] })), (0, jsx_runtime_1.jsx)("form", Object.assign({ className: "lk-username-container" }, { children: (0, jsx_runtime_1.jsx)("button", Object.assign({ className: "lk-button lk-join-button", type: "submit", onClick: handleSubmit, disabled: !isValid || error }, { children: joinLabel })) })), debug && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("strong", { children: "User Choices:" }), (0, jsx_runtime_1.jsxs)("ul", Object.assign({ className: "lk-list", style: { overflow: 'hidden', maxWidth: '15rem' } }, { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Username: ", `${userChoices.username}`] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Video Enabled: ", `${userChoices.videoEnabled}`] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Audio Enabled: ", `${userChoices.audioEnabled}`] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Video Device: ", `${userChoices.videoDeviceId}`] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Audio Device: ", `${userChoices.audioDeviceId}`] })] }))] }))] })));
256
299
  }
257
300
  exports.PreJoin = PreJoin;
@@ -17,6 +17,14 @@ const classnames_1 = tslib_1.__importDefault(require("classnames"));
17
17
  const styles_1 = require("@mui/material/styles");
18
18
  const material_1 = require("@mui/material");
19
19
  const system_1 = require("@mui/system");
20
+ const NoParticipants_1 = tslib_1.__importDefault(require("./NoParticipants"));
21
+ const LiveStreamSettingsMenu_1 = tslib_1.__importDefault(require("./LiveStreamSettingsMenu"));
22
+ const track_processors_1 = require("@livekit/track-processors");
23
+ const utils_1 = require("@selfcommunity/utils");
24
+ const LiveStream_1 = require("../../../constants/LiveStream");
25
+ const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
26
+ const notistack_1 = require("notistack");
27
+ const react_intl_1 = require("react-intl");
20
28
  const PREFIX = 'SCVideoConference';
21
29
  const classes = {
22
30
  root: `${PREFIX}-root`
@@ -37,7 +45,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
37
45
  *
38
46
  */
39
47
  function VideoConference(inProps) {
40
- var _a, _b;
48
+ var _a, _b, _c;
41
49
  // PROPS
42
50
  const props = (0, system_1.useThemeProps)({
43
51
  props: inProps,
@@ -54,15 +62,35 @@ function VideoConference(inProps) {
54
62
  const lastAutoFocusedScreenShareTrack = React.useRef(null);
55
63
  // HOOKS
56
64
  const scUserContext = (0, react_core_1.useSCUser)();
65
+ const [blurEnabled, setBlurEnabled] = React.useState((0, utils_1.isClientSideRendering)() ? ((_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.getItem(LiveStream_1.CHOICE_VIDEO_BLUR_EFFECT)) === 'true' : false);
66
+ const [processorPending, setProcessorPending] = React.useState(false);
57
67
  const tracks = (0, components_react_1.useTracks)([
58
68
  { source: livekit_client_1.Track.Source.Camera, withPlaceholder: true },
59
69
  { source: livekit_client_1.Track.Source.ScreenShare, withPlaceholder: false }
60
70
  ], { updateOnlyOn: [livekit_client_1.RoomEvent.ActiveSpeakersChanged], onlySubscribed: false });
71
+ const tracksNoParticipants = (0, react_1.useMemo)(() => tracks.filter((t) => t.participant.name === scUserContext.user.username || t.participant.name === speakerFocused.username || t.source === 'screen_share'), [tracks, scUserContext.user]);
72
+ const handleBlur = React.useCallback((event) => {
73
+ var _a, _b;
74
+ if (event.target) {
75
+ if ('checked' in event.target) {
76
+ setBlurEnabled((_a = event.target) === null || _a === void 0 ? void 0 : _a.checked);
77
+ }
78
+ else {
79
+ setBlurEnabled((enabled) => !enabled);
80
+ }
81
+ }
82
+ else {
83
+ setBlurEnabled((enabled) => !enabled);
84
+ }
85
+ (_b = window === null || window === void 0 ? void 0 : window.localStorage) === null || _b === void 0 ? void 0 : _b.setItem(LiveStream_1.CHOICE_VIDEO_BLUR_EFFECT, (!blurEnabled).toString());
86
+ }, [setBlurEnabled, blurEnabled]);
61
87
  const participants = (0, components_react_1.useParticipants)();
62
88
  const layoutContext = (0, components_react_1.useCreateLayoutContext)();
63
89
  const screenShareTracks = tracks.filter(components_core_1.isTrackReference).filter((track) => track.publication.source === livekit_client_1.Track.Source.ScreenShare);
64
- const focusTrack = (_a = (0, components_react_1.usePinnedTracks)(layoutContext)) === null || _a === void 0 ? void 0 : _a[0];
90
+ const focusTrack = (_b = (0, components_react_1.usePinnedTracks)(layoutContext)) === null || _b === void 0 ? void 0 : _b[0];
65
91
  const carouselTracks = tracks.filter((track) => !(0, components_core_1.isEqualTrackRef)(track, focusTrack));
92
+ const { cameraTrack } = (0, components_react_1.useLocalParticipant)();
93
+ const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
66
94
  (0, useLiveStreamCheck_1.useLivestreamCheck)();
67
95
  /**
68
96
  * widgetUpdate
@@ -118,7 +146,7 @@ function VideoConference(inProps) {
118
146
  }
119
147
  }, [
120
148
  screenShareTracks.map((ref) => `${ref.publication.trackSid}_${ref.publication.isSubscribed}`).join(),
121
- (_b = focusTrack === null || focusTrack === void 0 ? void 0 : focusTrack.publication) === null || _b === void 0 ? void 0 : _b.trackSid,
149
+ (_c = focusTrack === null || focusTrack === void 0 ? void 0 : focusTrack.publication) === null || _c === void 0 ? void 0 : _c.trackSid,
122
150
  tracks,
123
151
  participants,
124
152
  speakerFocused
@@ -141,11 +169,38 @@ function VideoConference(inProps) {
141
169
  }
142
170
  }
143
171
  }, [tracks, participants, speakerFocused]);
144
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root, 'lk-video-conference') }, rest, { children: [(0, components_core_1.isWeb)() && ((0, jsx_runtime_1.jsxs)(components_react_1.LayoutContextProvider, Object.assign({ value: layoutContext, onPinChange: handleFocusStateChange, onWidgetChange: widgetUpdate }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-video-conference-inner" }, { children: [!focusTrack ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-grid-layout-wrapper" }, { children: (0, jsx_runtime_1.jsx)(components_react_1.GridLayout, Object.assign({ tracks: tracks }, { children: (0, jsx_runtime_1.jsx)(ParticipantTile_1.ParticipantTile, {}) })) }))) : ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-focus-layout-wrapper" }, { children: hideParticipantsList ? ((0, jsx_runtime_1.jsx)(FocusLayout_1.FocusLayoutContainerNoParticipants, { children: focusTrack && (0, jsx_runtime_1.jsx)(FocusLayout_1.FocusLayout, { trackRef: focusTrack }) })) : ((0, jsx_runtime_1.jsxs)(FocusLayout_1.FocusLayoutContainer, { children: [(0, jsx_runtime_1.jsx)(components_react_1.CarouselLayout, Object.assign({ tracks: carouselTracks }, { children: (0, jsx_runtime_1.jsx)(ParticipantTile_1.ParticipantTile, {}) })), focusTrack && (0, jsx_runtime_1.jsx)(FocusLayout_1.FocusLayout, { trackRef: focusTrack })] })) }))), (0, jsx_runtime_1.jsx)(ControlBar_1.ControlBar, { controls: Object.assign({
172
+ (0, react_1.useEffect)(() => {
173
+ var _a;
174
+ const localCamTrack = cameraTrack === null || cameraTrack === void 0 ? void 0 : cameraTrack.track;
175
+ if (localCamTrack) {
176
+ setProcessorPending(true);
177
+ try {
178
+ if (blurEnabled && !localCamTrack.getProcessor()) {
179
+ localCamTrack.setProcessor((0, track_processors_1.BackgroundBlur)(20));
180
+ }
181
+ else if (!blurEnabled) {
182
+ localCamTrack.stopProcessor();
183
+ }
184
+ }
185
+ catch (e) {
186
+ console.log(e);
187
+ setBlurEnabled(false);
188
+ (_a = window === null || window === void 0 ? void 0 : window.localStorage) === null || _a === void 0 ? void 0 : _a.setItem(LiveStream_1.CHOICE_VIDEO_BLUR_EFFECT, false.toString());
189
+ enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamRoom.errorApplyVideoEffect", defaultMessage: "ui.contributionActionMenu.errorApplyVideoEffect" }), {
190
+ variant: 'warning',
191
+ autoHideDuration: 3000
192
+ });
193
+ }
194
+ finally {
195
+ setProcessorPending(false);
196
+ }
197
+ }
198
+ }, [blurEnabled, cameraTrack]);
199
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root, 'lk-video-conference') }, rest, { children: [(0, components_core_1.isWeb)() && ((0, jsx_runtime_1.jsxs)(components_react_1.LayoutContextProvider, Object.assign({ value: layoutContext, onPinChange: handleFocusStateChange, onWidgetChange: widgetUpdate }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-video-conference-inner" }, { children: [!focusTrack ? ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-grid-layout-wrapper" }, { children: (0, jsx_runtime_1.jsx)(components_react_1.GridLayout, Object.assign({ tracks: hideParticipantsList ? tracksNoParticipants : tracks }, { children: (0, jsx_runtime_1.jsx)(ParticipantTile_1.ParticipantTile, {}) })) }))) : ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-focus-layout-wrapper" }, { children: hideParticipantsList ? ((0, jsx_runtime_1.jsx)(FocusLayout_1.FocusLayoutContainerNoParticipants, { children: focusTrack && (0, jsx_runtime_1.jsx)(FocusLayout_1.FocusLayout, { trackRef: focusTrack }) })) : ((0, jsx_runtime_1.jsxs)(FocusLayout_1.FocusLayoutContainer, { children: [carouselTracks.length ? ((0, jsx_runtime_1.jsx)(components_react_1.CarouselLayout, Object.assign({ tracks: carouselTracks }, { children: (0, jsx_runtime_1.jsx)(ParticipantTile_1.ParticipantTile, {}) }))) : ((0, jsx_runtime_1.jsx)(NoParticipants_1.default, {})), focusTrack && (0, jsx_runtime_1.jsx)(FocusLayout_1.FocusLayout, { trackRef: focusTrack })] })) }))), (0, jsx_runtime_1.jsx)(ControlBar_1.ControlBar, { controls: Object.assign({
145
200
  chat: !disableChat,
146
201
  microphone: !disableMicrophone,
147
202
  camera: !disableCamera,
148
203
  screenShare: !disableShareScreen
149
- }, { settings: !!SettingsComponent }) })] })), !disableChat && ((0, jsx_runtime_1.jsx)(components_react_1.Chat, { style: { display: widgetState.showChat ? 'grid' : 'none' }, messageFormatter: chatMessageFormatter, messageEncoder: chatMessageEncoder, messageDecoder: chatMessageDecoder })), SettingsComponent && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-settings-menu-modal", style: { display: widgetState.showSettings ? 'block' : 'none' } }, { children: (0, jsx_runtime_1.jsx)(SettingsComponent, {}) })))] }))), (0, jsx_runtime_1.jsx)(components_react_1.RoomAudioRenderer, {}), (0, jsx_runtime_1.jsx)(components_react_1.ConnectionStateToast, {})] })));
204
+ }, { settings: true }) })] })), !disableChat && ((0, jsx_runtime_1.jsx)(components_react_1.Chat, { style: { display: widgetState.showChat ? 'grid' : 'none' }, messageFormatter: chatMessageFormatter, messageEncoder: chatMessageEncoder, messageDecoder: chatMessageDecoder })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-settings-menu-modal", style: { display: widgetState.showSettings ? 'block' : 'none' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: "lk-settings-menu-modal-icon-close", onClick: () => { var _a, _b; return (_b = layoutContext === null || layoutContext === void 0 ? void 0 : (_a = layoutContext.widget).dispatch) === null || _b === void 0 ? void 0 : _b.call(_a, { msg: 'toggle_settings' }); } }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "close" }) })), SettingsComponent ? ((0, jsx_runtime_1.jsx)(SettingsComponent, {})) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(LiveStreamSettingsMenu_1.default, { onlyContentMenu: true, actionBlurDisabled: !cameraTrack && !disableCamera, blurEnabled: blurEnabled, handleBlur: handleBlur }) }))] }))] }))), (0, jsx_runtime_1.jsx)(components_react_1.RoomAudioRenderer, {}), (0, jsx_runtime_1.jsx)(components_react_1.ConnectionStateToast, {})] })));
150
205
  }
151
206
  exports.VideoConference = VideoConference;
@@ -17,7 +17,7 @@ export interface NavigationToolbarProps extends ToolbarProps {
17
17
  /**
18
18
  * Searchbar props
19
19
  */
20
- SearchAutocompleteProps?: SearchAutocompleteProps;
20
+ SearchAutocompleteComponentProps?: SearchAutocompleteProps;
21
21
  /**
22
22
  * The navigation path
23
23
  */
@@ -98,7 +98,7 @@ function NavigationToolbar(inProps) {
98
98
  props: inProps,
99
99
  name: constants_1.PREFIX
100
100
  });
101
- const { value = '', className = '', disableSearch = false, disableComposer = false, SearchAutocompleteProps = {}, startActions = null, endActions = null, NavigationSettingsIconButtonComponent = NavigationSettingsIconButton_1.default, NavigationMenuIconButtonComponentProps = {}, NavigationMenuIconButtonComponent = NavigationMenuIconButton_1.default, children = null, NotificationMenuProps = {}, ComposerIconButtonProps = {}, onOpenNotificationMenu, onCloseNotificationMenu } = props, rest = tslib_1.__rest(props, ["value", "className", "disableSearch", "disableComposer", "SearchAutocompleteProps", "startActions", "endActions", "NavigationSettingsIconButtonComponent", "NavigationMenuIconButtonComponentProps", "NavigationMenuIconButtonComponent", "children", "NotificationMenuProps", "ComposerIconButtonProps", "onOpenNotificationMenu", "onCloseNotificationMenu"]);
101
+ const { value = '', className = '', disableSearch = false, disableComposer = false, SearchAutocompleteComponentProps = {}, startActions = null, endActions = null, NavigationSettingsIconButtonComponent = NavigationSettingsIconButton_1.default, NavigationMenuIconButtonComponentProps = {}, NavigationMenuIconButtonComponent = NavigationMenuIconButton_1.default, children = null, NotificationMenuProps = {}, ComposerIconButtonProps = {}, onOpenNotificationMenu, onCloseNotificationMenu } = props, rest = tslib_1.__rest(props, ["value", "className", "disableSearch", "disableComposer", "SearchAutocompleteComponentProps", "startActions", "endActions", "NavigationSettingsIconButtonComponent", "NavigationMenuIconButtonComponentProps", "NavigationMenuIconButtonComponent", "children", "NotificationMenuProps", "ComposerIconButtonProps", "onOpenNotificationMenu", "onCloseNotificationMenu"]);
102
102
  // CONTEXT
103
103
  const scUserContext = (0, react_core_1.useSCUser)();
104
104
  const scRoutingContext = (0, react_core_1.useSCRouting)();
@@ -148,7 +148,7 @@ function NavigationToolbar(inProps) {
148
148
  }), "aria-label": "Groups", to: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), component: react_core_1.Link }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "groups" }) }))), eventsEnabled && (scUserContext.user || preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY]) && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: (0, classnames_1.default)(classes.events, {
149
149
  [classes.active]: value.startsWith(scRoutingContext.url(react_core_1.SCRoutes.EVENTS_ROUTE_NAME, {}))
150
150
  }), "aria-label": "Events", to: scRoutingContext.url(react_core_1.SCRoutes.EVENTS_ROUTE_NAME, {}), component: react_core_1.Link }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "CalendarIcon" }) })))] })));
151
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: [(0, jsx_runtime_1.jsx)(NavigationMenuIconButtonComponent, Object.assign({}, NavigationMenuIconButtonComponentProps)), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.HOME_ROUTE_NAME, {}), className: classes.logo }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.LOGO_NAVBAR_LOGO], alt: "logo" }) })), !scUserContext.user && !preferences[react_core_1.SCPreferences.ADDONS_CLOSED_COMMUNITY] && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "inherit", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.SIGNUP_ROUTE_NAME, {}), className: classes.register }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.appBar.navigation.register", defaultMessage: "ui.appBar.navigation.register" }) }))), preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED] && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ target: "blank", to: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) })) }))) : ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ target: "blank", to: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) }))) })), _children, (preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY] || scUserContext.user) && !disableSearch ? ((0, jsx_runtime_1.jsx)(SearchAutocomplete_1.default, Object.assign({ className: classes.search, blurOnSelect: true }, SearchAutocompleteProps))) : ((0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.search })), startActions, scUserContext.user ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showComposer && (0, jsx_runtime_1.jsx)(ComposerIconButton_1.default, Object.assign({ className: classes.composer }, ComposerIconButtonProps)), (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: scUserContext.user.username }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scUserContext.user), "aria-label": "Profile", className: classes.profile }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: scUserContext.user.username, src: scUserContext.user.avatar }) })) })), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: (0, classnames_1.default)(classes.notification, {
151
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: [(0, jsx_runtime_1.jsx)(NavigationMenuIconButtonComponent, Object.assign({}, NavigationMenuIconButtonComponentProps)), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.HOME_ROUTE_NAME, {}), className: classes.logo }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.LOGO_NAVBAR_LOGO], alt: "logo" }) })), !scUserContext.user && !preferences[react_core_1.SCPreferences.ADDONS_CLOSED_COMMUNITY] && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "inherit", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.SIGNUP_ROUTE_NAME, {}), className: classes.register }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.appBar.navigation.register", defaultMessage: "ui.appBar.navigation.register" }) }))), preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED] && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ target: "blank", to: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) })) }))) : ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ target: "blank", to: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) }))) })), _children, (preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY] || scUserContext.user) && !disableSearch ? ((0, jsx_runtime_1.jsx)(SearchAutocomplete_1.default, Object.assign({ className: classes.search, blurOnSelect: true }, SearchAutocompleteComponentProps))) : ((0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.search })), startActions, scUserContext.user ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showComposer && (0, jsx_runtime_1.jsx)(ComposerIconButton_1.default, Object.assign({ className: classes.composer }, ComposerIconButtonProps)), (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: scUserContext.user.username }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scUserContext.user), "aria-label": "Profile", className: classes.profile }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: scUserContext.user.username, src: scUserContext.user.avatar }) })) })), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: (0, classnames_1.default)(classes.notification, {
152
152
  [classes.active]: value.startsWith(scRoutingContext.url(react_core_1.SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}))
153
153
  }), "aria-label": "Notification", onClick: handleOpenNotificationMenu }, { children: (0, jsx_runtime_1.jsx)(material_1.Badge, Object.assign({ badgeContent: scUserContext.user.unseen_notification_banners_counter + scUserContext.user.unseen_interactions_counter, color: "secondary" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_active" }) })) })), Boolean(anchorNotification) && ((0, jsx_runtime_1.jsx)(NotificationMenu_1.default, Object.assign({ className: classes.notificationsMenu, id: "notification-menu", anchorEl: anchorNotification, open: true, onClose: handleCloseNotificationMenu, onClick: handleCloseNotificationMenu, transformOrigin: { horizontal: 'right', vertical: 'top' }, anchorOrigin: { horizontal: 'right', vertical: 'bottom' } }, NotificationMenuProps)))] }), privateMessagingEnabled && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: (0, classnames_1.default)(classes.messages, {
154
154
  [classes.active]: value.startsWith(scRoutingContext.url(react_core_1.SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, {}))
@@ -16,7 +16,7 @@ export interface NavigationToolbarMobileProps extends ToolbarProps {
16
16
  /**
17
17
  * Props spread to SearchAutocomplete component
18
18
  */
19
- SearchAutocompleteProps?: SearchAutocompleteProps;
19
+ SearchAutocompleteComponentProps?: SearchAutocompleteProps;
20
20
  /**
21
21
  * Actions to be inserted before composer IconButton
22
22
  */
@@ -71,7 +71,7 @@ function NavigationToolbarMobile(inProps) {
71
71
  props: inProps,
72
72
  name: constants_1.PREFIX
73
73
  });
74
- const { className = '', disableSearch = false, preserveDesktopLogo = false, SearchAutocompleteProps = {}, children = null, startActions = null, endActions = null, NavigationMenuIconButtonComponent = NavigationMenuIconButton_1.default, NavigationSettingsIconButtonComponent = NavigationSettingsIconButton_1.default, ComposerIconButtonProps = {} } = props, rest = tslib_1.__rest(props, ["className", "disableSearch", "preserveDesktopLogo", "SearchAutocompleteProps", "children", "startActions", "endActions", "NavigationMenuIconButtonComponent", "NavigationSettingsIconButtonComponent", "ComposerIconButtonProps"]);
74
+ const { className = '', disableSearch = false, preserveDesktopLogo = false, SearchAutocompleteComponentProps = {}, children = null, startActions = null, endActions = null, NavigationMenuIconButtonComponent = NavigationMenuIconButton_1.default, NavigationSettingsIconButtonComponent = NavigationSettingsIconButton_1.default, ComposerIconButtonProps = {} } = props, rest = tslib_1.__rest(props, ["className", "disableSearch", "preserveDesktopLogo", "SearchAutocompleteComponentProps", "children", "startActions", "endActions", "NavigationMenuIconButtonComponent", "NavigationSettingsIconButtonComponent", "ComposerIconButtonProps"]);
75
75
  // CONTEXT
76
76
  const scUserContext = (0, react_core_1.useSCUser)();
77
77
  const scRoutingContext = (0, react_core_1.useSCRouting)();
@@ -98,10 +98,10 @@ function NavigationToolbarMobile(inProps) {
98
98
  // HANDLERS
99
99
  const handleOpenSearch = (0, react_1.useCallback)(() => {
100
100
  setSearchOpen(true);
101
- }, []);
101
+ }, [setSearchOpen]);
102
102
  const handleCloseSearch = (0, react_1.useCallback)(() => {
103
103
  setSearchOpen(false);
104
- }, []);
104
+ }, [setSearchOpen]);
105
105
  // RENDER
106
106
  if (scUserContext.loading) {
107
107
  return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
@@ -109,7 +109,7 @@ function NavigationToolbarMobile(inProps) {
109
109
  const _children = children || ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(NavigationMenuIconButtonComponent, {}), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.HOME_ROUTE_NAME, {}), className: (0, classnames_1.default)(className, classes.logo, {
110
110
  [classes.logoFlex]: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL].value
111
111
  }) }, { children: !preserveDesktopLogo ? ((0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.LOGO_NAVBAR_LOGO_MOBILE].value, alt: "logo" })) : ((0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.LOGO_NAVBAR_LOGO].value, alt: "logo" })) })), preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED].value && ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ target: "blank", to: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL].value, className: classes.customItem }, { children: (0, jsx_runtime_1.jsx)("img", { src: preferences[react_core_1.SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE].value, alt: "custom_item" }) })))] }));
112
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: [_children, startActions, (contentAvailable || scUserContext.user) && !disableSearch && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.search, onClick: handleOpenSearch }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "search" }) })), (0, jsx_runtime_1.jsx)(SearchDialog_1.default, { className: classes.searchDialog, fullScreen: true, open: searchOpen, SearchAutocompleteProps: Object.assign(Object.assign({}, SearchAutocompleteProps), { onClear: handleCloseSearch }) })] })), endActions, (!postOnlyStaffEnabled || (react_core_1.UserUtils.isStaff(scUserContext.user) && postOnlyStaffEnabled)) &&
112
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: [_children, startActions, (contentAvailable || scUserContext.user) && !disableSearch && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.search, onClick: handleOpenSearch }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "search" }) })), (0, jsx_runtime_1.jsx)(SearchDialog_1.default, { className: classes.searchDialog, fullScreen: true, open: searchOpen, SearchAutocompleteComponentProps: Object.assign(Object.assign({}, SearchAutocompleteComponentProps), { onClear: handleCloseSearch }) })] })), endActions, (!postOnlyStaffEnabled || (react_core_1.UserUtils.isStaff(scUserContext.user) && postOnlyStaffEnabled)) &&
113
113
  (scUserContext.user || contentAvailable) &&
114
114
  exploreStreamEnabled && (0, jsx_runtime_1.jsx)(ComposerIconButton_1.default, Object.assign({}, ComposerIconButtonProps)), scUserContext.user && (groupsEnabled || eventsEnabled) && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.notifications, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}) }, { children: (0, jsx_runtime_1.jsx)(material_1.Badge, Object.assign({ badgeContent: scUserContext.user.unseen_notification_banners_counter + scUserContext.user.unseen_interactions_counter, color: "secondary" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_active" }) })) }))), scUserContext.user ? ((0, jsx_runtime_1.jsx)(NavigationSettingsIconButtonComponent, { className: classes.settings })) : ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ className: classes.login, color: "inherit", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.SIGNIN_ROUTE_NAME, {}) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.appBar.navigation.login", defaultMessage: "ui.appBar.navigation.login" }) })))] })));
115
115
  }
@@ -6,7 +6,10 @@ export interface SearchDialogProps extends DialogProps {
6
6
  * @default null
7
7
  */
8
8
  className?: string;
9
- SearchAutocompleteProps: SearchAutocompleteProps;
9
+ /**
10
+ * Overrides props for the SearchAutocomplete component.
11
+ */
12
+ SearchAutocompleteComponentProps: SearchAutocompleteProps;
10
13
  /**
11
14
  * Other props
12
15
  */
@@ -30,7 +30,7 @@ function Search(inProps) {
30
30
  props: inProps,
31
31
  name: PREFIX
32
32
  });
33
- const { className, SearchAutocompleteProps = { autoFocus: true } } = props, rest = tslib_1.__rest(props, ["className", "SearchAutocompleteProps"]);
34
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(SearchAutocomplete_1.default, Object.assign({ className: classes.search, blurOnSelect: false, open: true, disablePortal: true }, SearchAutocompleteProps)) }) })));
33
+ const { className, SearchAutocompleteComponentProps = { autoFocus: true } } = props, rest = tslib_1.__rest(props, ["className", "SearchAutocompleteComponentProps"]);
34
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsx)(SearchAutocomplete_1.default, Object.assign({ className: classes.search, blurOnSelect: false, open: true, disablePortal: true }, SearchAutocompleteComponentProps)) }) })));
35
35
  }
36
36
  exports.default = Search;
@@ -1,3 +1,4 @@
1
1
  export declare const LIVE_STREAM_TITLE_MAX_LENGTH = 100;
2
2
  export declare const LIVE_STREAM_SLUG_MAX_LENGTH = 50;
3
3
  export declare const LIVE_STREAM_DESCRIPTION_MAX_LENGTH = 500;
4
+ export declare const CHOICE_VIDEO_BLUR_EFFECT = "lk-video-blur";
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LIVE_STREAM_DESCRIPTION_MAX_LENGTH = exports.LIVE_STREAM_SLUG_MAX_LENGTH = exports.LIVE_STREAM_TITLE_MAX_LENGTH = void 0;
3
+ exports.CHOICE_VIDEO_BLUR_EFFECT = exports.LIVE_STREAM_DESCRIPTION_MAX_LENGTH = exports.LIVE_STREAM_SLUG_MAX_LENGTH = exports.LIVE_STREAM_TITLE_MAX_LENGTH = void 0;
4
4
  exports.LIVE_STREAM_TITLE_MAX_LENGTH = 100;
5
5
  exports.LIVE_STREAM_SLUG_MAX_LENGTH = 50;
6
6
  exports.LIVE_STREAM_DESCRIPTION_MAX_LENGTH = 500;
7
+ exports.CHOICE_VIDEO_BLUR_EFFECT = 'lk-video-blur';
@@ -120,8 +120,12 @@ function EventActionsMenu(inProps) {
120
120
  });
121
121
  }
122
122
  const createGoogleCalendarLink = (event) => {
123
+ var _a;
123
124
  const baseUrl = 'https://www.google.com/calendar/render?action=TEMPLATE';
124
- return `${baseUrl}&text=${encodeURIComponent(event.name)}&details=${encodeURIComponent(event.description)}&location=${encodeURIComponent(event.geolocation)}&dates=${event.start_date}/${event.end_date}`;
125
+ const startDate = (0, events_1.formatDateForGC)(event.start_date);
126
+ const endDate = (0, events_1.formatDateForGC)(event.end_date);
127
+ const details = `${event.description ? event.description + '\n\n' : ''}${event.link ? 'Link: ' + event.link : ''}`;
128
+ return `${baseUrl}&text=${encodeURIComponent(event.name)}&details=${encodeURIComponent(details)}&location=${encodeURIComponent((_a = event.geolocation) !== null && _a !== void 0 ? _a : '')}&dates=${startDate}/${endDate}`;
125
129
  };
126
130
  /**
127
131
  * Handles actions
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const styles_1 = require("@mui/material/styles");
6
6
  const system_1 = require("@mui/system");
7
7
  const react_intl_1 = require("react-intl");
8
+ const react_core_1 = require("@selfcommunity/react-core");
8
9
  const material_1 = require("@mui/material");
9
10
  const react_1 = require("react");
10
11
  const types_1 = require("@selfcommunity/types");
@@ -30,6 +31,11 @@ function UpScalingTierBadge(inProps) {
30
31
  name: PREFIX
31
32
  });
32
33
  const { className, desiredTier = types_1.SCCommunitySubscriptionTier.GO } = props, rest = tslib_1.__rest(props, ["className", "desiredTier"]);
34
+ const { preferences } = (0, react_core_1.useSCPreferences)();
35
+ const isEnterpriseTier = (0, react_1.useMemo)(() => preferences &&
36
+ react_core_1.SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER in preferences &&
37
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value &&
38
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value === types_1.SCCommunitySubscriptionTier.ENTERPRISE, [preferences]);
33
39
  const tooltipMsg = (0, react_1.useMemo)(() => {
34
40
  let _msg = (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.upScalingTierBadge.goFeature", defaultMessage: "ui.upScalingTierBadge.goFeature" });
35
41
  switch (desiredTier) {
@@ -58,6 +64,9 @@ function UpScalingTierBadge(inProps) {
58
64
  }
59
65
  return _label;
60
66
  }, [desiredTier]);
67
+ if (desiredTier === types_1.SCCommunitySubscriptionTier.ENTERPRISE && isEnterpriseTier) {
68
+ return null;
69
+ }
61
70
  return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ classes: { root: (0, classnames_1.default)(className, classes.root) }, title: tooltipMsg, placement: "top" }, rest, { children: (0, jsx_runtime_1.jsx)(Badge, { color: "secondary", size: "small", label: badgeLabel, className: classes.badge }) })));
62
71
  }
63
72
  exports.default = UpScalingTierBadge;
@@ -1 +1,2 @@
1
+ export declare const DEFAULT_COUNTERS_LIMIT = 3;
1
2
  export declare function numberFormatter(num: number): JSX.Element;
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.numberFormatter = void 0;
3
+ exports.numberFormatter = exports.DEFAULT_COUNTERS_LIMIT = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ exports.DEFAULT_COUNTERS_LIMIT = 3;
5
6
  function numberFormatter(num) {
6
- const surplus = num - 3;
7
+ const surplus = num === exports.DEFAULT_COUNTERS_LIMIT ? 1 : num < exports.DEFAULT_COUNTERS_LIMIT ? num : num - exports.DEFAULT_COUNTERS_LIMIT;
7
8
  if (surplus > 999999) {
8
9
  return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", (Math.abs(surplus) / 1000000).toFixed(1), "M"] });
9
10
  }
10
- else if (num > 999) {
11
+ else if (surplus > 999) {
11
12
  return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", (Math.abs(surplus) / 1000).toFixed(1), "K"] });
12
13
  }
13
14
  return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", surplus] });
@@ -57,8 +57,7 @@ exports.getContributionSnippet = getContributionSnippet;
57
57
  * @param handleUrl Func that handle urls
58
58
  */
59
59
  function getContributionHtml(html, handleUrl) {
60
- const _html = html.replace(/<p\b[^>]*>(.*?)<\/p>/g, (match, content) => content);
61
- return _html.replace(/<mention.*? id="([0-9]+)"{1}.*?>@([a-z\d_-]+)<\/mention>/gi, (match, id, username) => {
60
+ return html.replace(/<mention.*? id="([0-9]+)"{1}.*?>@([a-z\d_-]+)<\/mention>/gi, (match, id, username) => {
62
61
  return `<a href='${handleUrl(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, { id, username })}'>@${username}</a>`;
63
62
  });
64
63
  }
@@ -1,2 +1,3 @@
1
1
  import { SCEventType } from '@selfcommunity/types';
2
2
  export declare function checkEventFinished(event: SCEventType | null): boolean;
3
+ export declare function formatDateForGC(eventDate: string): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkEventFinished = void 0;
3
+ exports.formatDateForGC = exports.checkEventFinished = void 0;
4
4
  function checkEventFinished(event) {
5
5
  if (event && !event.running) {
6
6
  return new Date().getTime() > new Date(event.end_date || event.start_date).getTime();
@@ -8,3 +8,8 @@ function checkEventFinished(event) {
8
8
  return false;
9
9
  }
10
10
  exports.checkEventFinished = checkEventFinished;
11
+ function formatDateForGC(eventDate) {
12
+ const date = new Date(eventDate);
13
+ return date.toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z';
14
+ }
15
+ exports.formatDateForGC = formatDateForGC;
@@ -22,6 +22,11 @@ export interface CategoryAutocompleteProps extends Pick<AutocompleteProps<SCCate
22
22
  * @param value
23
23
  */
24
24
  onChange?: (value: any) => void;
25
+ /**
26
+ * Feed API Query Params
27
+ * @default [{'limit': 10, 'offset': 0}]
28
+ */
29
+ endpointQueryParams?: Record<string, string | number | boolean>;
25
30
  }
26
31
  /**
27
32
  * > API documentation for the Community-JS Category Autocomplete component. Learn about the available props and the CSS API.
@@ -49,17 +49,17 @@ const CategoryAutocomplete = (inProps) => {
49
49
  name: PREFIX
50
50
  });
51
51
  // Props
52
- const { onChange, multiple = false, defaultValue = multiple ? [] : null, limitCountCategories = 0, checkboxSelect = false, disabled = false, TextFieldProps = {
52
+ const { onChange, multiple = false, defaultValue = multiple ? [] : null, limitCountCategories = 0, checkboxSelect = false, disabled = false, endpointQueryParams = {}, TextFieldProps = {
53
53
  variant: 'outlined',
54
54
  label: _jsx(FormattedMessage, { id: "ui.categoryAutocomplete.label", defaultMessage: "ui.categoryAutocomplete.label" })
55
- } } = props, rest = __rest(props, ["onChange", "multiple", "defaultValue", "limitCountCategories", "checkboxSelect", "disabled", "TextFieldProps"]);
55
+ } } = props, rest = __rest(props, ["onChange", "multiple", "defaultValue", "limitCountCategories", "checkboxSelect", "disabled", "endpointQueryParams", "TextFieldProps"]);
56
56
  // State
57
57
  const [open, setOpen] = useState(false);
58
58
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
59
59
  // @ts-ignore
60
60
  const [value, setValue] = useState(typeof defaultValue === 'string' ? null : defaultValue);
61
61
  // HOOKS
62
- const { categories, isLoading } = useSCFetchCategories();
62
+ const { categories, isLoading } = useSCFetchCategories({ endpointQueryParams });
63
63
  useEffect(() => {
64
64
  if (value === null) {
65
65
  return;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { BoxProps } from '@mui/material';
3
- import { SCCategoryType } from '@selfcommunity/types/src/index';
3
+ import { SCCategoryType } from '@selfcommunity/types';
4
4
  import { ComposerLayerProps } from '../../../../types/composer';
5
5
  export interface CategoryLayerProps extends Omit<BoxProps, 'defaultValue'>, ComposerLayerProps {
6
6
  defaultValue: SCCategoryType[];
@@ -4,6 +4,7 @@ import React, { useCallback, useState } from 'react';
4
4
  import { FormattedMessage } from 'react-intl';
5
5
  import { Box, Button, DialogTitle, IconButton, Typography } from '@mui/material';
6
6
  import { styled } from '@mui/material/styles';
7
+ import { UserUtils, useSCUser } from '@selfcommunity/react-core';
7
8
  import Icon from '@mui/material/Icon';
8
9
  import CategoryAutocomplete from '../../../CategoryAutocomplete';
9
10
  import DialogContent from '@mui/material/DialogContent';
@@ -23,9 +24,11 @@ const CategoryLayer = React.forwardRef((props, ref) => {
23
24
  const { className, onClose, onSave, defaultValue = [] } = props, rest = __rest(props, ["className", "onClose", "onSave", "defaultValue"]);
24
25
  // STATE
25
26
  const [value, setValue] = useState(defaultValue);
27
+ // CONTEXT
28
+ const scUserContext = useSCUser();
26
29
  // HANDLERS
27
30
  const handleSave = useCallback(() => onSave(value), [value, onSave]);
28
31
  const handleChange = useCallback((categories) => setValue(categories), []);
29
- return _jsxs(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest, { children: [_jsxs(DialogTitle, Object.assign({ className: classes.title }, { children: [_jsx(IconButton, Object.assign({ onClick: onClose }, { children: _jsx(Icon, { children: "arrow_back" }) })), _jsx(Typography, { children: _jsx(FormattedMessage, { id: "ui.composer.layer.category.title", defaultMessage: "ui.composer.layer.category.title" }) }), _jsx(Button, Object.assign({ size: "small", color: "secondary", variant: "contained", onClick: handleSave }, { children: _jsx(FormattedMessage, { id: "ui.composer.layer.save", defaultMessage: "ui.composer.layer.save" }) }))] })), _jsx(DialogContent, Object.assign({ className: classes.content }, { children: _jsx(CategoryAutocomplete, { multiple: true, onChange: handleChange, defaultValue: defaultValue }) }))] }));
32
+ return (_jsxs(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest, { children: [_jsxs(DialogTitle, Object.assign({ className: classes.title }, { children: [_jsx(IconButton, Object.assign({ onClick: onClose }, { children: _jsx(Icon, { children: "arrow_back" }) })), _jsx(Typography, { children: _jsx(FormattedMessage, { id: "ui.composer.layer.category.title", defaultMessage: "ui.composer.layer.category.title" }) }), _jsx(Button, Object.assign({ size: "small", color: "secondary", variant: "contained", onClick: handleSave }, { children: _jsx(FormattedMessage, { id: "ui.composer.layer.save", defaultMessage: "ui.composer.layer.save" }) }))] })), _jsx(DialogContent, Object.assign({ className: classes.content }, { children: _jsx(CategoryAutocomplete, Object.assign({ multiple: true, onChange: handleChange, defaultValue: defaultValue }, (!UserUtils.isStaff(scUserContext.user) && { endpointQueryParams: { can_create_content: true } }))) }))] })));
30
33
  });
31
34
  export default CategoryLayer;
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { Icon, IconButton, useMediaQuery, styled, useTheme, SwipeableDrawer, MenuList, MenuItem, ListItemIcon, ListItemText, Typography, useThemeProps, Menu } from '@mui/material';
5
- import { Link, SCRoutes, UserUtils, useSCContext, useSCRouting, useSCUser } from '@selfcommunity/react-core';
5
+ import { Link, SCPreferences, SCRoutes, UserUtils, useSCContext, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
6
6
  import { FormattedMessage } from 'react-intl';
7
7
  import Composer from '../Composer';
8
8
  import { useSnackbar } from 'notistack';
@@ -11,6 +11,7 @@ import EventFormDialog from '../EventFormDialog';
11
11
  import classNames from 'classnames';
12
12
  import GroupForm from '../GroupForm';
13
13
  import CreateLiveStreamDialog from '../CreateLiveStreamDialog';
14
+ import { SCCommunitySubscriptionTier } from '@selfcommunity/types';
14
15
  const PREFIX = 'SCComposerIconButton';
15
16
  const classes = {
16
17
  root: `${PREFIX}-root`,
@@ -81,10 +82,17 @@ export default React.forwardRef(function ComposerIconButton(inProps, ref) {
81
82
  // HOOKS
82
83
  const theme = useTheme();
83
84
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
85
+ const { preferences } = useSCPreferences();
84
86
  // MEMOS
85
87
  const canCreateGroup = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_group; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
86
88
  const canCreateEvent = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_event; }, [(_b = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _b === void 0 ? void 0 : _b.permission]);
87
- const canCreateLiveStream = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_c = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _c === void 0 ? void 0 : _c.permission]);
89
+ const canCreateLive = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_c = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _c === void 0 ? void 0 : _c.permission]);
90
+ const isCommunityOwner = useMemo(() => { var _a; return ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) === 1; }, [scUserContext.user]);
91
+ const isFreeTrialTier = useMemo(() => preferences &&
92
+ SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER in preferences &&
93
+ preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value &&
94
+ preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value === SCCommunitySubscriptionTier.FREE_TRIAL, [preferences]);
95
+ const canCreateLiveStream = useMemo(() => (isFreeTrialTier && isCommunityOwner && canCreateLive) || (!isFreeTrialTier && canCreateLive), [isFreeTrialTier, isCommunityOwner, canCreateLive]);
88
96
  const renderContent = useMemo(() => {
89
97
  return (_jsx(MenuList, { children: listItem.map((item, i) => (_jsxs(MenuItem, Object.assign({ onClick: item.onClick }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, Object.assign({ fontSize: "small" }, { children: item.icon })) }), _jsx(ListItemText, { primary: _jsx(Typography, Object.assign({ variant: "h6" }, { children: _jsx(FormattedMessage, { id: item.text, defaultMessage: item.text }) })) })] }), i))) }));
90
98
  }, [listItem]);
@@ -180,5 +188,5 @@ export default React.forwardRef(function ComposerIconButton(inProps, ref) {
180
188
  return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClick, ref: (innerRef) => {
181
189
  popperRef.current = innerRef;
182
190
  return ref;
183
- } }, rest, { children: _jsx(Icon, { children: "add_circle_outline" }) })), openComposer && _jsx(Composer, Object.assign({ open: openComposer, fullWidth: true, onClose: handleCloseComposer, onSuccess: handleSuccess }, ComposerProps)), openPopper && (_jsx(_Fragment, { children: isMobile ? (_jsx(SwipeableDrawer, Object.assign({ open: true, onClose: handleCloseMenu, onOpen: () => null, anchor: "bottom", disableSwipeToOpen: true }, { children: renderContent }))) : (_jsx(MenuRoot, Object.assign({ open: true, anchorEl: popperRef.current, role: undefined, className: classes.menuRoot, onClose: handleCloseMenu }, PopperProps, { children: renderContent }))) })), openCreateGroup && _jsx(GroupForm, Object.assign({ open: openCreateGroup, onClose: handleCloseCreateGroup }, GroupFormProps)), openCreateEvent && _jsx(EventFormDialog, Object.assign({ open: openCreateEvent, onClose: handleCloseCreateEvent }, EventFormDialogComponentProps)), openCreateLiveStream && (_jsx(CreateLiveStreamDialog, Object.assign({ open: openCreateLiveStream, onClose: handleCloseCreateLiveStream }, CreateLiveStreamDialogComponentProps)))] }));
191
+ } }, rest, { children: _jsx(Icon, { children: "add_circle_outline" }) })), openComposer && _jsx(Composer, Object.assign({ open: true, fullWidth: true, onClose: handleCloseComposer, onSuccess: handleSuccess }, ComposerProps)), openPopper && (_jsx(_Fragment, { children: isMobile ? (_jsx(SwipeableDrawer, Object.assign({ open: true, onClose: handleCloseMenu, onOpen: () => null, anchor: "bottom", disableSwipeToOpen: true }, { children: renderContent }))) : (_jsx(MenuRoot, Object.assign({ open: true, anchorEl: popperRef.current, role: undefined, className: classes.menuRoot, onClose: handleCloseMenu }, PopperProps, { children: renderContent }))) })), openCreateGroup && _jsx(GroupForm, Object.assign({ open: true, onClose: handleCloseCreateGroup }, GroupFormProps)), openCreateEvent && _jsx(EventFormDialog, Object.assign({ open: true, onClose: handleCloseCreateEvent }, EventFormDialogComponentProps)), openCreateLiveStream && _jsx(CreateLiveStreamDialog, Object.assign({ open: true, onClose: handleCloseCreateLiveStream }, CreateLiveStreamDialogComponentProps))] }));
184
192
  });
@@ -7,7 +7,7 @@ export interface CreateEventButtonProps extends ButtonProps {
7
7
  */
8
8
  className?: string;
9
9
  /**
10
- * Props to spread to CreateGroup component
10
+ * Props to spread to CreateEvent component
11
11
  * @default empty object
12
12
  */
13
13
  EventFormDialogComponentProps?: EventFormDialogProps;
@@ -16,7 +16,7 @@ const classes = {
16
16
  const Root = styled(Button, {
17
17
  name: PREFIX,
18
18
  slot: 'Root',
19
- overridesResolver: (props, styles) => styles.root
19
+ overridesResolver: (_props, styles) => styles.root
20
20
  })(() => ({}));
21
21
  /**
22
22
  *> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.