@selfcommunity/react-ui 0.11.0-alpha.3 → 0.11.0-alpha.31

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 (88) 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/plugins/ToolbarPlugin.js +1 -1
  11. package/lib/cjs/components/EventForm/EventForm.js +7 -5
  12. package/lib/cjs/components/EventMediaWidget/EventMediaWidget.js +2 -2
  13. package/lib/cjs/components/EventMembersWidget/EventMembersWidget.js +11 -11
  14. package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +9 -9
  15. package/lib/cjs/components/EventMembersWidget/types.d.ts +4 -5
  16. package/lib/cjs/components/EventMembersWidget/types.js +7 -7
  17. package/lib/cjs/components/EventParticipantsButton/EventParticipantsButton.js +4 -4
  18. package/lib/cjs/components/Events/Events.d.ts +6 -0
  19. package/lib/cjs/components/Events/Events.js +2 -2
  20. package/lib/cjs/components/FeedObject/Activities/Activities.js +1 -1
  21. package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +1 -1
  22. package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +1 -1
  23. package/lib/cjs/components/LiveStreamForm/LiveStreamForm.js +65 -6
  24. package/lib/cjs/components/LiveStreamForm/LiveStreamFormSettings.js +8 -3
  25. package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.js +8 -6
  26. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +3 -1
  27. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.d.ts +2 -1
  28. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.js +2 -2
  29. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.d.ts +9 -0
  30. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.js +106 -0
  31. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.d.ts +4 -0
  32. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.js +37 -0
  33. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
  34. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
  35. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +3 -2
  36. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +45 -2
  37. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +60 -5
  38. package/lib/cjs/constants/LiveStream.d.ts +1 -0
  39. package/lib/cjs/constants/LiveStream.js +2 -1
  40. package/lib/cjs/shared/AutoPlayer/index.js +1 -1
  41. package/lib/cjs/shared/UpScalingTierBadge/index.js +9 -0
  42. package/lib/cjs/utils/contribution.js +1 -2
  43. package/lib/esm/components/CategoryAutocomplete/CategoryAutocomplete.d.ts +5 -0
  44. package/lib/esm/components/CategoryAutocomplete/CategoryAutocomplete.js +3 -3
  45. package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +1 -1
  46. package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.js +4 -1
  47. package/lib/esm/components/ComposerIconButton/ComposerIconButton.js +11 -3
  48. package/lib/esm/components/CreateEventButton/CreateEventButton.d.ts +1 -1
  49. package/lib/esm/components/CreateEventButton/CreateEventButton.js +1 -1
  50. package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +11 -9
  51. package/lib/esm/components/CreateLiveStreamDialog/LiveStreamSelector/LiveStreamSelector.js +23 -14
  52. package/lib/esm/components/Editor/plugins/ToolbarPlugin.js +1 -1
  53. package/lib/esm/components/EventForm/EventForm.js +8 -6
  54. package/lib/esm/components/EventMediaWidget/EventMediaWidget.js +2 -2
  55. package/lib/esm/components/EventMembersWidget/EventMembersWidget.js +12 -12
  56. package/lib/esm/components/EventMembersWidget/TabContentComponent.js +10 -10
  57. package/lib/esm/components/EventMembersWidget/types.d.ts +4 -5
  58. package/lib/esm/components/EventMembersWidget/types.js +6 -6
  59. package/lib/esm/components/EventParticipantsButton/EventParticipantsButton.js +4 -4
  60. package/lib/esm/components/Events/Events.d.ts +6 -0
  61. package/lib/esm/components/Events/Events.js +2 -2
  62. package/lib/esm/components/FeedObject/Activities/Activities.js +1 -1
  63. package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +1 -1
  64. package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +1 -1
  65. package/lib/esm/components/LiveStreamForm/LiveStreamForm.js +67 -8
  66. package/lib/esm/components/LiveStreamForm/LiveStreamFormSettings.js +8 -3
  67. package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.js +8 -6
  68. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +3 -1
  69. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.d.ts +2 -1
  70. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/FocusLayout.js +2 -2
  71. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.d.ts +9 -0
  72. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamSettingsMenu.js +103 -0
  73. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.d.ts +4 -0
  74. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/NoParticipants.js +34 -0
  75. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
  76. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
  77. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +3 -2
  78. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +45 -2
  79. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +64 -9
  80. package/lib/esm/constants/LiveStream.d.ts +1 -0
  81. package/lib/esm/constants/LiveStream.js +1 -0
  82. package/lib/esm/shared/AutoPlayer/index.js +1 -1
  83. package/lib/esm/shared/UpScalingTierBadge/index.js +9 -0
  84. package/lib/esm/utils/contribution.js +1 -2
  85. package/lib/umd/{653.js → 212.js} +2 -2
  86. package/lib/umd/react-ui.js +1 -1
  87. package/package.json +8 -7
  88. /package/lib/umd/{653.js.LICENSE.txt → 212.js.LICENSE.txt} +0 -0
