@cometchat/chat-uikit-react-native 4.3.21 → 4.3.22

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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/AI/AIConversationSummary/AIConversationSummaryView.tsx +171 -167
  3. package/src/AI/CardView.tsx +55 -53
  4. package/src/CometChatCreateGroup/CometChatCreateGroup.tsx +8 -13
  5. package/src/CometChatGroups/CometChatGroups.tsx +545 -514
  6. package/src/CometChatJoinProtectedGroup/CometChatJoinProtectedGroup.tsx +5 -8
  7. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +544 -378
  8. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +90 -72
  9. package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +3 -8
  10. package/src/CometChatTransferOwnership/CometChatTransferOwnership.tsx +11 -13
  11. package/src/CometChatUsers/CometChatUsers.tsx +24 -23
  12. package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +24 -25
  13. package/src/extensions/Polls/Polls.tsx +8 -16
  14. package/src/extensions/Polls/PollsBubble.tsx +5 -10
  15. package/src/extensions/SmartReplies/SmartRepliesView.tsx +16 -22
  16. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +51 -51
  17. package/src/shared/libs/datePickerModal/DateTimePickerModal.android.js +1 -7
  18. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js +38 -46
  19. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +19 -19
  20. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +8 -20
  21. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -14
  22. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +141 -140
  23. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +47 -51
  24. package/src/shared/views/CometChatDate/CometChatDate.tsx +18 -17
  25. package/src/shared/views/CometChatDateTimePicker/CometChatDateTimePicker.tsx +65 -51
  26. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +76 -72
  27. package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +3 -8
  28. package/src/shared/views/CometChatList/CometChatList.tsx +133 -134
  29. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +62 -61
  30. package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +2 -6
  31. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +3 -8
  32. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +24 -23
  33. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +107 -53
  34. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +22 -14
  35. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +15 -8
  36. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +2 -6
  37. package/src/shared/views/SwipeRow/SwipeRow.tsx +6 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "4.3.21",
3
+ "version": "4.3.22",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -1,4 +1,3 @@
1
-
2
1
  import React, { useContext, useEffect, useState } from 'react';
3
2
  import { View } from 'react-native';
4
3
  import { CometChatContext, CometChatTheme, localize } from '../../shared';
@@ -6,186 +5,191 @@ import { AIConversationSummaryConfiguration } from './configuration';
6
5
  import { CometChatPanel } from '../../shared/views/CometChatPanel/CometChatPanel';
7
6
  import CometChatAICard from '../../shared/views/CometChatAICard/CometChatAICard';
8
7
  //@ts-ignore
9
- import { CometChat } from "@cometchat/chat-sdk-react-native";
8
+ import { CometChat } from '@cometchat/chat-sdk-react-native';
10
9
  interface IAIConversationSummaryProps {
11
- getConversationSummaryCallback?: (theme?: CometChatTheme) => Promise<string>
12
- editReplyCallback?: (reply: string) => void
13
- configuration?: AIConversationSummaryConfiguration
14
- theme?: CometChatTheme,
15
- onPanelClose: () => void
16
- };
17
-
18
- const defaultProps: IAIConversationSummaryProps = {
19
- getConversationSummaryCallback: undefined,
20
- editReplyCallback: undefined,
21
- configuration: undefined,
22
- theme: new CometChatTheme({}),
23
- onPanelClose: () => { }
10
+ getConversationSummaryCallback?: (theme?: CometChatTheme) => Promise<string>;
11
+ editReplyCallback?: (reply: string) => void;
12
+ configuration?: AIConversationSummaryConfiguration;
13
+ theme?: CometChatTheme;
14
+ onPanelClose: () => void;
24
15
  }
25
16
 
26
17
  const enum States {
27
- loading = "loading",
28
- error = "error",
29
- empty = "empty",
30
- loaded = "loaded"
18
+ loading = 'loading',
19
+ error = 'error',
20
+ empty = 'empty',
21
+ loaded = 'loaded',
31
22
  }
32
23
 
33
24
  let inProgress = false;
