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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. package/dist/{HLSView-P57IRMAR.js → HLSView-HNVYG5VE.js} +309 -151
  2. package/dist/HLSView-HNVYG5VE.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/Chat/ChatFooter.d.ts +7 -0
  7. package/dist/Prebuilt/components/Connection/ConnectionIndicator.d.ts +6 -0
  8. package/dist/Prebuilt/components/Connection/TileConnection.d.ts +10 -0
  9. package/dist/Prebuilt/components/Footer/ChatToggle.d.ts +4 -0
  10. package/dist/Prebuilt/components/Footer/Footer.d.ts +6 -0
  11. package/dist/Prebuilt/components/Footer/RoleAccordion.d.ts +14 -0
  12. package/dist/Prebuilt/components/Footer/RoleOptions.d.ts +6 -0
  13. package/dist/Prebuilt/components/Header/Header.d.ts +2 -0
  14. package/dist/Prebuilt/components/Header/StreamActions.d.ts +11 -0
  15. package/dist/Prebuilt/components/InsetTile.d.ts +2 -0
  16. package/dist/Prebuilt/components/Leave/DesktopLeaveRoom.d.ts +8 -0
  17. package/dist/Prebuilt/components/Leave/EndSessionContent.d.ts +9 -0
  18. package/dist/Prebuilt/components/Leave/LeaveAtoms.d.ts +2196 -0
  19. package/dist/Prebuilt/components/Leave/LeaveCard.d.ts +11 -0
  20. package/dist/Prebuilt/components/Leave/LeaveRoom.d.ts +5 -0
  21. package/dist/Prebuilt/components/Leave/LeaveSessionContent.d.ts +8 -0
  22. package/dist/Prebuilt/components/Leave/MwebLeaveRoom.d.ts +8 -0
  23. package/dist/Prebuilt/components/MoreSettings/MoreSettings.d.ts +6 -0
  24. package/dist/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.d.ts +6 -0
  25. package/dist/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.d.ts +6 -0
  26. package/dist/Prebuilt/components/Pagination.d.ts +6 -0
  27. package/dist/Prebuilt/components/Preview/PreviewContainer.d.ts +3 -0
  28. package/dist/Prebuilt/components/Preview/PreviewForm.d.ts +10 -0
  29. package/dist/Prebuilt/components/Preview/PreviewJoin.d.ts +16 -0
  30. package/dist/Prebuilt/components/RoleChangeRequestModal.d.ts +2 -0
  31. package/dist/Prebuilt/components/SecondaryTiles.d.ts +3 -0
  32. package/dist/Prebuilt/components/VideoLayouts/EqualProminence.d.ts +3 -0
  33. package/dist/Prebuilt/components/VideoLayouts/Grid.d.ts +6 -0
  34. package/dist/Prebuilt/components/VideoLayouts/GridLayout.d.ts +12 -0
  35. package/dist/Prebuilt/components/VideoLayouts/ProminenceLayout.d.ts +15 -0
  36. package/dist/Prebuilt/components/VideoLayouts/RoleProminence.d.ts +3 -0
  37. package/dist/Prebuilt/components/VideoLayouts/ScreenshareLayout.d.ts +3 -0
  38. package/dist/Prebuilt/components/VideoLayouts/interface.d.ts +9 -0
  39. package/dist/Prebuilt/components/hooks/useAutoStartStreaming.d.ts +1 -0
  40. package/dist/Prebuilt/components/hooks/useRedirectToLeave.d.ts +3 -0
  41. package/dist/Prebuilt/components/hooks/useRoleProminencePeers.d.ts +5 -0
  42. package/dist/Prebuilt/components/hooks/useTileLayout.d.ts +13 -0
  43. package/dist/Prebuilt/components/hooks/useVideoTileLayout.d.ts +13 -0
  44. package/dist/Prebuilt/layouts/SidePane.d.ts +9 -0
  45. package/dist/Prebuilt/layouts/VideoStreamingSection.d.ts +7 -0
  46. package/dist/Prebuilt/plugins/whiteboard/ToggleWhiteboard.d.ts +5 -0
  47. package/dist/Prebuilt/provider/roomLayoutProvider/hooks/useFetchRoomLayout.d.ts +1 -0
  48. package/dist/Prebuilt/provider/roomLayoutProvider/hooks/useInsetEnabled.d.ts +1 -0
  49. package/dist/Prebuilt/provider/roomLayoutProvider/hooks/useRoomLayoutScreen.d.ts +17 -0
  50. package/dist/Prebuilt/provider/roomLayoutProvider/index.d.ts +6 -1
  51. package/dist/{VirtualBackground-GGCQJ5JM.js → VirtualBackground-UM2FOUHQ.js} +5 -11
  52. package/dist/VirtualBackground-UM2FOUHQ.js.map +7 -0
  53. package/dist/{chunk-P5X32KOD.js → chunk-364HP22I.js} +8 -5
  54. package/dist/chunk-364HP22I.js.map +7 -0
  55. package/dist/{chunk-OSM4QEQG.js → chunk-LYSAET4G.js} +3742 -5462
  56. package/dist/chunk-LYSAET4G.js.map +7 -0
  57. package/dist/chunk-POE7H4IE.js +898 -0
  58. package/dist/chunk-POE7H4IE.js.map +7 -0
  59. package/dist/conference-UWLJHMB2.js +5727 -0
  60. package/dist/conference-UWLJHMB2.js.map +7 -0
  61. package/dist/index.cjs.js +9655 -15326
  62. package/dist/index.cjs.js.map +4 -4
  63. package/dist/index.js +2 -2
  64. package/dist/meta.cjs.json +2513 -3456
  65. package/dist/meta.esbuild.json +2807 -3838
  66. package/package.json +8 -7
  67. package/src/Button/Button.tsx +2 -2
  68. package/src/Prebuilt/App.tsx +58 -53
  69. package/src/Prebuilt/{AppContext.jsx → AppContext.tsx} +11 -3
  70. package/src/Prebuilt/IconButton.jsx +11 -0
  71. package/src/Prebuilt/Prebuilt.stories.tsx +1 -0
  72. package/src/Prebuilt/common/{PeersSorter.js → PeersSorter.ts} +16 -11
  73. package/src/Prebuilt/common/constants.js +4 -114
  74. package/src/Prebuilt/common/hooks.js +34 -1
  75. package/src/Prebuilt/common/utils.js +1 -9
  76. package/src/Prebuilt/components/AppData/AppData.jsx +11 -15
  77. package/src/Prebuilt/components/AppData/useUISettings.js +6 -10
  78. package/src/Prebuilt/components/AudioVideoToggle.jsx +10 -2
  79. package/src/Prebuilt/components/AuthToken.jsx +11 -42
  80. package/src/Prebuilt/components/Chat/Chat.jsx +75 -27
  81. package/src/Prebuilt/components/Chat/ChatBody.jsx +95 -36
  82. package/src/Prebuilt/components/Chat/ChatFooter.tsx +199 -0
  83. package/src/Prebuilt/components/Chat/ChatParticipantHeader.jsx +84 -0
  84. package/src/Prebuilt/components/Chat/ChatSelector.jsx +16 -17
  85. package/src/Prebuilt/components/Chat/ChatSelectorContainer.jsx +81 -0
  86. package/src/Prebuilt/components/Chat/useEmojiPickerStyles.js +5 -4
  87. package/src/Prebuilt/components/Connection/{ConnectionIndicator.jsx → ConnectionIndicator.tsx} +12 -4
  88. package/src/Prebuilt/components/Connection/TileConnection.tsx +71 -0
  89. package/src/Prebuilt/components/EmojiReaction.jsx +19 -22
  90. package/src/Prebuilt/components/Footer/{ChatToggle.jsx → ChatToggle.tsx} +13 -9
  91. package/src/Prebuilt/components/Footer/Footer.tsx +98 -0
  92. package/src/Prebuilt/components/Footer/ParticipantList.jsx +187 -179
  93. package/src/Prebuilt/components/Footer/RoleAccordion.tsx +94 -0
  94. package/src/Prebuilt/components/Footer/RoleOptions.tsx +155 -0
  95. package/src/Prebuilt/components/FullPageProgress.jsx +3 -3
  96. package/src/Prebuilt/components/HMSVideo/Controls.jsx +3 -2
  97. package/src/Prebuilt/components/HMSVideo/HLSQualitySelector.jsx +63 -18
  98. package/src/Prebuilt/components/HMSVideo/HMSVideo.jsx +2 -2
  99. package/src/Prebuilt/components/HMSVideo/PlayButton.jsx +1 -1
  100. package/src/Prebuilt/components/HMSVideo/VideoProgress.jsx +5 -6
  101. package/src/Prebuilt/components/HMSVideo/VideoTime.jsx +3 -3
  102. package/src/Prebuilt/components/HMSVideo/VolumeControl.jsx +38 -9
  103. package/src/Prebuilt/components/Header/{ConferencingHeader.jsx → Header.tsx} +9 -7
  104. package/src/Prebuilt/components/Header/HeaderComponents.jsx +13 -4
  105. package/src/Prebuilt/components/Header/{StreamActions.jsx → StreamActions.tsx} +54 -67
  106. package/src/Prebuilt/components/Header/common.jsx +5 -2
  107. package/src/Prebuilt/components/Header/index.tsx +1 -0
  108. package/src/Prebuilt/components/IconButtonWithOptions/IconButtonWithOptions.jsx +23 -4
  109. package/src/Prebuilt/components/InsetTile.tsx +128 -0
  110. package/src/Prebuilt/components/{MoreSettings/SplitComponents/DesktopLeaveRoom.jsx → Leave/DesktopLeaveRoom.tsx} +67 -25
  111. package/src/Prebuilt/components/{EndSessionContent.jsx → Leave/EndSessionContent.tsx} +18 -11
  112. package/src/Prebuilt/components/Leave/LeaveAtoms.tsx +26 -0
  113. package/src/Prebuilt/components/Leave/LeaveCard.tsx +36 -0
  114. package/src/Prebuilt/components/Leave/LeaveRoom.tsx +66 -0
  115. package/src/Prebuilt/components/{LeaveSessionContent.jsx → Leave/LeaveSessionContent.tsx} +20 -6
  116. package/src/Prebuilt/components/{MoreSettings/SplitComponents/MwebLeaveRoom.jsx → Leave/MwebLeaveRoom.tsx} +43 -18
  117. package/src/Prebuilt/components/MetaActions.jsx +15 -23
  118. package/src/Prebuilt/components/MoreSettings/ActionTile.jsx +5 -0
  119. package/src/Prebuilt/components/MoreSettings/ChangeNameContent.jsx +16 -7
  120. package/src/Prebuilt/components/MoreSettings/ChangeNameModal.jsx +1 -1
  121. package/src/Prebuilt/components/MoreSettings/FullScreenItem.jsx +1 -4
  122. package/src/Prebuilt/components/MoreSettings/MoreSettings.tsx +27 -0
  123. package/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.tsx +216 -0
  124. package/src/Prebuilt/components/MoreSettings/SplitComponents/{MwebOptions.jsx → MwebOptions.tsx} +107 -45
  125. package/src/Prebuilt/components/Notifications/HLSFailureModal.jsx +3 -1
  126. package/src/Prebuilt/components/Notifications/Notifications.jsx +46 -30
  127. package/src/Prebuilt/components/Notifications/PeerNotifications.jsx +14 -2
  128. package/src/Prebuilt/components/Notifications/PermissionErrorModal.jsx +10 -4
  129. package/src/Prebuilt/components/Notifications/ReconnectNotifications.jsx +5 -11
  130. package/src/Prebuilt/components/PIP/PIPComponent.jsx +7 -16
  131. package/src/Prebuilt/components/PIP/PIPManager.js +1 -0
  132. package/src/Prebuilt/components/Pagination.tsx +60 -0
  133. package/src/Prebuilt/components/Playlist/Playlist.jsx +1 -6
  134. package/src/Prebuilt/components/PostLeave.jsx +7 -7
  135. package/src/Prebuilt/components/Preview/{PreviewContainer.jsx → PreviewContainer.tsx} +16 -15
  136. package/src/Prebuilt/components/Preview/{PreviewForm.jsx → PreviewForm.tsx} +16 -8
  137. package/src/Prebuilt/components/Preview/{PreviewJoin.jsx → PreviewJoin.tsx} +48 -22
  138. package/src/Prebuilt/components/RaiseHand.jsx +0 -7
  139. package/src/Prebuilt/components/RoleChangeRequestModal.tsx +119 -0
  140. package/src/Prebuilt/components/ScreenshareDisplay.jsx +4 -10
  141. package/src/Prebuilt/components/ScreenshareTile.jsx +43 -36
  142. package/src/Prebuilt/components/SecondaryTiles.tsx +36 -0
  143. package/src/Prebuilt/components/Settings/LayoutSettings.jsx +2 -12
  144. package/src/Prebuilt/components/Settings/NotificationSettings.jsx +3 -9
  145. package/src/Prebuilt/components/Settings/SettingsModal.jsx +3 -9
  146. package/src/Prebuilt/components/StatsForNerds.jsx +3 -1
  147. package/src/Prebuilt/components/TileMenu/TileMenu.jsx +16 -17
  148. package/src/Prebuilt/components/TileMenu/TileMenuContent.jsx +33 -27
  149. package/src/Prebuilt/components/Toast/ToastConfig.jsx +58 -15
  150. package/src/Prebuilt/components/VideoLayouts/EqualProminence.tsx +65 -0
  151. package/src/Prebuilt/components/VideoLayouts/Grid.tsx +43 -0
  152. package/src/Prebuilt/components/VideoLayouts/GridLayout.tsx +110 -0
  153. package/src/Prebuilt/components/VideoLayouts/ProminenceLayout.tsx +74 -0
  154. package/src/Prebuilt/components/VideoLayouts/RoleProminence.tsx +59 -0
  155. package/src/Prebuilt/components/VideoLayouts/ScreenshareLayout.tsx +52 -0
  156. package/src/Prebuilt/components/VideoLayouts/interface.ts +10 -0
  157. package/src/Prebuilt/components/VideoTile.jsx +116 -74
  158. package/src/Prebuilt/components/conference.jsx +86 -85
  159. package/src/Prebuilt/components/hooks/useAutoStartStreaming.tsx +57 -0
  160. package/src/Prebuilt/components/hooks/useMetadata.jsx +19 -3
  161. package/src/Prebuilt/components/hooks/useRedirectToLeave.tsx +34 -0
  162. package/src/Prebuilt/components/hooks/useRoleProminencePeers.tsx +38 -0
  163. package/src/Prebuilt/components/hooks/useTileLayout.tsx +127 -0
  164. package/src/Prebuilt/components/hooks/useVideoTileLayout.ts +26 -0
  165. package/src/Prebuilt/components/pdfAnnotator/pdfFileOptions.jsx +5 -72
  166. package/src/Prebuilt/components/pdfAnnotator/submitPdf.jsx +4 -45
  167. package/src/Prebuilt/components/pdfAnnotator/uploadedFile.jsx +2 -17
  168. package/src/Prebuilt/components/peerTileUtils.jsx +1 -1
  169. package/src/Prebuilt/images/empty-chat.svg +12 -0
  170. package/src/Prebuilt/layouts/EmbedView.jsx +17 -50
  171. package/src/Prebuilt/layouts/HLSView.jsx +138 -51
  172. package/src/Prebuilt/layouts/PDFView.jsx +1 -11
  173. package/src/Prebuilt/layouts/SidePane.tsx +108 -0
  174. package/src/Prebuilt/layouts/VideoStreamingSection.tsx +96 -0
  175. package/src/Prebuilt/layouts/WhiteboardView.jsx +10 -34
  176. package/src/Prebuilt/plugins/FlyingEmoji.jsx +14 -2
  177. package/src/Prebuilt/plugins/VirtualBackground/VirtualBackground.jsx +1 -4
  178. package/src/Prebuilt/plugins/whiteboard/{ToggleWhiteboard.jsx → ToggleWhiteboard.tsx} +5 -9
  179. package/src/Prebuilt/primitives/DialogContent.jsx +15 -11
  180. package/src/Prebuilt/provider/roomLayoutProvider/constants/index.ts +17 -2
  181. package/src/Prebuilt/provider/roomLayoutProvider/hooks/useFetchRoomLayout.ts +36 -13
  182. package/src/Prebuilt/provider/roomLayoutProvider/hooks/useInsetEnabled.ts +10 -0
  183. package/src/Prebuilt/provider/roomLayoutProvider/hooks/useRoomLayoutScreen.ts +65 -0
  184. package/src/Prebuilt/provider/roomLayoutProvider/index.tsx +17 -6
  185. package/src/Prebuilt/services/FeatureFlags.jsx +0 -1
  186. package/src/VideoTile/StyledVideoTile.tsx +1 -0
  187. package/dist/HLSView-P57IRMAR.js.map +0 -7
  188. package/dist/PinnedTrackView-4FYJEBTB.js +0 -102
  189. package/dist/PinnedTrackView-4FYJEBTB.js.map +0 -7
  190. package/dist/VirtualBackground-GGCQJ5JM.js.map +0 -7
  191. package/dist/chunk-IVTWKQI3.js +0 -827
  192. package/dist/chunk-IVTWKQI3.js.map +0 -7
  193. package/dist/chunk-OSM4QEQG.js.map +0 -7
  194. package/dist/chunk-P5X32KOD.js.map +0 -7
  195. package/dist/chunk-RVCZPPTL.js +0 -1100
  196. package/dist/chunk-RVCZPPTL.js.map +0 -7
  197. package/dist/conference-P6I6ESVF.js +0 -8995
  198. package/dist/conference-P6I6ESVF.js.map +0 -7
  199. package/src/Prebuilt/components/AudioLevel/BeamSpeakerLabelsLogging.jsx +0 -16
  200. package/src/Prebuilt/components/Chat/ChatFooter.jsx +0 -150
  201. package/src/Prebuilt/components/Chat/ChatHeader.jsx +0 -67
  202. package/src/Prebuilt/components/Connection/TileConnection.jsx +0 -39
  203. package/src/Prebuilt/components/EqualProminence.jsx +0 -180
  204. package/src/Prebuilt/components/FirstPersonDisplay.jsx +0 -50
  205. package/src/Prebuilt/components/Footer/Footer.jsx +0 -73
  206. package/src/Prebuilt/components/Header/Header.jsx +0 -8
  207. package/src/Prebuilt/components/Header/StreamingHeader.jsx +0 -54
  208. package/src/Prebuilt/components/LeaveCard.jsx +0 -19
  209. package/src/Prebuilt/components/LeaveRoom.jsx +0 -94
  210. package/src/Prebuilt/components/MoreSettings/MoreSettings.jsx +0 -10
  211. package/src/Prebuilt/components/MoreSettings/SplitComponents/DesktopOptions.jsx +0 -219
  212. package/src/Prebuilt/components/Notifications/MessageNotifications.jsx +0 -25
  213. package/src/Prebuilt/components/Pagination.jsx +0 -29
  214. package/src/Prebuilt/components/RoleChangeRequestModal.jsx +0 -26
  215. package/src/Prebuilt/components/VideoList.jsx +0 -73
  216. package/src/Prebuilt/components/gridView.jsx +0 -85
  217. package/src/Prebuilt/components/hooks/useFeatures.js +0 -22
  218. package/src/Prebuilt/components/hooks/useNavigation.js +0 -19
  219. package/src/Prebuilt/components/hooks/useSkipPreview.jsx +0 -20
  220. package/src/Prebuilt/components/pdfAnnotator/pdfErrorView.jsx +0 -29
  221. package/src/Prebuilt/images/Logo.svg +0 -8
  222. package/src/Prebuilt/layouts/ActiveSpeakerView.jsx +0 -34
  223. package/src/Prebuilt/layouts/InsetView.jsx +0 -260
  224. package/src/Prebuilt/layouts/PinnedTrackView.jsx +0 -59
  225. package/src/Prebuilt/layouts/SidePane.jsx +0 -52
  226. package/src/Prebuilt/layouts/mainGridView.jsx +0 -98
  227. package/src/Prebuilt/layouts/mainView.jsx +0 -141
  228. package/src/Prebuilt/layouts/screenShareView.jsx +0 -183
  229. /package/{src/Prebuilt/components/Header/index.jsx → dist/Prebuilt/components/Header/index.d.ts} +0 -0
  230. /package/src/Prebuilt/components/{ScreenShare.jsx → ScreenShareToggle.jsx} +0 -0
  231. /package/src/{assets → Prebuilt/images}/android-perm-1.png +0 -0
  232. /package/src/{assets → Prebuilt/images}/ios-perm-0.png +0 -0
