@100mslive/roomkit-react 0.2.6 → 0.2.7-alpha.1

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 (28) hide show
  1. package/README.md +30 -33
  2. package/dist/{HLSView-A5DVXKEU.js → HLSView-4B5MUDFR.js} +2 -2
  3. package/dist/Prebuilt/common/constants.d.ts +4 -3
  4. package/dist/Prebuilt/components/AudioVideoToggle.d.ts +9 -0
  5. package/dist/Prebuilt/components/IconButtonWithOptions/IconButtonWithOptions.d.ts +11 -0
  6. package/dist/Prebuilt/components/hooks/useAudioOutputTest.d.ts +8 -0
  7. package/dist/{chunk-KUVM2TEZ.js → chunk-KST24BRA.js} +4227 -3807
  8. package/dist/chunk-KST24BRA.js.map +7 -0
  9. package/dist/index.cjs.js +5518 -5092
  10. package/dist/index.cjs.js.map +4 -4
  11. package/dist/index.js +1 -1
  12. package/dist/meta.cjs.json +666 -597
  13. package/dist/meta.esbuild.json +673 -604
  14. package/package.json +7 -6
  15. package/src/Prebuilt/common/constants.ts +7 -4
  16. package/src/Prebuilt/components/AppData/useUISettings.js +1 -1
  17. package/src/Prebuilt/components/AudioVideoToggle.tsx +308 -0
  18. package/src/Prebuilt/components/Footer/RoleOptions.tsx +1 -0
  19. package/src/Prebuilt/components/IconButtonWithOptions/IconButtonWithOptions.tsx +159 -0
  20. package/src/Prebuilt/components/Leave/DesktopLeaveRoom.tsx +0 -2
  21. package/src/Prebuilt/components/Notifications/HandRaisedNotifications.tsx +13 -2
  22. package/src/Prebuilt/components/Notifications/Notifications.tsx +1 -18
  23. package/src/Prebuilt/components/Settings/DeviceSettings.jsx +10 -17
  24. package/src/Prebuilt/components/hooks/useAudioOutputTest.tsx +20 -0
  25. package/dist/chunk-KUVM2TEZ.js.map +0 -7
  26. package/src/Prebuilt/components/AudioVideoToggle.jsx +0 -171
  27. package/src/Prebuilt/components/IconButtonWithOptions/IconButtonWithOptions.jsx +0 -121
  28. /package/dist/{HLSView-A5DVXKEU.js.map → HLSView-4B5MUDFR.js.map} +0 -0
