@selfcommunity/react-ui 0.8.0-live.59 → 0.8.0-live.61

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 (60) hide show
  1. package/lib/cjs/components/EventForm/EventAddress.js +5 -2
  2. package/lib/cjs/components/LiveStreamForm/LiveStreamForm.js +1 -3
  3. package/lib/cjs/components/LiveStreamForm/LiveStreamFormSettings.js +1 -1
  4. package/lib/cjs/components/LiveStreamForm/constants.d.ts +2 -2
  5. package/lib/cjs/components/LiveStreamForm/constants.js +2 -2
  6. package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.js +5 -6
  7. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.d.ts +29 -0
  8. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +62 -0
  9. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/DisconnectButton.d.ts +10 -0
  10. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/DisconnectButton.js +16 -0
  11. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamProvider.d.ts +17 -0
  12. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamProvider.js +13 -0
  13. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.d.ts +0 -6
  14. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.js +16 -88
  15. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
  16. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
  17. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileActions.js +33 -26
  18. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.d.ts +2 -2
  19. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.js +14 -3
  20. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +1 -7
  21. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +5 -3
  22. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/SettingsMenuToggle.d.ts +19 -0
  23. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/SettingsMenuToggle.js +35 -0
  24. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.d.ts +2 -17
  25. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +8 -22
  26. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/utils.d.ts +27 -0
  27. package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/utils.js +82 -0
  28. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +1 -1
  29. package/lib/esm/components/EventForm/EventAddress.js +6 -3
  30. package/lib/esm/components/LiveStreamForm/LiveStreamForm.js +2 -4
  31. package/lib/esm/components/LiveStreamForm/LiveStreamFormSettings.js +1 -1
  32. package/lib/esm/components/LiveStreamForm/constants.d.ts +2 -2
  33. package/lib/esm/components/LiveStreamForm/constants.js +2 -2
  34. package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.js +5 -6
  35. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.d.ts +29 -0
  36. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ControlBar.js +58 -0
  37. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/DisconnectButton.d.ts +10 -0
  38. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/DisconnectButton.js +12 -0
  39. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamProvider.d.ts +17 -0
  40. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamProvider.js +9 -0
  41. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.d.ts +0 -6
  42. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/LiveStreamVideoConference.js +17 -89
  43. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.d.ts +1 -0
  44. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTile.js +2 -2
  45. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileActions.js +35 -28
  46. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.d.ts +2 -2
  47. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/ParticipantTileAvatar.js +13 -2
  48. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.d.ts +1 -7
  49. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/PreJoin.js +5 -3
  50. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/SettingsMenuToggle.d.ts +19 -0
  51. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/SettingsMenuToggle.js +30 -0
  52. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.d.ts +2 -17
  53. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/VideoConference.js +9 -23
  54. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/utils.d.ts +27 -0
  55. package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/utils.js +74 -0
  56. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +1 -1
  57. package/lib/umd/{43.js → 32.js} +2 -2
  58. package/lib/umd/react-ui.js +1 -1
  59. package/package.json +8 -7
  60. /package/lib/umd/{43.js.LICENSE.txt → 32.js.LICENSE.txt} +0 -0
@@ -15,6 +15,9 @@ const react_core_1 = require("@selfcommunity/react-core");
15
15
  const constants_1 = require("./constants");
16
16
  const ConfirmDialog_1 = tslib_1.__importDefault(require("../../../shared/ConfirmDialog/ConfirmDialog"));
17
17
  const components_react_1 = require("@livekit/components-react");
18
+ const LiveStreamProvider_1 = require("./LiveStreamProvider");
19
+ const utils_1 = require("@selfcommunity/utils");
20
+ const Errors_1 = require("../../../constants/Errors");
18
21
  const PREFIX = 'SCParticipantTileActionsMenu';
