@100mslive/roomkit-react 0.1.5 → 0.1.6-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. package/dist/{HLSView-P57IRMAR.js → HLSView-PY2FKWX3.js} +191 -123
  2. package/dist/HLSView-PY2FKWX3.js.map +7 -0
  3. package/dist/Prebuilt/App.d.ts +3 -0
  4. package/dist/Prebuilt/AppContext.d.ts +13 -0
  5. package/dist/Prebuilt/common/PeersSorter.d.ts +21 -0
  6. package/dist/Prebuilt/components/Footer/Footer.d.ts +6 -0
  7. package/dist/Prebuilt/components/Header/Header.d.ts +2 -0
  8. package/dist/Prebuilt/components/InsetTile.d.ts +2 -0
  9. package/dist/Prebuilt/components/Leave/DesktopLeaveRoom.d.ts +7 -0
  10. package/dist/Prebuilt/components/Leave/EndSessionContent.d.ts +8 -0
  11. package/dist/Prebuilt/components/Leave/LeaveAtoms.d.ts +2196 -0
  12. package/dist/Prebuilt/components/Leave/LeaveCard.d.ts +12 -0
  13. package/dist/Prebuilt/components/Leave/LeaveRoom.d.ts +5 -0
  14. package/dist/Prebuilt/components/Leave/LeaveSessionContent.d.ts +6 -0
  15. package/dist/Prebuilt/components/Leave/MwebLeaveRoom.d.ts +7 -0
  16. package/dist/Prebuilt/components/MoreSettings/MoreSettings.d.ts +6 -0
  17. package/dist/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.d.ts +6 -0
  18. package/dist/Prebuilt/components/Pagination.d.ts +6 -0
  19. package/dist/Prebuilt/components/Preview/PreviewForm.d.ts +10 -0
  20. package/dist/Prebuilt/components/SecondaryTiles.d.ts +3 -0
  21. package/dist/Prebuilt/components/VideoLayouts/EqualProminence.d.ts +3 -0
  22. package/dist/Prebuilt/components/VideoLayouts/Grid.d.ts +5 -0
  23. package/dist/Prebuilt/components/VideoLayouts/GridLayout.d.ts +10 -0
  24. package/dist/Prebuilt/components/VideoLayouts/ProminenceLayout.d.ts +12 -0
  25. package/dist/Prebuilt/components/VideoLayouts/RoleProminence.d.ts +3 -0
  26. package/dist/Prebuilt/components/VideoLayouts/ScreenshareLayout.d.ts +3 -0
  27. package/dist/Prebuilt/components/VideoLayouts/interface.d.ts +8 -0
  28. package/dist/Prebuilt/components/hooks/useRoleProminencePeers.d.ts +5 -0
  29. package/dist/Prebuilt/components/hooks/useTileLayout.d.ts +12 -0
  30. package/dist/Prebuilt/components/hooks/useVideoTileLayout.d.ts +11 -0
  31. package/dist/Prebuilt/layouts/SidePane.d.ts +6 -0
  32. package/dist/Prebuilt/layouts/VideoStreamingSection.d.ts +6 -0
  33. package/dist/Prebuilt/plugins/whiteboard/ToggleWhiteboard.d.ts +5 -0
  34. package/dist/Prebuilt/provider/roomLayoutProvider/hooks/useFetchRoomLayout.d.ts +1 -0
  35. package/dist/Prebuilt/provider/roomLayoutProvider/hooks/useInsetEnabled.d.ts +1 -0
  36. package/dist/Prebuilt/provider/roomLayoutProvider/hooks/useRoomLayoutScreen.d.ts +17 -0
  37. package/dist/Prebuilt/provider/roomLayoutProvider/index.d.ts +6 -1
  38. package/dist/{VirtualBackground-GGCQJ5JM.js → VirtualBackground-AYDHYLIZ.js} +5 -11
  39. package/dist/VirtualBackground-AYDHYLIZ.js.map +7 -0
  40. package/dist/{chunk-P5X32KOD.js → chunk-E2M2ZSOL.js} +8 -5
  41. package/dist/chunk-E2M2ZSOL.js.map +7 -0
  42. package/dist/chunk-GQD2AGWW.js +888 -0
  43. package/dist/chunk-GQD2AGWW.js.map +7 -0
  44. package/dist/{chunk-OSM4QEQG.js → chunk-RXTHJUMZ.js} +2462 -4738
  45. package/dist/chunk-RXTHJUMZ.js.map +7 -0
  46. package/dist/conference-V2XZGTKU.js +5927 -0
  47. package/dist/conference-V2XZGTKU.js.map +7 -0
  48. package/dist/index.cjs.js +9414 -15534
  49. package/dist/index.cjs.js.map +4 -4
  50. package/dist/index.js +2 -2
  51. package/dist/meta.cjs.json +2156 -3347
  52. package/dist/meta.esbuild.json +2601 -3885
  53. package/package.json +7 -7
  54. package/src/Button/Button.tsx +2 -2
  55. package/src/Prebuilt/App.tsx +49 -33
  56. package/src/Prebuilt/{AppContext.jsx → AppContext.tsx} +11 -3
  57. package/src/Prebuilt/IconButton.jsx +1 -0
  58. package/src/Prebuilt/Prebuilt.stories.tsx +1 -0
  59. package/src/Prebuilt/common/{PeersSorter.js → PeersSorter.ts} +15 -10
  60. package/src/Prebuilt/common/constants.js +3 -112
  61. package/src/Prebuilt/common/hooks.js +34 -1
  62. package/src/Prebuilt/common/utils.js +0 -8
  63. package/src/Prebuilt/components/AppData/AppData.jsx +3 -13
  64. package/src/Prebuilt/components/AppData/useUISettings.js +0 -4
  65. package/src/Prebuilt/components/AudioVideoToggle.jsx +6 -0
  66. package/src/Prebuilt/components/AuthToken.jsx +11 -42
  67. package/src/Prebuilt/components/Chat/Chat.jsx +57 -26
  68. package/src/Prebuilt/components/Chat/ChatBody.jsx +92 -32
  69. package/src/Prebuilt/components/Chat/ChatFooter.jsx +72 -48
  70. package/src/Prebuilt/components/Chat/ChatParticipantHeader.jsx +73 -0
  71. package/src/Prebuilt/components/Chat/ChatSelector.jsx +16 -17
  72. package/src/Prebuilt/components/Chat/ChatSelectorContainer.jsx +81 -0
  73. package/src/Prebuilt/components/Connection/TileConnection.jsx +30 -12
  74. package/src/Prebuilt/components/EmojiReaction.jsx +18 -17
  75. package/src/Prebuilt/components/Footer/ChatToggle.jsx +1 -7
  76. package/src/Prebuilt/components/Footer/Footer.tsx +89 -0
  77. package/src/Prebuilt/components/Footer/ParticipantList.jsx +213 -173
  78. package/src/Prebuilt/components/Footer/RoleAccordion.jsx +78 -0
  79. package/src/Prebuilt/components/HMSVideo/Controls.jsx +2 -2
  80. package/src/Prebuilt/components/HMSVideo/HLSQualitySelector.jsx +33 -10
  81. package/src/Prebuilt/components/HMSVideo/PlayButton.jsx +1 -1
  82. package/src/Prebuilt/components/HMSVideo/VideoTime.jsx +3 -3
  83. package/src/Prebuilt/components/HMSVideo/VolumeControl.jsx +38 -9
  84. package/src/Prebuilt/components/Header/{ConferencingHeader.jsx → Header.tsx} +9 -7
  85. package/src/Prebuilt/components/Header/HeaderComponents.jsx +13 -4
  86. package/src/Prebuilt/components/Header/StreamActions.jsx +33 -60
  87. package/src/Prebuilt/components/Header/index.tsx +1 -0
  88. package/src/Prebuilt/components/IconButtonWithOptions/IconButtonWithOptions.jsx +17 -3
  89. package/src/Prebuilt/components/InsetTile.tsx +122 -0
  90. package/src/Prebuilt/components/{MoreSettings/SplitComponents/DesktopLeaveRoom.jsx → Leave/DesktopLeaveRoom.tsx} +50 -18
  91. package/src/Prebuilt/components/{EndSessionContent.jsx → Leave/EndSessionContent.tsx} +19 -9
  92. package/src/Prebuilt/components/Leave/LeaveAtoms.tsx +26 -0
  93. package/src/Prebuilt/components/{LeaveCard.jsx → Leave/LeaveCard.tsx} +22 -3
  94. package/src/Prebuilt/components/Leave/LeaveRoom.tsx +63 -0
  95. package/src/Prebuilt/components/{LeaveSessionContent.jsx → Leave/LeaveSessionContent.tsx} +13 -5
  96. package/src/Prebuilt/components/{MoreSettings/SplitComponents/MwebLeaveRoom.jsx → Leave/MwebLeaveRoom.tsx} +38 -13
  97. package/src/Prebuilt/components/MetaActions.jsx +15 -23
  98. package/src/Prebuilt/components/MoreSettings/ActionTile.jsx +5 -0
  99. package/src/Prebuilt/components/MoreSettings/ChangeNameContent.jsx +12 -7
  100. package/src/Prebuilt/components/MoreSettings/ChangeNameModal.jsx +1 -1
  101. package/src/Prebuilt/components/MoreSettings/FullScreenItem.jsx +1 -4
  102. package/src/Prebuilt/components/MoreSettings/MoreSettings.tsx +27 -0
  103. package/src/Prebuilt/components/MoreSettings/SplitComponents/{DesktopOptions.jsx → DesktopOptions.tsx} +86 -75
  104. package/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.jsx +20 -19
  105. package/src/Prebuilt/components/Notifications/HLSFailureModal.jsx +3 -1
  106. package/src/Prebuilt/components/Notifications/Notifications.jsx +18 -11
  107. package/src/Prebuilt/components/Notifications/PeerNotifications.jsx +14 -2
  108. package/src/Prebuilt/components/Notifications/PermissionErrorModal.jsx +10 -4
  109. package/src/Prebuilt/components/PIP/PIPComponent.jsx +7 -16
  110. package/src/Prebuilt/components/PIP/PIPManager.js +1 -0
  111. package/src/Prebuilt/components/{Pagination.jsx → Pagination.tsx} +35 -6
  112. package/src/Prebuilt/components/Playlist/Playlist.jsx +1 -6
  113. package/src/Prebuilt/components/PostLeave.jsx +7 -7
  114. package/src/Prebuilt/components/Preview/PreviewContainer.jsx +5 -13
  115. package/src/Prebuilt/components/Preview/{PreviewForm.jsx → PreviewForm.tsx} +14 -4
  116. package/src/Prebuilt/components/Preview/PreviewJoin.jsx +9 -7
  117. package/src/Prebuilt/components/RaiseHand.jsx +0 -7
  118. package/src/Prebuilt/components/RoleChangeRequestModal.jsx +82 -6
  119. package/src/Prebuilt/components/ScreenshareDisplay.jsx +4 -10
  120. package/src/Prebuilt/components/ScreenshareTile.jsx +41 -33
  121. package/src/Prebuilt/components/SecondaryTiles.tsx +34 -0
  122. package/src/Prebuilt/components/Settings/LayoutSettings.jsx +2 -12
  123. package/src/Prebuilt/components/Settings/NotificationSettings.jsx +3 -9
  124. package/src/Prebuilt/components/Settings/SettingsModal.jsx +3 -9
  125. package/src/Prebuilt/components/StatsForNerds.jsx +3 -1
  126. package/src/Prebuilt/components/TileMenu/TileMenu.jsx +15 -16
  127. package/src/Prebuilt/components/TileMenu/TileMenuContent.jsx +21 -19
  128. package/src/Prebuilt/components/Toast/ToastConfig.jsx +53 -11
  129. package/src/Prebuilt/components/VideoLayouts/EqualProminence.tsx +62 -0
  130. package/src/Prebuilt/components/VideoLayouts/Grid.tsx +41 -0
  131. package/src/Prebuilt/components/VideoLayouts/GridLayout.tsx +92 -0
  132. package/src/Prebuilt/components/VideoLayouts/ProminenceLayout.tsx +60 -0
  133. package/src/Prebuilt/components/VideoLayouts/RoleProminence.tsx +56 -0
  134. package/src/Prebuilt/components/VideoLayouts/ScreenshareLayout.tsx +36 -0
  135. package/src/Prebuilt/components/VideoLayouts/interface.ts +9 -0
  136. package/src/Prebuilt/components/VideoTile.jsx +93 -43
  137. package/src/Prebuilt/components/conference.jsx +24 -20
  138. package/src/Prebuilt/components/hooks/useMetadata.jsx +7 -0
  139. package/src/Prebuilt/components/hooks/useRoleProminencePeers.tsx +38 -0
  140. package/src/Prebuilt/components/hooks/useTileLayout.tsx +121 -0
  141. package/src/Prebuilt/components/hooks/useVideoTileLayout.ts +22 -0
  142. package/src/Prebuilt/components/pdfAnnotator/pdfFileOptions.jsx +5 -72
  143. package/src/Prebuilt/components/pdfAnnotator/submitPdf.jsx +4 -45
  144. package/src/Prebuilt/components/pdfAnnotator/uploadedFile.jsx +2 -17
  145. package/src/Prebuilt/components/peerTileUtils.jsx +1 -1
  146. package/src/Prebuilt/images/empty-chat.svg +12 -0
  147. package/src/Prebuilt/layouts/EmbedView.jsx +17 -40
  148. package/src/Prebuilt/layouts/HLSView.jsx +83 -66
  149. package/src/Prebuilt/layouts/PDFView.jsx +1 -11
  150. package/src/Prebuilt/layouts/SidePane.tsx +96 -0
  151. package/src/Prebuilt/layouts/{mainView.jsx → VideoStreamingSection.tsx} +38 -47
  152. package/src/Prebuilt/layouts/WhiteboardView.jsx +10 -34
  153. package/src/Prebuilt/plugins/VirtualBackground/VirtualBackground.jsx +1 -4
  154. package/src/Prebuilt/plugins/whiteboard/{ToggleWhiteboard.jsx → ToggleWhiteboard.tsx} +5 -9
  155. package/src/Prebuilt/primitives/DialogContent.jsx +15 -11
  156. package/src/Prebuilt/provider/roomLayoutProvider/constants/index.ts +17 -2
  157. package/src/Prebuilt/provider/roomLayoutProvider/hooks/useFetchRoomLayout.ts +36 -13
  158. package/src/Prebuilt/provider/roomLayoutProvider/hooks/useInsetEnabled.ts +10 -0
  159. package/src/Prebuilt/provider/roomLayoutProvider/hooks/useRoomLayoutScreen.ts +65 -0
  160. package/src/Prebuilt/provider/roomLayoutProvider/index.tsx +17 -6
  161. package/dist/HLSView-P57IRMAR.js.map +0 -7
  162. package/dist/PinnedTrackView-4FYJEBTB.js +0 -102
  163. package/dist/PinnedTrackView-4FYJEBTB.js.map +0 -7
  164. package/dist/VirtualBackground-GGCQJ5JM.js.map +0 -7
  165. package/dist/chunk-IVTWKQI3.js +0 -827
  166. package/dist/chunk-IVTWKQI3.js.map +0 -7
  167. package/dist/chunk-OSM4QEQG.js.map +0 -7
  168. package/dist/chunk-P5X32KOD.js.map +0 -7
  169. package/dist/chunk-RVCZPPTL.js +0 -1100
  170. package/dist/chunk-RVCZPPTL.js.map +0 -7
  171. package/dist/conference-P6I6ESVF.js +0 -8995
  172. package/dist/conference-P6I6ESVF.js.map +0 -7
  173. package/src/Prebuilt/components/Chat/ChatHeader.jsx +0 -67
  174. package/src/Prebuilt/components/EqualProminence.jsx +0 -180
  175. package/src/Prebuilt/components/FirstPersonDisplay.jsx +0 -50
  176. package/src/Prebuilt/components/Footer/Footer.jsx +0 -73
  177. package/src/Prebuilt/components/Header/Header.jsx +0 -8
  178. package/src/Prebuilt/components/Header/StreamingHeader.jsx +0 -54
  179. package/src/Prebuilt/components/LeaveRoom.jsx +0 -94
  180. package/src/Prebuilt/components/MoreSettings/MoreSettings.jsx +0 -10
  181. package/src/Prebuilt/components/Notifications/MessageNotifications.jsx +0 -25
  182. package/src/Prebuilt/components/gridView.jsx +0 -85
  183. package/src/Prebuilt/components/hooks/useFeatures.js +0 -22
  184. package/src/Prebuilt/components/hooks/useNavigation.js +0 -19
  185. package/src/Prebuilt/components/hooks/useSkipPreview.jsx +0 -20
  186. package/src/Prebuilt/components/pdfAnnotator/pdfErrorView.jsx +0 -29
  187. package/src/Prebuilt/images/Logo.svg +0 -8
  188. package/src/Prebuilt/layouts/ActiveSpeakerView.jsx +0 -34
  189. package/src/Prebuilt/layouts/InsetView.jsx +0 -260
  190. package/src/Prebuilt/layouts/PinnedTrackView.jsx +0 -59
  191. package/src/Prebuilt/layouts/SidePane.jsx +0 -52
  192. package/src/Prebuilt/layouts/mainGridView.jsx +0 -98
  193. package/src/Prebuilt/layouts/screenShareView.jsx +0 -183
  194. /package/{src/Prebuilt/components/Header/index.jsx → dist/Prebuilt/components/Header/index.d.ts} +0 -0
  195. /package/src/Prebuilt/components/{ScreenShare.jsx → ScreenShareToggle.jsx} +0 -0
  196. /package/src/{assets → Prebuilt/images}/android-perm-1.png +0 -0
  197. /package/src/{assets → Prebuilt/images}/ios-perm-0.png +0 -0
