@cometchat/chat-uikit-react-native 4.0.2 → 4.1.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 (175) hide show
  1. package/README.md +1 -1
  2. package/ios/FileManager.m +1 -1
  3. package/package.json +3 -3
  4. package/src/AI/AIAssistBot/AIAssistBotDecorator.tsx +164 -0
  5. package/src/AI/AIAssistBot/AIAssistBotExtension.tsx +22 -0
  6. package/src/AI/AIAssistBot/AIAssistBotStyle.ts +43 -0
  7. package/src/AI/AIAssistBot/AIAssistBotView.tsx +294 -0
  8. package/src/AI/AIAssistBot/configuration.ts +22 -0
  9. package/src/AI/AIAssistBot/resources/index.ts +5 -0
  10. package/src/AI/{configuration.ts → AIBaseConfiguration.ts} +3 -6
  11. package/src/AI/AIBaseStyle.ts +58 -0
  12. package/src/AI/AIConversationStarter/AIConversationStarter.ts +5 -19
  13. package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +144 -130
  14. package/src/AI/AIConversationStarter/AIConversationStarterStyle.ts +11 -6
  15. package/src/AI/AIConversationStarter/configuration.ts +10 -17
  16. package/src/AI/AIConversationSummary/AIConversationSummaryDecorator.tsx +175 -0
  17. package/src/AI/AIConversationSummary/AIConversationSummaryExtension.ts +21 -0
  18. package/src/AI/AIConversationSummary/AIConversationSummaryStyle.tsx +20 -0
  19. package/src/AI/AIConversationSummary/AIConversationSummaryView.tsx +190 -0
  20. package/src/AI/AIConversationSummary/configuration.ts +14 -0
  21. package/src/AI/AIConversationSummary/resources/close.png +0 -0
  22. package/src/AI/AIConversationSummary/resources/index.ts +5 -0
  23. package/src/AI/AIExtensionDataSource.ts +17 -12
  24. package/src/AI/AIOptionsStyle.ts +14 -0
  25. package/src/AI/AISmartReplies/AISmartReplies.ts +6 -15
  26. package/src/AI/AISmartReplies/AISmartRepliesDecorator.tsx +302 -0
  27. package/src/AI/AISmartReplies/AISmartRepliesStyle.ts +1 -1
  28. package/src/AI/AISmartReplies/configuration.ts +4 -11
  29. package/src/AI/resources/index.ts +0 -2
  30. package/src/AI/utils.ts +3 -3
  31. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +118 -5
  32. package/src/CometChatMessageComposer/MessageComposerConfiguration.tsx +3 -0
  33. package/src/CometChatMessageComposer/resources/index.ts +2 -0
  34. package/src/CometChatMessageComposer/styles.ts +1 -4
  35. package/src/CometChatMessageList/CometChatMessageList.tsx +52 -35
  36. package/src/CometChatMessages/CometChatMessages.tsx +4 -13
  37. package/src/CometChatMessages/MessagesConfiguration.ts +2 -2
  38. package/src/calls/CallEvents.ts +1 -0
  39. package/src/calls/CallUtils.ts +106 -45
  40. package/src/calls/CallingDetailsUtils.tsx +133 -15
  41. package/src/calls/CallingExtentionDecorator.tsx +56 -45
  42. package/src/calls/CallingPackage.ts +16 -2
  43. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +9 -10
  44. package/src/calls/CometChatCallLogDetails/CallLogDetailsConfiguration.ts +116 -0
  45. package/src/calls/CometChatCallLogDetails/CallLogDetailsStyle.ts +36 -0
  46. package/src/calls/CometChatCallLogDetails/CometChatCallLogDetails.tsx +308 -0
  47. package/src/calls/CometChatCallLogDetails/index.ts +12 -0
  48. package/src/calls/CometChatCallLogDetails/resources/CloseIcon.png +0 -0
  49. package/src/calls/{CometChatCallDetails → CometChatCallLogDetails}/style.ts +1 -0
  50. package/src/calls/{CometChatCallHistory/CallHistoryConfiguration.ts → CometChatCallLogHistory/CallLogHistoryConfiguration.ts} +15 -27
  51. package/src/calls/CometChatCallLogHistory/CallLogHistoryStyle.ts +46 -0
  52. package/src/calls/CometChatCallLogHistory/CometChatCallLogHistory.tsx +337 -0
  53. package/src/calls/CometChatCallLogHistory/index.ts +12 -0
  54. package/src/calls/CometChatCallLogHistory/resources/incomingcall.png +0 -0
  55. package/src/calls/CometChatCallLogHistory/resources/incomingvideo.png +0 -0
  56. package/src/calls/CometChatCallLogHistory/resources/index.ts +29 -0
  57. package/src/calls/CometChatCallLogHistory/resources/missedcall.png +0 -0
  58. package/src/calls/CometChatCallLogHistory/resources/missedvideo.png +0 -0
  59. package/src/calls/CometChatCallLogHistory/resources/outgoingcall.png +0 -0
  60. package/src/calls/CometChatCallLogHistory/resources/outgoingvideo.png +0 -0
  61. package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/style.ts +2 -1
  62. package/src/calls/CometChatCallLogParticipants/CallLogParticipantsConfiguration.ts +61 -0
  63. package/src/calls/CometChatCallLogParticipants/CallLogParticipantsStyle.ts +59 -0
  64. package/src/calls/CometChatCallLogParticipants/CometChatCallLogParticipants.tsx +220 -0
  65. package/src/calls/CometChatCallLogParticipants/index.ts +12 -0
  66. package/src/calls/CometChatCallLogParticipants/resources/Back.png +0 -0
  67. package/src/calls/CometChatCallLogParticipants/resources/index.ts +4 -0
  68. package/src/calls/CometChatCallLogParticipants/style.ts +24 -0
  69. package/src/calls/CometChatCallLogRecordings/CallLogRecordingsConfiguration.ts +63 -0
  70. package/src/calls/CometChatCallLogRecordings/CallLogRecordingsStyle.ts +63 -0
  71. package/src/calls/CometChatCallLogRecordings/CometChatCallLogRecordings.tsx +253 -0
  72. package/src/calls/CometChatCallLogRecordings/index.ts +12 -0
  73. package/src/calls/CometChatCallLogRecordings/resources/Back.png +0 -0
  74. package/src/calls/CometChatCallLogRecordings/resources/download.png +0 -0
  75. package/src/calls/CometChatCallLogRecordings/resources/index.ts +6 -0
  76. package/src/calls/CometChatCallLogRecordings/style.ts +24 -0
  77. package/src/calls/CometChatCallLogs/CallLogsConfiguration.ts +87 -0
  78. package/src/calls/CometChatCallLogs/CallLogsStyle.ts +95 -0
  79. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +482 -0
  80. package/src/calls/CometChatCallLogs/index.ts +12 -0
  81. package/src/calls/CometChatCallLogs/resources/Back.png +0 -0
  82. package/src/calls/CometChatCallLogs/resources/Info.png +0 -0
  83. package/src/calls/CometChatCallLogs/resources/Selection.png +0 -0
  84. package/src/calls/CometChatCallLogs/resources/Spinner.png +0 -0
  85. package/src/calls/CometChatCallLogs/resources/check.png +0 -0
  86. package/src/calls/CometChatCallLogs/resources/incomingcall.png +0 -0
  87. package/src/calls/CometChatCallLogs/resources/incomingvideo.png +0 -0
  88. package/src/calls/CometChatCallLogs/resources/index.ts +25 -0
  89. package/src/calls/CometChatCallLogs/resources/missedcall.png +0 -0
  90. package/src/calls/CometChatCallLogs/resources/missedvideo.png +0 -0
  91. package/src/calls/CometChatCallLogs/resources/outgoingcall.png +0 -0
  92. package/src/calls/CometChatCallLogs/resources/outgoingvideo.png +0 -0
  93. package/src/calls/CometChatCallLogs/style.ts +24 -0
  94. package/src/calls/CometChatCallLogsWithDetails/CallLogsWithDetailsConfiguration.ts +9 -0
  95. package/src/calls/{CometChatCallHistoryWithDetails/CometChatCallHistoryWithDetails.tsx → CometChatCallLogsWithDetails/CometChatCallLogsWithDetails.tsx} +17 -16
  96. package/src/calls/CometChatCallLogsWithDetails/index.ts +7 -0
  97. package/src/calls/index.ts +40 -1
  98. package/src/calls/resources/index.ts +3 -1
  99. package/src/calls/resources/nextarrow.png +0 -0
  100. package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +3 -5
  101. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +1 -1
  102. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +5 -3
  103. package/src/extensions/ThumbnailGeneration/resources/empty.png +0 -0
  104. package/src/extensions/ThumbnailGeneration/resources/index.ts +5 -0
  105. package/src/index.ts +79 -4
  106. package/src/shared/CometChatUiKit/CometChatUIKit.ts +154 -130
  107. package/src/shared/CometChatUiKit/UIKitSettings.ts +2 -2
  108. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +4 -1
  109. package/src/shared/events/CometChatUIEventHandler/Listener.ts +5 -1
  110. package/src/shared/framework/DataSource.ts +4 -0
  111. package/src/shared/framework/DataSourceDecorator.tsx +5 -0
  112. package/src/shared/framework/MessageDataSource.tsx +4 -1
  113. package/src/shared/index.ts +4 -0
  114. package/src/shared/modals/CometChatCallLogDetailsOptions.ts +23 -0
  115. package/src/shared/modals/CometChatCallLogDetailsTemplate.ts +16 -0
  116. package/src/shared/modals/index.ts +5 -1
  117. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +19 -5
  118. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +19 -5
  119. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +21 -7
  120. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +19 -5
  121. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +19 -5
  122. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +19 -5
  123. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +19 -5
  124. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +19 -5
  125. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +19 -5
  126. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +19 -5
  127. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +19 -5
  128. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +19 -4
  129. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +19 -5
  130. package/src/shared/resources/CometChatTheme/Palette.ts +16 -0
  131. package/src/shared/utils/DetailsUtils/DetailsUtils.tsx +1 -1
  132. package/src/shared/utils/conversationUtils.ts +1 -1
  133. package/src/shared/views/CometChatAICard/CometChatAICard.tsx +71 -0
  134. package/src/shared/views/CometChatAICard/resources/errormessage.png +0 -0
  135. package/src/shared/views/CometChatAICard/resources/index.ts +4 -0
  136. package/src/shared/views/CometChatAICard/resources/nomessage.png +0 -0
  137. package/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +4 -0
  138. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +11 -7
  139. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +56 -47
  140. package/src/shared/views/CometChatBottomSheet/style.ts +0 -2
  141. package/src/shared/views/CometChatDate/CometChatDate.tsx +7 -3
  142. package/src/shared/views/CometChatDate/DateConfiguration.ts +4 -0
  143. package/src/shared/views/CometChatDate/style.ts +1 -1
  144. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +31 -19
  145. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -2
  146. package/src/shared/views/CometChatPanel/CometChatPanel.tsx +51 -0
  147. package/src/shared/views/CometChatPanel/PanelStyle.tsx +43 -0
  148. package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
  149. package/src/shared/views/CometChatPanel/resources/index.ts +5 -0
  150. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +7 -5
  151. package/src/AI/AIEnabler.ts +0 -115
  152. package/src/AI/AIEnablerDecorator.tsx +0 -324
  153. package/src/AI/AISmartReplies/AISmartRepliesDecorator.ts +0 -18
  154. package/src/calls/CometChatCallDetails/CallDetailsConfiguration.ts +0 -68
  155. package/src/calls/CometChatCallDetails/CallDetailsStyle.ts +0 -52
  156. package/src/calls/CometChatCallDetails/CometChatCallDetails.tsx +0 -268
  157. package/src/calls/CometChatCallDetails/index.ts +0 -9
  158. package/src/calls/CometChatCallHistory/CallHistoryStyle.ts +0 -34
  159. package/src/calls/CometChatCallHistory/CometChatCallHistory.tsx +0 -422
  160. package/src/calls/CometChatCallHistory/index.ts +0 -9
  161. package/src/calls/CometChatCallHistory/resources/index.ts +0 -17
  162. package/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsConfiguration.ts +0 -7
  163. package/src/calls/CometChatCallHistoryWithDetails/HistoryWithDetailsStyle.ts +0 -3
  164. package/src/calls/CometChatCallHistoryWithDetails/index.ts +0 -8
  165. /package/src/{calls/CometChatCallDetails → AI/AIAssistBot}/resources/CloseIcon.png +0 -0
  166. /package/src/{AI → CometChatMessageComposer}/resources/ai.png +0 -0
  167. /package/src/calls/{CometChatCallDetails → CometChatCallLogDetails}/resources/index.ts +0 -0
  168. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Back.png +0 -0
  169. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Call.png +0 -0
  170. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Info.png +0 -0
  171. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Selection.png +0 -0
  172. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Spineer.png +0 -0
  173. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/Video.png +0 -0
  174. /package/src/calls/{CometChatCallHistory → CometChatCallLogHistory}/resources/check.png +0 -0
  175. /package/src/calls/{CometChatCallHistoryWithDetails → CometChatCallLogsWithDetails}/style.ts +0 -0