19
22
  const classes = {
20
23
  root: `${PREFIX}-root`,
@@ -60,10 +63,9 @@ function ContributionActionsMenu(props) {
60
63
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
61
64
  const scContext = (0, react_1.useContext)(react_core_1.SCContext);
62
65
  const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
63
- const scUserId = scUserContext.user ? scUserContext.user.id : null;
64
- const scRoutingContext = (0, react_core_1.useSCRouting)();
65
66
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
66
67
  const p = (0, components_react_1.useEnsureParticipant)(participant);
68
+ const { liveStream } = (0, LiveStreamProvider_1.useLiveStream)();
67
69
  // GENERAL POPPER STATE
68
70
  const [open, setOpen] = (0, react_1.useState)(false);
69
71
  const [isLoading, setIsLoading] = (0, react_1.useState)(false);
@@ -97,23 +99,17 @@ function ContributionActionsMenu(props) {
97
99
  }
98
100
  }
99
101
  /**
100
- * Perform delete contribution
102
+ * Perform ban participant
101
103
  */
102
- const performBanParticipant = (0, react_1.useMemo)(() => () => {
103
- return api_services_1.http
104
- .request({
105
- url: api_services_1.Endpoints.DeleteComment.url({ id: p.identity }),
106
- method: api_services_1.Endpoints.DeleteComment.method
107
- })
108
- .then((res) => {
109
- if (res.status >= 300) {
110
- return Promise.reject(res);
111
- }
112
- return Promise.resolve(res.data);
113
- });
114
- }, [p]);
104
+ const performBanParticipant = (0, react_1.useMemo)(() => () => tslib_1.__awaiter(this, void 0, void 0, function* () {
105
+ const res = yield api_services_1.LiveStreamApiClient.removeUserFromRoom(liveStream.id, p.identity);
106
+ if (res.status >= 300) {
107
+ return Promise.reject(res);
108
+ }
109
+ return yield Promise.resolve(res.data);
110
+ }), [p]);
115
111
  /**
116
- * handle action
112
+ * Handle action
117
113
  */
118
114
  function handleAction(action) {
119
115
  if (action === constants_1.BAN_ROOM_USER) {
@@ -150,24 +146,29 @@ function ContributionActionsMenu(props) {
150
146
  if (p && !isLoading && !currentActionLoading) {
151
147
  if (currentAction === constants_1.BAN_ROOM_USER) {
152
148
  setCurrentActionLoading(constants_1.BAN_ROOM_USER);
153
- /* performBanParticipant()
154
- .then(() => {
149
+ performBanParticipant()
150
+ .then(() => {
155
151
  onBanParticipant && onBanParticipant(p);
156
152
  performPostConfirmAction(true);
157
- })
158
- .catch((error) => {
159
- Logger.error(SCOPE_SC_UI, error);
153
+ })
154
+ .catch((error) => {
155
+ utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
160
156
  performPostConfirmAction(false);
161
- }); */
157
+ });
162
158
  }
163
159
  }
164
160
  }
165
161
  /**
166
162
  * Can authenticated ban a user in a room
167
163
  */
168
- function canBanUser() {
169
- return scUserContext.user && react_core_1.UserUtils.isStaff(scUserContext.user) && scUserContext.user.id.toString() !== p.identity;
170
- }
164
+ const canBanUser = (0, react_1.useMemo)(() => () => {
165
+ return (scUserContext.user &&
166
+ liveStream &&
167
+ p &&
168
+ p.identity &&
169
+ liveStream.host.id === scUserContext.user.id &&
170
+ scUserContext.user.id.toString() !== p.identity);
171
+ }, [scUserContext, liveStream, p]);
171
172
  /**
172
173
  * Renders section general
173
174
  */
@@ -180,6 +181,12 @@ function ContributionActionsMenu(props) {
180
181
  function renderContent() {
181
182
  return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.MenuList, { children: renderGeneralSection() }) }));
182
183
  }
184
+ /**
185
+ * Renders component only if the logged user has actions available
186
+ */
187
+ if (!canBanUser()) {
188
+ return null;
189
+ }
183
190
  /**
184
191
  * Renders component
185
192
  */
@@ -1,5 +1,5 @@
1
1
  import { SCUserType } from '@selfcommunity/types';
2
- export interface ParticipantTileProps {
2
+ export interface ParticipantTileAvatarProps {
3
3
  className?: string;
4
4
  /**
5
5
  * User Object
@@ -12,4 +12,4 @@ export interface ParticipantTileProps {
12
12
  */
13
13
  participant?: any;
14
14
  }
15
- export default function UserAvatar(inProps: ParticipantTileProps): JSX.Element;
15
+ export default function ParticipantTileAvatar(inProps: ParticipantTileAvatarProps): JSX.Element;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
5
6
  const styles_1 = require("@mui/material/styles");
6
7
  const system_1 = require("@mui/system");
7
8
  const material_1 = require("@mui/material");
@@ -24,7 +25,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
24
25
  height: 100
25
26
  }
26
27
  }));
27
- function UserAvatar(inProps) {
28
+ function ParticipantTileAvatar(inProps) {
28
29
  // PROPS
29
30
  const props = (0, system_1.useThemeProps)({
30
31
  props: inProps,
@@ -33,6 +34,16 @@ function UserAvatar(inProps) {
33
34
  const { className, user, participant } = props, rest = tslib_1.__rest(props, ["className", "user", "participant"]);
34
35
  // CONTEXT
35
36
  const scContext = (0, react_core_1.useSCContext)();
36
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: user ? ((0, jsx_runtime_1.jsx)("img", { src: `${user.avatar}` })) : participant ? ((0, jsx_runtime_1.jsx)("img", { src: `${scContext.settings.portal}/api/v2/avatar/${participant.identity}` })) : ((0, jsx_runtime_1.jsx)(ParticipantPlaceholder_1.default, {})) })));
37
+ // AVATAR
38
+ const avatar = (0, react_1.useMemo)(() => {
39
+ if (user) {
40
+ return (0, jsx_runtime_1.jsx)("img", { src: `${user.avatar}` });
41
+ }
42
+ if (participant) {
43
+ return (0, jsx_runtime_1.jsx)("img", { src: `${scContext.settings.portal}/api/v2/avatar/${participant.identity}` });
44
+ }
45
+ return (0, jsx_runtime_1.jsx)(ParticipantPlaceholder_1.default, {});
46
+ }, [user, participant]);
47
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: avatar })));
37
48
  }
