@@ -2,7 +2,7 @@ import './index.scss';
22import './__experimental__typography.scss' ;
33
44import React , { useEffect , useReducer , useState } from 'react' ;
5- import PropTypes from 'prop-types ' ;
5+ import { User } from '@sendbird/chat ' ;
66
77import { SendbirdSdkContext } from './SendbirdSdkContext' ;
88import { handleConnection } from './dux/sdk/thunks' ;
@@ -26,39 +26,93 @@ import { MediaQueryProvider } from './MediaQueryContext';
2626import getStringSet from '../ui/Label/stringSet' ;
2727import { VOICE_RECORDER_DEFAULT_MAX , VOICE_RECORDER_DEFAULT_MIN } from '../utils/consts' ;
2828
29- export default function Sendbird ( props ) {
30- const {
31- userId,
32- dateLocale,
33- appId,
34- accessToken,
35- configureSession,
36- // mediaQueryBreakPoint,
37- customApiHost,
38- customWebSocketHost,
39- children,
40- disableUserProfile,
41- disableMarkAsDelivered,
42- renderUserProfile,
43- onUserProfileMessage,
44- allowProfileEdit,
45- theme,
46- nickname,
47- profileUrl,
48- userListQuery,
49- config = { } ,
50- colorSet,
51- stringSet,
52- imageCompression,
53- isReactionEnabled,
54- isMentionEnabled,
55- isVoiceMessageEnabled,
56- voiceRecord,
57- isTypingIndicatorEnabledOnChannelList,
58- isMessageReceiptStatusEnabledOnChannelList,
59- replyType,
60- } = props ;
29+ export type UserListQueryType = {
30+ hasNext ?: boolean ;
31+ next : ( ) => Promise < Array < User > > ;
32+ }
33+
34+ interface VoiceRecordOptions {
35+ maxRecordingTime ?: number ;
36+ minRecordingTime ?: number ;
37+ }
38+
39+ export interface ImageCompressionOptions {
40+ compressionRate ?: number ;
41+ resizingWidth ?: number | string ;
42+ resizingHeight ?: number | string ;
43+ }
6144
45+ export interface SendbirdConfig {
46+ logLevel ?: string | Array < string > ;
47+ pubSub ?: ( ) => void ; // TODO: Define pubSub type and apply it here
48+ userMention ?: {
49+ maxMentionCount ?: number ;
50+ maxSuggestionCount ?: number ;
51+ } ;
52+ isREMUnitEnabled ?: boolean ;
53+ }
54+
55+ export interface SendbirdProviderProps {
56+ appId : string ;
57+ userId : string ;
58+ children : React . ReactElement ;
59+ accessToken ?: string ;
60+ customApiHost ?: string ;
61+ customWebSocketHost ?: string ;
62+ configureSession ?: ( ) => void ;
63+ theme ?: 'light' | 'dark' ;
64+ config ?: SendbirdConfig ;
65+ nickname ?: string ;
66+ colorSet ?: Record < string , string > ;
67+ stringSet ?: Record < string , string > ;
68+ replyType ?: 'NONE' | 'QUOTE_REPLY' | 'THREAD' ;
69+ dateLocale ?: Locale ;
70+ profileUrl ?: string ;
71+ voiceRecord ?: VoiceRecordOptions ;
72+ userListQuery ?: UserListQueryType ;
73+ imageCompression ?: ImageCompressionOptions ;
74+ allowProfileEdit ?: boolean ;
75+ isMentionEnabled ?: boolean ;
76+ isReactionEnabled ?: boolean ;
77+ disableUserProfile ?: boolean ;
78+ isVoiceMessageEnabled ?: boolean ;
79+ disableMarkAsDelivered ?: boolean ;
80+ isTypingIndicatorEnabledOnChannelList ?: boolean ;
81+ isMessageReceiptStatusEnabledOnChannelList ?: boolean ;
82+ renderUserProfile ?: ( ) => React . ReactElement ;
83+ onUserProfileMessage ?: ( ) => void ;
84+ }
85+
86+ const Sendbird = ( {
87+ appId,
88+ userId,
89+ children,
90+ accessToken = '' ,
91+ customApiHost = '' ,
92+ customWebSocketHost = '' ,
93+ configureSession = null ,
94+ theme = 'light' ,
95+ config = { } ,
96+ nickname = '' ,
97+ colorSet = null ,
98+ stringSet = null ,
99+ replyType = 'NONE' ,
100+ dateLocale = null ,
101+ profileUrl = '' ,
102+ voiceRecord = { maxRecordingTime : VOICE_RECORDER_DEFAULT_MAX , minRecordingTime : VOICE_RECORDER_DEFAULT_MIN } ,
103+ userListQuery = null ,
104+ imageCompression = { } ,
105+ allowProfileEdit = false ,
106+ isMentionEnabled = false ,
107+ isReactionEnabled = true ,
108+ disableUserProfile = false ,
109+ isVoiceMessageEnabled = true ,
110+ disableMarkAsDelivered = false ,
111+ isTypingIndicatorEnabledOnChannelList = false ,
112+ isMessageReceiptStatusEnabledOnChannelList = false ,
113+ renderUserProfile = null ,
114+ onUserProfileMessage = null ,
115+ } : SendbirdProviderProps ) : React . ReactElement => {
62116 const mediaQueryBreakPoint = false ;
63117
64118 const {
@@ -223,98 +277,4 @@ export default function Sendbird(props) {
223277 ) ;
224278}
225279
226- Sendbird . propTypes = {
227- userId : PropTypes . string . isRequired ,
228- appId : PropTypes . string . isRequired ,
229- accessToken : PropTypes . string ,
230- customApiHost : PropTypes . string ,
231- customWebSocketHost : PropTypes . string ,
232- // mediaQueryBreakPoint: PropTypes.string,
233- configureSession : PropTypes . func ,
234- children : PropTypes . oneOfType ( [
235- PropTypes . element ,
236- PropTypes . arrayOf ( PropTypes . element ) ,
237- PropTypes . any ,
238- ] ) . isRequired ,
239- theme : PropTypes . string ,
240- nickname : PropTypes . string ,
241- dateLocale : PropTypes . shape ( { } ) ,
242- profileUrl : PropTypes . string ,
243- disableUserProfile : PropTypes . bool ,
244- disableMarkAsDelivered : PropTypes . bool ,
245- renderUserProfile : PropTypes . func ,
246- onUserProfileMessage : PropTypes . func ,
247- allowProfileEdit : PropTypes . bool ,
248- userListQuery : PropTypes . func ,
249- config : PropTypes . shape ( {
250- // None Error Warning Info 'All/Debug'
251- logLevel : PropTypes . oneOfType ( [
252- PropTypes . string ,
253- PropTypes . arrayOf ( PropTypes . string ) ,
254- ] ) ,
255- pubSub : PropTypes . shape ( {
256- subscribe : PropTypes . func ,
257- publish : PropTypes . func ,
258- } ) ,
259- userMention : PropTypes . shape ( {
260- maxMentionCount : PropTypes . number ,
261- maxSuggestionCount : PropTypes . number ,
262- } ) ,
263- isREMUnitEnabled : PropTypes . bool ,
264- } ) ,
265- stringSet : PropTypes . objectOf ( PropTypes . string ) ,
266- colorSet : PropTypes . objectOf ( PropTypes . string ) ,
267- isReactionEnabled : PropTypes . bool ,
268- isMentionEnabled : PropTypes . bool ,
269- isVoiceMessageEnabled : PropTypes . bool ,
270- voiceRecord : PropTypes . shape ( {
271- maxRecordingTime : PropTypes . number ,
272- minRecordingTime : PropTypes . number ,
273- } ) ,
274- imageCompression : PropTypes . shape ( {
275- compressionRate : PropTypes . number ,
276- resizingWidth : PropTypes . oneOfType ( [
277- PropTypes . number ,
278- PropTypes . string ,
279- ] ) ,
280- resizingHeight : PropTypes . oneOfType ( [
281- PropTypes . number ,
282- PropTypes . string ,
283- ] ) ,
284- } ) ,
285- isTypingIndicatorEnabledOnChannelList : PropTypes . bool ,
286- isMessageReceiptStatusEnabledOnChannelList : PropTypes . bool ,
287- replyType : PropTypes . oneOf ( [ 'NONE' , 'QUOTE_REPLY' , 'THREAD' ] ) ,
288- } ;
289-
290- Sendbird . defaultProps = {
291- accessToken : '' ,
292- customApiHost : null ,
293- customWebSocketHost : null ,
294- configureSession : null ,
295- theme : 'light' ,
296- // mediaQueryBreakPoint: null,
297- nickname : '' ,
298- dateLocale : null ,
299- profileUrl : '' ,
300- disableUserProfile : false ,
301- disableMarkAsDelivered : false ,
302- renderUserProfile : null ,
303- onUserProfileMessage : null ,
304- allowProfileEdit : false ,
305- userListQuery : null ,
306- config : { } ,
307- stringSet : null ,
308- colorSet : null ,
309- imageCompression : { } ,
310- isReactionEnabled : true ,
311- isMentionEnabled : false ,
312- isVoiceMessageEnabled : true ,
313- voiceRecord : {
314- maxRecordingTime : VOICE_RECORDER_DEFAULT_MAX ,
315- minRecordingTime : VOICE_RECORDER_DEFAULT_MIN ,
316- } ,
317- isTypingIndicatorEnabledOnChannelList : false ,
318- isMessageReceiptStatusEnabledOnChannelList : false ,
319- replyType : 'NONE' ,
320- } ;
280+ export default Sendbird ;
0 commit comments