@@ -1,6 +1,15 @@
1
- import React from 'react';
2
- import { ChatIcon, ConnectivityIcon, HandIcon, PersonIcon, PoorConnectivityIcon } from '@100mslive/react-icons';
1
+ import React, { useCallback } from 'react';
2
+ import { selectPeerByID, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
3
+ import {
4
+ ChatUnreadIcon,
5
+ ConnectivityIcon,
6
+ HandIcon,
7
+ PeopleAddIcon,
8
+ PeopleRemoveIcon,
9
+ PoorConnectivityIcon,
10
+ } from '@100mslive/react-icons';
3
11
  import { Button } from '../../../Button';
12
+ import { useRoomLayout } from '../../provider/roomLayoutProvider';
4
13
  import { useIsSidepaneTypeOpen, useSidepaneToggle } from '../AppData/useSidepane';
5
14
  import { SIDE_PANE_OPTIONS } from '../../common/constants';
6
15
 
@@ -18,26 +27,57 @@ const ChatAction = React.forwardRef((_, ref) => {
18
27
  </Button>
19
28
  );
20
29
  });
30
+
31
+ const HandRaiseAction = React.forwardRef(({ id = '', isSingleHandRaise = true }, ref) => {
32
+ const hmsActions = useHMSActions();
33
+ const toggleSidepane = useSidepaneToggle(SIDE_PANE_OPTIONS.PARTICIPANTS);
34
+ const isParticipantsOpen = useIsSidepaneTypeOpen(SIDE_PANE_OPTIONS.PARTICIPANTS);
35
+ const peer = useHMSStore(selectPeerByID(id));
36
+ const layout = useRoomLayout();
37
+ const {
38
+ bring_to_stage_label,
39
+ on_stage_role,
40
+ off_stage_roles = [],
41
+ } = layout?.screens?.conferencing?.default?.elements.on_stage_exp || {};
42
+
43
+ const onClickHandler = useCallback(() => {
44
+ if (isSingleHandRaise) {
45
+ hmsActions.changeRoleOfPeer(id, on_stage_role);
46
+ } else {
47
+ !isParticipantsOpen && toggleSidepane();
48
+ }
49
+ }, [hmsActions, id, isParticipantsOpen, isSingleHandRaise, on_stage_role, toggleSidepane]);
50
+
51
+ // show nothing if handRaise is single and peer role is not hls
52
+ if (isSingleHandRaise && (!peer || !off_stage_roles.includes(peer.roleName))) {
53
+ return null;
54
+ }
55
+ return (
56
+ <Button outlined as="div" variant="standard" css={{ w: 'max-content' }} onClick={onClickHandler} ref={ref}>
57
+ {isSingleHandRaise ? bring_to_stage_label : 'View'}
58
+ </Button>
59
+ );
60
+ });
21
61
  export const ToastConfig = {
22
62
  PEER_LIST: {
23
63
  single: function (notification) {
24
64
  if (notification.data.length === 1) {
25
65
  return {
26
66
  title: `${notification.data[0]?.name} joined`,
27
- icon: <PersonIcon />,
67
+ icon: <PeopleAddIcon />,
28
68
  };
29
69
  }
30
70
  return {
31
71
  title: `${notification.data[notification.data.length - 1]?.name} and ${
32
72
  notification.data.length - 1
33
73
  } others joined`,
34
- icon: <PersonIcon />,
74
+ icon: <PeopleAddIcon />,
35
75
  };
36
76
  },
37
77
  multiple: notifications => {
38
78
  return {
39
79
  title: `${notifications[0].data.name} and ${notifications.length - 1} others joined`,
40
- icon: <PersonIcon />,
80
+ icon: <PeopleAddIcon />,
41
81
  };
42
82
  },
43
83
  },
@@ -45,13 +85,13 @@ export const ToastConfig = {
45
85
  single: function (notification) {
46
86
  return {
47
87
  title: `${notification.data?.name} joined`,
48
- icon: <PersonIcon />,
88
+ icon: <PeopleAddIcon />,
49
89
  };
50
90
  },
51
91
  multiple: function (notifications) {
52
92
  return {
53
93
  title: `${notifications[notifications.length - 1].data.name} and ${notifications.length - 1} others joined`,
54
- icon: <PersonIcon />,
94
+ icon: <PeopleAddIcon />,
55
95
  };
56
96
  },
57
97
  },
@@ -59,13 +99,13 @@ export const ToastConfig = {
59
99
  single: function (notification) {
60
100
  return {
61
101
  title: `${notification.data?.name} left`,
62
- icon: <PersonIcon />,
102
+ icon: <PeopleRemoveIcon />,
63
103
  };
64
104
  },
65
105
  multiple: function (notifications) {
66
106
  return {
67
107
  title: `${notifications[notifications.length - 1].data.name} and ${notifications.length - 1} others left`,
68
- icon: <PersonIcon />,
108
+ icon: <PeopleRemoveIcon />,
69
109
  };
70
110
  },
71
111
  },
@@ -74,6 +114,7 @@ export const ToastConfig = {
74
114
  return {
75
115
  title: `${notification.data?.name} raised hand`,
76
116
  icon: <HandIcon />,
117
+ action: <HandRaiseAction id={notification.data?.id} />,
77
118
  };
78
119
  },
79
120
  multiple: notifications => {
@@ -82,6 +123,7 @@ export const ToastConfig = {
82
123
  notifications.length - 1
83
124
  } others raised hand`,
84
125
  icon: <HandIcon />,
126
+ action: <HandRaiseAction isSingleHandRaise={false} />,
85
127
  };
86
128
  },
87
129
  },
@@ -89,14 +131,14 @@ export const ToastConfig = {
89
131
  single: notification => {
90
132
  return {
91
133
  title: `New message from ${notification.data?.senderName}`,
92
- icon: <ChatIcon />,
134
+ icon: <ChatUnreadIcon />,
93
135
  action: <ChatAction />,
94
136
  };
95
137
  },
96
138
  multiple: notifications => {
97
139
  return {
98
140
  title: `${notifications.length} new messages`,
99
- icon: <ChatIcon />,
141
+ icon: <ChatUnreadIcon />,
100
142
  action: <ChatAction />,
101
143
  };
102
144
  },
@@ -0,0 +1,62 @@
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import { useMedia } from 'react-use';
3
+ import { selectLocalPeer, useHMSStore } from '@100mslive/react-sdk';
4
+ import { Flex } from '../../../Layout';
5
+ import { config as cssConfig } from '../../../Theme';
6
+ import { InsetTile } from '../InsetTile';
7
+ import { Pagination } from '../Pagination';
8
+ import { Grid } from './Grid';
9
+ import { LayoutProps } from './interface';
10
+ // @ts-ignore: No implicit Any
11
+ import { useUISettings } from '../AppData/useUISettings';
12
+ import { usePagesWithTiles, useTileLayout } from '../hooks/useTileLayout';
13
+ // @ts-ignore: No implicit Any
14
+ import { UI_SETTINGS } from '../../common/constants';
15
+
16
+ export function EqualProminence({ isInsetEnabled = false, peers, onPageChange, onPageSize }: LayoutProps) {
17
+ const localPeer = useHMSStore(selectLocalPeer);
18
+ const isMobile = useMedia(cssConfig.media.md);
19
+ let maxTileCount = useUISettings(UI_SETTINGS.maxTileCount);
20
+ maxTileCount = isMobile ? Math.min(maxTileCount, 6) : maxTileCount;
21
+ let pageList = usePagesWithTiles({
22
+ peers,
23
+ maxTileCount,
24
+ });
25
+ // useMemo is needed to prevent recursion as new array is created for localPeer
26
+ const inputPeers = useMemo(
27
+ () => (pageList.length === 0 ? (localPeer ? [localPeer] : []) : peers),
28
+ [pageList.length, peers, localPeer],
29
+ );
30
+ // Pass local peer to main grid if no other peer has tiles
31
+ pageList = usePagesWithTiles({
32
+ peers: inputPeers,
33
+ maxTileCount,
34
+ });
35
+ const { ref, pagesWithTiles } = useTileLayout({
36
+ pageList,
37
+ maxTileCount,
38
+ });
39
+ const [page, setPage] = useState(0);
40
+ const pageSize = pagesWithTiles[0]?.length || 0;
41
+
42
+ useEffect(() => {
43
+ if (pageSize > 0) {
44
+ onPageSize?.(pageSize);
45
+ }
46
+ }, [pageSize, onPageSize]);
47
+
48
+ return (
49
+ <Flex direction="column" css={{ flex: '1 1 0', h: '100%', position: 'relative', minWidth: 0 }}>
50
+ <Grid tiles={pagesWithTiles[page]} ref={ref} />
51
+ <Pagination
52
+ page={page}
53
+ onPageChange={page => {
54
+ setPage(page);
55
+ onPageChange?.(page);
56
+ }}
57
+ numPages={pagesWithTiles.length}
58
+ />
59
+ {isInsetEnabled && pageList.length > 0 && pageList[0][0].peer.id !== localPeer?.id && <InsetTile />}
60
+ </Flex>
61
+ );
62
+ }
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { TrackWithPeerAndDimensions } from '@100mslive/react-sdk';
3
+ import { Box } from '../../../Layout';
4
+ // @ts-ignore: No implicit Any
5
+ import VideoTile from '../VideoTile';
6
+ import { useVideoTileContext } from '../hooks/useVideoTileLayout';
7
+
8
+ export const Grid = React.forwardRef<HTMLDivElement, { tiles: TrackWithPeerAndDimensions[] }>(({ tiles }, ref) => {
9
+ const videoTileProps = useVideoTileContext();
10
+ return (
11
+ <Box
12
+ ref={ref}
13
+ css={{
14
+ flex: '1 1 0',
15
+ gap: '$4',
16
+ py: '$4',
17
+ display: 'flex',
18
+ placeContent: 'center',
19
+ alignItems: 'center',
20
+ justifyContent: 'center',
21
+ flexFlow: 'row wrap',
22
+ minHeight: 0,
23
+ }}
24
+ >
25
+ {tiles?.map(tile => {
26
+ return (
27
+ <VideoTile
28
+ key={tile.track?.id || tile.peer?.id}
29
+ width={tile.width}
30
+ height={tile.height}
31
+ peerId={tile.peer?.id}
32
+ trackId={tile.track?.id}
33
+ rootCSS={{ padding: 0 }}
34
+ objectFit="contain"
35
+ {...videoTileProps}
36
+ />
37
+ );
38
+ })}
39
+ </Box>
40
+ );
41
+ });
@@ -0,0 +1,92 @@
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import { GridVideoTileLayout } from '@100mslive/types-prebuilt/elements/video_tile_layout';
3
+ import {
4
+ selectPeers,
5
+ selectPeerScreenSharing,
6
+ selectRemotePeers,
7
+ useHMSStore,
8
+ useHMSVanillaStore,
9
+ } from '@100mslive/react-sdk';
10
+ import { EqualProminence } from './EqualProminence';
11
+ import { RoleProminence } from './RoleProminence';
12
+ import { ScreenshareLayout } from './ScreenshareLayout';
13
+ // @ts-ignore: No implicit Any
14
+ import { usePinnedTrack } from '../AppData/useUISettings';
15
+ import { VideoTileContext } from '../hooks/useVideoTileLayout';
16
+ import PeersSorter from '../../common/PeersSorter';
17
+
18
+ export type GridLayoutProps = GridVideoTileLayout & {
19
+ hide_participant_name_on_tile: boolean;
20
+ hide_audio_level_on_tile: boolean;
21
+ rounded_video_tile: boolean;
22
+ hide_audio_mute_on_tile: boolean;
23
+ video_object_fit: 'contain' | 'cover';
24
+ };
25
+
26
+ export const GridLayout = ({
27
+ enable_local_tile_inset: isInsetEnabled = false,
28
+ prominent_roles: prominentRoles = [],
29
+ enable_spotlighting_peer = false,
30
+ hide_participant_name_on_tile = false,
31
+ rounded_video_tile = true,
32
+ hide_audio_mute_on_tile = false,
33
+ video_object_fit = 'contain',
34
+ }: GridLayoutProps) => {
35
+ const peerSharing = useHMSStore(selectPeerScreenSharing);
36
+ const pinnedTrack = usePinnedTrack();
37
+ const isRoleProminence = prominentRoles.length > 0 || pinnedTrack;
38
+ const peers = useHMSStore(isInsetEnabled && !isRoleProminence && !peerSharing ? selectRemotePeers : selectPeers);
39
+ const vanillaStore = useHMSVanillaStore();
40
+ const [sortedPeers, setSortedPeers] = useState(peers);
41
+ const peersSorter = useMemo(() => new PeersSorter(vanillaStore), [vanillaStore]);
42
+ const [pageSize, setPageSize] = useState(0);
43
+ const [mainPage, setMainPage] = useState(0);
44
+ const tileLayout = {
45
+ enableSpotlightingPeer: enable_spotlighting_peer,
46
+ hideParticipantNameOnTile: hide_participant_name_on_tile,
47
+ roundedVideoTile: rounded_video_tile,
48
+ hideAudioMuteOnTile: hide_audio_mute_on_tile,
49
+ objectFit: video_object_fit,
50
+ };
51
+
52
+ useEffect(() => {
53
+ if (mainPage !== 0) {
54
+ return;
55
+ }
56
+ peersSorter.setPeersAndTilesPerPage({
57
+ peers,
58
+ tilesPerPage: pageSize,
59
+ });
60
+ peersSorter.onUpdate(setSortedPeers);
61
+ }, [mainPage, peersSorter, peers, pageSize]);
62
+
63
+ if (peerSharing) {
64
+ return (
65
+ <VideoTileContext.Provider value={tileLayout}>
66
+ <ScreenshareLayout peers={sortedPeers} onPageSize={setPageSize} onPageChange={setMainPage} />
67
+ </VideoTileContext.Provider>
68
+ );
69
+ } else if (isRoleProminence) {
70
+ return (
71
+ <VideoTileContext.Provider value={tileLayout}>
72
+ <RoleProminence
73
+ peers={sortedPeers}
74
+ onPageSize={setPageSize}
75
+ onPageChange={setMainPage}
76
+ prominentRoles={prominentRoles}
77
+ isInsetEnabled={isInsetEnabled}
78
+ />
79
+ </VideoTileContext.Provider>
80
+ );
81
+ }
82
+ return (
83
+ <VideoTileContext.Provider value={tileLayout}>
84
+ <EqualProminence
85
+ peers={sortedPeers}
86
+ onPageSize={setPageSize}
87
+ onPageChange={setMainPage}
88
+ isInsetEnabled={isInsetEnabled}
89
+ />
90
+ </VideoTileContext.Provider>
91
+ );
92
+ };
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import { TrackWithPeerAndDimensions } from '@100mslive/react-sdk';
3
+ import { Flex } from '../../../Layout';
4
+ import { CSS } from '../../../Theme';
5
+ // @ts-ignore: No implicit Any
6
+ import VideoTile from '../VideoTile';
7
+ import { useVideoTileContext } from '../hooks/useVideoTileLayout';
8
+
9
+ const Root = ({ children }: React.PropsWithChildren) => (
10
+ <Flex direction="column" css={{ size: '100%', gap: '$6' }}>
11
+ {children}
12
+ </Flex>
13
+ );
14
+
15
+ const ProminentSection = ({ children, css = {} }: React.PropsWithChildren<{ css?: CSS }>) => {
16
+ return (
17
+ <Flex direction="column" css={{ flex: '1 1 0', gap: '$2', minHeight: 0, ...css }}>
18
+ {children}
19
+ </Flex>
20
+ );
21
+ };
22
+
23
+ const SecondarySection = ({ tiles, children }: React.PropsWithChildren<{ tiles: TrackWithPeerAndDimensions[] }>) => {
24
+ const tileLayoutProps = useVideoTileContext();
25
+ return (
26
+ <Flex direction="column" css={{ flexBasis: tiles?.length > 0 ? 154 : 0, minHeight: 0, gap: '$2' }}>
27
+ <Flex justify="center" align="center" css={{ gap: '$4', minHeight: 0, margin: '0 auto' }}>
28
+ {tiles?.map(tile => {
29
+ return (
30
+ <VideoTile
31
+ key={tile.track?.id || tile.peer?.id}
32
+ height="100%"
33
+ peerId={tile.peer?.id}
34
+ trackId={tile.track?.id}
35
+ rootCSS={{
36
+ padding: 0,
37
+ flex: '1 1 0',
38
+ maxWidth: 'max-content',
39
+ }}
40
+ containerCSS={{
41
+ width: 'unset',
42
+ aspectRatio: 16 / 9,
43
+ '@md': { aspectRatio: 1 },
44
+ }}
45
+ objectFit="contain"
46
+ {...tileLayoutProps}
47
+ />
48
+ );
49
+ })}
50
+ </Flex>
51
+ {children}
52
+ </Flex>
53
+ );
54
+ };
55
+
56
+ export const ProminenceLayout = {
57
+ Root,
58
+ ProminentSection,
59
+ SecondarySection,
60
+ };
@@ -0,0 +1,56 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { selectLocalPeer, useHMSStore } from '@100mslive/react-sdk';
3
+ import { InsetTile } from '../InsetTile';
4
+ import { Pagination } from '../Pagination';
5
+ import { SecondaryTiles } from '../SecondaryTiles';
6
+ import { Grid } from './Grid';
7
+ import { LayoutProps } from './interface';
8
+ import { ProminenceLayout } from './ProminenceLayout';
9
+ import { useRoleProminencePeers } from '../hooks/useRoleProminencePeers';
10
+ import { usePagesWithTiles, useTileLayout } from '../hooks/useTileLayout';
11
+
12
+ export function RoleProminence({
13
+ isInsetEnabled = false,
14
+ prominentRoles = [],
15
+ peers,
16
+ onPageChange,
17
+ onPageSize,
18
+ }: LayoutProps) {
19
+ const { prominentPeers, secondaryPeers } = useRoleProminencePeers(prominentRoles, peers, isInsetEnabled);
20
+ const localPeer = useHMSStore(selectLocalPeer);
21
+ const maxTileCount = 4;
22
+ const pageList = usePagesWithTiles({
23
+ peers: prominentPeers,
24
+ maxTileCount,
25
+ });
26
+ const { ref, pagesWithTiles } = useTileLayout({
27
+ pageList,
28
+ maxTileCount,
29
+ });
30
+ const [page, setPage] = useState(0);
31
+ const pageSize = pagesWithTiles[0]?.length || 0;
32
+
33
+ useEffect(() => {
34
+ if (pageSize > 0) {
35
+ onPageSize?.(pageSize);
36
+ }
37
+ }, [pageSize, onPageSize]);
38
+
39
+ return (
40
+ <ProminenceLayout.Root>
41
+ <ProminenceLayout.ProminentSection>
42
+ <Grid ref={ref} tiles={pagesWithTiles[page]} />
43
+ </ProminenceLayout.ProminentSection>
44
+ <Pagination
45
+ page={page}
46
+ onPageChange={page => {
47
+ setPage(page);
48
+ onPageChange?.(page);
49
+ }}
50
+ numPages={pagesWithTiles.length}
51
+ />
52
+ <SecondaryTiles peers={secondaryPeers} isInsetEnabled={isInsetEnabled} />
53
+ {isInsetEnabled && localPeer && !prominentPeers.includes(localPeer) && <InsetTile />}
54
+ </ProminenceLayout.Root>
55
+ );
56
+ }
@@ -0,0 +1,36 @@
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import { selectPeersScreenSharing, useHMSStore } from '@100mslive/react-sdk';
3
+ import { Pagination } from '../Pagination';
4
+ // @ts-ignore: No implicit Any
5
+ import ScreenshareTile from '../ScreenshareTile';
6
+ import { SecondaryTiles } from '../SecondaryTiles';
7
+ import { LayoutProps } from './interface';
8
+ import { ProminenceLayout } from './ProminenceLayout';
9
+ // @ts-ignore: No implicit Any
10
+ import { useSetAppDataByKey } from '../AppData/useUISettings';
11
+ // @ts-ignore: No implicit Any
12
+ import { APP_DATA } from '../../common/constants';
13
+
14
+ export const ScreenshareLayout = ({ peers, onPageChange, onPageSize }: LayoutProps) => {
15
+ const peersSharing = useHMSStore(selectPeersScreenSharing);
16
+ const [, setActiveScreenSharePeer] = useSetAppDataByKey(APP_DATA.activeScreensharePeerId);
17
+ const [page, setPage] = useState(0);
18
+ const activeSharePeerId = peersSharing[page]?.id;
19
+ const secondaryPeers = useMemo(() => peers.filter(p => p.id !== activeSharePeerId), [activeSharePeerId, peers]);
20
+ useEffect(() => {
21
+ setActiveScreenSharePeer(activeSharePeerId);
22
+ return () => {
23
+ setActiveScreenSharePeer('');
24
+ };
25
+ }, [activeSharePeerId, setActiveScreenSharePeer]);
26
+
27
+ return (
28
+ <ProminenceLayout.Root>
29
+ <ProminenceLayout.ProminentSection>
30
+ <ScreenshareTile peerId={peersSharing[page].id} />
31
+ <Pagination page={page} onPageChange={setPage} numPages={peersSharing.length} />
32
+ </ProminenceLayout.ProminentSection>
33
+ <SecondaryTiles peers={secondaryPeers} onPageChange={onPageChange} onPageSize={onPageSize} />
34
+ </ProminenceLayout.Root>
35
+ );
36
+ };
@@ -0,0 +1,9 @@
1
+ import { HMSPeer } from '@100mslive/react-sdk';
2
+
3
+ export interface LayoutProps {
4
+ isInsetEnabled?: boolean;
5
+ prominentRoles?: string[];
6
+ peers: HMSPeer[];
7
+ onPageChange?: (page: number) => void;
8
+ onPageSize?: (size: number) => void;
9
+ }