38
- exports.default = UserAvatar;
49
+ exports.default = ParticipantTileAvatar;
@@ -2,7 +2,6 @@ import type { CreateLocalTracksOptions, LocalAudioTrack, LocalTrack, LocalVideoT
2
2
  import { Track } from 'livekit-client';
3
3
  import * as React from 'react';
4
4
  import type { LocalUserChoices } from '@livekit/components-core';
5
- import { SCLiveStreamType } from '@selfcommunity/types';
6
5
  /**
7
6
  * Props for the PreJoin component.
8
7
  * @public
@@ -15,11 +14,6 @@ export interface PreJoinProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
15
14
  */
16
15
  onValidate?: (values: LocalUserChoices) => boolean;
17
16
  onError?: (error: Error) => void;
18
- /**
19
- * Livestream Object
20
- * @default null
21
- */
22
- liveStream?: SCLiveStreamType;
23
17
  /** Prefill the input form with initial values. */
24
18
  defaults?: Partial<LocalUserChoices>;
25
19
  /** Display a debug window for your convenience. */
@@ -58,4 +52,4 @@ export declare function usePreviewDevice<T extends LocalVideoTrack | LocalAudioT
58
52
  * ```
59
53
  * @public
60
54
  */
61
- export declare function PreJoin({ liveStream, defaults, onValidate, onSubmit, onError, debug, joinLabel, micLabel, camLabel, userLabel, persistUserChoices, ...htmlProps }: PreJoinProps): JSX.Element;
55
+ export declare function PreJoin({ defaults, onValidate, onSubmit, onError, debug, joinLabel, micLabel, camLabel, userLabel, persistUserChoices, ...htmlProps }: PreJoinProps): JSX.Element;
@@ -12,6 +12,7 @@ const react_core_1 = require("@selfcommunity/react-core");
12
12
  const ParticipantTileAvatar_1 = tslib_1.__importDefault(require("./ParticipantTileAvatar"));
13
13
  const react_1 = require("react");
14
14
  const TrackToggle_1 = require("./TrackToggle");
15
+ const LiveStreamProvider_1 = require("./LiveStreamProvider");
15
16
  /** @alpha */
16
17
  function usePreviewTracks(options, onError) {
17
18
  const [tracks, setTracks] = React.useState();
@@ -152,7 +153,8 @@ exports.usePreviewDevice = usePreviewDevice;
152
153
  * @public
153
154
  */
154
155
  function PreJoin(_a) {
155
- var { liveStream, defaults = {}, onValidate, onSubmit, onError, debug, joinLabel = 'Join Room', micLabel = 'Microphone', camLabel = 'Camera', userLabel = 'Username', persistUserChoices = true } = _a, htmlProps = tslib_1.__rest(_a, ["liveStream", "defaults", "onValidate", "onSubmit", "onError", "debug", "joinLabel", "micLabel", "camLabel", "userLabel", "persistUserChoices"]);
156
+ 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"]);
157
+ const { liveStream } = (0, LiveStreamProvider_1.useLiveStream)();
156
158
  const [userChoices, setUserChoices] = React.useState(components_core_2.defaultUserChoices);
157
159
  // TODO: Remove and pipe `defaults` object directly into `usePersistentUserChoices` once we fully switch from type `LocalUserChoices` to `UserChoices`.
158
160
  const partialDefaults = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (defaults.audioDeviceId !== undefined && { audioDeviceId: defaults.audioDeviceId })), (defaults.videoDeviceId !== undefined && { videoDeviceId: defaults.videoDeviceId })), (defaults.audioEnabled !== undefined && { audioEnabled: defaults.audioEnabled })), (defaults.videoEnabled !== undefined && { videoEnabled: defaults.videoEnabled })), (defaults.username !== undefined && { username: defaults.username }));
@@ -240,8 +242,8 @@ function PreJoin(_a) {
240
242
  components_core_1.log.warn('Validation failed with: ', userChoices);
241
243
  }
242
244
  }
243
- const canUseAudio = (0, react_1.useMemo)(() => { var _a; return (scUserContext.user && liveStream && liveStream.host.id === scUserContext.user.id) || (liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.muteParticipant)); }, [scUserContext, liveStream]);
244
- const canUseVideo = (0, react_1.useMemo)(() => { var _a; return (scUserContext.user && liveStream && liveStream.host.id === scUserContext.user.id) || (liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.disableVideo)); }, [scUserContext, liveStream]);
245
+ const canUseAudio = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && liveStream && (liveStream.host.id === scUserContext.user.id || (liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.muteParticipants))); }, [scUserContext, liveStream]);
246
+ const canUseVideo = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && liveStream && (liveStream.host.id === scUserContext.user.id || (liveStream && !((_a = liveStream === null || liveStream === void 0 ? void 0 : liveStream.settings) === null || _a === void 0 ? void 0 : _a.disableVideo))); }, [scUserContext, liveStream]);
245
247
  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, 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, tracks: { videoinput: videoTrack }, onActiveDeviceChange: (_, id) => setVideoDeviceId(id) }) }))] }))] })), (0, jsx_runtime_1.jsxs)("form", Object.assign({ className: "lk-username-container" }, { children: [(0, jsx_runtime_1.jsx)("input", { className: "lk-form-control", id: "username", name: "username", type: "text", defaultValue: username, placeholder: userLabel, onChange: (inputEl) => setUsername(inputEl.target.value), autoComplete: "off" }), (0, jsx_runtime_1.jsx)("button", Object.assign({ className: "lk-button lk-join-button", type: "submit", onClick: handleSubmit, disabled: !isValid }, { 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}`] })] }))] }))] })));
246
248
  }