@@ -1,31 +1,55 @@
1
- import React, { Suspense, useRef, useState } from 'react';
1
+ import React, { useRef, useState } from 'react';
2
2
  import { useClickAway } from 'react-use';
3
+ import { ConferencingScreen, DefaultConferencingScreen_Elements } from '@100mslive/types-prebuilt';
3
4
  import {
4
5
  selectIsConnectedToRoom,
5
- selectIsLocalVideoEnabled,
6
6
  selectPeerCount,
7
7
  selectPermissions,
8
8
  useHMSActions,
9
9
  useHMSStore,
10
10
  useRecordingStreaming,
11
11
  } from '@100mslive/react-sdk';
12
- import { CrossIcon, DragHandleIcon, EmojiIcon, PeopleIcon, RecordIcon, SettingsIcon } from '@100mslive/react-icons';
13
- import { Box, Loading, Tooltip } from '../../../../';
12
+ import {
13
+ BrbIcon,
14
+ CrossIcon,
15
+ DragHandleIcon,
16
+ EmojiIcon,
17
+ HandIcon,
18
+ HandRaiseSlashedIcon,
19
+ PeopleIcon,
20
+ RecordIcon,
21
+ SettingsIcon,
22
+ } from '@100mslive/react-icons';
23
+ import { Box, Loading, Tooltip } from '../../../..';
14
24
  import { Sheet } from '../../../../Sheet';