34
25
  const AIConversationSummaryView = (props: IAIConversationSummaryProps) => {
35
-
36
- const [messageListState, setMessageListState] = useState<States>(States.loading);
37
- const [activeView, setActiveView] = useState<JSX.Element | null>(null);
38
-
39
- const { theme } = useContext(CometChatContext)
40
-
41
- const errorStateText: string = localize("SOMETHING_WRONG");
42
- const emptyStateText: string = localize("NO_MESSAGES_FOUND");
43
- const loadingStateText: string = localize("GENERATING_SUMMARY");
44
- const titleText: string = localize("CONVERSATION_SUMMARY")
45
-
46
- useEffect(() => {
47
- fetchButtonContent();
48
- }, []);
49
-
50
- function fetchButtonContent() {
51
- setMessageListState(States.loading);
52
- if (props && props.getConversationSummaryCallback) {
53
- props.getConversationSummaryCallback(theme)
54
- .then((response) => {
55
- if (response) {
56
- inProgress = true;
57
- getLoadedView(response)
58
- .then(res => {
59
- setMessageListState(States.loaded);
60
- setActiveView(res);
61
- })
62
- .catch(err => {
63
- inProgress = false;
64
- setMessageListState(States.empty);
65
- })
66
- } else {
67
- inProgress = false;
68
- setMessageListState(States.empty);
69
- }
70
- })
71
- .catch((err) => {
72
- inProgress = false;
73
- setMessageListState(States.error);
74
- })
75
- }
76
- }
77
-
78
- /**
79
- * Create a view based on the value of the `state` prop.
80
- */
81
- function getStateView(): JSX.Element | null {
82
- let res: JSX.Element | null = null;
83
- switch (messageListState) {
84
- case States.loading:
85
- res = getLoadingView();
86
- break;
87
- case States.error:
88
- res = getErrorView();
89
- break;
90
- case States.empty:
91
- res = getEmptyView();
92
- break;
93
- case States.loaded:
94
- break;
95
- default:
96
- const x: never = messageListState;
97
- }
98
- return res;
99
- }
100
-
101
- /**
102
- * Creates the loading view
103
- */
104
- function getLoadingView(): JSX.Element {
105
- let LoadingView = props.configuration?.LoadingStateView;
106
- return (
107
-
108
- <CometChatAICard
109
- state={States.loading}
110
- style={props.configuration?.conversationSummaryStyle || {}}
111
- loadingIconURL={props.configuration?.loadingIconURL}
112
- loadingStateText={loadingStateText}
113
- >
114
- {LoadingView ? <LoadingView /> : null}
115
- </CometChatAICard>
116
- );
26
+ const {
27
+ getConversationSummaryCallback = undefined,
28
+ editReplyCallback = undefined,
29
+ configuration = undefined,
30
+ theme = useContext(CometChatContext)?.theme || new CometChatTheme({}),
31
+ onPanelClose = () => {},
32
+ } = props;
33
+
34
+ const [messageListState, setMessageListState] = useState<States>(
35
+ States.loading
36
+ );
37
+ const [activeView, setActiveView] = useState<JSX.Element | null>(null);
38
+
39
+ const errorStateText: string = localize('SOMETHING_WRONG');
40
+ const emptyStateText: string = localize('NO_MESSAGES_FOUND');
41
+ const loadingStateText: string = localize('GENERATING_SUMMARY');
42
+ const titleText: string = localize('CONVERSATION_SUMMARY');
43
+
44
+ useEffect(() => {
45
+ fetchButtonContent();
46
+ }, []);
47
+
48
+ function fetchButtonContent() {
49
+ setMessageListState(States.loading);
50
+ if (getConversationSummaryCallback) {
51
+ getConversationSummaryCallback(theme)
52
+ .then((response) => {
53
+ if (response) {
54
+ inProgress = true;
55
+ getLoadedView(response)
56
+ .then((res) => {
57
+ setMessageListState(States.loaded);
58
+ setActiveView(res);
59
+ })
60
+ .catch((err) => {
61
+ inProgress = false;
62
+ setMessageListState(States.empty);
63
+ });
64
+ } else {
65
+ inProgress = false;
66
+ setMessageListState(States.empty);
67
+ }
68
+ })
69
+ .catch((err) => {
70
+ inProgress = false;
71
+ setMessageListState(States.error);
72
+ });
117
73
  }
118
-
119
- /**
120
- * Creates the error view
121
- */
122
- function getErrorView(): JSX.Element | null {
123
- let ErrorView = props.configuration?.ErrorStateView;
124
- return (
125
- <CometChatAICard
126
- state={States.error}
127
- style={props.configuration?.conversationSummaryStyle || {}}
128
- errorIconURL={props.configuration?.errorIconURL}
129
- errorStateText={errorStateText}
130
- >
131
- {ErrorView ? <ErrorView /> : null}
132
- </CometChatAICard>
133
- );
74
+ }
75
+
76
+ /**
77
+ * Create a view based on the value of the `state` prop.
78
+ */
79
+ function getStateView(): JSX.Element | null {
80
+ let res: JSX.Element | null = null;
81
+ switch (messageListState) {
82
+ case States.loading:
83
+ res = getLoadingView();
84
+ break;
85
+ case States.error:
86
+ res = getErrorView();
87
+ break;
88
+ case States.empty:
89
+ res = getEmptyView();
90
+ break;
91
+ case States.loaded:
92
+ break;
93
+ default:
94
+ const x: never = messageListState;
134
95
  }
96
+ return res;
97
+ }
98
+
99
+ /**
100
+ * Creates the loading view
101
+ */
102
+ function getLoadingView(): JSX.Element {
103
+ let LoadingView = configuration?.LoadingStateView;
104
+ return (
105
+ <CometChatAICard
106
+ state={States.loading}
107
+ style={configuration?.conversationSummaryStyle || {}}
108
+ loadingIconURL={configuration?.loadingIconURL}
109
+ loadingStateText={loadingStateText}
110
+ >
111
+ {LoadingView ? <LoadingView /> : null}
112
+ </CometChatAICard>
113
+ );
114
+ }
135
115
 
136
- /**
137
- * Creates the empty view
138
- */
139
- function getEmptyView(): JSX.Element {
140
- let EmptyView = props.configuration?.EmptyStateView;
141
- return (
142
- <CometChatAICard
143
- state={States.empty}
144
- style={props.configuration?.conversationSummaryStyle || {}}
145
- emptyIconURL={props.configuration?.emptyIconURL}
146
- emptyStateText={emptyStateText}
147
- >
148
- {EmptyView ? <EmptyView /> : null}
149
- </CometChatAICard>
150
- );
151
- }
152
-
153
- /**
154
- * Creates the loaded view
155
- */
156
- async function getLoadedView(conversationSummary: string): Promise<JSX.Element> {
157
- return new Promise((resolve, reject) => {
158
- try {
159
- let CustomView = props.configuration?.customView;
160
-
161
- if (CustomView) {
162
- props.configuration?.customView!(conversationSummary, props.onPanelClose).then((res: any) => {
163
- return resolve(res);
164
- })
165
- .catch((err: CometChat.CometChatException) => {
166
- return reject(err)
167
- })
168
- } else {
169
- let conversationSummaryView = <CometChatPanel
170
- title={titleText}
171
- textContent={conversationSummary}
172
- style={props.configuration?.conversationSummaryStyle}
173
- onClose={props.onPanelClose}
174
- />
175
- return resolve(conversationSummaryView);
176
- }
177
- } catch (e) {
178
- reject(e);
179
- }
180
- })
181
- }
116
+ /**
117
+ * Creates the error view
118
+ */
119
+ function getErrorView(): JSX.Element | null {
120
+ let ErrorView = configuration?.ErrorStateView;
121
+ return (
122
+ <CometChatAICard
123
+ state={States.error}
124
+ style={configuration?.conversationSummaryStyle || {}}
125
+ errorIconURL={configuration?.errorIconURL}
126
+ errorStateText={errorStateText}
127
+ >
128
+ {ErrorView ? <ErrorView /> : null}
129
+ </CometChatAICard>
130
+ );
131
+ }
182
132
 
133
+ /**
134
+ * Creates the empty view
135
+ */
136
+ function getEmptyView(): JSX.Element {
137
+ let EmptyView = configuration?.EmptyStateView;
183
138
  return (
184
- <View style={{ marginTop: 10, overflow: "hidden" }} >
185
- {messageListState === States.loaded ? activeView : getStateView()}
186
- </View>
139
+ <CometChatAICard
140
+ state={States.empty}
141
+ style={configuration?.conversationSummaryStyle || {}}
142
+ emptyIconURL={configuration?.emptyIconURL}
143
+ emptyStateText={emptyStateText}
144
+ >
145
+ {EmptyView ? <EmptyView /> : null}
146
+ </CometChatAICard>
187
147
  );
148
+ }
149
+
150
+ /**
151
+ * Creates the loaded view
152
+ */
153
+ async function getLoadedView(
154
+ conversationSummary: string
155
+ ): Promise<JSX.Element> {
156
+ return new Promise((resolve, reject) => {
157
+ try {
158
+ let CustomView = configuration?.customView;
159
+
160
+ if (CustomView) {
161
+ configuration?.customView!(
162
+ conversationSummary,
163
+ onPanelClose
164
+ )
165
+ .then((res: any) => {
166
+ return resolve(res);
167
+ })
168
+ .catch((err: CometChat.CometChatException) => {
169
+ return reject(err);
170
+ });
171
+ } else {
172
+ let conversationSummaryView = (
173
+ <CometChatPanel
174
+ title={titleText}
175
+ textContent={conversationSummary}
176
+ style={configuration?.conversationSummaryStyle}
177
+ onClose={onPanelClose}
178
+ />
179
+ );
180
+ return resolve(conversationSummaryView);
181
+ }
182
+ } catch (e) {
183
+ reject(e);
184
+ }
185
+ });
186
+ }
187
+
188
+ return (
189
+ <View style={{ marginTop: 10, overflow: 'hidden' }}>
190
+ {messageListState === States.loaded ? activeView : getStateView()}
191
+ </View>
192
+ );
188
193
  };
189
194
 
190
- AIConversationSummaryView.defaultProps = defaultProps
191
195
  export default AIConversationSummaryView;
@@ -1,8 +1,12 @@
1
- import { useState } from 'react';
2
- import { contentContainerStyle, getButtonStyles, getPopoverStyle } from './style';
1
+ import { useState } from 'react';
2
+ import {
3
+ contentContainerStyle,
4
+ getButtonStyles,
5
+ getPopoverStyle,
6
+ } from './style';
3
7
  import { CardViewStyle } from './CardViewStyle';
4
8
  import { CometChatTheme } from '../shared';
5
- import { TouchableOpacity,Text,ScrollView, TextStyle } from 'react-native';
9
+ import { TouchableOpacity, Text, ScrollView, TextStyle } from 'react-native';
6
10
  import React from 'react';
7
11
  import { View } from 'react-native';
8
12
  import { AIButtonsStyle } from './utils';
@@ -10,72 +14,70 @@ export type Card = {
10
14
  title?: string;
11
15
  id?: string;
12
16
  onClick?: (id: string) => void;
13
- style?:AIButtonsStyle;
17
+ style?: AIButtonsStyle;
14
18
  };
15
- interface CardProps {
19
+ interface CardProps {
16
20
  buttons?: Card[];
17
- backCallback?:(callback:()=>void) => void;
18
- cardViewStyle?:CardViewStyle;
19
- };
20
-
21
- const defaultProps:CardProps = {
22
- buttons: undefined,
23
- backCallback:undefined,
24
- cardViewStyle:undefined
21
+ backCallback?: (callback: () => void) => void;
22
+ cardViewStyle?: CardViewStyle;
25
23
  }
26
24
 
27
-
28
- export const CardView = (props:CardProps) => {
25
+ export const CardView = (
26
+ {
27
+ buttons= undefined,
28
+ backCallback= undefined,
29
+ cardViewStyle= undefined,
30
+ }: CardProps
31
+ ) => {
29
32
  const [currentSection, setCurrentSection] = useState<string | null>(null);
30
33
 
31
- function fetchButtonContent(button:Card){
32
-
33
-
34
- setCurrentSection(button?.id!)
35
- if(button && button.onClick){
36
- button.onClick(button.id!)
34
+ function fetchButtonContent(button: Card) {
35
+ setCurrentSection(button?.id!);
36
+ if (button && button.onClick) {
37
+ button.onClick(button.id!);
38
+ }
37
39
  }
38
- }
39
-
40
40
 
41
-
42
- function getButtons():JSX.Element | null{
43
- return (
44
- <View style={{
45
- width:"100%",
46
- backgroundColor: "transparent",
47
- }}>
48
- {props.buttons?.map(item => (
49
- <TouchableOpacity
50
- key={item.id} // Make sure to set a unique key for each item
51
- onPress={() => fetchButtonContent(item)}
52
-
41
+ function getButtons(): JSX.Element | null {
42
+ return (
43
+ <View
44
+ style={{
45
+ width: '100%',
46
+ backgroundColor: 'transparent',
47
+ }}
53
48
  >
54
- <Text style={getButtonStyles(new CometChatTheme({}),item?.style || {}) as TextStyle}>{item.title}</Text>
55
- </TouchableOpacity>
56
-
57
- ))}
58
- </View>)
59
-
60
- }
49
+ {buttons?.map((item) => (
50
+ <TouchableOpacity
51
+ key={item.id} // Make sure to set a unique key for each item
52
+ onPress={() => fetchButtonContent(item)}
53
+ >
54
+ <Text
55
+ style={
56
+ getButtonStyles(
57
+ new CometChatTheme({}),
58
+ item?.style || {}
59
+ ) as TextStyle
60
+ }
61
+ >
62
+ {item.title}
63
+ </Text>
64
+ </TouchableOpacity>
65
+ ))}
66
+ </View>
67
+ );
68
+ }
61
69
 
62
70
  return (
63
- <View style={getPopoverStyle(props.cardViewStyle || {}) as TextStyle}>
64
-
71
+ <View style={getPopoverStyle(cardViewStyle || {}) as TextStyle}>
65
72
  <View style={contentContainerStyle as TextStyle}>
66
- {!currentSection && props.buttons && (
67
- <ScrollView style={{height:"100%",width:"100%"}}>
68
-
69
- { getButtons()}
73
+ {!currentSection && buttons && (
74
+ <ScrollView style={{ height: '100%', width: '100%' }}>
75
+ {getButtons()}
70
76
  </ScrollView>
71
-
72
-
73
77
  )}
74
-
75
78
  </View>
76
79
  </View>
77
80
  );
78
81
  };
79
82
 
80
- CardView.defaultProps = defaultProps
81
- export default CardView;
83
+ export default CardView;
@@ -117,13 +117,13 @@ export const CometChatCreateGroup = (props: CometChatCreateGroupInterface) => {
117
117
  title = localize("NEW_GROUP"),
118
118
  closeIcon,
119
119
  createIcon,
120
- passwordPlaceholderText,
121
- namePlaceholderText,
120
+ namePlaceholderText= localize('NAME'),
121
+ passwordPlaceholderText= localize('ENTER_YOUR_PASSWORD'),
122
+ createGroupStyle= {},
122
123
  disableCloseButton,
123
124
  onCreatePress,
124
125
  onError,
125
126
  onBack,
126
- createGroupStyle,
127
127
  } = props;
128
128
  const [password, setPassword] = useState('');
129
129
  const [groupType, setGroupType] = React.useState(GroupTypeConstants.public);
@@ -160,7 +160,7 @@ export const CometChatCreateGroup = (props: CometChatCreateGroupInterface) => {
160
160
  ...(createGroupStyle?.tabTextStyle &&
161
161
  createGroupStyle?.tabTextStyle),
162
162
  },
163
- ] as TextStyle}
163
+ ] as TextStyle[]}
164
164
  >
165
165
  {name}
166
166
  </Text>
@@ -259,7 +259,7 @@ export const CometChatCreateGroup = (props: CometChatCreateGroupInterface) => {
259
259
  styles.errorTextTitle,
260
260
  theme.typography.body,
261
261
  { color: theme.palette.getError() },
262
- ] as TextStyle}
262
+ ] as TextStyle[]}
263
263
  >