247
249
  exports.PreJoin = PreJoin;
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ export interface UseSettingsToggleProps {
3
+ props: React.ButtonHTMLAttributes<HTMLButtonElement>;
4
+ }
5
+ /**
6
+ * The `useSettingsToggle` hook provides state and functions for toggling the settings menu.
7
+ */
8
+ export declare function useSettingsToggle({ props }: UseSettingsToggleProps): {
9
+ mergedProps: React.ButtonHTMLAttributes<HTMLButtonElement> & {
10
+ className: string;
11
+ onClick: () => void;
12
+ 'aria-pressed': string;
13
+ };
14
+ };
15
+ export type SettingsMenuToggleProps = React.ButtonHTMLAttributes<HTMLButtonElement>;
16
+ /**
17
+ * The `SettingsMenuToggle` component is a button that toggles the visibility of the `SettingsMenu` component.
18
+ */
19
+ export declare const SettingsMenuToggle: (props: SettingsMenuToggleProps & React.RefAttributes<HTMLButtonElement>) => React.ReactNode;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SettingsMenuToggle = exports.useSettingsToggle = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const React = tslib_1.__importStar(require("react"));
7
+ const utils_1 = require("./utils");
8
+ const components_react_1 = require("@livekit/components-react");
9
+ /**
10
+ * The `useSettingsToggle` hook provides state and functions for toggling the settings menu.
11
+ */
12
+ function useSettingsToggle({ props }) {
13
+ const { dispatch, state } = (0, components_react_1.useLayoutContext)().widget;
14
+ const className = 'lk-button lk-settings-toggle';
15
+ const mergedProps = React.useMemo(() => {
16
+ return (0, utils_1.mergePropsReactAria)(props, {
17
+ className,
18
+ onClick: () => {
19
+ if (dispatch)
20
+ dispatch({ msg: 'toggle_settings' });
21
+ },
22
+ 'aria-pressed': (state === null || state === void 0 ? void 0 : state.showSettings) ? 'true' : 'false'
23
+ });
24
+ }, [props, className, dispatch, state]);
25
+ return { mergedProps };
26
+ }
27
+ exports.useSettingsToggle = useSettingsToggle;
28
+ /**
29
+ * The `SettingsMenuToggle` component is a button that toggles the visibility of the `SettingsMenu` component.
30
+ */
31
+ exports.SettingsMenuToggle =
32
+ /* @__PURE__ */ React.forwardRef(function SettingsMenuToggle(props, ref) {
33
+ const { mergedProps } = useSettingsToggle({ props });
34
+ return ((0, jsx_runtime_1.jsx)("button", Object.assign({ ref: ref }, mergedProps, { children: props.children })));
35
+ });
@@ -2,9 +2,6 @@ import * as React from 'react';
2
2
  import type { MessageDecoder, MessageEncoder } from '@livekit/components-core';
3
3
  import { MessageFormatter } from '@livekit/components-react';
4
4
  import { SCUserType } from '@selfcommunity/types';
5
- /**
6
- * @public
7
- */
8
5
  export interface VideoConferenceProps extends React.HTMLAttributes<HTMLDivElement> {
9
6
  chatMessageFormatter?: MessageFormatter;
10
7
  chatMessageEncoder?: MessageEncoder;
@@ -16,7 +13,7 @@ export interface VideoConferenceProps extends React.HTMLAttributes<HTMLDivElemen
16
13
  disableMicrophone?: boolean;
17
14
  disableCamera?: boolean;
18
15
  disableShareScreen?: boolean;
19
- hideParticipantList?: boolean;
16
+ hideParticipantsList?: boolean;
20
17
  showSettings?: boolean;
21
18
  }
22
19
  /**
@@ -24,17 +21,5 @@ export interface VideoConferenceProps extends React.HTMLAttributes<HTMLDivElemen
24
21
  * It provides functionality such as focusing on one participant, grid view with pagination to handle large numbers
25
22
  * of participants, basic non-persistent chat, screen sharing, and more.
26
23
  *
27
- * @remarks
28
- * The component is implemented with other LiveKit components like `FocusContextProvider`,
29
- * `GridLayout`, `ControlBar`, `FocusLayoutContainer` and `FocusLayout`.
30
- * You can use these components as a starting point for your own custom video conferencing application.
31
- *
32
- * @example
33
- * ```tsx
34
- * <LiveKitRoom>
35
- * <VideoConference />
36
- * <LiveKitRoom>
37
- * ```
38
- * @public
39
24
  */
40
- export declare function VideoConference({ chatMessageFormatter, chatMessageDecoder, chatMessageEncoder, SettingsComponent, speakerFocused, disableChat, disableMicrophone, disableCamera, disableShareScreen, hideParticipantList, showSettings, ...props }: VideoConferenceProps): JSX.Element;
25
+ export declare function VideoConference({ chatMessageFormatter, chatMessageDecoder, chatMessageEncoder, SettingsComponent, speakerFocused, disableChat, disableMicrophone, disableCamera, disableShareScreen, hideParticipantsList, showSettings, ...props }: VideoConferenceProps): JSX.Element;
@@ -8,27 +8,16 @@ const components_core_1 = require("@livekit/components-core");
8
8
  const livekit_client_1 = require("livekit-client");
9
9
  const components_react_1 = require("@livekit/components-react");
10
10
  const ParticipantTile_1 = require("./ParticipantTile");
11
+ const ControlBar_1 = require("./ControlBar");
11
12
  /**
12
13
  * The `VideoConference` ready-made component is your drop-in solution for a classic video conferencing application.
13
14
  * It provides functionality such as focusing on one participant, grid view with pagination to handle large numbers
14
15
  * of participants, basic non-persistent chat, screen sharing, and more.
15
16
  *
16
- * @remarks
17
- * The component is implemented with other LiveKit components like `FocusContextProvider`,
18
- * `GridLayout`, `ControlBar`, `FocusLayoutContainer` and `FocusLayout`.
19
- * You can use these components as a starting point for your own custom video conferencing application.
20
- *
21
- * @example
22
- * ```tsx
23
- * <LiveKitRoom>
24
- * <VideoConference />
25
- * <LiveKitRoom>
26
- * ```
27
- * @public
28
17
  */