25
+ // @ts-ignore: No implicit any
15
26
  import IconButton from '../../../IconButton';
16
- import { EmojiCard } from '../../Footer/EmojiCard';
27
+ // @ts-ignore: No implicit any
28
+ import { EmojiReaction } from '../../EmojiReaction';
29
+ // @ts-ignore: No implicit any
17
30
  import { StopRecordingInSheet } from '../../Header/StreamActions';
31
+ // @ts-ignore: No implicit any
18
32
  import SettingsModal from '../../Settings/SettingsModal';
33
+ // @ts-ignore: No implicit any
19
34
  import { ToastManager } from '../../Toast/ToastManager';
20
- import { ActionTile } from '.././ActionTile';
21
- import { ChangeNameModal } from '.././ChangeNameModal';
22
- import { MuteAllModal } from '.././MuteAllModal';
35
+ // @ts-ignore: No implicit any
36
+ import { ActionTile } from '../ActionTile';
37
+ // @ts-ignore: No implicit any
38
+ import { ChangeNameModal } from '../ChangeNameModal';
39
+ // @ts-ignore: No implicit any
40
+ import { MuteAllModal } from '../MuteAllModal';
41
+ // @ts-ignore: No implicit any
23
42
  import { useSidepaneToggle } from '../../AppData/useSidepane';
