@cometchat/chat-uikit-react-native 4.0.0 → 4.0.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.
- package/LICENSE.md +3 -0
- package/README.md +1 -1
- package/lib/AI/AIConversationStarter/AIConversationStarter.d.ts +12 -0
- package/lib/AI/AIConversationStarter/AIConversationStarter.js +31 -0
- package/lib/AI/AIConversationStarter/AIConversationStarter.js.map +1 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.d.ts +25 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.js +175 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.js.map +1 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterStyle.d.ts +4 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterStyle.js +8 -0
- package/lib/AI/AIConversationStarter/AIConversationStarterStyle.js.map +1 -0
- package/lib/AI/AIConversationStarter/configuration.d.ts +14 -0
- package/lib/AI/AIConversationStarter/configuration.js +16 -0
- package/lib/AI/AIConversationStarter/configuration.js.map +1 -0
- package/lib/AI/AIConversationStarter/style.d.ts +31 -0
- package/lib/AI/AIConversationStarter/style.js +62 -0
- package/lib/AI/AIConversationStarter/style.js.map +1 -0
- package/lib/AI/AIEnabler.d.ts +10 -0
- package/lib/AI/AIEnabler.js +102 -0
- package/lib/AI/AIEnabler.js.map +1 -0
- package/lib/AI/AIEnablerDecorator.d.ts +43 -0
- package/lib/AI/AIEnablerDecorator.js +251 -0
- package/lib/AI/AIEnablerDecorator.js.map +1 -0
- package/lib/AI/AIExtensionDataSource.d.ts +6 -0
- package/lib/AI/AIExtensionDataSource.js +10 -0
- package/lib/AI/AIExtensionDataSource.js.map +1 -0
- package/lib/AI/AISmartReplies/AISmartReplies.d.ts +10 -0
- package/lib/AI/AISmartReplies/AISmartReplies.js +23 -0
- package/lib/AI/AISmartReplies/AISmartReplies.js.map +1 -0
- package/lib/AI/AISmartReplies/AISmartRepliesDecorator.d.ts +7 -0
- package/lib/AI/AISmartReplies/AISmartRepliesDecorator.js +12 -0
- package/lib/AI/AISmartReplies/AISmartRepliesDecorator.js.map +1 -0
- package/lib/AI/AISmartReplies/AISmartRepliesStyle.d.ts +12 -0
- package/lib/AI/AISmartReplies/AISmartRepliesStyle.js +15 -0
- package/lib/AI/AISmartReplies/AISmartRepliesStyle.js.map +1 -0
- package/lib/AI/AISmartReplies/configuration.d.ts +14 -0
- package/lib/AI/AISmartReplies/configuration.js +16 -0
- package/lib/AI/AISmartReplies/configuration.js.map +1 -0
- package/lib/AI/CardView.d.ts +19 -0
- package/lib/AI/CardView.js +45 -0
- package/lib/AI/CardView.js.map +1 -0
- package/lib/AI/CardViewStyle.d.ts +29 -0
- package/lib/AI/CardViewStyle.js +36 -0
- package/lib/AI/CardViewStyle.js.map +1 -0
- package/lib/AI/configuration.d.ts +14 -0
- package/lib/AI/configuration.js +16 -0
- package/lib/AI/configuration.js.map +1 -0
- package/lib/AI/resources/index.d.ts +5 -0
- package/lib/AI/resources/index.js +6 -0
- package/lib/AI/resources/index.js.map +1 -0
- package/lib/AI/style.d.ts +115 -0
- package/lib/AI/style.js +139 -0
- package/lib/AI/style.js.map +1 -0
- package/lib/AI/utils.d.ts +38 -0
- package/lib/AI/utils.js +28 -0
- package/lib/AI/utils.js.map +1 -0
- package/lib/CometChatConversations/ConversationsConfiguration.d.ts +0 -1
- package/lib/CometChatDetails/DetailsConfiguration.d.ts +0 -1
- package/lib/CometChatGroupMembers/GroupMemberConfiguration.d.ts +0 -1
- package/lib/CometChatGroups/GroupsConfiguration.d.ts +0 -1
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js +7 -1
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js.map +1 -1
- package/lib/CometChatMessageHeader/MessageHeaderConfiguration.d.ts +0 -1
- package/lib/CometChatMessageList/CometChatMessageList.js +49 -18
- package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
- package/lib/CometChatMessageList/MessageListConfiguration.d.ts +0 -1
- package/lib/CometChatMessages/MessagesConfiguration.d.ts +0 -1
- package/lib/CometChatTabs/TabItems.d.ts +0 -1
- package/lib/CometChatThreadedMessages/ThreadedMessagesConfiguration.d.ts +0 -1
- package/lib/calls/CometChatCallDetails/CallDetailsConfiguration.d.ts +0 -1
- package/lib/calls/CometChatCallHistory/CallHistoryConfiguration.d.ts +0 -1
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js +3 -3
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js.map +1 -1
- package/lib/extensions/ImageModeration/ImageModerationDecorator.d.ts +0 -1
- package/lib/extensions/ImageModeration/ImageModerationFilter.js +4 -4
- package/lib/extensions/ImageModeration/ImageModerationFilter.js.map +1 -1
- package/lib/extensions/LinkPreview/LinkPreviewExtentionDecorator.d.ts +0 -1
- package/lib/extensions/MessageTranslation/MessageTranslationDecorator.d.ts +0 -1
- package/lib/extensions/SmartReplies/SmartRepliesDecorator.js +1 -1
- package/lib/extensions/SmartReplies/SmartRepliesDecorator.js.map +1 -1
- package/lib/extensions/Stickers/StickersExtensionDecorator.d.ts +1 -1
- package/lib/extensions/Stickers/StickersExtensionDecorator.js +4 -2
- package/lib/extensions/Stickers/StickersExtensionDecorator.js.map +1 -1
- package/lib/extensions/TextModeration/TextModerationExtensionDecorator.d.ts +0 -1
- package/lib/index.d.ts +13 -0
- package/lib/index.js +14 -0
- package/lib/index.js.map +1 -1
- package/lib/shared/CometChatUiKit/CometChatUIKit.d.ts +2 -0
- package/lib/shared/CometChatUiKit/CometChatUIKit.js +13 -2
- package/lib/shared/CometChatUiKit/CometChatUIKit.js.map +1 -1
- package/lib/shared/CometChatUiKit/UIKitSettings.d.ts +5 -1
- package/lib/shared/CometChatUiKit/UIKitSettings.js +3 -1
- package/lib/shared/CometChatUiKit/UIKitSettings.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js +2 -0
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.d.ts +3 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.js +4 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.js.map +1 -1
- package/lib/shared/events/CometChatUIEvents.d.ts +2 -1
- package/lib/shared/events/CometChatUIEvents.js +1 -0
- package/lib/shared/events/CometChatUIEvents.js.map +1 -1
- package/lib/shared/framework/DataSource.d.ts +1 -2
- package/lib/shared/framework/DataSourceDecorator.d.ts +1 -2
- package/lib/shared/framework/DataSourceDecorator.js +2 -2
- package/lib/shared/framework/DataSourceDecorator.js.map +1 -1
- package/lib/shared/framework/MessageDataSource.d.ts +1 -1
- package/lib/shared/framework/MessageDataSource.js +2 -2
- package/lib/shared/framework/MessageDataSource.js.map +1 -1
- package/lib/shared/helper/types/index.d.ts +0 -1
- package/lib/shared/modals/CometChatDetailsOption.d.ts +0 -1
- package/lib/shared/modals/CometChatMessageOption.d.ts +0 -1
- package/lib/shared/modals/CometChatMessageTemplate.d.ts +0 -1
- package/lib/shared/resources/CometChatLocalize/CometChatLocalize.d.ts +230 -153
- package/lib/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/de/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/en/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/es/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -0
- package/lib/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -0
- package/package.json +3 -3
- package/src/AI/AIConversationStarter/AIConversationStarter.ts +33 -0
- package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +232 -0
- package/src/AI/AIConversationStarter/AIConversationStarterStyle.ts +8 -0
- package/src/AI/AIConversationStarter/configuration.ts +18 -0
- package/src/AI/AIConversationStarter/style.ts +76 -0
- package/src/AI/AIEnabler.ts +115 -0
- package/src/AI/AIEnablerDecorator.tsx +324 -0
- package/src/AI/AIExtensionDataSource.ts +12 -0
- package/src/AI/AISmartReplies/AISmartReplies.ts +28 -0
- package/src/AI/AISmartReplies/AISmartRepliesDecorator.ts +18 -0
- package/src/AI/AISmartReplies/AISmartRepliesStyle.ts +16 -0
- package/src/AI/AISmartReplies/configuration.ts +17 -0
- package/src/AI/CardView.tsx +81 -0
- package/src/AI/CardViewStyle.ts +37 -0
- package/src/AI/configuration.ts +17 -0
- package/src/AI/resources/ai-empty.png +0 -0
- package/src/AI/resources/ai-error.png +0 -0
- package/src/AI/resources/ai.png +0 -0
- package/src/AI/resources/index.ts +11 -0
- package/src/AI/resources/spineer.png +0 -0
- package/src/AI/style.ts +177 -0
- package/src/AI/utils.ts +39 -0
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +13 -4
- package/src/CometChatMessageList/CometChatMessageList.tsx +24 -17
- package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +1 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +4 -2
- package/src/index.ts +15 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +20 -7
- package/src/shared/CometChatUiKit/UIKitSettings.ts +8 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +2 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +5 -1
- package/src/shared/events/CometChatUIEvents.ts +1 -0
- package/src/shared/framework/DataSource.ts +1 -1
- package/src/shared/framework/DataSourceDecorator.tsx +2 -2
- package/src/shared/framework/MessageDataSource.tsx +2 -2
- package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/de/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/en/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/es/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -0
- package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -0
- package/LICENSE +0 -21
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/.gitignore +0 -3
- package/android/.idea/gradle.xml +0 -13
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/src/.DS_Store +0 -0
- package/src/CometChatMessageInformation/.DS_Store +0 -0
- package/src/calls/CometChatCallHistory/.DS_Store +0 -0
- package/src/shared/framework/.DS_Store +0 -0
- package/src/shared/views/.DS_Store +0 -0
- package/src/shared/views/CometChatAudioBubble/.DS_Store +0 -0
- package/src/shared/views/CometChatFileBubble/.DS_Store +0 -0
package/LICENSE.md
ADDED
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
[](#)
|
|
13
13
|
[](#)
|
|
14
|
-

|
|
15
15
|

|
|
16
16
|
|
|
17
17
|
## Table of contents
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AIExtensionDataSource } from "../AIExtensionDataSource";
|
|
2
|
+
import { AIConversationStarterConfiguration } from "./configuration";
|
|
3
|
+
import { AIEnablerConfiguration } from "../configuration";
|
|
4
|
+
export declare class AIConversationStarterExtension extends AIExtensionDataSource {
|
|
5
|
+
configuration?: AIConversationStarterConfiguration;
|
|
6
|
+
constructor(configuration?: AIConversationStarterConfiguration);
|
|
7
|
+
addExtension(): void;
|
|
8
|
+
getExtensionId(): string;
|
|
9
|
+
enable(): void;
|
|
10
|
+
getConfiguration(): AIConversationStarterConfiguration;
|
|
11
|
+
setConfiguration(config?: AIEnablerConfiguration): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AIConversationStarterDecorator } from "./AIConversationStarterDecorator";
|
|
2
|
+
import { ChatConfigurator } from "../../shared";
|
|
3
|
+
import { AIExtensionDataSource } from "../AIExtensionDataSource";
|
|
4
|
+
export class AIConversationStarterExtension extends AIExtensionDataSource {
|
|
5
|
+
configuration;
|
|
6
|
+
constructor(configuration) {
|
|
7
|
+
super();
|
|
8
|
+
this.configuration = configuration;
|
|
9
|
+
}
|
|
10
|
+
addExtension() {
|
|
11
|
+
ChatConfigurator.enable((dataSource) => new AIConversationStarterDecorator(dataSource, this.configuration));
|
|
12
|
+
}
|
|
13
|
+
getExtensionId() {
|
|
14
|
+
return "conversation-starter";
|
|
15
|
+
}
|
|
16
|
+
enable() {
|
|
17
|
+
this.addExtension();
|
|
18
|
+
}
|
|
19
|
+
getConfiguration() {
|
|
20
|
+
return this.configuration;
|
|
21
|
+
}
|
|
22
|
+
setConfiguration(config) {
|
|
23
|
+
this.configuration = { ...this.configuration, ...config };
|
|
24
|
+
this.configuration.conversationStarterStyle = {
|
|
25
|
+
...this.configuration.conversationStarterStyle,
|
|
26
|
+
...(config?.listItemStyle || config?.listStyle)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=AIConversationStarter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AIConversationStarter.js","sourceRoot":"","sources":["../../../src/AI/AIConversationStarter/AIConversationStarter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAuB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,MAAM,OAAO,8BAA+B,SAAQ,qBAAqB;IACvE,aAAa,CAAqC;IAClD,YAAY,aAAiD;QAC3D,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IAEpC,CAAC;IACQ,YAAY;QACnB,gBAAgB,CAAC,MAAM,CAAC,CAAC,UAAe,EAAE,EAAE,CAAC,IAAI,8BAA8B,CAAC,UAAU,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IAClH,CAAC;IACQ,cAAc;QACrB,OAAO,sBAAsB,CAAC;IAChC,CAAC;IACQ,MAAM;QACb,IAAI,CAAC,YAAY,EAAE,CAAA;IACrB,CAAC;IACQ,gBAAgB;QAC3B,OAAO,IAAI,CAAC,aAAa,CAAA;IACvB,CAAC;IACU,gBAAgB,CAAC,MAA8B;QACxD,IAAI,CAAC,aAAa,GAAG,EAAC,GAAG,IAAI,CAAC,aAAa,EAAC,GAAG,MAAM,EAAC,CAAA;QACtD,IAAI,CAAC,aAAa,CAAC,wBAAwB,GAAG;YAC5C,GAAG,IAAI,CAAC,aAAa,CAAC,wBAAwB;YAC9C,GAAG,CAAC,MAAM,EAAE,aAAa,IAAI,MAAM,EAAE,SAAS,CAAC;SAChD,CAAC;IACJ,CAAC;IAAA,CAAC;CAEH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CometChatTheme, DataSource, DataSourceDecorator } from "../../shared";
|
|
2
|
+
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
3
|
+
import { State } from "../utils";
|
|
4
|
+
import { AIConversationStarterConfiguration } from "./configuration";
|
|
5
|
+
import { CardViewStyle } from "../CardViewStyle";
|
|
6
|
+
export declare class AIConversationStarterDecorator extends DataSourceDecorator {
|
|
7
|
+
configuration?: AIConversationStarterConfiguration;
|
|
8
|
+
currentMessage: CometChat.BaseMessage | null;
|
|
9
|
+
loggedInUser: CometChat.User | null;
|
|
10
|
+
messageListenerId: string;
|
|
11
|
+
user: CometChat.User;
|
|
12
|
+
group: CometChat.Group;
|
|
13
|
+
cardViewStyle: CardViewStyle;
|
|
14
|
+
errorStateText: string;
|
|
15
|
+
emptyStateText: string;
|
|
16
|
+
theme: CometChatTheme;
|
|
17
|
+
constructor(dataSource: DataSource, configuration?: AIConversationStarterConfiguration);
|
|
18
|
+
getId(): string;
|
|
19
|
+
showDefaultPanel(state?: State, error?: CometChat.CometChatException): void;
|
|
20
|
+
editReply(reply: string): void;
|
|
21
|
+
closePanel: () => void;
|
|
22
|
+
closeIfMessageReceived(message: any): void;
|
|
23
|
+
getConversationStarter(): Promise<JSX.Element>;
|
|
24
|
+
attachMessageListener(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { CometChatTheme, CometChatUIEventHandler, CometChatUIEvents, DataSourceDecorator, MessageEvents, localize } from "../../shared";
|
|
2
|
+
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
3
|
+
import { MessageStatusConstants, ReceiverTypeConstants, ViewAlignment } from "../../shared/constants/UIKitConstants";
|
|
4
|
+
import { Image, TouchableOpacity, View, Text, ScrollView } from "react-native";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { loadingIcon, emptyIcon, errorIcon } from "../resources";
|
|
7
|
+
import { emptyLabelStyle, errorLabelStyle } from "./style";
|
|
8
|
+
import { getCardViewStyle, getRepliesWrapperStyle, getRepliesStyle, getloadingStateStyle } from "./style";
|
|
9
|
+
import { State } from "../utils";
|
|
10
|
+
export class AIConversationStarterDecorator extends DataSourceDecorator {
|
|
11
|
+
configuration;
|
|
12
|
+
currentMessage = null;
|
|
13
|
+
loggedInUser;
|
|
14
|
+
messageListenerId = 'message_' + new Date().getTime();
|
|
15
|
+
user;
|
|
16
|
+
group;
|
|
17
|
+
cardViewStyle = {};
|
|
18
|
+
errorStateText = localize("SOMETHING_WRONG");
|
|
19
|
+
emptyStateText = localize("NO_MESSAGES_FOUND");
|
|
20
|
+
theme;
|
|
21
|
+
constructor(dataSource, configuration) {
|
|
22
|
+
super(dataSource);
|
|
23
|
+
this.configuration = configuration;
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
CometChat.getLoggedinUser()
|
|
26
|
+
.then((u) => {
|
|
27
|
+
this.loggedInUser = u;
|
|
28
|
+
})
|
|
29
|
+
.catch((err) => console.log(err));
|
|
30
|
+
CometChatUIEventHandler.addMessageListener(MessageEvents.ccActiveChatChanged, {
|
|
31
|
+
ccActiveChatChanged: ({ message, user, group, theme, parentMessageId }) => {
|
|
32
|
+
this.user = user;
|
|
33
|
+
this.group = group;
|
|
34
|
+
if (theme) {
|
|
35
|
+
this.theme = theme;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.theme = new CometChatTheme({});
|
|
39
|
+
}
|
|
40
|
+
if (!message && !parentMessageId) {
|
|
41
|
+
this.attachMessageListener();
|
|
42
|
+
this.showDefaultPanel(State.loading);
|
|
43
|
+
this.getConversationStarter().then((replies) => {
|
|
44
|
+
if (!replies || (replies?.length && replies.length <= 0)) {
|
|
45
|
+
this.showDefaultPanel(State.empty);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, {
|
|
49
|
+
alignment: ViewAlignment.composerTop,
|
|
50
|
+
child: () => (<View style={{ boxShadow: this.cardViewStyle?.boxShadow, width: this.cardViewStyle?.width || "100%", height: this.cardViewStyle?.height || 130, backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius: this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border }}>
|
|
51
|
+
<ScrollView style={{ height: "100%", width: "100%" }}>
|
|
52
|
+
{replies}
|
|
53
|
+
</ScrollView>
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
</View>),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
.catch((err) => {
|
|
61
|
+
console.log(err);
|
|
62
|
+
this.showDefaultPanel(State.error);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
ccMessageSent: ({ message, status }) => {
|
|
67
|
+
if (status == MessageStatusConstants.success && message?.sender?.uid == this.loggedInUser?.uid) {
|
|
68
|
+
this.closePanel();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}, 1000);
|
|
73
|
+
}
|
|
74
|
+
getId() {
|
|
75
|
+
return "aiconversationstarter";
|
|
76
|
+
}
|
|
77
|
+
showDefaultPanel(state = State.loading, error) {
|
|
78
|
+
let LoadingView = this.configuration?.LoadingStateView;
|
|
79
|
+
let EmptyView = this.configuration?.EmptyStateView;
|
|
80
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.showPanel, {
|
|
81
|
+
alignment: ViewAlignment.composerTop,
|
|
82
|
+
child: () => (<View style={{ width: this.cardViewStyle?.width || "100%", height: 'auto', backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius: this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center" }}>
|
|
83
|
+
{state == State.loading ? LoadingView ? <LoadingView /> : <View style={{ width: this.cardViewStyle?.width || "100%", height: "auto", backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius: this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center", flexDirection: "row", paddingBottom: 8 }}>
|
|
84
|
+
<Image source={this.configuration?.loadingIconURL ?? loadingIcon} style={{ height: 32, width: 32, tintColor: this.cardViewStyle?.loadingIconTint }}/>
|
|
85
|
+
<Text style={getloadingStateStyle(this.theme, this.configuration)}> {localize("GENERATIONG_ICEBREAKER")}</Text>
|
|
86
|
+
</View>
|
|
87
|
+
:
|
|
88
|
+
state == State.empty ? EmptyView ? <EmptyView /> : <View style={{ width: this.cardViewStyle?.width || "100%", height: 'auto', backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius: this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center", flexDirection: "row", paddingBottom: 8 }}>
|
|
89
|
+
<Image source={this.configuration?.emptyIconURL ?? emptyIcon} style={{ height: 32, width: 32, tintColor: this.cardViewStyle?.emptyIconTint }}/>
|
|
90
|
+
<Text style={emptyLabelStyle(this.cardViewStyle)}>{this.emptyStateText}</Text>
|
|
91
|
+
</View>
|
|
92
|
+
: this.configuration?.ErrorStateView ? this.configuration?.ErrorStateView(error) :
|
|
93
|
+
<View style={{ width: this.cardViewStyle?.width || "100%", height: 'auto', backgroundColor: this.cardViewStyle?.backgroundColor, borderRadius: this.cardViewStyle?.borderRadius, ...this.cardViewStyle?.border, justifyContent: "center", alignItems: "center", flexDirection: "row", paddingBottom: 8 }}>
|
|
94
|
+
<Image source={this.configuration?.errorIconURL ?? errorIcon} style={{ height: 32, width: 32, tintColor: this.cardViewStyle?.errorIconTint }}/>
|
|
95
|
+
<Text style={errorLabelStyle(this.cardViewStyle)}>{this.errorStateText}</Text>
|
|
96
|
+
</View>}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
</View>),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
editReply(reply) {
|
|
103
|
+
this.closePanel();
|
|
104
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.ccComposeMessage, { text: reply });
|
|
105
|
+
}
|
|
106
|
+
closePanel = () => {
|
|
107
|
+
CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
|
|
108
|
+
alignment: ViewAlignment.composerTop,
|
|
109
|
+
child: () => (null),
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
closeIfMessageReceived(message) {
|
|
113
|
+
if (message?.receiverId == this.loggedInUser?.uid) {
|
|
114
|
+
this.closePanel();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
getConversationStarter() {
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
let receiverId = this.user ? this.user?.getUid() : this.group?.getGuid();
|
|
120
|
+
let receiverType = this.user ? ReceiverTypeConstants.user : ReceiverTypeConstants.group;
|
|
121
|
+
if (this.configuration?.customView) {
|
|
122
|
+
CometChat.getConversationStarter(receiverId, receiverType).then((response) => {
|
|
123
|
+
this.configuration.customView(response).then((res) => {
|
|
124
|
+
return resolve((<View>{res}</View>));
|
|
125
|
+
})
|
|
126
|
+
.catch((err) => {
|
|
127
|
+
return reject(err);
|
|
128
|
+
});
|
|
129
|
+
})
|
|
130
|
+
.catch((err) => {
|
|
131
|
+
return reject(err);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else if (this.configuration?.onLoad) {
|
|
135
|
+
this.configuration?.onLoad(this.user, this.group).then((response) => {
|
|
136
|
+
return resolve((<View>{response}</View>));
|
|
137
|
+
})
|
|
138
|
+
.catch((err) => {
|
|
139
|
+
return reject(err);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
CometChat.getConversationStarter(receiverId, receiverType).then((response) => {
|
|
144
|
+
let view = [];
|
|
145
|
+
Object.keys(response).forEach((reply) => {
|
|
146
|
+
if (response[reply] && response[reply] != "") {
|
|
147
|
+
view.push((<TouchableOpacity style={getRepliesWrapperStyle(this.theme, this.configuration?.conversationStarterStyle)} key={response[reply]} onPress={() => this.editReply(response[reply])}>
|
|
148
|
+
<Text style={getRepliesStyle(this.theme, this.configuration?.conversationStarterStyle)}>{response[reply]}</Text>
|
|
149
|
+
</TouchableOpacity>));
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return resolve((<View>{view}</View>));
|
|
153
|
+
})
|
|
154
|
+
.catch((err) => {
|
|
155
|
+
return reject(err);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
attachMessageListener() {
|
|
161
|
+
this.cardViewStyle = getCardViewStyle(this.theme, this.configuration?.conversationStarterStyle);
|
|
162
|
+
CometChat.addMessageListener(this.messageListenerId, new CometChat.MessageListener({
|
|
163
|
+
onTextMessageReceived: (textMessage) => {
|
|
164
|
+
this.closeIfMessageReceived(textMessage);
|
|
165
|
+
},
|
|
166
|
+
onMediaMessageReceived: (mediaMessage) => {
|
|
167
|
+
this.closeIfMessageReceived(mediaMessage);
|
|
168
|
+
},
|
|
169
|
+
onCustomMessageReceived: (customMessage) => {
|
|
170
|
+
this.closeIfMessageReceived(customMessage);
|
|
171
|
+
}
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=AIConversationStarterDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AIConversationStarterDecorator.js","sourceRoot":"","sources":["../../../src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx"],"names":[],"mappings":"AACA,OAAO,EAAG,cAAc,EAAE,uBAAuB,EAAE,iBAAiB,EAAa,mBAAmB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpJ,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,sBAAsB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AAC,CAAA;gBACpB,CAAC,CAAC,CAAA;aACL;QAEH,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,qBAAqB;QAEnB,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAC,IAAI,CAAC,aAAa,EAAE,wBAAwB,CAAC,CAAA;QAC9F,SAAS,CAAC,kBAAkB,CAC1B,IAAI,CAAC,iBAAiB,EACtB,IAAI,SAAS,CAAC,eAAe,CAAC;YAC5B,qBAAqB,EAAE,CAAC,WAAW,EAAE,EAAE;gBACrC,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAA;YAE1C,CAAC;YACD,sBAAsB,EAAE,CAAC,YAAY,EAAE,EAAE;gBACvC,IAAI,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAA;YAE3C,CAAC;YACD,uBAAuB,EAAE,CAAC,aAAa,EAAE,EAAE;gBACzC,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAA;YAE5C,CAAC;SACJ,CAAC,CACD,CAAC;IAGJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AIConversationStarterStyle.js","sourceRoot":"","sources":["../../../src/AI/AIConversationStarter/AIConversationStarterStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,OAAO,0BAA2B,SAAQ,cAAc;IAC1D,YAAY,KAA8B;QACxC,KAAK,CAAC,EAAC,GAAG,KAAK,EAAC,CAAC,CAAA;QACjB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
2
|
+
import { AIConversationStarterStyle } from './AIConversationStarterStyle';
|
|
3
|
+
export declare class AIConversationStarterConfiguration {
|
|
4
|
+
onLoad?: (user?: CometChat.User, group?: CometChat.Group) => Promise<Object>;
|
|
5
|
+
conversationStarterStyle?: AIConversationStarterStyle;
|
|
6
|
+
customView?: (response: Object) => Promise<Object>;
|
|
7
|
+
ErrorStateView?: (e?: CometChat.CometChatException) => JSX.Element;
|
|
8
|
+
EmptyStateView?: () => JSX.Element;
|
|
9
|
+
LoadingStateView?: () => JSX.Element;
|
|
10
|
+
loadingIconURL?: string;
|
|
11
|
+
errorIconURL?: string;
|
|
12
|
+
emptyIconURL?: string;
|
|
13
|
+
constructor(props: Partial<AIConversationStarterConfiguration>);
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { loadingIcon, errorIcon, emptyIcon } from '../resources';
|
|
2
|
+
export class AIConversationStarterConfiguration {
|
|
3
|
+
onLoad;
|
|
4
|
+
conversationStarterStyle;
|
|
5
|
+
customView;
|
|
6
|
+
ErrorStateView;
|
|
7
|
+
EmptyStateView;
|
|
8
|
+
LoadingStateView;
|
|
9
|
+
loadingIconURL = loadingIcon;
|
|
10
|
+
errorIconURL = errorIcon;
|
|
11
|
+
emptyIconURL = emptyIcon;
|
|
12
|
+
constructor(props) {
|
|
13
|
+
Object.assign(this, props);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/AI/AIConversationStarter/configuration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACjE,MAAM,OAAO,kCAAkC;IAC3C,MAAM,CAAiE;IACvE,wBAAwB,CAA6B;IACrD,UAAU,CAAuC;IACjD,cAAc,CAAqD;IACnE,cAAc,CAAqB;IACnC,gBAAgB,CAAqB;IACrC,cAAc,GAAW,WAAW,CAAC;IACrC,YAAY,GAAW,SAAS,CAAC;IACjC,YAAY,GAAW,SAAS,CAAC;IACjC,YAAY,KAAkD;QAC5D,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;CAEF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CometChatTheme } from "../../shared";
|
|
2
|
+
import { AIConversationStarterStyle } from "../utils";
|
|
3
|
+
import { CardViewStyle } from "../CardViewStyle";
|
|
4
|
+
import { StyleSheet } from 'react-native';
|
|
5
|
+
export declare function getCardViewStyle(theme: CometChatTheme, style: AIConversationStarterStyle): any;
|
|
6
|
+
export declare function getRepliesStyle(theme: any, configStyles: any): any;
|
|
7
|
+
export declare function getloadingStateStyle(theme: any, configStyles: AIConversationStarterStyle): any;
|
|
8
|
+
export declare function errorLabelStyle(style: CardViewStyle): {
|
|
9
|
+
color: string;
|
|
10
|
+
fontFamily?: string;
|
|
11
|
+
fontWeight?: "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";
|
|
12
|
+
fontSize?: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function emptyLabelStyle(style: CardViewStyle): {
|
|
15
|
+
color: string;
|
|
16
|
+
fontFamily?: string;
|
|
17
|
+
fontWeight?: "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";
|
|
18
|
+
fontSize?: number;
|
|
19
|
+
};
|
|
20
|
+
export declare function getRepliesWrapperStyle(theme: CometChatTheme, configStyles: AIConversationStarterStyle): StyleSheet.NamedStyles<any> | StyleSheet.NamedStyles<{
|
|
21
|
+
borderRadius: any;
|
|
22
|
+
boxSizing: string;
|
|
23
|
+
cursor: string;
|
|
24
|
+
borderWidth?: number;
|
|
25
|
+
borderStyle?: "solid" | "dotted" | "dashed";
|
|
26
|
+
borderColor?: string;
|
|
27
|
+
flexDirection: string;
|
|
28
|
+
padding: number;
|
|
29
|
+
margin: number;
|
|
30
|
+
backgroundColor: any;
|
|
31
|
+
}>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BorderStyle } from "../../shared";
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
export function getCardViewStyle(theme, style) {
|
|
4
|
+
const defaultStyle = StyleSheet.create({
|
|
5
|
+
emptyStateTextColor: theme?.palette?.getAccent600(),
|
|
6
|
+
loadingStateTextColor: theme?.palette?.getAccent600(),
|
|
7
|
+
errorStateTextColor: theme?.palette?.getAccent600(),
|
|
8
|
+
emptyStateTextFont: theme?.typography?.title2,
|
|
9
|
+
errorStateTextFont: theme?.typography?.title2,
|
|
10
|
+
loadingStateTextFont: theme?.typography?.title2,
|
|
11
|
+
backgroundColor: theme?.palette?.getBackgroundColor(),
|
|
12
|
+
loadingIconTint: theme?.palette?.getAccent600(),
|
|
13
|
+
errorIconTint: theme?.palette?.getAccent600(),
|
|
14
|
+
emptyIconTint: theme?.palette?.getAccent600(),
|
|
15
|
+
border: {},
|
|
16
|
+
borderRadius: 8,
|
|
17
|
+
height: 130,
|
|
18
|
+
width: "100%",
|
|
19
|
+
});
|
|
20
|
+
return StyleSheet.flatten([defaultStyle, style]);
|
|
21
|
+
}
|
|
22
|
+
export function getRepliesStyle(theme, configStyles) {
|
|
23
|
+
let fontFamily = configStyles?.repliesTextFont || theme?.typography?.text3;
|
|
24
|
+
return StyleSheet.create({
|
|
25
|
+
...fontFamily,
|
|
26
|
+
color: configStyles?.repliesTextColor || theme?.palette?.getAccent700(),
|
|
27
|
+
backgroundColor: theme?.palette?.getBackgroundColor(),
|
|
28
|
+
textAlign: 'left',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export function getloadingStateStyle(theme, configStyles) {
|
|
32
|
+
let fontFamily = configStyles?.loadingStateTextFont || theme?.typography?.title2;
|
|
33
|
+
return StyleSheet.create({
|
|
34
|
+
...fontFamily,
|
|
35
|
+
color: configStyles?.loadingStateTextColor || theme?.palette?.getAccent700(),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export function errorLabelStyle(style) {
|
|
39
|
+
return {
|
|
40
|
+
...style?.errorStateTextFont,
|
|
41
|
+
color: style?.errorStateTextColor,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function emptyLabelStyle(style) {
|
|
45
|
+
return {
|
|
46
|
+
...style?.emptyStateTextFont,
|
|
47
|
+
color: style?.emptyStateTextColor,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function getRepliesWrapperStyle(theme, configStyles) {
|
|
51
|
+
return StyleSheet.create({
|
|
52
|
+
flexDirection: 'row',
|
|
53
|
+
padding: 8,
|
|
54
|
+
margin: 4,
|
|
55
|
+
backgroundColor: configStyles?.repliesTextBackgroundColor || theme?.palette?.getBackgroundColor(),
|
|
56
|
+
...new BorderStyle({ borderWidth: 1, borderStyle: "solid", borderColor: theme?.palette.getAccent200() }),
|
|
57
|
+
borderRadius: configStyles?.repliesTextBorderRadius || 8,
|
|
58
|
+
boxSizing: 'border-box',
|
|
59
|
+
cursor: 'pointer',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/AI/AIConversationStarter/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,cAAc,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,UAAU,gBAAgB,CAAC,KAAoB,EAAE,KAAgC;IACnF,MAAM,YAAY,GAA8B,UAAU,CAAC,MAAM,CAAC;QAC9D,mBAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;QACnD,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;QACrD,mBAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;QACnD,kBAAkB,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM;QAC7C,kBAAkB,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM;QAC7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AC5B,KAAK,EAAE,KAAK,EAAE,mBAAmB;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAmB;IACjD,OAAO;QACL,GAAG,KAAK,EAAE,kBAAkB;QAC5B,KAAK,EAAE,KAAK,EAAE,mBAAmB;KAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAoB,EAAE,YAAuC;IAElG,OAAO,UAAU,CAAC,MAAM,CAAC;QAErB,aAAa,EAAE,KAAK;QACpB,OAAO,EAAE,CAAC;QACV,MAAM,EAAC,CAAC;QACR,eAAe,EAAE,YAAY,EAAE,0BAA0B,IAAI,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE;QAChG,GAAG,IAAI,WAAW,CAAC,EAAC,WAAW,EAAC,CAAC,EAAC,WAAW,EAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAE,OAAO,CAAC,YAAY,EAAE,EAAC,CAAC;QAClG,YAAY,EAAE,YAAY,EAAE,uBAAuB,IAAI,CAAC;QACxD,SAAS,EAAE,YAAY;QACvB,MAAM,EAAE,SAAS;KAEpB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AIExtensionDataSource } from "./AIExtensionDataSource";
|
|
2
|
+
import { AIEnablerConfiguration } from "./configuration";
|
|
3
|
+
export declare class AIEnabler extends AIExtensionDataSource {
|
|
4
|
+
defaultAIFeatures: AIExtensionDataSource[] | undefined;
|
|
5
|
+
configuration?: AIEnablerConfiguration;
|
|
6
|
+
constructor(defaultFeatures?: AIExtensionDataSource[], configuration?: AIEnablerConfiguration);
|
|
7
|
+
addExtension(): void;
|
|
8
|
+
getExtensionId(): string;
|
|
9
|
+
enable(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ChatConfigurator } 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
|
+
export class AIEnabler extends AIExtensionDataSource {
|
|
8
|
+
defaultAIFeatures;
|
|
9
|
+
configuration = {};
|
|
10
|
+
constructor(defaultFeatures, configuration) {
|
|
11
|
+
super();
|
|
12
|
+
this.configuration = configuration;
|
|
13
|
+
this.defaultAIFeatures = defaultFeatures;
|
|
14
|
+
}
|
|
15
|
+
addExtension() {
|
|
16
|
+
}
|
|
17
|
+
getExtensionId() {
|
|
18
|
+
return "ai-enabler";
|
|
19
|
+
}
|
|
20
|
+
enable() {
|
|
21
|
+
let features = {};
|
|
22
|
+
if (this.defaultAIFeatures && this.defaultAIFeatures?.length >= 1) {
|
|
23
|
+
const promiseArray = this.defaultAIFeatures.map((feature) => {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
CometChat.isAIFeatureEnabled(feature.getExtensionId())
|
|
26
|
+
.then((response) => {
|
|
27
|
+
if (response) {
|
|
28
|
+
if (feature.getExtensionId() !== "conversation-starter") {
|
|
29
|
+
feature?.enable();
|
|
30
|
+
features[feature.getExtensionId()] = {
|
|
31
|
+
enabled: true,
|
|
32
|
+
configuration: feature.getConfiguration(),
|
|
33
|
+
enabler: feature,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
feature.setConfiguration(this.configuration);
|
|
38
|
+
feature.enable();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
resolve(true);
|
|
42
|
+
})
|
|
43
|
+
.catch((err) => {
|
|
44
|
+
console.error(err);
|
|
45
|
+
reject(err);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
Promise.all(promiseArray)
|
|
50
|
+
.then(() => {
|
|
51
|
+
if (Object.keys(features).length > 0) {
|
|
52
|
+
ChatConfigurator.enable((dataSource) => new AIEnablerDecorator(dataSource, features, this.configuration));
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.catch((err) => {
|
|
56
|
+
console.error('An error occurred:', err);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else if (this.defaultAIFeatures?.length == 0) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
let defaultFeatures = [new AISmartRepliesExtension(), new AIConversationStarterExtension()];
|
|
64
|
+
const promiseArray = defaultFeatures.map((feature) => {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
CometChat.isAIFeatureEnabled(feature.getExtensionId())
|
|
67
|
+
.then((response) => {
|
|
68
|
+
if (response) {
|
|
69
|
+
if (feature.getExtensionId() !== "conversation-starter") {
|
|
70
|
+
feature?.enable();
|
|
71
|
+
features[feature.getExtensionId()] = {
|
|
72
|
+
enabled: true,
|
|
73
|
+
configuration: feature.getConfiguration(),
|
|
74
|
+
enabler: feature,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
feature.setConfiguration(this.configuration);
|
|
79
|
+
feature.enable();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
resolve(true);
|
|
83
|
+
})
|
|
84
|
+
.catch((err) => {
|
|
85
|
+
console.error(err);
|
|
86
|
+
reject(err);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
Promise.all(promiseArray)
|
|
91
|
+
.then(() => {
|
|
92
|
+
if (Object.keys(features).length > 0) {
|
|
93
|
+
ChatConfigurator.enable((dataSource) => new AIEnablerDecorator(dataSource, features, this.configuration));
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
.catch((err) => {
|
|
97
|
+
console.error('An error occurred:', err);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMapping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CAAC;iBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;SACN;IACA,CAAC;CAED"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
|
+
import { DataSourceDecorator, DataSource, CometChatTheme } from "../shared";
|
|
3
|
+
import { CardViewStyle } from "./CardViewStyle";
|
|
4
|
+
import { JSX } from "react";
|
|
5
|
+
import { AIEnablerConfiguration } from "./configuration";
|
|
6
|
+
import { AIConfigurations, ICard, State } from "./utils";
|
|
7
|
+
import { AIConversationStarterConfiguration } from "./AIConversationStarter/configuration";
|
|
8
|
+
import { AISmartRepliesConfiguration } from "./AISmartReplies/configuration";
|
|
9
|
+
export declare class AIEnablerDecorator extends DataSourceDecorator {
|
|
10
|
+
smartReplyConfiguration: AISmartRepliesConfiguration;
|
|
11
|
+
conversationStarterConfiguration: AIConversationStarterConfiguration;
|
|
12
|
+
features?: AIConfigurations;
|
|
13
|
+
configuration?: AIEnablerConfiguration;
|
|
14
|
+
newDataSource: DataSource;
|
|
15
|
+
showAiButton: boolean;
|
|
16
|
+
theme: CometChatTheme;
|
|
17
|
+
id: any;
|
|
18
|
+
user: CometChat.User;
|
|
19
|
+
group: CometChat.Group;
|
|
20
|
+
loggedInUser: CometChat.User | null;
|
|
21
|
+
cardViewStyle: CardViewStyle;
|
|
22
|
+
buttonRef: any;
|
|
23
|
+
setCallback: any;
|
|
24
|
+
isPannelVisible: boolean;
|
|
25
|
+
repliesView: JSX.Element;
|
|
26
|
+
errorStateText: string;
|
|
27
|
+
emptyStateText: string;
|
|
28
|
+
keyboardDidShowListener: any;
|
|
29
|
+
keyboardDidHideListener: any;
|
|
30
|
+
onButtonClick: (id: string) => void;
|
|
31
|
+
cardsData: ICard;
|
|
32
|
+
constructor(dataSource: DataSource, features?: AIConfigurations, configuration?: AIEnablerConfiguration);
|
|
33
|
+
getDataSource(): DataSource;
|
|
34
|
+
getId(): string;
|
|
35
|
+
hideOnKeyboardShow: () => void;
|
|
36
|
+
showOnKeyboardShow: () => void;
|
|
37
|
+
editReply(reply: string): void;
|
|
38
|
+
closeBottomsheet: () => void;
|
|
39
|
+
getSmartReplies(): Promise<JSX.Element>;
|
|
40
|
+
showDefaultPanel(state?: State, error?: CometChat.CometChatException): void;
|
|
41
|
+
getAuxiliaryOptions(user?: CometChat.User, group?: CometChat.Group, id?: Map<string, any>, theme?: CometChatTheme): globalThis.JSX.Element[];
|
|
42
|
+
getAIAuxiliaryButton(id: Map<string, any>, user?: CometChat.User, group?: CometChat.Group, theme?: CometChatTheme): JSX.Element;
|
|
43
|
+
}
|