29
18
  function VideoConference(_a) {
30
19
  var _b, _c;
31
- var { chatMessageFormatter, chatMessageDecoder, chatMessageEncoder, SettingsComponent, speakerFocused, disableChat = false, disableMicrophone = false, disableCamera = false, disableShareScreen = false, hideParticipantList = false, showSettings } = _a, props = tslib_1.__rest(_a, ["chatMessageFormatter", "chatMessageDecoder", "chatMessageEncoder", "SettingsComponent", "speakerFocused", "disableChat", "disableMicrophone", "disableCamera", "disableShareScreen", "hideParticipantList", "showSettings"]);
20
+ var { chatMessageFormatter, chatMessageDecoder, chatMessageEncoder, SettingsComponent, speakerFocused, disableChat = false, disableMicrophone = false, disableCamera = false, disableShareScreen = false, hideParticipantsList = false, showSettings } = _a, props = tslib_1.__rest(_a, ["chatMessageFormatter", "chatMessageDecoder", "chatMessageEncoder", "SettingsComponent", "speakerFocused", "disableChat", "disableMicrophone", "disableCamera", "disableShareScreen", "hideParticipantsList", "showSettings"]);
32
21
  const [widgetState, setWidgetState] = React.useState({
33
22
  showChat: false,
34
23
  unreadMessages: 0,
@@ -39,7 +28,6 @@ function VideoConference(_a) {
39
28
  { source: livekit_client_1.Track.Source.Camera, withPlaceholder: true },
40
29
  { source: livekit_client_1.Track.Source.ScreenShare, withPlaceholder: false }
41
30
  ], { updateOnlyOn: [livekit_client_1.RoomEvent.ActiveSpeakersChanged], onlySubscribed: false });
42
- const { localParticipant } = (0, components_react_1.useLocalParticipant)();
43
31
  const participants = (0, components_react_1.useParticipants)();
44
32
  const widgetUpdate = (state) => {
45
33
  components_core_1.log.debug('updating widget state', state);
@@ -100,13 +88,11 @@ function VideoConference(_a) {
100
88
  participants,
101
89
  speakerFocused
102
90
  ]);
103
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-video-conference" }, props, { 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: (0, jsx_runtime_1.jsxs)(components_react_1.FocusLayoutContainer, { children: [!hideParticipantList && ((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)(components_react_1.FocusLayout, { trackRef: focusTrack })] }) }))), (0, jsx_runtime_1.jsx)(components_react_1.ControlBar, { controls: Object.assign(Object.assign({}, (localParticipant.name !== speakerFocused.username
104
- ? {
105
- chat: !disableChat,
106
- microphone: !disableMicrophone,
107
- camera: !disableCamera,
108
- screenShare: !disableShareScreen
109
- }
110
- : {})), { 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, {})] })));
91
+ return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "lk-video-conference" }, props, { 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: (0, jsx_runtime_1.jsxs)(components_react_1.FocusLayoutContainer, { children: [!hideParticipantsList && ((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)(components_react_1.FocusLayout, { trackRef: focusTrack })] }) }))), (0, jsx_runtime_1.jsx)(ControlBar_1.ControlBar, { controls: Object.assign({
92
+ chat: !disableChat,
93
+ microphone: !disableMicrophone,
94
+ camera: !disableCamera,
95
+ screenShare: !disableShareScreen
96
+ }, { 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, {})] })));
111
97
  }
