@100mslive/roomkit-react 0.1.7-alpha.0 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. package/dist/{HLSView-F5BDZVT2.js → HLSView-3S74KF3A.js} +6 -5
  2. package/dist/{HLSView-F5BDZVT2.js.map → HLSView-3S74KF3A.js.map} +2 -2
  3. package/dist/Prebuilt/components/RoleChangeRequest/RequestPrompt.d.ts +9 -0
  4. package/dist/VideoTile/StyledVideoTile.d.ts +445 -3
  5. package/dist/{VirtualBackground-THDRYDRA.js → VirtualBackground-3TI5NA4V.js} +3 -3
  6. package/dist/{chunk-JSH7SKEH.js → chunk-36X4ZCLC.js} +2 -2
  7. package/dist/{chunk-U3G743OY.js → chunk-5DQ3WTED.js} +2 -2
  8. package/dist/{chunk-U3G743OY.js.map → chunk-5DQ3WTED.js.map} +1 -1
  9. package/dist/{chunk-CDYRVICT.js → chunk-Z7P5WITU.js} +40 -32
  10. package/dist/chunk-Z7P5WITU.js.map +7 -0
  11. package/dist/{conference-6IVZHILI.js → conference-JNABIZBG.js} +506 -490
  12. package/dist/conference-JNABIZBG.js.map +7 -0
  13. package/dist/index.cjs.js +826 -790
  14. package/dist/index.cjs.js.map +4 -4
  15. package/dist/index.js +2 -2
  16. package/dist/meta.cjs.json +185 -126
  17. package/dist/meta.esbuild.json +221 -162
  18. package/package.json +6 -6
  19. package/src/Input/Input.tsx +1 -1
  20. package/src/Prebuilt/common/utils.js +7 -0
  21. package/src/Prebuilt/components/Chat/ChatBody.jsx +125 -106
  22. package/src/Prebuilt/components/Footer/ParticipantList.jsx +1 -1
  23. package/src/Prebuilt/components/Leave/DesktopLeaveRoom.tsx +36 -44
  24. package/src/Prebuilt/components/Leave/MwebLeaveRoom.tsx +23 -35
  25. package/src/Prebuilt/components/Preview/PreviewJoin.tsx +5 -3
  26. package/src/Prebuilt/components/RaiseHand.jsx +4 -11
  27. package/src/Prebuilt/components/RoleChangeRequest/RequestPrompt.tsx +66 -0
  28. package/src/Prebuilt/components/{RoleChangeRequestModal.tsx → RoleChangeRequest/RoleChangeRequestModal.tsx} +18 -50
  29. package/src/Prebuilt/components/VideoTile.jsx +18 -12
  30. package/src/Prebuilt/components/conference.jsx +1 -1
  31. package/src/Prebuilt/components/hooks/useMetadata.jsx +2 -1
  32. package/src/Prebuilt/layouts/HLSView.jsx +3 -2
  33. package/src/Prebuilt/layouts/SidePane.tsx +0 -1
  34. package/src/VideoTile/StyledVideoTile.tsx +10 -14
  35. package/dist/chunk-CDYRVICT.js.map +0 -7
  36. package/dist/conference-6IVZHILI.js.map +0 -7
  37. /package/dist/Prebuilt/components/{RoleChangeRequestModal.d.ts → RoleChangeRequest/RoleChangeRequestModal.d.ts} +0 -0
  38. /package/dist/{VirtualBackground-THDRYDRA.js.map → VirtualBackground-3TI5NA4V.js.map} +0 -0
  39. /package/dist/{chunk-JSH7SKEH.js.map → chunk-36X4ZCLC.js.map} +0 -0
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import { useMedia } from 'react-use';
3
+ import { Box, Button, config as cssConfig, Dialog, Flex, Text } from '../../..';
4
+ import { Sheet } from '../../../Sheet';
5
+
6
+ export const RequestPrompt = ({
7
+ open = true,
8
+ onOpenChange,
9
+ title,
10
+ body,
11
+ actionText = 'Accept',
12
+ onAction,
13
+ }: {
14
+ open?: boolean;
15
+ onOpenChange: (value: boolean) => void;
16
+ title: string;
17
+ body: React.ReactNode;
18
+ actionText?: string;
19
+ onAction: () => void;
20
+ }) => {
21
+ const isMobile = useMedia(cssConfig.media.md);
22
+
23
+ if (isMobile) {
24
+ return (
25
+ <Sheet.Root open={open} onOpenChange={onOpenChange}>
26
+ <Sheet.Content css={{ py: '$8' }}>
27
+ <Text css={{ fontWeight: '$semiBold', c: '$on_surface_high', '@md': { px: '$8' } }}>{title}</Text>
28
+ {body}
29
+ <RequestActions actionText={actionText} onAction={onAction} />
30
+ </Sheet.Content>
31
+ </Sheet.Root>
32
+ );
33
+ }
34
+
35
+ return (
36
+ <Dialog.Root open={open} onOpenChange={onOpenChange}>
37
+ <Dialog.Portal>
38
+ <Dialog.Overlay />
39
+ <Dialog.Content css={{ p: '$10' }}>
40
+ <Dialog.Title css={{ p: 0, display: 'flex', flexDirection: 'row', gap: '$md', justifyContent: 'center' }}>
41
+ <Text variant="h6">{title}</Text>
42
+ </Dialog.Title>
43
+ <Box css={{ mt: '$4', mb: '$10' }}>{body}</Box>
44
+ <RequestActions actionText={actionText} onAction={onAction} />
45
+ </Dialog.Content>
46
+ </Dialog.Portal>
47
+ </Dialog.Root>
48
+ );
49
+ };
50
+
51
+ const RequestActions = ({ onAction, actionText }: { actionText?: string; onAction: () => void }) => (
52
+ <Flex justify="center" align="center" css={{ width: '100%', gap: '$md', '@md': { mt: '$8', px: '$8' } }}>
53
+ <Box css={{ width: '50%' }}>
54
+ <Dialog.Close css={{ width: '100%' }}>
55
+ <Button variant="standard" outlined css={{ width: '100%' }}>
56
+ Decline
57
+ </Button>
58
+ </Dialog.Close>
59
+ </Box>
60
+ <Box css={{ width: '50%' }}>
61
+ <Button variant="primary" css={{ width: '100%' }} onClick={onAction}>
62
+ {actionText}
63
+ </Button>
64
+ </Box>
65
+ </Flex>
66
+ );
@@ -7,13 +7,14 @@ import {
7
7
  useHMSActions,
8
8
  useHMSStore,
9
9
  } from '@100mslive/react-sdk';