@@ -0,0 +1,51 @@
1
+ import { View, Text, TouchableOpacity, Image } from 'react-native'
2
+ import React, { useContext } from 'react'
3
+ import { PanelStyle, PanelStyleInterface } from './PanelStyle'
4
+ import { CometChatContext } from '../../CometChatContext';
5
+ import { CloseIcon } from './resources';
6
+
7
+ export interface CometChatPanelInterface {
8
+ title: string,
9
+ hideCloseButton?: boolean,
10
+ style?: PanelStyleInterface,
11
+ textContent: string,
12
+ onClose: () => void
13
+ }
14
+
15
+ export const CometChatPanel = (props: CometChatPanelInterface) => {
16
+ const { hideCloseButton, style, textContent, title, onClose } = props;
17
+
18
+ const { theme } = useContext(CometChatContext);
19
+
20
+ const {
21
+ backgroundColor, border, borderRadius, closeIconTint,
22
+ textColor, textFont, titleColor, titleFont
23
+ } = new PanelStyle({
24
+ closeIconTint: theme.palette.getAccent(),
25
+ border: { borderWidth: 1, borderColor: theme.palette.getPrimary() },
26
+ titleFont: theme.typography.title1,
27
+ titleColor: theme.palette.getAccent(),
28
+ textColor: theme.palette.getAccent600(),
29
+ textFont: theme.typography.text1,
30
+ backgroundColor: theme.palette.getPrimary40(),
31
+ ...style,
32
+ })
33
+
34
+ const _onClose = () => {
35
+ onClose && onClose();
36
+ }
37
+
38
+ return (
39
+ <View style={[{ backgroundColor: backgroundColor, borderRadius, padding: 10 }, { ...border }]}>
40
+ <View style={{ flexDirection: "row", justifyContent: "space-between", marginBottom: 10 }}>
41
+ <Text style={[titleFont, { color: titleColor }]}>{title}</Text>
42
+ {!hideCloseButton && <TouchableOpacity onPress={_onClose}>
43
+ <Image style={{ width: 20, height: 20, tintColor: closeIconTint }} source={CloseIcon} />
44
+ </TouchableOpacity>}
45
+ </View>
46
+ <Text style={[textFont, { color: textColor }]}>
47
+ {textContent}
48
+ </Text>
49
+ </View>
50
+ )
51
+ }
@@ -0,0 +1,43 @@
1
+ import { BaseStyle, FontStyle } from "../../base";
2
+
3
+ export interface PanelStyleInterface extends BaseStyle {
4
+ titleFont?: FontStyle,
5
+ titleColor?: string,
6
+ closeIconTint?: string,
7
+ textFont?: FontStyle,
8
+ textColor?: string
9
+ }
10
+
11
+ export class PanelStyle extends BaseStyle {
12
+ titleFont?: FontStyle;
13
+ titleColor?: string;
14
+ closeIconTint?: string;
15
+ textFont?: FontStyle;
16
+ textColor?: string;
17
+
18
+ constructor({
19
+ height,
20
+ width,
21
+ backgroundColor,
22
+ border,
23
+ borderRadius,
24
+ closeIconTint,
25
+ titleFont,
26
+ titleColor,
27
+ textColor,
28
+ textFont
29
+ }: PanelStyleInterface) {
30
+ super({
31
+ backgroundColor,
32
+ border,
33
+ borderRadius,
34
+ height,
35
+ width
36
+ })
37
+ this.closeIconTint = closeIconTint;
38
+ this.titleColor = titleColor;
39
+ this.titleFont = titleFont;
40
+ this.textColor = textColor;
41
+ this.textFont = textFont;
42
+ }
43
+ }
@@ -0,0 +1,5 @@
1
+ import CloseIcon from "./CloseIcon.png";
2
+
3
+ export {
4
+ CloseIcon
5
+ }
@@ -1,4 +1,4 @@
1
- import React, {useContext, useEffect, useState} from "react";
1
+ import React, { useContext, useEffect, useState } from "react";
2
2
  import { View, Image, ImageBackground, NativeModules, Platform, NativeEventEmitter, EmitterSubscription } from "react-native";