@@ -1,171 +0,0 @@
1
- import React, { Fragment } from 'react';
2
- import {
3
- DeviceType,
4
- HMSRoomState,
5
- selectLocalVideoTrackID,
6
- selectRoomState,
7
- selectVideoTrackByID,
8
- useAVToggle,
9
- useDevices,
10
- useHMSActions,
11
- useHMSStore,
12
- } from '@100mslive/react-sdk';
13
- import { CameraFlipIcon, MicOffIcon, MicOnIcon, VideoOffIcon, VideoOnIcon } from '@100mslive/react-icons';
14
- import { IconButtonWithOptions } from './IconButtonWithOptions/IconButtonWithOptions';
15
- import { ToastManager } from './Toast/ToastManager';
16
- import { Text } from '../../Text';
17
- import { Tooltip } from '../../Tooltip';
18
- import IconButton from '../IconButton';
19
- import { isMacOS } from '../common/constants';
20
-
21
- const optionsCSS = { fontWeight: '$semiBold', color: '$on_surface_high', w: '100%', p: '$8' };
22
-
23
- export const AudioVideoToggle = ({ hideOptions = false }) => {
24
- const { allDevices, selectedDeviceIDs, updateDevice } = useDevices();
25
- const { videoInput, audioInput } = allDevices;
26
-
27
- const formattedVideoInputList = videoInput?.map(videoInput => ({
28
- active: selectedDeviceIDs.videoInput === videoInput.deviceId,
29
- content: (
30
- <Text
31
- variant="sm"
32
- onClick={() =>
33
- updateDevice({
34
- deviceType: DeviceType.videoInput,
35
- deviceId: videoInput.deviceId,
36
- })
37
- }
38
- css={optionsCSS}
39
- >
40
- {videoInput.label}
41
- </Text>
42
- ),
43
- title: videoInput.label,
44
- }));
45
-
46
- const formattedAudioInputList = audioInput?.map(audioInput => ({
47
- active: selectedDeviceIDs.audioInput === audioInput.deviceId,
48
- content: (
49
- <Text
50
- variant="sm"
51
- onClick={() =>
52
- updateDevice({
53
- deviceType: DeviceType.audioInput,
54
- deviceId: audioInput.deviceId,
55
- })
56
- }
57
- css={optionsCSS}
58
- >
59
- {audioInput.label}
60
- </Text>
61
- ),
62
- title: audioInput.label,
63
- }));
64
-
65
- const { isLocalVideoEnabled, isLocalAudioEnabled, toggleAudio, toggleVideo } = useAVToggle();
66
- const actions = useHMSActions();
67
- const videoTrackId = useHMSStore(selectLocalVideoTrackID);
68
- const localVideoTrack = useHMSStore(selectVideoTrackByID(videoTrackId));
69
- const roomState = useHMSStore(selectRoomState);
70
- const hasAudioDevices = audioInput?.length > 0;
71
- const hasVideoDevices = videoInput?.length > 0;
72
-
73
- return (
74
- <Fragment>
75
- {toggleAudio ? (
76
- hideOptions || !hasAudioDevices ? (
77
- <Tooltip title={`Turn ${isLocalAudioEnabled ? 'off' : 'on'} audio (${isMacOS ? '⌘' : 'ctrl'} + d)`}>
78
- <IconButton
79
- active={isLocalAudioEnabled}
80
- disabled={!toggleAudio}
81
- onClick={toggleAudio}
82
- key="toggleAudio"
83
- data-testid="audio_btn"
84
- className="__cancel-drag-event"
85
- >
86
- {!isLocalAudioEnabled ? (
87
- <MicOffIcon data-testid="audio_off_btn" />
88
- ) : (
89
- <MicOnIcon data-testid="audio_on_btn" />
90
- )}
91
- </IconButton>
92
- </Tooltip>
93
- ) : (
94
- <IconButtonWithOptions
95
- options={formattedAudioInputList}
96
- disabled={!toggleAudio}
97
- onDisabledClick={toggleAudio}
98
- tooltipMessage={`Turn ${isLocalAudioEnabled ? 'off' : 'on'} audio (${isMacOS ? '⌘' : 'ctrl'} + d)`}
99
- icon={
100
- !isLocalAudioEnabled ? (
101
- <MicOffIcon data-testid="audio_off_btn" />
102
- ) : (
103
- <MicOnIcon data-testid="audio_on_btn" />
104
- )
105
- }
106
- active={isLocalAudioEnabled}
107
- onClick={toggleAudio}
108
- key="toggleAudio"
109
- />
110
- )
111
- ) : null}
112
-
113
- {toggleVideo ? (
114
- hideOptions || !hasVideoDevices ? (
115
- <Tooltip title={`Turn ${isLocalVideoEnabled ? 'off' : 'on'} video (${isMacOS ? '⌘' : 'ctrl'} + e)`}>
116
- <IconButton
117
- key="toggleVideo"
118
- active={isLocalVideoEnabled}
119
- disabled={!toggleVideo}
120
- onClick={toggleVideo}
121
- data-testid="video_btn"
122
- className="__cancel-drag-event"
123
- >
124
- {!isLocalVideoEnabled ? (
125
- <VideoOffIcon data-testid="video_off_btn" />
126
- ) : (
127
- <VideoOnIcon data-testid="video_on_btn" />
128
- )}
129
- </IconButton>
130
- </Tooltip>
131
- ) : (
132
- <IconButtonWithOptions
133
- disabled={!toggleVideo}
134
- onDisabledClick={toggleVideo}
135
- options={formattedVideoInputList}
136
- tooltipMessage={`Turn ${isLocalVideoEnabled ? 'off' : 'on'} video (${isMacOS ? '⌘' : 'ctrl'} + e)`}
137
- icon={
138
- !isLocalVideoEnabled ? (
139
- <VideoOffIcon data-testid="video_off_btn" />
140
- ) : (
141
- <VideoOnIcon data-testid="video_on_btn" />
142
- )
143
- }
144
- key="toggleVideo"
145
- active={isLocalVideoEnabled}
146
- onClick={toggleVideo}
147
- />
148
- )
149
- ) : null}
150
-
151
- {localVideoTrack?.facingMode && roomState === HMSRoomState.Preview ? (
152
- <Tooltip title="Switch Camera" key="switchCamera">
153
- <IconButton
154
- onClick={async () => {
155
- try {
156
- await actions.switchCamera();
157
- } catch (e) {
158
- ToastManager.addToast({
159
- title: `Error while flipping camera ${e.message || ''}`,
160
- variant: 'error',
161
- });
162
- }
163
- }}
164
- >
165
- <CameraFlipIcon />
166
- </IconButton>
167
- </Tooltip>
168
- ) : null}
169
- </Fragment>
170
- );
171
- };
@@ -1,121 +0,0 @@
1
- import React from 'react';
2
- import { VerticalMenuIcon } from '@100mslive/react-icons';
3
- import { Dropdown } from '../../../Dropdown';
4
- import { Box, Flex } from '../../../Layout';
5
- import { styled } from '../../../Theme';
6
- import { Tooltip } from '../../../Tooltip';
7
- import IconButton from '../../IconButton';
8
-
9
- const IconSection = styled(IconButton, {
10
- w: 'unset',
11
- h: '$14',
12
- p: '$4',
13
- r: '$1',
14
- borderTopRightRadius: 0,
15
- borderColor: '$border_bright',
16
- borderBottomRightRadius: 0,
17
- position: 'relative',
18
- '&:not([disabled]):focus-visible': {
19
- zIndex: 1,
20
- },
21
- '@md': {
22
- mx: 0,
23
- borderTopRightRadius: '$1',
24
- borderBottomRightRadius: '$1',
25
- },
26
- });
27
-
28
- const OptionsSection = styled(IconButton, {
29
- w: 'unset',
30
- h: '$14',
31
- p: '$4 $2',
32
- r: '$1',
33
- borderTopLeftRadius: 0,
34
- borderColor: '$border_bright',
35
- borderBottomLeftRadius: 0,
36
- borderLeftWidth: 0,
37
- position: 'relative',
38
- '&:not([disabled]):focus-visible': {
39
- zIndex: 1,
40
- },
41
- '@md': {
42
- display: 'none',
43
- },
44
- });
45
-
46
- export const IconButtonWithOptions = ({
47
- disabled = false,
48
- onDisabledClick = () => {
49
- return;
50
- },
51
- tooltipMessage = '',
52
- icon,
53
- options = [],
54
- active,
55
- onClick = () => {
56
- return;
57
- },
58
- }) => {
59
- const bgCss = { backgroundColor: disabled ? '$surface_brighter' : active ? '$transparent' : '$secondary_dim' };
60
- const iconCss = { color: disabled ? '$on_surface_low' : active ? '$on_surface_high' : '$on_primary_high' };
61
-
62
- return (
63
- <Flex>
64
- <IconSection css={bgCss} onClick={onClick}>
65
- <Tooltip disabled={!tooltipMessage} title={tooltipMessage}>
66
- <Flex align="center" justify="center" css={iconCss}>
67
- {icon}
68
- </Flex>
69
- </Tooltip>
70
- </IconSection>
71
- <Dropdown.Root>
72
- <Dropdown.Trigger
73
- asChild
74
- // onClick does not work
75
- onPointerDown={e => {
76
- if (disabled) {
77
- e.preventDefault();
78
- onDisabledClick();
79
- }
80
- }}
81
- >
82
- <OptionsSection css={bgCss}>
83
- <Tooltip title="View Options">
84
- <Box css={iconCss}>
85
- <VerticalMenuIcon />
86
- </Box>
87
- </Tooltip>
88
- </OptionsSection>
89
- </Dropdown.Trigger>
90
- <Dropdown.Content
91
- sideOffset={5}
92
- align="center"
93
- css={{
94
- w: '$64',
95
- maxHeight: '$96',
96
- p: 0,
97
- border: 'none',
98
- }}
99
- >
100
- {options.map((option, index) => (
101
- <Dropdown.Item
102
- key={option.title}
103
- css={{
104
- flexDirection: 'column',
105
- alignItems: 'flex-start',
106
- backgroundColor: option.active ? '$surface_bright' : '$surface_dim',
107
- borderTop: index === 0 ? 'none' : '1px solid $border_default',
108
- '&:hover': {
109
- cursor: 'pointer',
110
- },
111
- p: '0',
112
- }}
113
- >
114
- {option.content}
115
- </Dropdown.Item>
116
- ))}
117
- </Dropdown.Content>
118
- </Dropdown.Root>
119
- </Flex>
120
- );
121
- };