10
+ import { Flex, Text } from '../../..';
10
11
  // @ts-ignore: No implicit Any
11
- import { PreviewControls, PreviewTile } from './Preview/PreviewJoin';
12
- import { Box, Button, Dialog, Flex, Text } from '../..';
12
+ import { PreviewControls, PreviewTile } from '../Preview/PreviewJoin';
13
+ import { RequestPrompt } from './RequestPrompt';
13
14
  // @ts-ignore: No implicit Any
14
- import { useMyMetadata } from './hooks/useMetadata';
15
+ import { useMyMetadata } from '../hooks/useMetadata';
15
16
  // @ts-ignore: No implicit Any
16
- import { ROLE_CHANGE_DECLINED } from '../common/constants';
17
+ import { ROLE_CHANGE_DECLINED } from '../../common/constants';
17
18
 
18
19
  export const RoleChangeRequestModal = () => {
19
20
  const hmsActions = useHMSActions();
@@ -38,7 +39,14 @@ export const RoleChangeRequestModal = () => {
38
39
 
39
40
  const body = (
40
41
  <>
41
- <Text css={{ fontWeight: 400, c: '$on_surface_medium', textAlign: 'center' }}>
42
+ <Text
43
+ variant="xs"
44
+ css={{
45
+ c: '$on_surface_medium',
46
+ textAlign: 'center',
47
+ '@md': { textAlign: 'left', borderBottom: '1px solid $border_bright', pb: '$4', px: '$8' },
48
+ }}
49
+ >
42
50
  Setup your audio and video before joining
43
51
  </Text>
44
52
  <Flex
@@ -48,20 +56,22 @@ export const RoleChangeRequestModal = () => {
48
56
  '@sm': { width: '100%' },
49
57
  flexDirection: 'column',
50
58
  mt: '$6',
59
+ '@md': { px: '$8' },
51
60
  }}
52
61
  >
53
62
  <PreviewTile name={name || ''} />
63
+
54
64
  <PreviewControls hideSettings={true} />
55
65
  </Flex>
56
66
  </>
57
67
  );
58
68
 
59
69
  return (
60
- <RequestDialog
61
- title={`You're invited to join the ${roleChangeRequest.role.name} role`}
70
+ <RequestPrompt
71
+ title="You're invited to join the stage"
62
72
  onOpenChange={async value => {
63
73
  if (!value) {
64
- await hmsActions.rejectChangeRole(roleChangeRequest);
74
+ hmsActions.rejectChangeRole(roleChangeRequest);
65
75
  sendEvent({ ...roleChangeRequest, peerName: name }, { peerId: roleChangeRequest.requestedBy?.id });
66
76
  await hmsActions.cancelMidCallPreview();
67
77
  await hmsActions.lowerLocalPeerHand();
@@ -77,45 +87,3 @@ export const RoleChangeRequestModal = () => {
77
87
  />
78
88
  );
79
89
  };
80
-
81
- const RequestDialog = ({
82
- open = true,
83
- onOpenChange,
84
- title,
85
- body,
86
- actionText = 'Accept',
87
- onAction,
88
- }: {
89
- open?: boolean;
90
- onOpenChange: (value: boolean) => void;
91
- title: string;
92
- body: React.ReactNode;
93
- actionText?: string;
94
- onAction: () => void;
95
- }) => (
96
- <Dialog.Root open={open} onOpenChange={onOpenChange}>
97
- <Dialog.Portal>
98
- <Dialog.Overlay />
99
- <Dialog.Content css={{ p: '$10' }}>
100
- <Dialog.Title css={{ p: 0, display: 'flex', flexDirection: 'row', gap: '$md', justifyContent: 'center' }}>
101
- <Text variant="h6">{title}</Text>
102
- </Dialog.Title>
103
- <Box css={{ mt: '$4', mb: '$10' }}>{body}</Box>
104
- <Flex justify="center" align="center" css={{ width: '100%', gap: '$md' }}>
105
- <Box css={{ width: '50%' }}>
106
- <Dialog.Close css={{ width: '100%' }}>
107
- <Button variant="standard" outlined css={{ width: '100%' }}>
108
- Cancel
109
- </Button>
110
- </Dialog.Close>
111
- </Box>
112
- <Box css={{ width: '50%' }}>
113
- <Button variant="primary" css={{ width: '100%' }} onClick={onAction}>
114
- {actionText}
115
- </Button>
116
- </Box>
117
- </Flex>
118
- </Dialog.Content>
119
- </Dialog.Portal>
120
- </Dialog.Root>
121
- );
@@ -25,6 +25,7 @@ import { Video } from '../../Video';
25
25
  import { StyledVideoTile } from '../../VideoTile';
26
26
  import { getVideoTileLabel } from './peerTileUtils';
27
27
  import { useSetAppDataByKey, useUISettings } from './AppData/useUISettings';
28
+ import { getAttributeBoxSize } from '../common/utils';
28
29
  import { APP_DATA, SESSION_STORE_KEY, UI_SETTINGS } from '../common/constants';
29
30
 
30
31
  const Tile = ({
@@ -72,21 +73,28 @@ const Tile = ({
72
73
  const onHoverHandler = useCallback(event => {
73
74
  setIsMouseHovered(event.type === 'mouseenter');
74
75
  }, []);
75
- const isTileBigEnoughToShowStats = height >= 180 && width >= 180;
76
+
77
+ const ref = useRef(null);
78
+ const calculatedHeight = ref.current?.clientHeight || '';
79
+ const calculatedWidth = ref.current?.clientWidth || '';
80
+
81
+ const isTileBigEnoughToShowStats = calculatedHeight >= 180 && calculatedWidth >= 180;
82
+
76
83
  const avatarSize = useMemo(() => {
77
- if (!width || !height) {
84
+ if (!calculatedWidth || !calculatedHeight) {
78
85
  return undefined;
79
86
  }
80
- if (width <= 150 || height <= 150) {
87
+ if (calculatedWidth <= 150 || calculatedHeight <= 150) {
81
88
  return 'small';
82
- } else if (width <= 300 || height <= 300) {
89
+ } else if (calculatedWidth <= 300 || calculatedHeight <= 300) {
83
90
  return 'medium';
84
91
  }
85
92
  return 'large';
86
- }, [width, height]);
93
+ }, [calculatedWidth, calculatedHeight]);
87
94
 
88
95
  return (
89
96
  <StyledVideoTile.Root
97
+ ref={ref}
90
98
  css={{
91
99
  width,
92
100
  height,
@@ -133,7 +141,7 @@ const Tile = ({
133
141
  isAudioMuted ? (
134
142
  <StyledVideoTile.AudioIndicator
135
143
  data-testid="participant_audio_mute_icon"
136
- size={width && height && (width < 180 || height < 180) ? 'small' : 'medium'}
144
+ size={getAttributeBoxSize(calculatedWidth, calculatedHeight)}
137
145
  >
138
146
  <MicOffIcon />
139
147
  </StyledVideoTile.AudioIndicator>
@@ -150,7 +158,7 @@ const Tile = ({
150
158
  enableSpotlightingPeer={enableSpotlightingPeer}
151
159
  />
152
160
  ) : null}
153
- {!hideMetadataOnTile && <PeerMetadata peerId={peerId} />}
161
+ {!hideMetadataOnTile && <PeerMetadata peerId={peerId} height={calculatedHeight} width={calculatedWidth} />}
154
162
 
155
163
  <TileConnection
156
164
  hideLabel={hideParticipantNameOnTile}
@@ -167,8 +175,6 @@ const Tile = ({
167
175
  );
168
176
  };
169
177
 
170
- const metaStyles = { top: '$4', left: '$4', width: '$14', height: '$14' };
171
-
172
178
  const heightAnimation = value =>
173
179
  keyframes({
174
180
  '50%': {
@@ -218,7 +224,7 @@ export const AudioLevel = ({ trackId }) => {
218
224
  );
219
225
  };
220
226
 
221
- const PeerMetadata = ({ peerId }) => {
227
+ const PeerMetadata = ({ peerId, height, width }) => {
222
228
  const metaData = useHMSStore(selectPeerMetadata(peerId));
223
229
  const isBRB = metaData?.isBRBOn || false;
224
230
  const isHandRaised = useHMSStore(selectHasPeerHandRaised(peerId));
@@ -226,12 +232,12 @@ const PeerMetadata = ({ peerId }) => {
226
232
  return (
227
233
  <Fragment>
228
234
  {isHandRaised ? (
229
- <StyledVideoTile.AttributeBox css={metaStyles} data-testid="raiseHand_icon_onTile">
235
+ <StyledVideoTile.AttributeBox size={getAttributeBoxSize(width, height)} data-testid="raiseHand_icon_onTile">
230
236
  <HandIcon width={24} height={24} />
231
237
  </StyledVideoTile.AttributeBox>
232
238
  ) : null}
233
239
  {isBRB ? (
234
- <StyledVideoTile.AttributeBox css={metaStyles} data-testid="brb_icon_onTile">
240
+ <StyledVideoTile.AttributeBox size={getAttributeBoxSize(width, height)} data-testid="brb_icon_onTile">
235
241
  <BrbTileIcon width={22} height={22} />
236
242
  </StyledVideoTile.AttributeBox>
237
243
  ) : null}
@@ -13,12 +13,12 @@ import { Footer } from './Footer/Footer';
13
13
  import { HLSFailureModal } from './Notifications/HLSFailureModal';
14
14
  import { ActivatedPIP } from './PIP/PIPComponent';
15
15
  import { PictureInPicture } from './PIP/PIPManager';
16
+ import { RoleChangeRequestModal } from './RoleChangeRequest/RoleChangeRequestModal';
16
17
  import { Box, Flex } from '../../Layout';
17
18
  import { useHMSPrebuiltContext } from '../AppContext';
18
19
  import { VideoStreamingSection } from '../layouts/VideoStreamingSection';
19
20
  import FullPageProgress from './FullPageProgress';
20
21
  import { Header } from './Header';
21
- import { RoleChangeRequestModal } from './RoleChangeRequestModal';
22
22
  import {
23
23
  useRoomLayoutConferencingScreen,
24
24
  useRoomLayoutPreviewScreen,
@@ -31,12 +31,13 @@ export const useMyMetadata = () => {
31
31
  await hmsActions.lowerLocalPeerHand();
32
32
  } else {
33
33
  await hmsActions.raiseLocalPeerHand();
34
+ await update({ isBRBOn: false });
34
35
  }
35
36
  }, [isHandRaised]); //eslint-disable-line
36
37
 
37
38
  const toggleBRB = useCallback(async () => {
38
39
  const newValue = !metaData?.isBRBOn;
39
- await update({ isBRBOn: !metaData?.isBRBOn });
40
+ await update({ isBRBOn: newValue });
40
41
  if (newValue) {
41
42
  await hmsActions.lowerLocalPeerHand();
42
43
  }
@@ -272,9 +272,10 @@ const HLSView = () => {
272
272
  top: '40%',
273
273
  left: '50%',
274
274
  transform: 'translateY(-40%) translateX(-50%)',
275
- padding: '$4 $14',
275
+ padding: '$8 14px $8 18px',
276
276
  display: 'inline-flex',
277
- r: '$0',
277
+ r: '50%',
278
+ gap: '$1',
278
279
  bg: '$primary_default',
279
280
  }}
280
281
  >
@@ -64,7 +64,6 @@ const SidePane = ({
64
64
  <VideoTile
65
65
  peerId={activeScreensharePeerId}
66
66
  trackId={trackId}
67
- width="100%"
68
67
  height={225}
69
68
  rootCSS={{ p: 0, alignSelf: 'start', flexShrink: 0 }}
70
69
  {...tileLayout}
@@ -56,20 +56,9 @@ const Info = styled('div', {
56
56
  });
57
57
 
58
58
  const AttributeBox = styled('div', {
59
- position: 'absolute',
60
- color: '$on_primary_high',
61
- w: '$12',
62
- h: '$12',
63
- bg: '$secondary_dim',
64
- r: '$round',
65
- ...flexCenter,
66
- });
67
-
68
- const AudioIndicator = styled('div', {
69
59
  position: 'absolute',
70
60
  top: '$4',
71
- right: '$4',
72
- color: '$on_primary_high',
61
+ color: '$on_secondary_high',
73
62
  bg: '$secondary_dim',
74
63
  borderRadius: '$round',
75
64
  width: '$14',
@@ -91,12 +80,19 @@ const AudioIndicator = styled('div', {
91
80
  height: '$13',
92
81
  },
93
82
  },
83
+ position: {
84
+ left: { left: '$4' },
85
+ right: { right: '$4' },
86
+ },
94
87
  },
95
88
  defaultVariants: {
96
89
  size: 'medium',
90
+ position: 'left',
97
91
  },
98
92
  });
99
93
 
94
+ const AudioIndicator = styled(AttributeBox, { defaultVariants: { position: 'right' } });
95
+
100
96
  const FullScreenButton = styled('button', {
101
97
  width: '2.25rem',
102
98
  height: '2.25rem',
@@ -136,9 +132,9 @@ interface VideoTileType {
136
132
  Container: typeof Container;
137
133
  Overlay: typeof Overlay;
138
134
  Info: typeof Info;
139
- AudioIndicator: typeof AudioIndicator;
140
135
  AvatarContainer: typeof AvatarContainer;
141
136
  AttributeBox: typeof AttributeBox;
137
+ AudioIndicator: typeof AudioIndicator;
142
138
  FullScreenButton: typeof FullScreenButton;
143
139
  }
144
140
 
@@ -147,8 +143,8 @@ export const StyledVideoTile: VideoTileType = {
147
143
  Container,
148
144
  Overlay,
149
145
  Info,
150
- AudioIndicator,
151
146
  AvatarContainer,
152
147
  AttributeBox,
148
+ AudioIndicator,
153
149
  FullScreenButton,
154
150
  };