112
98
  exports.VideoConference = VideoConference;
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Calls all functions in the order they were chained with the same arguments.
4
+ * @internal
5
+ */
6
+ export declare function chain(...callbacks: any[]): (...args: any[]) => void;
7
+ interface Props {
8
+ [key: string]: any;
9
+ }
10
+ type TupleTypes<T> = {
11
+ [P in keyof T]: T[P];
12
+ } extends {
13
+ [key: number]: infer V;
14
+ } ? V : never;
15
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
16
+ /**
17
+ * Merges multiple props objects together. Event handlers are chained,
18
+ * classNames are combined, and ids are deduplicated - different ids
19
+ * will trigger a side-effect and re-render components hooked up with `useId`.
20
+ * For all other props, the last prop object overrides all previous ones.
21
+ * @param args - Multiple sets of props to merge together.
22
+ * @internal
23
+ */
24
+ export declare function mergePropsReactAria<T extends Props[]>(...args: T): UnionToIntersection<TupleTypes<T>>;
25
+ export declare function isProp<U extends HTMLElement, T extends React.HTMLAttributes<U>>(prop: T | undefined): prop is T;
26
+ export declare function mergeProps<U extends HTMLElement, T extends Array<React.HTMLAttributes<U> | undefined>>(...props: T): import("react").HTMLAttributes<U>;
27
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2020 Adobe. All rights reserved.
4
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License. You may obtain a copy
6
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
7
+ *
8
+ * Unless required by applicable law or agreed to in writing, software distributed under
9
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
10
+ * OF ANY KIND, either express or implied. See the License for the specific language
11
+ * governing permissions and limitations under the License.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.mergeProps = exports.isProp = exports.mergePropsReactAria = exports.chain = void 0;
15
+ const tslib_1 = require("tslib");
16
+ const clsx_1 = tslib_1.__importDefault(require("clsx"));
17
+ /**
18
+ * Calls all functions in the order they were chained with the same arguments.
19
+ * @internal
20
+ */
21
+ function chain(...callbacks) {
22
+ return (...args) => {
23
+ for (const callback of callbacks) {
24
+ if (typeof callback === 'function') {
25
+ try {
26
+ callback(...args);
27
+ }
28
+ catch (e) {
29
+ console.error(e);
30
+ }
31
+ }
32
+ }
33
+ };
34
+ }
35
+ exports.chain = chain;
36
+ /**
37
+ * Merges multiple props objects together. Event handlers are chained,
38
+ * classNames are combined, and ids are deduplicated - different ids
39
+ * will trigger a side-effect and re-render components hooked up with `useId`.
40
+ * For all other props, the last prop object overrides all previous ones.
41
+ * @param args - Multiple sets of props to merge together.
42
+ * @internal
43
+ */
44
+ function mergePropsReactAria(...args) {
45
+ // Start with a base clone of the first argument. This is a lot faster than starting
46
+ // with an empty object and adding properties as we go.
47
+ const result = Object.assign({}, args[0]);
48
+ for (let i = 1; i < args.length; i++) {
49
+ const props = args[i];
50
+ for (const key in props) {
51
+ const a = result[key];
52
+ const b = props[key];
53
+ // Chain events
54
+ if (typeof a === 'function' &&
55
+ typeof b === 'function' &&
56
+ // This is a lot faster than a regex.
57
+ key[0] === 'o' &&
58
+ key[1] === 'n' &&
59
+ key.charCodeAt(2) >= /* 'A' */ 65 &&
60
+ key.charCodeAt(2) <= /* 'Z' */ 90) {
61
+ result[key] = chain(a, b);
62
+ // Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check
63
+ }
64
+ else if ((key === 'className' || key === 'UNSAFE_className') && typeof a === 'string' && typeof b === 'string') {
65
+ result[key] = (0, clsx_1.default)(a, b);
66
+ }
67
+ else {
68
+ result[key] = b !== undefined ? b : a;
69
+ }
70
+ }
71
+ }
72
+ return result;
73
+ }
74
+ exports.mergePropsReactAria = mergePropsReactAria;
75
+ function isProp(prop) {
76
+ return prop !== undefined;
77
+ }
78
+ exports.isProp = isProp;
79
+ function mergeProps(...props) {
80
+ return mergePropsReactAria(...props.filter(isProp));
81
+ }
82
+ exports.mergeProps = mergeProps;
@@ -39,6 +39,6 @@ function NavigationMenuDrawer(inProps) {
39
39
  const { className = null, showDrawerHeader = true, drawerHeaderContent = (0, jsx_runtime_1.jsx)(DefaultHeaderContent_1.default, {}), drawerContent = (0, jsx_runtime_1.jsx)(DefaultDrawerContent_1.default, {}), showDrawerFooterContent = true, drawerFooterContent = null, ScrollContainerProps = {}, CreateLiveStreamButtonComponentProps = {}, open, onClose } = props, rest = tslib_1.__rest(props, ["className", "showDrawerHeader", "drawerHeaderContent", "drawerContent", "showDrawerFooterContent", "drawerFooterContent", "ScrollContainerProps", "CreateLiveStreamButtonComponentProps", "open", "onClose"]);
40
40
  const scUserContext = (0, react_core_1.useSCUser)();
41
41
  const canCreateLiveStream = (0, react_1.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_livestream; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
42
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ anchor: "left", className: (0, classnames_1.default)(classes.root, className), open: open, onClose: onClose }, rest, { children: [showDrawerHeader && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.drawerHeader }, { children: [drawerHeaderContent, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {})] })), (0, jsx_runtime_1.jsx)(ScrollContainer_1.default, Object.assign({}, ScrollContainerProps, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ className: classes.drawerContent, onClick: onClose }, { children: drawerContent })) })), showDrawerFooterContent && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [Boolean(drawerContent || canCreateLiveStream) && (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.drawerFooter }, { children: drawerFooterContent ? (drawerFooterContent) : ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.drawerFooterLiveStream }, { children: (0, jsx_runtime_1.jsx)(CreateLiveStreamButton_1.default, Object.assign({ color: "primary", className: classes.drawerFooterLiveStreamButton, fullWidth: true }, CreateLiveStreamButtonComponentProps)) }))) }))] }))] })));
42
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ anchor: "left", className: (0, classnames_1.default)(classes.root, className), open: open, onClose: onClose }, rest, { children: [showDrawerHeader && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.drawerHeader }, { children: [drawerHeaderContent, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {})] })), (0, jsx_runtime_1.jsx)(ScrollContainer_1.default, Object.assign({}, ScrollContainerProps, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ className: classes.drawerContent, onClick: onClose }, { children: drawerContent })) })), showDrawerFooterContent && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.drawerFooter }, { children: drawerFooterContent ? (drawerFooterContent) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [canCreateLiveStream && (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.drawerFooterLiveStream }, { children: (0, jsx_runtime_1.jsx)(CreateLiveStreamButton_1.default, Object.assign({ color: "primary", className: classes.drawerFooterLiveStreamButton, fullWidth: true }, CreateLiveStreamButtonComponentProps)) }))] })) })) }))] })));
43
43
  }
44
44
  exports.default = NavigationMenuDrawer;
@@ -5,7 +5,7 @@ import Icon from '@mui/material/Icon';
5
5
  import { styled } from '@mui/material/styles';
6
6
  import { useThemeProps } from '@mui/system';
7
7
  import { useLoadScript } from '@react-google-maps/api';
8
- import { useSCContext } from '@selfcommunity/react-core';
8
+ import { useSCContext, useSCUser } from '@selfcommunity/react-core';
9
9
  import { SCEventLocationType } from '@selfcommunity/types';
10
10
  import axios from 'axios';
11
11
  import classNames from 'classnames';
@@ -40,6 +40,7 @@ const Root = styled(Box, {
40
40
  slot: 'EventAddressRoot'
41
41
  })(() => ({}));