@@ -0,0 +1,37 @@
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 styles_1 = require("@mui/material/styles");
6
+ const system_1 = require("@mui/system");
7
+ const material_1 = require("@mui/material");
8
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
9
+ const react_intl_1 = require("react-intl");
10
+ const PREFIX = 'SCNoParticipants';
11
+ const classes = {
12
+ root: `${PREFIX}-root`
13
+ };
14
+ const Root = (0, styles_1.styled)(material_1.Box, {
15
+ name: PREFIX,
16
+ slot: 'Root',
17
+ overridesResolver: (props, styles) => styles.root
18
+ })(({ theme }) => ({
19
+ display: 'flex',
20
+ alignItems: 'center',
21
+ justifyContent: 'center',
22
+ backgroundColor: '#1e1e1e',
23
+ transition: 'opacity .2sease-in-out',
24
+ pointerEvents: 'none',
25
+ borderRadius: 7
26
+ }));
27
+ function NoParticipants(inProps) {
28
+ // PROPS
29
+ const props = (0, system_1.useThemeProps)({
30
+ props: inProps,
31
+ name: PREFIX
32
+ });
33
+ const { className } = props, rest = tslib_1.__rest(props, ["className"]);
34
+ // RENDER
35
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamRoom.noParticipants", defaultMessage: "ui.liveStreamRoom.noParticipants" }) })));
36
+ }
37
+ exports.default = NoParticipants;
@@ -19,6 +19,7 @@ export interface ParticipantTileProps extends React.HTMLAttributes<HTMLDivElemen
19
19
  trackRef?: TrackReferenceOrPlaceholder;
20
20
  disableSpeakingIndicator?: boolean;
21
21
  disableTileActions?: boolean;
22
+ disableTileFocusToggle?: boolean;
22
23
  onParticipantClick?: (event: ParticipantClickEvent) => void;
23
24
  }
24
25
  /**
@@ -34,7 +34,7 @@ exports.TrackRefContextIfNeeded = TrackRefContextIfNeeded;
34
34
  exports.ParticipantTile =
35
35
  /* @__PURE__ */ React.forwardRef(function ParticipantTile(_a, ref) {
36
36
  var _b, _c;
37
- var { trackRef, children, onParticipantClick, disableSpeakingIndicator, disableTileActions = false } = _a, htmlProps = tslib_1.__rest(_a, ["trackRef", "children", "onParticipantClick", "disableSpeakingIndicator", "disableTileActions"]);
37
+ var { trackRef, children, onParticipantClick, disableSpeakingIndicator, disableTileFocusToggle = false, disableTileActions = false } = _a, htmlProps = tslib_1.__rest(_a, ["trackRef", "children", "onParticipantClick", "disableSpeakingIndicator", "disableTileFocusToggle", "disableTileActions"]);
38
38
  const scUserContext = (0, react_core_1.useSCUser)();
39
39
  const trackReference = (0, components_react_1.useEnsureTrackRef)(trackRef);
40
40
  const { elementProps } = (0, components_react_1.useParticipantTile)({
@@ -61,5 +61,5 @@ exports.ParticipantTile =
61
61
  trackReference.source === livekit_client_1.Track.Source.ScreenShare) ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(components_react_1.VideoTrack, { trackRef: trackReference, onSubscriptionStatusChanged: handleSubscribe, manageSubscription: autoManageSubscription }) })) : ((0, components_core_1.isTrackReference)(trackReference) && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(components_react_1.AudioTrack, { trackRef: trackReference, onSubscriptionStatusChanged: handleSubscribe }) }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-participant-placeholder" }, { children: (0, jsx_runtime_1.jsx)(ParticipantTileAvatar_1.default, { participant: trackReference.participant }) })), (0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-participant-metadata" }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: "lk-participant-metadata-item" }, { children: trackReference.source === livekit_client_1.Track.Source.Camera ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isEncrypted && (0, jsx_runtime_1.jsx)(components_react_1.LockLockedIcon, { style: { marginRight: '0.25rem' } }), (0, jsx_runtime_1.jsx)(components_react_1.TrackMutedIndicator, { trackRef: {
62
62
  participant: trackReference.participant,
63
63
  source: livekit_client_1.Track.Source.Microphone
64
- }, show: 'muted' }), (0, jsx_runtime_1.jsx)(components_react_1.ParticipantName, { children: !disableTileActions && (0, jsx_runtime_1.jsx)(ParticipantTileActions_1.default, {}) })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_react_1.ScreenShareIcon, { style: { marginRight: '0.25rem' } }), (0, jsx_runtime_1.jsx)(components_react_1.ParticipantName, { children: "'s screen" })] })) })), (0, jsx_runtime_1.jsx)(components_react_1.ConnectionQualityIndicator, { className: "lk-participant-metadata-item" })] }))] })), (0, jsx_runtime_1.jsx)(components_react_1.FocusToggle, { trackRef: trackReference })] })) })) })));
64
+ }, show: 'muted' }), (0, jsx_runtime_1.jsx)(components_react_1.ParticipantName, { children: !disableTileActions && (0, jsx_runtime_1.jsx)(ParticipantTileActions_1.default, {}) })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_react_1.ScreenShareIcon, { style: { marginRight: '0.25rem' } }), (0, jsx_runtime_1.jsx)(components_react_1.ParticipantName, { children: "'s screen" })] })) })), (0, jsx_runtime_1.jsx)(components_react_1.ConnectionQualityIndicator, { className: "lk-participant-metadata-item" })] }))] })), !disableTileFocusToggle && (0, jsx_runtime_1.jsx)(components_react_1.FocusToggle, { trackRef: trackReference })] })) })) })));
65
65
  });