3
3
  import { CometChatContext } from "../../CometChatContext";
4
4
  import { ImageType } from "../../base/Types";
@@ -48,7 +48,7 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
48
48
  onPress,
49
49
  } = props;
50
50
 
51
- const {theme} = useContext<CometChatContextType>(CometChatContext);
51
+ const { theme } = useContext<CometChatContextType>(CometChatContext);
52
52
  const [isOpening, setOpening] = useState(false);
53
53
 
54
54
  const _style = new VideoBubbleStyle({
@@ -69,7 +69,7 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
69
69
 
70
70
 
71
71
  const getFileName = (url) => {
72
- return (url.substring(url.lastIndexOf("/") + 1, url.length)).replace(" ","_");
72
+ return (url.substring(url.lastIndexOf("/") + 1, url.length)).replace(" ", "_");
73
73
  }
74
74
 
75
75
  const playVideo = () => {
@@ -82,9 +82,11 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => {
82
82
  return;
83
83
  }
84
84
 
85
+ if (!videoUrl) return;
86
+
85
87
  Platform.OS == 'ios' ?
86
- FileManager.openFile(videoUrl, getFileName(videoUrl), (s) => {}) :
87
- VideoManager.openVideo(videoUrl, (s) => {});
88
+ FileManager.openFile(videoUrl, getFileName(videoUrl), (s) => { }) :
89
+ VideoManager.openVideo(videoUrl, (s) => { });
88
90
 
89
91
  }
90
92
 
@@ -1,115 +0,0 @@
1
- import { ChatConfigurator, DataSource } from "../shared";
2
- import { AIConversationStarterExtension } from "./AIConversationStarter/AIConversationStarter";
3
- import { AIEnablerDecorator } from "./AIEnablerDecorator";
4
- import { AIExtensionDataSource } from "./AIExtensionDataSource";
5
- import { AISmartRepliesExtension } from "./AISmartReplies/AISmartReplies";
6
- import {CometChat} from '@cometchat/chat-sdk-react-native'
7
- import { AIEnablerConfiguration } from "./configuration";
8
- export class AIEnabler extends AIExtensionDataSource {
9
- defaultAIFeatures:AIExtensionDataSource[] | undefined;
10
- configuration?:AIEnablerConfiguration = {}
11
- constructor(defaultFeatures?:AIExtensionDataSource[], configuration?:AIEnablerConfiguration){
12
- super()
13
- this.configuration = configuration
14
- this.defaultAIFeatures = defaultFeatures
15
- }
16
- override addExtension(): void {
17
-
18
- }
19
- override getExtensionId(): string {
20
- return "ai-enabler";
21
- }
22
- override enable(): void {
23
- let features = {}
24
- if (this.defaultAIFeatures && this.defaultAIFeatures?.length >= 1) {
25
- const promiseArray = this.defaultAIFeatures.map((feature) => {
26
- return new Promise((resolve, reject) => {
27
- CometChat.isAIFeatureEnabled(feature.getExtensionId())
28
- .then((response) => {
29
- if (response) {
30
-
31
- if (feature.getExtensionId() !== "conversation-starter") {
32
- feature?.enable();
33
- features[feature.getExtensionId()] = {
34
- enabled: true,
35
- configuration: feature.getConfiguration(),
36
- enabler: feature,
37
- };
38
- }
39
- else{
40
- feature.setConfiguration(this.configuration)
41
- feature.enable();
42
- }
43
- }
44
- resolve(true);
45
- })
46
- .catch((err) => {
47
- console.error(err);
48
- reject(err);
49
- });
50
- });
51
- });
52
-
53
- Promise.all(promiseArray)
54
- .then(() => {
55
- if (Object.keys(features).length > 0) {
56
- ChatConfigurator.enable(
57
- (dataSource: DataSource) =>
58
- new AIEnablerDecorator(dataSource, features, this.configuration)
59
- );
60
- }
61
- })
62
- .catch((err) => {
63
- console.error('An error occurred:', err);
64
- });
65
- }
66
- else if(this.defaultAIFeatures?.length == 0){
67
- return;
68
- }
69
- else{
70
- let defaultFeatures: AIExtensionDataSource[] = [new AISmartRepliesExtension(), new AIConversationStarterExtension()];
71
-
72
- const promiseArray = defaultFeatures.map((feature) => {
73
- return new Promise((resolve, reject) => {
74
- CometChat.isAIFeatureEnabled(feature.getExtensionId())
75
- .then((response) => {
76
- if (response) {
77
-
78
- if (feature.getExtensionId() !== "conversation-starter") {
79
- feature?.enable();
80
- features[feature.getExtensionId()] = {
81
- enabled: true,
82
- configuration: feature.getConfiguration(),
83
- enabler: feature,
84
- };
85
- }
86
- else{
87
- feature.setConfiguration(this.configuration)
88
- feature.enable();
89
- }
90
- }
91
- resolve(true);
92
- })
93
- .catch((err) => {
94
- console.error(err);
95
- reject(err);
96
- });
97
- });
98
- });
99
-
100
- Promise.all(promiseArray)
101
- .then(() => {
102
- if (Object.keys(features).length > 0) {
103
- ChatConfigurator.enable(
104
- (dataSource: DataSource) =>
105
- new AIEnablerDecorator(dataSource, features, this.configuration)
106
- );
107
- }
108
- })
109
- .catch((err) => {
110
- console.error('An error occurred:', err);
111
- });
112
- }
113
- }
114
-
115
- }
@@ -1,324 +0,0 @@
1
- import { CometChat } from "@cometchat/chat-sdk-react-native";
2
- import { DataSourceDecorator, DataSource, CometChatTheme, CometChatUIEvents, localize, CometChatUIEventHandler, CometChatBottomSheet, FontStyleInterface, BorderStyleInterface, BaseStyle } from "../shared";
3
- import { CometChatButton } from "../shared/views/CometChatButton";
4
-
5
- import { CardView, Card } from "./CardView";
6
- import { CardViewStyle } from "./CardViewStyle";
7
- import { getRepliesWrapperStyle, getRepliesStyle, getCardViewStyle, getButtonStyles, getPopoverStyle, defaultViewStyle, viewContainerStyle, emptyLabelStyle, errorLabelStyle, getloadingStateStyle } from "./style";
8
- import { ReceiverTypeConstants, ViewAlignment } from "../shared/constants/UIKitConstants";
9
- import { Image, TouchableOpacity, View, Text, ScrollView, Keyboard } from "react-native";
10
- import React, { useEffect, useRef, useState, JSX ,useContext} from "react";
11
- import { AIBotIcon,loadingIcon,emptyIcon,errorIcon } from './resources';
12
- import { CometChatContext } from "../shared/CometChatContext";
13
- import { AIEnablerConfiguration } from "./configuration";
14
- import { AIConfigurations, ICard, State } from "./utils";
15
- import { AIConversationStarterConfiguration } from "./AIConversationStarter/configuration";
16
- import { AISmartRepliesConfiguration } from "./AISmartReplies/configuration";
17
-
18
- export class AIEnablerDecorator extends DataSourceDecorator {
19
- smartReplyConfiguration: AISmartRepliesConfiguration = new AISmartRepliesConfiguration({});
20
- conversationStarterConfiguration: AIConversationStarterConfiguration = new AIConversationStarterConfiguration({});
21
- features?: AIConfigurations = {};
22
- configuration?: AIEnablerConfiguration = new AIEnablerConfiguration({});
23
- public newDataSource!: DataSource;
24
- public showAiButton: boolean = false;
25
- public theme!: CometChatTheme;
26
- public id: any;
27
- public user!: CometChat.User;
28
- public group!: CometChat.Group;
29
- public loggedInUser!: CometChat.User | null;
30
- public cardViewStyle: CardViewStyle = {};
31
- public buttonRef: any;
32
- public setCallback: any;
33
- public isPannelVisible:boolean = false;
34
- public repliesView:JSX.Element;
35
- public errorStateText:string = localize("SOMETHING_WRONG");
36
- public emptyStateText:string = localize("NO_MESSAGES_FOUND");
37
- public keyboardDidShowListener;
38
- public keyboardDidHideListener;
39
- onButtonClick = (id: string): void => {
40
- if (id == "smart-replies") {
41
- this.showDefaultPanel(State.loading)
42
- this.getSmartReplies().then((replies) => {
43
- if(!replies || (replies?.length && replies.length <= 0)){
44
- this.showDefaultPanel(State.empty)
45
- }
46
- else{
47
- this.repliesView = ( <View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 200, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, marginTop: 8 }}>
48
- <ScrollView style={{ height: "100%", width: "100%" }}>
49
- {replies}
50
- </ScrollView>
51
-
52
-
53
- </View>)
54
- CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, {
55
- alignment: ViewAlignment.composerBottom,
56
- child: () => this.repliesView,
57
- });
58
- }
59
-
60
- this.isPannelVisible = true
61
-
62
- })
63
- .catch((err) => {
64
- this.showDefaultPanel(State.error,err)
65
-
66
- })
67
- }
68
- }
69
- public cardsData: ICard = {}
70
- constructor(dataSource: DataSource, features?: AIConfigurations, configuration?: AIEnablerConfiguration) {
71
- super(dataSource);
72
- this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this.hideOnKeyboardShow);
73
- this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this.showOnKeyboardShow);
74
- if (configuration) {
75
- this.configuration = configuration;
76
- }
77
- this.newDataSource = dataSource;
78
- this.features = features;
79
- CometChat.getLoggedinUser().then(
80
- (user: CometChat.User | null) => {
81
- if (user) {
82
- this.loggedInUser = user
83
- }
84
- }
85
- );
86
- }
87
- getDataSource() {
88
- return this.newDataSource;
89
- }
90
- getId(): string {
91
- return "aienabler";
92
- }
93
- hideOnKeyboardShow = () => {
94
- if(this.isPannelVisible){
95
- CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
96
- alignment: ViewAlignment.composerBottom,
97
- child: () => (null),
98
- });
99
- }
100
- }
101
- showOnKeyboardShow = () => {
102
- if(this.isPannelVisible){
103
- CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
104
- alignment: ViewAlignment.composerBottom,
105
- child: () => this.repliesView,
106
- });
107
- }
108
- }
109
- editReply(reply: string) {
110
- CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
111
- alignment: ViewAlignment.composerBottom,
112
- child: () => (null),
113
- });
114
- this.isPannelVisible = false;
115
- CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccComposeMessage, { text: reply });
116
- this.keyboardDidShowListener?.remove();
117
- this.keyboardDidHideListener?.remove();
118
- }
119
- closeBottomsheet = () => {
120
- if (this.setCallback) {
121
- this.setCallback(false)
122
- }
123
- }
124
-
125
- getSmartReplies(): Promise<JSX.Element> {
126
- return new Promise((resolve, reject) => {
127
- let receiverId: string = this.user ? this.user?.getUid() : this.group?.getGuid();
128
- let receiverType: string = this.user ? ReceiverTypeConstants.user : ReceiverTypeConstants.group;
129
- if (this.smartReplyConfiguration?.customView) {
130
- CometChat.getSmartReplies(receiverId, receiverType).then((response: any) => {
131
- this.smartReplyConfiguration.customView(response, this.closeBottomsheet).then((res)=>{
132
- return resolve((<View>{res}</View>))
133
-
134
- })
135
- .catch((err: CometChat.CometChatException) => {
136
- return reject(err)
137
- })
138
-
139
- })
140
- .catch((err: CometChat.CometChatException) => {
141
- return reject(err)
142
- })
143
- }
144
- else if (this.smartReplyConfiguration?.onClick) {
145
- this.smartReplyConfiguration?.onClick(this.user, this.group).then((response: any) => {
146
- return resolve((<View>{response}</View>))
147
- })
148
- .catch((err: CometChat.CometChatException) => {
149
- return reject(err)
150
- })
151
-
152
- }
153
- else {
154
- CometChat.getSmartReplies(receiverId, receiverType).then((response: any) => {
155
- let view: JSX.Element[] = []
156
- Object.keys(response).forEach((reply) => {
157
- if (response[reply] && response[reply] != "") {
158
- view.push(
159
- (<TouchableOpacity
160
- style={getRepliesWrapperStyle(this.theme, this.smartReplyConfiguration?.smartRepliesStyle, this.configuration?.listItemStyle)}
161
- key={response[reply]} // Make sure to set a unique key for each item
162
- onPress={() => this.editReply(response[reply])}
163
- >
164
- <Text style={getRepliesStyle(this.theme, this.smartReplyConfiguration?.smartRepliesStyle, this.configuration?.listItemStyle)}>{response[reply]}</Text>
165
- </TouchableOpacity>)
166
-
167
- )
168
- }
169
-
170
-
171
-
172
- })
173
- return resolve((<View>{view}</View>))
174
-
175
- })
176
- .catch((err: CometChat.CometChatException) => {
177
- return reject(err)
178
- })
179
- }
180
-
181
- })
182
-
183
- }
184
-
185
- showDefaultPanel(state:State = State.loading, error?:CometChat.CometChatException) {
186
- this.closeBottomsheet()
187
- let LoadingView:JSX.Element = this.smartReplyConfiguration?.LoadingStateView || this.configuration.LoadingStateView
188
- let EmptyView:JSX.Element = this.smartReplyConfiguration?.EmptyStateView || this.configuration.EmptyStateView
189
- let ErrorView:JSX.Element = this.smartReplyConfiguration?.ErrorStateView || this.configuration.ErrorStateView
190
-
191
- CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, {
192
- alignment: ViewAlignment.composerBottom,
193
- child: () => (
194
- <View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 160, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center" }}>
195
- {state == State.loading ? LoadingView ? <LoadingView/> : <View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 160, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center" }}>
196
- <Image
197
- source={this.configuration?.loadingIconURL ?? loadingIcon}
198
- style={{ height: 32, width: 32,tintColor:this.cardViewStyle?.loadingIconTint}}
199
- />
200
- <Text style={getloadingStateStyle(this.theme,this.cardViewStyle, this.smartReplyConfiguration?.smartRepliesStyle)}> {localize("GENERATING_REPLIES")}</Text>
201
- </View>
202
-
203
- :
204
-
205
- state == State.empty ?
206
- EmptyView ? <EmptyView/> : <View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 160, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center" }}>
207
- <Image
208
- source={this.configuration?.emptyIconURL ?? emptyIcon}
209
- style={{ height: 32, width: 32,tintColor:this.cardViewStyle?.emptyIconTint}}
210
- />
211
- <Text style={emptyLabelStyle(this.cardViewStyle,this.smartReplyConfiguration.smartRepliesStyle)} > {this.emptyStateText}</Text>
212
- </View>
213
- : ErrorView ? ErrorView(error) :
214
- <View style={{ width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 160, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius:this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center" }}>
215
- <Image
216
- source={this.configuration?.errorIconURL ?? errorIcon}
217
- style={{ height: 32, width: 32,tintColor:this.cardViewStyle?.errorIconTint}}
218
- />
219
- <Text style={errorLabelStyle(this.cardViewStyle,this.smartReplyConfiguration.smartRepliesStyle)} >{this.errorStateText}</Text>
220
- </View>
221
-
222
- }
223
-
224
-
225
- </View>
226
-
227
- ),
228
- });
229
-
230
- this.isPannelVisible = true;
231
- }
232
-
233
-
234
- getAuxiliaryOptions(user?: CometChat.User, group?: CometChat.Group, id?: Map<string, any>, theme?: CometChatTheme) {
235
- let contextTheme = useContext(CometChatContext)
236
- if(contextTheme?.theme){
237
- this.theme = contextTheme.theme
238
- }
239
- else{
240
- this.theme = theme || new CometChatTheme({});
241
- }
242
- this.cardViewStyle = getCardViewStyle(this.theme, this.configuration?.listStyle,this.smartReplyConfiguration.smartRepliesStyle);
243
- this.id = id;
244
- this.user = user!;
245
- this.group = group!;
246
- let auxiliaryOptions = super.getAuxiliaryOptions(user, group, id, theme);
247
- this.cardsData = {
248
- smartReply: {
249
- title: localize("SUGGEST_A_REPLIES"),
250
- onClick: this.onButtonClick,
251
- id: "smart-replies",
252
- style: getButtonStyles(this.theme, this.smartReplyConfiguration?.smartRepliesStyle, this.configuration?.listItemStyle)
253
-
254
- },
255
- conversationStarter: {
256
- title: "Conversation Starter",
257
- onClick: this.onButtonClick,
258
- id: "conversation-starter",
259
- style: getButtonStyles(this.theme, this.conversationStarterConfiguration?.conversationStarterStyle)
260
-
261
- }
262
- };
263
-
264
-
265
-
266
- if (!(id as any).parentMessageId || Number((id as any).parentMessageId) <= 0 || (id as any).parentMessageId == undefined) {
267
-
268
- auxiliaryOptions.unshift(this.getAIAuxiliaryButton(id, user, group, theme));
269
- }
270
- return auxiliaryOptions;
271
- }
272
-
273
- getAIAuxiliaryButton(id: Map<string, any>, user?: CometChat.User, group?: CometChat.Group, theme?: CometChatTheme): JSX.Element {
274
- const [aiFeatures, setAiFeatures] = useState(false);
275
- let cards: Card[] = []
276
- this.setCallback = setAiFeatures
277
- if (this.features && Object.keys(this.features).length > 0) {
278
-
279
- if (this.features?.["smart-replies"]?.enabled) {
280
- this.smartReplyConfiguration = this.features?.["smart-replies"]?.configuration ?? new AISmartRepliesConfiguration({})
281
- cards.push(this.cardsData.smartReply!)
282
- }
283
-
284
-
285
- }
286
-
287
- return (<TouchableOpacity onPress={() => {
288
- CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
289
- alignment: ViewAlignment.composerBottom,
290
- child: () => (null),
291
- });
292
- if(this.isPannelVisible){
293
- setAiFeatures(false);
294
- this.isPannelVisible = false;
295
- return;
296
- }
297
- setAiFeatures(true);
298
-
299
- }} style={{ justifyContent: "center" }}>
300
- <Image
301
- source={this.configuration?.buttonIconURL || AIBotIcon}
302
- style={{ height: 32, width: 32, marginLeft: 8, marginRight: 8 , color:'red'}}
303
- />
304
- {
305
- <CometChatBottomSheet
306
- isOpen={aiFeatures}
307
- sliderMaxHeight={this.cardViewStyle?.height || 350}
308
- onClose={() => {
309
- setAiFeatures(false)
310
- }}
311
-
312
- >
313
- <CardView
314
- cardViewStyle={this.cardViewStyle}
315
- buttons={cards}
316
- />
317
- </CometChatBottomSheet>
318
- }
319
- </TouchableOpacity>)
320
-
321
- }
322
-
323
- }
324
-
@@ -1,18 +0,0 @@
1
- import { DataSource,DataSourceDecorator } from "../../shared";
2
- import { CometChat } from "@cometchat/chat-sdk-react-native";
3
- import { AIButtonsStyle } from "../utils";
4
- import { AISmartRepliesConfiguration } from "./configuration";
5
- export class AISmartRepliesExtensionDecorator extends DataSourceDecorator {
6
- public configuration?:AISmartRepliesConfiguration;
7
- constructor(dataSource:DataSource,configuration?:AISmartRepliesConfiguration){
8
- super(dataSource);
9
- this.configuration = configuration;
10
- }
11
- override getId(): string {
12
- return "aismartreply";
13
- }
14
- }
15
-
16
-
17
-
18
-
@@ -1,68 +0,0 @@
1
- import { AvatarStyleInterface, CometChatDetailsTemplate, ImageType, ListItemStyleInterface } from "../../shared"
2
- import { AvatarConfigurationInterface } from "../../shared/views/CometChatAvatar/AvatarConfiguration"
3
- import { StatusIndicatorStyleInterface } from "../../shared/views/CometChatStatusIndicator/StatusIndicatorStyle"
4
- // import { CometChatCallDetailsInterface } from "./CometChatCallDetails"
5
- import { CometChat } from '@cometchat/chat-sdk-react-native'
6
- import { CallDetailsStyleInterface } from "./CallDetailsStyle"
7
-
8
- export interface CallDetailsConfigurationInterface {
9
- showCloseButton?: boolean
10
- closeButtonIconImage?: ImageType
11
- hideProfile?: boolean
12
- SubtitleView?: (props: { user?: CometChat.User, group?: CometChat.Group }) => JSX.Element
13
- CustomProfileView?: (props: { user?: CometChat.User }) => JSX.Element
14
- data?: (props: { message: CometChat.BaseMessage, user?: CometChat.User, group?: CometChat.Group }) => CometChatDetailsTemplate[]
15
- disableUsersPresence?: boolean
16
- onError?: (e: CometChat.CometChatException) => void
17
- onBack?: () => void
18
- avatarStyle?: AvatarStyleInterface
19
- statusIndicatorStyle?: StatusIndicatorStyleInterface
20
- listItemStyle?: ListItemStyleInterface
21
- callDetailsStyle?: CallDetailsStyleInterface
22
- }
23
-
24
- export class CallDetailsConfiguration implements CallDetailsConfigurationInterface {
25
- showCloseButton?: boolean
26
- closeButtonIconImage?: ImageType
27
- hideProfile: boolean
28
- SubtitleView: (props: { user?: CometChat.User; group?: CometChat.Group }) => JSX.Element
29
- CustomProfileView: (props: { user?: CometChat.User }) => JSX.Element
30
- data: (props: { message: CometChat.BaseMessage; user?: CometChat.User; group?: CometChat.Group }) => CometChatDetailsTemplate[]
31
- disableUsersPresence: boolean
32
- onError: (e: CometChat.CometChatException) => void
33
- onBack: () => void
34
- avatarStyle: AvatarStyleInterface
35
- statusIndicatorStyle: StatusIndicatorStyleInterface
36
- listItemStyle: ListItemStyleInterface
37
- callDetailsStyle: CallDetailsStyleInterface
38
-
39
- constructor({
40
- showCloseButton,
41
- closeButtonIconImage,
42
- hideProfile,
43
- SubtitleView,
44
- CustomProfileView,
45
- data,
46
- disableUsersPresence,
47
- onError,
48
- onBack,
49
- avatarStyle,
50
- statusIndicatorStyle,
51
- listItemStyle,
52
- callDetailsStyle,
53
- }: CallDetailsConfigurationInterface) {
54
- this.showCloseButton = showCloseButton;
55
- this.closeButtonIconImage = closeButtonIconImage;
56
- this.hideProfile = hideProfile;
57
- this.SubtitleView = SubtitleView;
58
- this.CustomProfileView = CustomProfileView;
59
- this.data = data;
60
- this.disableUsersPresence = disableUsersPresence;
61
- this.onError = onError;
62
- this.onBack = onBack;
63
- this.avatarStyle = avatarStyle;
64
- this.statusIndicatorStyle = statusIndicatorStyle;
65
- this.listItemStyle = listItemStyle;
66
- this.callDetailsStyle = callDetailsStyle;
67
- }
68
- }