42
42
  export default function EventAddress(inProps) {
43
+ var _a;
43
44
  //PROPS
44
45
  const props = useThemeProps({
45
46
  props: inProps,
@@ -65,11 +66,13 @@ export default function EventAddress(inProps) {
65
66
  }, [event]);
66
67
  // CONTEXT
67
68
  const scContext = useSCContext();
69
+ const scUserContext = useSCUser();
68
70
  const geocodingApiKey = useMemo(() => scContext.settings.integrations && scContext.settings.integrations.geocoding.apiKey, [scContext.settings.integrations]);
69
71
  const { isLoaded } = useLoadScript({
70
72
  googleMapsApiKey: scContext.settings.integrations.geocoding.apiKey,
71
73
  libraries: ['places', 'geocoding']
72
74
  });
75
+ const canViewLiveTab = 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) || event.live_stream; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
73
76
  // HANDLERS
74
77
  const handleChange = (_event, newValue) => {
75
78
  setLocation(newValue);
@@ -133,7 +136,7 @@ export default function EventAddress(inProps) {
133
136
  if (!geocodingApiKey && !isLoaded) {
134
137
  return _jsx(HiddenPlaceholder, {});
135
138
  }
136
- return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsxs(Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [_jsx(Tab, { value: SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "add_location_alt" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) }), _jsx(Tab, { value: SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "play_circle_outline" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) }), _jsx(Tab, { value: SCEventLocationType.LIVESTREAM, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "photo_camera" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.liveStream.label", defaultMessage: "ui.eventForm.address.liveStream.label" }) })] })), _jsxs(Box, Object.assign({ className: classes.tabContent }, { children: [location === SCEventLocationType.PERSON && (_jsx(Autocomplete, { size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => (_jsx(TextField, Object.assign({}, params, { label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (_jsxs(_Fragment, { children: [_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(Icon, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), location === SCEventLocationType.ONLINE && (_jsx(UrlTextField, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
139
+ return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsxs(Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [_jsx(Tab, { value: SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "add_location_alt" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) }), _jsx(Tab, { value: SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "play_circle_outline" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) }), canViewLiveTab && (_jsx(Tab, { value: SCEventLocationType.LIVESTREAM, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "photo_camera" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.liveStream.label", defaultMessage: "ui.eventForm.address.liveStream.label" }) }))] })), _jsxs(Box, Object.assign({ className: classes.tabContent }, { children: [location === SCEventLocationType.PERSON && (_jsx(Autocomplete, { size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => (_jsx(TextField, Object.assign({}, params, { label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (_jsxs(_Fragment, { children: [_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(Icon, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), location === SCEventLocationType.ONLINE && (_jsx(UrlTextField, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
137
140
  endAdornment: _jsx(Icon, { children: "play_circle_outline" })
138
- }, onChange: handleLinkChange })), location === SCEventLocationType.LIVESTREAM && (_jsxs(_Fragment, { children: [_jsx(LiveStream, { template: SCLiveStreamTemplateType.SNIPPET, liveStream: liveStream, actions: _jsx(_Fragment, {}) }), _jsx(LiveStreamFormSettings, { settings: liveStream.settings, onChange: handleLiveStreamSettingsChange })] }))] }))] })));
141
+ }, onChange: handleLinkChange })), canViewLiveTab && location === SCEventLocationType.LIVESTREAM && (_jsxs(_Fragment, { children: [_jsx(LiveStream, { template: SCLiveStreamTemplateType.SNIPPET, liveStream: liveStream, actions: _jsx(_Fragment, {}) }), _jsx(LiveStreamFormSettings, { settings: liveStream.settings, onChange: handleLiveStreamSettingsChange })] }))] }))] })));
139
142
  }
@@ -6,7 +6,7 @@ import { styled } from '@mui/material/styles';
6
6
  import { useThemeProps } from '@mui/system';
7
7
  import { SCPreferences, useSCPreferences } from '@selfcommunity/react-core';
8
8
  import classNames from 'classnames';
9
- import { useCallback, useMemo, useState } from 'react';
9
+ import { useCallback, useState } from 'react';
10
10
  import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
11
11
  import { LIVE_STREAM_DESCRIPTION_MAX_LENGTH, LIVE_STREAM_TITLE_MAX_LENGTH, LIVE_STREAM_SLUG_MAX_LENGTH } from '../../constants/LiveStream';
12
12
  import { LIVESTREAM_DEFAULT_SETTINGS, PREFIX } from './constants';