@@ -1,5 +1,5 @@
1
1
  import type { CreateLocalTracksOptions, LocalAudioTrack, LocalTrack, LocalVideoTrack } from 'livekit-client';
2
- import { Track } from 'livekit-client';
2
+ import { Track, TrackProcessor } from 'livekit-client';
3
3
  import * as React from 'react';
4
4
  import type { LocalUserChoices } from '@livekit/components-core';
5
5
  /**
@@ -28,6 +28,7 @@ export interface PreJoinProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
28
28
  * @alpha
29
29
  */
30
30
  persistUserChoices?: boolean;
31
+ videoProcessor?: TrackProcessor<Track.Kind.Video>;
31
32
  }
32
33
  /** @alpha */
33
34
  export declare function usePreviewTracks(options: CreateLocalTracksOptions, onError?: (err: Error) => void): {
@@ -55,4 +56,4 @@ export declare function usePreviewDevice<T extends LocalVideoTrack | LocalAudioT
55
56
  * ```
56
57
  * @public
57
58
  */
58
- export declare function PreJoin({ defaults, onValidate, onSubmit, onError, debug, joinLabel, micLabel, camLabel, userLabel, persistUserChoices, ...htmlProps }: PreJoinProps): JSX.Element;
59
+ export declare function PreJoin({ defaults, onValidate, onSubmit, onError, debug, joinLabel, micLabel, camLabel, userLabel, persistUserChoices, videoProcessor, ...htmlProps }: PreJoinProps): JSX.Element;
@@ -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;
@@ -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';
@@ -22,7 +22,7 @@ function AutoPlayer(props) {
22
22
  const [played, setPlayed] = (0, react_1.useState)(0);
23
23
  (0, react_1.useEffect)(() => {
24
24
  if (played >= 10 && played <= 11) {
25
- onVideoWatch();
25
+ onVideoWatch === null || onVideoWatch === void 0 ? void 0 : onVideoWatch();
26
26
  }
27
27
  }, [played]);
28
28
  /**
@@ -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;
@@ -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
  }
@@ -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.
@@ -23,10 +23,11 @@ const classes = {
23
23
  const Root = styled(BaseDialog, {
24
24
  name: PREFIX,
25
25
  slot: 'Root'
26
- })(({ theme }) => ({
26
+ })(() => ({
27
27
  paddingBottom: '0px !important',
28
28
  [`& .${classes.title}`]: {
29
- display: 'flex'
29
+ display: 'flex',
30
+ alignItems: 'center'
30
31
  },
31
32
  [`& .${classes.content}`]: {
32
33
  paddingBottom: 0
@@ -56,7 +57,7 @@ const Transition = React.forwardRef(function Transition(props, ref) {
56
57
  * @param inProps
57
58
  */
58
59
  export default function CreateLiveStreamDialog(inProps) {
59
- var _a, _b;
60
+ var _a;
60
61
  //PROPS
61
62
  const props = useThemeProps({
62
63
  props: inProps,
@@ -65,11 +66,12 @@ export default function CreateLiveStreamDialog(inProps) {
65
66
  const { className, open = true, onClose, onSuccess } = props, rest = __rest(props, ["className", "open", "onClose", "onSuccess"]);
66
67
  // CONTEXT
67
68
  const scUserContext = useSCUser();
68
- 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; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
69
- 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]);
69
+ // PERMISSION
70
+ 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; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
70
71
  // STATE
71
72
  const [step, setStep] = useState(canCreateEvent ? CreateLiveStreamStep.SELECT_TYPE : CreateLiveStreamStep.CREATE_LIVE);
72
73
  const [liveType, setLiveType] = useState(canCreateEvent ? null : LiveStreamType.DIRECT_LIVE);
74
+ const canShowBackButton = useMemo(() => step === CreateLiveStreamStep.CREATE_LIVE && canCreateEvent, [step, canCreateEvent]);
73
75
  // HANDLER
74
76
  const handleLiveTypeSelected = useCallback((l) => {
75
77
  setLiveType(l);
@@ -78,23 +80,23 @@ export default function CreateLiveStreamDialog(inProps) {
78
80
  setLiveType(l);
79
81
  setStep(CreateLiveStreamStep.CREATE_LIVE);
80
82
  }, []);
81
- const handleBack = useCallback((l) => {
83
+ const handleBack = useCallback(() => {
82
84
  setStep(CreateLiveStreamStep.SELECT_TYPE);
83
85
  }, []);
84
86
  const handleSubmit = useCallback((e) => {
85
87
  onSuccess && onSuccess(e);
86
- }, []);
88
+ }, [onSuccess]);
87
89
  useEffect(() => {
88
90
  if (!canCreateEvent) {
89
91
  setLiveType(LiveStreamType.DIRECT_LIVE);
90
92
  }
91
93
  }, [canCreateEvent]);
92
94
  // user must be logged
93
- if (!scUserContext.user || !canCreateLiveStream) {
95
+ if (!scUserContext.user) {
94
96
  return null;
95
97
  }
96
98
  /**
97
99
  * Renders root object
98
100
  */
99
- return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: 'md', title: _jsxs(Box, Object.assign({ className: classes.title, component: 'span' }, { children: [Boolean(step === CreateLiveStreamStep.CREATE_LIVE && canCreateEvent) && (_jsx(Button, Object.assign({ variant: "text", onClick: handleBack, startIcon: _jsx(Icon, { children: "arrow_back" }) }, { children: "Back" }))), _jsx(Box, Object.assign({ component: 'span' }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.title", defaultMessage: "ui.createLivestreamDialog.title" }) }))] })), fullWidth: true, open: open, scroll: 'paper', onClose: onClose, className: classNames(classes.root, className), TransitionComponent: Transition, PaperProps: { elevation: 0 } }, rest, { children: _jsxs(Box, Object.assign({ className: classes.content }, { children: [step === CreateLiveStreamStep.SELECT_TYPE && (_jsx(LiveStreamSelector, { liveSelected: liveType, onLiveSelected: handleLiveTypeSelected, onNext: handleLiveTypeSelectedNext })), step === CreateLiveStreamStep.CREATE_LIVE && (_jsx(_Fragment, { children: liveType === LiveStreamType.EVENT_LIVE ? (_jsx(EventForm, { EventAddressComponentProps: { locations: [SCEventLocationType.LIVESTREAM] }, onSuccess: handleSubmit })) : (_jsx(LiveStreamForm, { onSuccess: handleSubmit })) }))] })) })));
101
+ return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: "md", title: _jsxs(Box, Object.assign({ className: classes.title, component: "span" }, { children: [canShowBackButton && (_jsx(Button, Object.assign({ variant: "text", onClick: handleBack, startIcon: _jsx(Icon, { children: "arrow_back" }) }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.button.back", defaultMessage: "ui.createLivestreamDialog.button.back" }) }))), _jsx(Box, Object.assign({ component: "span" }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.title", defaultMessage: "ui.createLivestreamDialog.title" }) }))] })), fullWidth: true, open: open, scroll: "body", onClose: !canShowBackButton ? onClose : undefined, className: classNames(classes.root, className), TransitionComponent: Transition, PaperProps: { elevation: 0 } }, rest, { children: _jsxs(Box, Object.assign({ className: classes.content }, { children: [step === CreateLiveStreamStep.SELECT_TYPE && (_jsx(LiveStreamSelector, { liveSelected: liveType, onLiveSelected: handleLiveTypeSelected, onNext: handleLiveTypeSelectedNext })), step === CreateLiveStreamStep.CREATE_LIVE && (_jsx(_Fragment, { children: liveType === LiveStreamType.EVENT_LIVE ? (_jsx(EventForm, { EventAddressComponentProps: { locations: [SCEventLocationType.LIVESTREAM] }, onSuccess: handleSubmit })) : (_jsx(LiveStreamForm, { onSuccess: handleSubmit })) }))] })) })));
100
102
  }