264
264
  {error?.length > 0 ? error : localize('ERROR_GROUP_CREATE')}
265
265
  </Text>
@@ -268,7 +268,7 @@ export const CometChatCreateGroup = (props: CometChatCreateGroupInterface) => {
268
268
  styles.errorText,
269
269
  theme.typography.body,
270
270
  { color: theme.palette.getError() },
271
- ] as TextStyle}
271
+ ] as TextStyle[]}
272
272
  >
273
273
  {localize('TRY_AGAIN_LATER')}
274
274
  </Text>
@@ -354,7 +354,7 @@ export const CometChatCreateGroup = (props: CometChatCreateGroupInterface) => {
354
354
  groupName?.length > 0
355
355
  ? createGroupStyle?.namePlaceholderTextStyle
356
356
  : createGroupStyle?.nameInputTextStyle,
357
- ] as TextStyle}
357
+ ] as TextStyle[]}
358
358
  />
359
359
  {groupType === GroupTypeConstants.password && (
360
360
  <TextInput
@@ -372,7 +372,7 @@ export const CometChatCreateGroup = (props: CometChatCreateGroupInterface) => {
372
372
  password?.length > 0
373
373
  ? createGroupStyle?.passwordPlaceholderTextStyle
374
374
  : createGroupStyle?.passwordInputTextStyle,
375
- ] as TextStyle}
375
+ ] as TextStyle[]}
376
376
  />
377
377
  )}
378
378
  <ErrorView />
@@ -380,8 +380,3 @@ export const CometChatCreateGroup = (props: CometChatCreateGroupInterface) => {
380
380
  );
381
381
  };
382
382
 
383
- CometChatCreateGroup.defaultProps = {
384
- namePlaceholderText: localize('NAME'),
385
- passwordPlaceholderText: localize('ENTER_YOUR_PASSWORD'),
386
- createGroupStyle: {},
387
- };