@@ -96,8 +96,6 @@ export default function LiveStreamForm(inProps) {
96
96
  const [error, setError] = useState({});
97
97
  // PREFERENCES
98
98
  const scPreferences = useSCPreferences();
99
- const privateEnabled = useMemo(() => scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED].value, [scPreferences.preferences]);
100
- const visibilityEnabled = useMemo(() => scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED].value, [scPreferences.preferences]);
101
99
  const _backgroundCover = Object.assign({}, (field.cover
102
100
  ? { background: `url('${field.cover}') center / cover` }
103
101
  : { background: `url('${scPreferences.preferences[SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
@@ -151,7 +149,7 @@ export default function LiveStreamForm(inProps) {
151
149
  Logger.error(SCOPE_SC_UI, e);
152
150
  onError === null || onError === void 0 ? void 0 : onError(e);
153
151
  });
154
- }, [field, privateEnabled, visibilityEnabled, onSuccess, onError]);
152
+ }, [field, onSuccess, onError]);
155
153
  const handleChange = useCallback((event) => {
156
154
  const { name, value } = event.target;
157
155
  setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
@@ -51,7 +51,7 @@ export default function LiveStreamSettingsForm(inProps) {
51
51
  /**
52
52
  * Renders root object
53
53
  */
54
- return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.muteParticipant), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['muteParticipant']: !(settings === null || settings === void 0 ? void 0 : settings.muteParticipant) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.muteParticipant", defaultMessage: "ui.liveStreamForm.muteParticipant" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.disableVideo), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['disableVideo']: !(settings === null || settings === void 0 ? void 0 : settings.disableVideo) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.disableVideo", defaultMessage: "ui.liveStreamForm.disableVideo" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.disableChat), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['disableChat']: !(settings === null || settings === void 0 ? void 0 : settings.disableChat) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.disableChat", defaultMessage: "ui.liveStreamForm.disableChat" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.disableShareScreen), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['disableShareScreen']: !(settings === null || settings === void 0 ? void 0 : settings.disableShareScreen) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.disableShareScreen", defaultMessage: "ui.liveStreamForm.disableShareScreen" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.hideParticipantList), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['hideParticipantList']: !(settings === null || settings === void 0 ? void 0 : settings.hideParticipantList) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.hideParticipantList", defaultMessage: "ui.liveStreamForm.hideParticipantList" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.automaticallyNotifyFollowers), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['automaticallyNotifyFollowers']: !(settings === null || settings === void 0 ? void 0 : settings.automaticallyNotifyFollowers) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.automaticallyNotifyFollowers", defaultMessage: "ui.liveStreamForm.automaticallyNotifyFollowers" }) }))] })), _jsxs(FormControl, Object.assign({ className: classes.accessView }, { children: [_jsx(InputLabel, Object.assign({ id: "viewLabel" }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.view.label", defaultMessage: "ui.liveStreamForm.view.label" }) })), _jsx(Select, Object.assign({ name: "view", label: _jsx(FormattedMessage, { id: "ui.liveStreamForm.view.label", defaultMessage: "ui.liveStreamForm.view.label" }), labelId: "viewLabel", fullWidth: true, value: (_a = settings === null || settings === void 0 ? void 0 : settings.view) !== null && _a !== void 0 ? _a : SCLiveStreamViewType.SPEAKER, onChange: (e) => onChange(Object.assign(Object.assign({}, settings), { ['view']: e.target.value })), displayEmpty: true, renderValue: (selected) => {
54
+ return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.muteParticipants), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['muteParticipants']: !(settings === null || settings === void 0 ? void 0 : settings.muteParticipants) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.muteParticipants", defaultMessage: "ui.liveStreamForm.muteParticipants" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.disableVideo), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['disableVideo']: !(settings === null || settings === void 0 ? void 0 : settings.disableVideo) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.disableVideo", defaultMessage: "ui.liveStreamForm.disableVideo" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.disableChat), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['disableChat']: !(settings === null || settings === void 0 ? void 0 : settings.disableChat) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.disableChat", defaultMessage: "ui.liveStreamForm.disableChat" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.disableShareScreen), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['disableShareScreen']: !(settings === null || settings === void 0 ? void 0 : settings.disableShareScreen) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.disableShareScreen", defaultMessage: "ui.liveStreamForm.disableShareScreen" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.hideParticipantsList), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['hideParticipantsList']: !(settings === null || settings === void 0 ? void 0 : settings.hideParticipantsList) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.hideParticipantsList", defaultMessage: "ui.liveStreamForm.hideParticipantsList" }) }))] })), _jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center" }, { children: [_jsx(Switch, { className: classes.switch, checked: Boolean(settings === null || settings === void 0 ? void 0 : settings.automaticallyNotifyFollowers), onChange: () => onChange(Object.assign(Object.assign({}, settings), { ['automaticallyNotifyFollowers']: !(settings === null || settings === void 0 ? void 0 : settings.automaticallyNotifyFollowers) })) }), _jsx(Typography, Object.assign({ className: classes.switchLabel }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.automaticallyNotifyFollowers", defaultMessage: "ui.liveStreamForm.automaticallyNotifyFollowers" }) }))] })), _jsxs(FormControl, Object.assign({ className: classes.accessView }, { children: [_jsx(InputLabel, Object.assign({ id: "viewLabel" }, { children: _jsx(FormattedMessage, { id: "ui.liveStreamForm.view.label", defaultMessage: "ui.liveStreamForm.view.label" }) })), _jsx(Select, Object.assign({ name: "view", label: _jsx(FormattedMessage, { id: "ui.liveStreamForm.view.label", defaultMessage: "ui.liveStreamForm.view.label" }), labelId: "viewLabel", fullWidth: true, value: (_a = settings === null || settings === void 0 ? void 0 : settings.view) !== null && _a !== void 0 ? _a : SCLiveStreamViewType.SPEAKER, onChange: (e) => onChange(Object.assign(Object.assign({}, settings), { ['view']: e.target.value })), displayEmpty: true, renderValue: (selected) => {
55
55
  return (_jsxs(_Fragment, { children: [_jsx(Icon, Object.assign({ className: classes.accessViewIcon }, { children: selected === SCLiveStreamViewType.SPEAKER ? 'upload' : 'category' })), "\u00A0", _jsx(FormattedMessage, { id: `ui.liveStreamForm.view.${selected}`, defaultMessage: `ui.liveStreamForm.view.${selected}` })] }));
56
56
  } }, { children: Object.values(SCLiveStreamViewType).map((f) => (_jsx(MenuItem, Object.assign({ value: f }, { children: _jsxs(Box, { children: [_jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsxs("b", { children: [_jsx(Icon, Object.assign({ className: classes.accessViewIcon }, { children: f === SCLiveStreamViewType.SPEAKER ? 'upload' : 'category' })), "\u00A0", _jsx(FormattedMessage, { id: `ui.liveStreamForm.view.${f}`, defaultMessage: `ui.liveStreamForm.view.${f}` })] }) })), _jsx(Typography, { children: _jsx(FormattedMessage, { id: `ui.liveStreamForm.view.${f}.description`, defaultMessage: `ui.liveStreamForm.view.${f}.description` }) })] }) }), f))) }))] }))] })));
57
57
  }