43
+ // @ts-ignore: No implicit any
24
44
  import { useDropdownList } from '../../hooks/useDropdownList';
45
+ // @ts-ignore: No implicit any
46
+ import { useMyMetadata } from '../../hooks/useMetadata';
47
+ // @ts-ignore: No implicit any
25
48
  import { getFormattedCount } from '../../../common/utils';
49
+ // @ts-ignore: No implicit any
26
50
  import { SIDE_PANE_OPTIONS } from '../../../common/constants';
27
51
 
28
- const VirtualBackground = React.lazy(() => import('../../../plugins/VirtualBackground/VirtualBackground'));
52
+ // const VirtualBackground = React.lazy(() => import('../../../plugins/VirtualBackground/VirtualBackground'));
29
53
 
30
54
  const MODALS = {
31
55
  CHANGE_NAME: 'changeName',
@@ -39,14 +63,18 @@ const MODALS = {
39
63
  EMBED_URL: 'embedUrl',
40
64
  };
41
65
 
42
- export const MwebOptions = () => {
66
+ export const MwebOptions = ({
67
+ elements,
68
+ screenType,
69
+ }: {
70
+ elements: DefaultConferencingScreen_Elements;
71
+ screenType: keyof ConferencingScreen;
72
+ }) => {
43
73
  const hmsActions = useHMSActions();
44
74
  const permissions = useHMSStore(selectPermissions);
45
75
  const isConnected = useHMSStore(selectIsConnectedToRoom);
46
76
  const { isBrowserRecordingOn, isStreamingOn, isHLSRunning } = useRecordingStreaming();
47
-
48
77
  const [openModals, setOpenModals] = useState(new Set());
49
-
50
78
  const [openOptionsSheet, setOpenOptionsSheet] = useState(false);
51
79
  const [openSettingsSheet, setOpenSettingsSheet] = useState(false);
52
80
  const [showEmojiCard, setShowEmojiCard] = useState(false);
@@ -55,11 +83,12 @@ export const MwebOptions = () => {
55
83
  const toggleParticipants = useSidepaneToggle(SIDE_PANE_OPTIONS.PARTICIPANTS);
56
84
  const peerCount = useHMSStore(selectPeerCount);
57
85
  const emojiCardRef = useRef(null);
58
- const isVideoOn = useHMSStore(selectIsLocalVideoEnabled);
86
+ const { isBRBOn, toggleBRB, isHandRaised, toggleHandRaise } = useMyMetadata();
87
+ // const isVideoOn = useHMSStore(selectIsLocalVideoEnabled);
59
88
 
60
- useDropdownList({ open: openModals.size > 0, name: 'MoreSettings' });
89
+ useDropdownList({ open: openModals.size > 0 || openOptionsSheet || openSettingsSheet, name: 'MoreSettings' });
61
90
 
62
- const updateState = (modalName, value) => {
91
+ const updateState = (modalName: string, value: boolean) => {
63
92
  setOpenModals(modals => {
64
93
  const copy = new Set(modals);
65
94
  if (value) {
@@ -76,13 +105,13 @@ export const MwebOptions = () => {
76
105
  return (
77
106
  <>
78
107
  <Sheet.Root open={openOptionsSheet} onOpenChange={setOpenOptionsSheet}>
79
- <Sheet.Trigger asChild data-testid="more_settings_btn">
80
- <IconButton>
81
- <Tooltip title="More options">
108
+ <Tooltip title="More options">
109
+ <Sheet.Trigger asChild data-testid="more_settings_btn">
110
+ <IconButton>
82
111
  <DragHandleIcon />
83
- </Tooltip>
84
- </IconButton>
85
- </Sheet.Trigger>
112
+ </IconButton>
113
+ </Sheet.Trigger>
114
+ </Tooltip>
86
115
  <Sheet.Content css={{ bg: '$surface_dim', pb: '$14' }}>
87
116
  <Sheet.Title
88
117
  css={{
@@ -116,32 +145,62 @@ export const MwebOptions = () => {
116
145
  px: '$9',
117
146
  }}
118
147
  >
119
- <ActionTile.Root
120
- onClick={() => {
121
- toggleParticipants();
122
- setOpenOptionsSheet(false);
123
- }}
124
- >
125
- <ActionTile.Count>{getFormattedCount(peerCount)}</ActionTile.Count>
126
- <PeopleIcon />
127
- <ActionTile.Title>Participants</ActionTile.Title>
128
- </ActionTile.Root>
148
+ {elements?.participant_list && (
149
+ <ActionTile.Root
150
+ onClick={() => {
151
+ toggleParticipants();
152
+ setOpenOptionsSheet(false);
153
+ }}
154
+ >
155
+ <ActionTile.Count>{getFormattedCount(peerCount)}</ActionTile.Count>
156
+ <PeopleIcon />
157
+ <ActionTile.Title>Participants</ActionTile.Title>
158
+ </ActionTile.Root>
159
+ )}
129
160
 
130
- {isVideoOn ? (
161
+ {screenType !== 'hls_live_streaming' ? (
162
+ <ActionTile.Root
163
+ active={isHandRaised}
164
+ onClick={() => {
165
+ toggleHandRaise();
166
+ setOpenOptionsSheet(false);
167
+ }}
168
+ >
169
+ {isHandRaised ? <HandRaiseSlashedIcon /> : <HandIcon />}
170
+ <ActionTile.Title>{isHandRaised ? 'Lower' : 'Raise'} Hand</ActionTile.Title>
171
+ </ActionTile.Root>
172
+ ) : null}
173
+
174
+ {/* {isVideoOn ? (
131
175
  <Suspense fallback="">
132
176
  <VirtualBackground asActionTile onVBClick={() => setOpenOptionsSheet(false)} />
133
177
  </Suspense>
134
- ) : null}
178
+ ) : null} */}
135
179
 
136
- <ActionTile.Root
137
- onClick={() => {
138
- setShowEmojiCard(true);
139
- setOpenOptionsSheet(false);
140
- }}
141
- >
142
- <EmojiIcon />
143
- <ActionTile.Title>Emoji Reactions</ActionTile.Title>
144
- </ActionTile.Root>
180
+ {elements?.emoji_reactions && (
181
+ <ActionTile.Root
182
+ onClick={() => {
183
+ setShowEmojiCard(true);
184
+ setOpenOptionsSheet(false);
185
+ }}
186
+ >
187
+ <EmojiIcon />
188
+ <ActionTile.Title>Emoji Reactions</ActionTile.Title>
189
+ </ActionTile.Root>
190
+ )}
191
+
192
+ {elements?.brb && (
193
+ <ActionTile.Root
194
+ active={isBRBOn}
195
+ onClick={() => {
196
+ toggleBRB();
197
+ setOpenOptionsSheet(false);
198
+ }}
199
+ >
200
+ <BrbIcon />
201
+ <ActionTile.Title>Be Right Back</ActionTile.Title>
202
+ </ActionTile.Root>
203
+ )}
145
204
 
146
205
  <ActionTile.Root
147
206
  onClick={() => {
@@ -173,6 +232,7 @@ export const MwebOptions = () => {
173
232
  setOpenOptionsSheet(false);
174
233
  setIsRecordingLoading(false);
175
234
  } catch (error) {
235
+ // @ts-ignore
176
236
  if (error.message.includes('stream already running')) {
177
237
  ToastManager.addToast({
178
238
  title: 'Recording already running',
@@ -180,6 +240,7 @@ export const MwebOptions = () => {
180
240
  });
181
241
  } else {
182
242
  ToastManager.addToast({
243
+ // @ts-ignore
183
244
  title: error.message,
184
245
  variant: 'error',
185
246
  });
@@ -207,11 +268,11 @@ export const MwebOptions = () => {
207
268
  </Sheet.Root>
208
269
  <SettingsModal open={openSettingsSheet} onOpenChange={setOpenSettingsSheet} />
209
270
  {openModals.has(MODALS.MUTE_ALL) && (
210
- <MuteAllModal onOpenChange={value => updateState(MODALS.MUTE_ALL, value)} isMobile />
271
+ <MuteAllModal onOpenChange={(value: boolean) => updateState(MODALS.MUTE_ALL, value)} isMobile />
211
272
  )}
212
273
  {openModals.has(MODALS.CHANGE_NAME) && (
213
274
  <ChangeNameModal
214
- onOpenChange={value => updateState(MODALS.CHANGE_NAME, value)}
275
+ onOpenChange={(value: boolean) => updateState(MODALS.CHANGE_NAME, value)}
215
276
  openParentSheet={() => setOpenOptionsSheet(true)}
216
277
  />
217
278
  )}
@@ -235,7 +296,7 @@ export const MwebOptions = () => {
235
296
  mx: '$4',
236
297
  }}
237
298
  >
238
- <EmojiCard />
299
+ <EmojiReaction />
239
300
  </Box>
240
301
  )}
241
302
  {showRecordingOn && (
@@ -247,6 +308,7 @@ export const MwebOptions = () => {
247
308
  setShowRecordingOn(false);
248
309
  } catch (error) {
249
310
  ToastManager.addToast({
311
+ // @ts-ignore
250
312
  title: error.message,
251
313
  variant: 'error',
252
314
  });
@@ -60,7 +60,9 @@ export function HLSFailureModal() {
60
60
  <Button outlined variant="standard" css={{ w: '100%' }} onClick={() => setOpenModal(false)}>
61
61
  Dismiss
62
62
  </Button>
63
- <Button css={{ w: '100%' }}>Go Live</Button>
63
+ <Button css={{ w: '100%' }} onClick={startHLS}>
64
+ Go Live
65
+ </Button>
64
66
  </Flex>
65
67
  </Dialog.Content>
66
68
  </Dialog.Portal>
@@ -1,43 +1,66 @@
1
1
  /* eslint-disable no-case-declarations */
2
- import React, { useEffect } from 'react';
3
- import { HMSNotificationTypes, useHMSNotifications } from '@100mslive/react-sdk';
2
+ import React, { useCallback, useEffect } from 'react';
3
+ import { useNavigate, useParams } from 'react-router-dom';
4
+ import {
5
+ HMSNotificationTypes,
6
+ HMSRoomState,
7
+ selectRoomState,
8
+ useCustomEvent,
9
+ useHMSNotifications,
10
+ useHMSStore,
11
+ } from '@100mslive/react-sdk';
4
12
  import { Button } from '../../../';
13
+ import { useUpdateRoomLayout } from '../../provider/roomLayoutProvider';
5
14
  import { ToastBatcher } from '../Toast/ToastBatcher';
6
15
  import { ToastManager } from '../Toast/ToastManager';
7
16
  import { AutoplayBlockedModal } from './AutoplayBlockedModal';
8
17
  import { InitErrorModal } from './InitErrorModal';
9
- import { MessageNotifications } from './MessageNotifications';
10
18
  import { PeerNotifications } from './PeerNotifications';
11
19
  import { PermissionErrorModal } from './PermissionErrorModal';
12
20
  import { ReconnectNotifications } from './ReconnectNotifications';
13
21
  import { TrackBulkUnmuteModal } from './TrackBulkUnmuteModal';
14
22
  import { TrackNotifications } from './TrackNotifications';
15
23
  import { TrackUnmuteModal } from './TrackUnmuteModal';
16
- import { useHLSViewerRole, useIsHeadless, useSubscribedNotifications } from '../AppData/useUISettings';
17
- import { useNavigation } from '../hooks/useNavigation';
24
+ import { useIsNotificationDisabled, useSubscribedNotifications } from '../AppData/useUISettings';
25
+ import { useRedirectToLeave } from '../hooks/useRedirectToLeave';
18
26
  import { getMetadata } from '../../common/utils';
19
-
27
+ import { ROLE_CHANGE_DECLINED } from '../../common/constants';
20
28
  export function Notifications() {
21
29
  const notification = useHMSNotifications();
22
- const navigate = useNavigation();
23
- const HLS_VIEWER_ROLE = useHLSViewerRole();
30
+ const navigate = useNavigate();
31
+ const params = useParams();
24
32
  const subscribedNotifications = useSubscribedNotifications() || {};
25
- const isHeadless = useIsHeadless();
33
+ const roomState = useHMSStore(selectRoomState);
34
+ const updateRoomLayoutForRole = useUpdateRoomLayout();
35
+ const isNotificationDisabled = useIsNotificationDisabled();
36
+ const { redirectToLeave } = useRedirectToLeave();
37
+
38
+ const handleRoleChangeDenied = useCallback(request => {
39
+ ToastManager.addToast({
40
+ title: `${request.peerName} denied your request to join the ${request.role.name} role`,
41
+ variant: 'error',
42
+ });
43
+ }, []);
44
+
45
+ useCustomEvent({ type: ROLE_CHANGE_DECLINED, onEvent: handleRoleChangeDenied });
26
46
 
27
47
  useEffect(() => {
28
- if (!notification) {
48
+ if (!notification || isNotificationDisabled) {
29
49
  return;
30
50
  }
31
51
  switch (notification.type) {
32
52
  case HMSNotificationTypes.METADATA_UPDATED:
53
+ if (roomState !== HMSRoomState.Connected) {
54
+ return;
55
+ }
33
56
  // Don't toast message when metadata is updated and raiseHand is false.
34
57
  // Don't toast message in case of local peer.
35
58
  const metadata = getMetadata(notification.data?.metadata);
36
- if (!metadata?.isHandRaised || notification.data.isLocal || isHeadless) return;
59
+ if (!metadata?.isHandRaised || notification.data.isLocal) return;
37
60
 
38
61
  console.debug('Metadata updated', notification.data);
39
62
  if (!subscribedNotifications.METADATA_UPDATED) return;
40
- ToastBatcher.showToast({ notification });
63
+ ToastBatcher.showToast({ notification, type: 'RAISE_HAND' });
41
64
  break;
42
65
  case HMSNotificationTypes.NAME_UPDATED:
43
66
  console.log(notification.data.id + ' changed their name to ' + notification.data.name);
@@ -59,7 +82,7 @@ export function Notifications() {
59
82
  <Button
60
83
  onClick={() => {
61
84
  ToastManager.removeToast(toastId);
62
- window.location.reload();
85
+ navigate(`/${params.roomId}${params.role ? `/${params.role}` : ''}`);
63
86
  }}
64
87
  >
65
88
  Rejoin
@@ -70,11 +93,7 @@ export function Notifications() {
70
93
  }
71
94
  // goto leave for terminal if any action is not performed within 2secs
72
95
  // if network is still unavailable going to preview will throw an error
73
- setTimeout(() => {
74
- const previewLocation = window.location.pathname.replace('meeting', 'leave');
75
- ToastManager.clearAllToast();
76
- navigate(previewLocation);
77
- }, 2000);
96
+ redirectToLeave(1000);
78
97
  return;
79
98
  }
80
99
  // Autoplay error or user denied screen share (cancelled browser pop-up)
@@ -90,13 +109,11 @@ export function Notifications() {
90
109
  });
91
110
  break;
92
111
  case HMSNotificationTypes.ROLE_UPDATED:
93
- if (notification.data.roleName === HLS_VIEWER_ROLE) {
94
- return;
95
- }
96
112
  if (notification.data?.isLocal) {
97
113
  ToastManager.addToast({
98
114
  title: `You are now a ${notification.data.roleName}`,
99
115
  });
116
+ updateRoomLayoutForRole(notification.data.roleName);
100
117
  }
101
118
  break;
102
119
  case HMSNotificationTypes.CHANGE_TRACK_STATE_REQUEST:
@@ -114,11 +131,7 @@ export function Notifications() {
114
131
  title: `${notification.message}.
115
132
  ${notification.data.reason && `Reason: ${notification.data.reason}`}`,
116
133
  });
117
- setTimeout(() => {
118
- const leaveLocation = window.location.pathname.replace('meeting', 'leave');
119
- navigate(leaveLocation);
120
- ToastManager.clearAllToast();
121
- }, 2000);
134
+ redirectToLeave(1000);
122
135
  break;
123
136
  case HMSNotificationTypes.DEVICE_CHANGE_UPDATE:
124
137
  ToastManager.addToast({
@@ -129,18 +142,21 @@ export function Notifications() {
129
142
  break;
130
143
  }
131
144
  // eslint-disable-next-line react-hooks/exhaustive-deps
132
- }, [notification, subscribedNotifications.ERROR, subscribedNotifications.METADATA_UPDATED, HLS_VIEWER_ROLE]);
145
+ }, [notification, subscribedNotifications.ERROR, subscribedNotifications.METADATA_UPDATED]);
146
+
147
+ if (isNotificationDisabled) {
148
+ return null;
149
+ }
133
150
 
134
151
  return (
135
152
  <>
136
- {!isHeadless && <TrackUnmuteModal />}
137
- {!isHeadless && <TrackBulkUnmuteModal />}
153
+ <TrackUnmuteModal />
154
+ <TrackBulkUnmuteModal />
138
155
  <TrackNotifications />
139
156
  <PeerNotifications />
140
157
  <ReconnectNotifications />
141
158
  <AutoplayBlockedModal />
142
159
  <PermissionErrorModal />
143
- <MessageNotifications />
144
160
  <InitErrorModal notification={notification} />
145
161
  </>
146
162
  );
@@ -1,5 +1,11 @@
1
1
  import { useEffect } from 'react';
2
- import { HMSNotificationTypes, useHMSNotifications } from '@100mslive/react-sdk';
2
+ import {
3
+ HMSNotificationTypes,
4
+ HMSRoomState,
5
+ selectRoomState,
6
+ useHMSNotifications,
7
+ useHMSStore,
8
+ } from '@100mslive/react-sdk';
3
9
  import { ToastBatcher } from '../Toast/ToastBatcher';
4
10
  import { useSubscribedNotifications } from '../AppData/useUISettings';
5
11
  import { isInternalRole } from '../../common/utils';
@@ -15,10 +21,15 @@ export const PeerNotifications = () => {
15
21
  const notification = useHMSNotifications(notificationTypes);
16
22
  const isPeerJoinSubscribed = useSubscribedNotifications(SUBSCRIBED_NOTIFICATIONS.PEER_JOINED);
17
23
  const isPeerLeftSubscribed = useSubscribedNotifications(SUBSCRIBED_NOTIFICATIONS.PEER_LEFT);
24
+ const roomState = useHMSStore(selectRoomState);
18
25
  useEffect(() => {
26
+ if (roomState !== HMSRoomState.Connected) {
27
+ return;
28
+ }
19
29
  if (!notification || (notification?.data?.roleName && isInternalRole(notification.data.roleName))) {
20
30
  return;
21
31
  }
32
+
22
33
  console.debug(`[${notification.type}]`, notification);
23
34
  switch (notification.type) {
24
35
  case HMSNotificationTypes.PEER_LIST:
@@ -39,8 +50,9 @@ export const PeerNotifications = () => {
39
50
  default:
40
51
  return;
41
52
  }
53
+
42
54
  ToastBatcher.showToast({ notification });
43
- }, [notification, isPeerJoinSubscribed, isPeerLeftSubscribed]);
55
+ }, [notification, isPeerJoinSubscribed, isPeerLeftSubscribed, roomState]);
44
56
 
45
57
  return null;
46
58
  };
@@ -2,8 +2,8 @@ import React, { useEffect, useState } from 'react';
2
2
  import { useMedia } from 'react-use';
3
3
  import { HMSNotificationTypes, useHMSNotifications } from '@100mslive/react-sdk';
4
4
  import { Button, config as cssConfig, Dialog, Flex, Text } from '../../../';
5
- import androidPermissionAlert from '../../../assets/android-perm-1.png';
6
- import iosPermissions from '../../../assets/ios-perm-0.png';
5
+ import androidPermissionAlert from '../../images/android-perm-1.png';
6
+ import iosPermissions from '../../images/ios-perm-0.png';
7
7
  import { isAndroid, isIOS } from '../../common/constants';
8
8
 
9
9
  export function PermissionErrorModal() {
@@ -47,11 +47,17 @@ export function PermissionErrorModal() {
47
47
  borderBottom: '1px solid $border_default',
48
48
  }}
49
49
  >
50
- {isMobile && isIOS ? <img style={{ maxWidth: '100%', maxHeight: '100%' }} src={iosPermissions} /> : null}
50
+ {isMobile && isIOS ? (
51
+ <img style={{ maxWidth: '100%', maxHeight: '100%' }} src={iosPermissions} alt="iOS Permission flow" />
52
+ ) : null}
51
53
 
52
54
  {/* Images for android */}
53
55
  {isMobile && isAndroid ? (
54
- <img src={androidPermissionAlert} style={{ maxWidth: '100%', maxHeight: '100%' }} />
56
+ <img
57
+ src={androidPermissionAlert}
58
+ style={{ maxWidth: '100%', maxHeight: '100%' }}
59
+ alt="Android Permission flow "
60
+ />
55
61
  ) : null}
56
62
 
57
63
  <Text variant="h6">We can't access your {deviceType}</Text>
@@ -11,7 +11,6 @@ const notificationTypes = [
11
11
  ];
12
12
  let notificationId = null;
13
13
 
14
- const isQA = process.env.REACT_APP_ENV === 'qa';
15
14
  export const ReconnectNotifications = () => {
16
15
  const notification = useHMSNotifications(notificationTypes);
17
16
  const [open, setOpen] = useState(false);
@@ -22,18 +21,13 @@ export const ReconnectNotifications = () => {
22
21
  notificationId = ToastManager.replaceToast(notificationId, ToastConfig.RECONNECTED.single());
23
22
  setOpen(false);
24
23
  } else if (notification?.type === HMSNotificationTypes.RECONNECTING) {
25
- if (isQA) {
26
- ToastManager.removeToast(notificationId);
27
- setOpen(true);
28
- } else {
29
- notificationId = ToastManager.replaceToast(
30
- notificationId,
31
- ToastConfig.RECONNECTING.single(notification.data.message),
32
- );
33
- }
24
+ notificationId = ToastManager.replaceToast(
25
+ notificationId,
26
+ ToastConfig.RECONNECTING.single(notification.data.message),
27
+ );
34
28
  }
35
29
  }, [notification]);
36
- if (!open || !isQA) return null;
30
+ if (!open) return null;
37
31
  return (
38
32
  <Dialog.Root open={open} modal={true}>
39
33
  <Dialog.Portal container={document.getElementById('conferencing')}>
@@ -1,31 +1,20 @@
1
1
  import React, { useCallback, useEffect, useState } from 'react';
2
- import {
3
- selectLocalPeerRoleName,
4
- selectPeers,
5
- selectTracksMap,
6
- useHMSActions,
7
- useHMSStore,
8
- useHMSVanillaStore,
9
- } from '@100mslive/react-sdk';
2
+ import { selectPeers, selectTracksMap, useHMSActions, useHMSStore, useHMSVanillaStore } from '@100mslive/react-sdk';
10
3
  import { PipIcon } from '@100mslive/react-icons';
11
4
  import { Flex, Tooltip } from '../../../';
12
5
  import IconButton from '../../IconButton';
13
6
  import { PictureInPicture } from './PIPManager';
14
7
  import { MediaSession } from './SetupMediaSession';
15
8
  import { usePinnedTrack } from '../AppData/useUISettings';
16
- import { useIsFeatureEnabled } from '../hooks/useFeatures';
17
- import { DEFAULT_HLS_VIEWER_ROLE, FEATURE_LIST } from '../../common/constants';
18
9
 
19
10
  /**
20
11
  * shows a button which when clicked shows some videos in PIP, clicking
21
12
  * again turns it off.
22
13
  */
23
14
  const PIPComponent = ({ content = null }) => {
24
- const localPeerRole = useHMSStore(selectLocalPeerRoleName);
25
15
  const [isPipOn, setIsPipOn] = useState(PictureInPicture.isOn());
26
16
  const hmsActions = useHMSActions();
27
17
  const store = useHMSVanillaStore();
28
- const isFeatureEnabled = useIsFeatureEnabled(FEATURE_LIST.PICTURE_IN_PICTURE);
29
18
 
30
19
  const onPipToggle = useCallback(() => {
31
20
  if (!isPipOn) {
@@ -36,7 +25,7 @@ const PIPComponent = ({ content = null }) => {
36
25
  }
37
26
  }, [hmsActions, isPipOn, store]);
38
27
 
39
- if (!PictureInPicture.isSupported() || localPeerRole === DEFAULT_HLS_VIEWER_ROLE || !isFeatureEnabled) {
28
+ if (!PictureInPicture.isSupported()) {
40
29
  return null;
41
30
  }
42
31
  return (
@@ -66,8 +55,8 @@ export const ActivatedPIP = () => {
66
55
  const pinnedTrack = usePinnedTrack();
67
56
 
68
57
  useEffect(() => {
69
- PictureInPicture.listenToStateChange(isPipOn => {
70
- if (!isPipOn) {
58
+ function updatePIP() {
59
+ if (!PictureInPicture.isOn()) {
71
60
  return;
72
61
  }
73
62
  let pipPeers = storePeers;
@@ -77,7 +66,9 @@ export const ActivatedPIP = () => {
77
66
  PictureInPicture.updatePeersAndTracks(pipPeers, tracksMap).catch(err => {
78
67
  console.error('error in updating pip', err);
79
68
  });
80
- });
69
+ }
70
+ PictureInPicture.listenToStateChange(updatePIP);
71
+ updatePIP();
81
72
  }, [storePeers, tracksMap, pinnedTrack]);
82
73
 
83
74
  return <></>;
@@ -107,6 +107,7 @@ class PipManager {
107
107
  this.pipVideo?.removeEventListener(LEAVE_EVENT_NAME, this.stop);
108
108
  if (this.timeoutRef) {
109
109
  workerTimers.clearTimeout(this.timeoutRef);
110
+ this.timeoutRef = null;
110
111
  }
111
112
  if (this.isOn()) {
112
113
  this.exitPIP();
@@ -0,0 +1,60 @@
1
+ import React, { useEffect } from 'react';
2
+ import { ChevronLeftIcon, ChevronRightIcon } from '@100mslive/react-icons';
3
+ import { StyledPagination } from '../../Pagination';
4
+
5
+ export const Pagination = ({
6
+ page,
7
+ onPageChange,
8
+ numPages,
9
+ }: {
10
+ page: number;
11
+ onPageChange: (page: number) => void;
12
+ numPages: number;
13
+ }) => {
14
+ const disableLeft = page === 0;
15
+ const disableRight = page === numPages - 1;
16
+ const nextPage = (e: React.SyntheticEvent) => {
17
+ e.stopPropagation();
18
+ onPageChange(Math.min(page + 1, numPages - 1));
19
+ };
20
+ const prevPage = (e: React.SyntheticEvent) => {
21
+ e.stopPropagation();
22
+ onPageChange(Math.max(page - 1, 0));
23
+ };
24
+
25
+ useEffect(() => {
26
+ // currentPageIndex should not exceed pages length
27
+ if (page >= numPages) {
28
+ onPageChange(Math.max(0, numPages - 1));
29
+ }
30
+ }, [numPages, onPageChange, page]);
31
+
32
+ if (numPages <= 1) {
33
+ return null;
34
+ }
35
+
36
+ return (
37
+ <StyledPagination.Root css={{ flexShrink: 0 }}>
38
+ <StyledPagination.Chevron disabled={disableLeft} onClick={prevPage}>
39
+ <ChevronLeftIcon width={16} height={16} style={{ cursor: disableLeft ? 'not-allowed' : 'pointer' }} />
40
+ </StyledPagination.Chevron>
41
+ {numPages <= 5 ? (
42
+ <StyledPagination.Dots>
43
+ {[...Array(numPages)].map((_, i) => (
44
+ <StyledPagination.Dot
45
+ key={i}
46
+ active={page === i}
47
+ onClick={e => {
48
+ e.stopPropagation();
49
+ onPageChange(i);
50
+ }}
51
+ />
52
+ ))}
53
+ </StyledPagination.Dots>
54
+ ) : null}
55
+ <StyledPagination.Chevron disabled={disableRight} onClick={nextPage}>
56
+ <ChevronRightIcon width={16} height={16} style={{ cursor: disableRight ? 'not-allowed' : 'pointer' }} />
57
+ </StyledPagination.Chevron>
58
+ </StyledPagination.Root>
59
+ );
60
+ };