@cometchat/chat-uikit-react-native 4.0.1 → 4.0.2

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 (235) hide show
  1. package/README.md +1 -1
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
  4. package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
  5. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  6. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  7. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  8. package/android/.gradle/7.4/gc.properties +0 -0
  9. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  10. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  11. package/android/.gradle/vcs-1/gc.properties +0 -0
  12. package/android/.idea/gradle.xml +13 -0
  13. package/android/.idea/misc.xml +9 -0
  14. package/android/.idea/vcs.xml +6 -0
  15. package/android/src/main/java/com/reactnativecometchatuikit/{RNSoundModule.java → CometChatSoundModule.java} +22 -22
  16. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -1
  17. package/ios/{RNSound.h → CometChatSoundModule.h} +1 -1
  18. package/ios/{RNSound.m → CometChatSoundModule.m} +2 -2
  19. package/lib/CometChatConversations/ConversationsConfiguration.d.ts +1 -0
  20. package/lib/CometChatDetails/DetailsConfiguration.d.ts +1 -0
  21. package/lib/CometChatGroupMembers/GroupMemberConfiguration.d.ts +1 -0
  22. package/lib/CometChatGroups/GroupsConfiguration.d.ts +1 -0
  23. package/lib/CometChatMessageComposer/CometChatMessageComposer.js +1 -7
  24. package/lib/CometChatMessageComposer/CometChatMessageComposer.js.map +1 -1
  25. package/lib/CometChatMessageHeader/MessageHeaderConfiguration.d.ts +1 -0
  26. package/lib/CometChatMessageList/CometChatMessageList.js +18 -49
  27. package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
  28. package/lib/CometChatMessageList/MessageListConfiguration.d.ts +1 -0
  29. package/lib/CometChatMessages/MessagesConfiguration.d.ts +1 -0
  30. package/lib/CometChatTabs/TabItems.d.ts +1 -0
  31. package/lib/CometChatThreadedMessages/ThreadedMessagesConfiguration.d.ts +1 -0
  32. package/lib/calls/CometChatCallDetails/CallDetailsConfiguration.d.ts +1 -0
  33. package/lib/calls/CometChatCallHistory/CallHistoryConfiguration.d.ts +1 -0
  34. package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js +3 -3
  35. package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js.map +1 -1
  36. package/lib/extensions/ImageModeration/ImageModerationDecorator.d.ts +1 -0
  37. package/lib/extensions/ImageModeration/ImageModerationFilter.js +4 -4
  38. package/lib/extensions/ImageModeration/ImageModerationFilter.js.map +1 -1
  39. package/lib/extensions/LinkPreview/LinkPreviewExtentionDecorator.d.ts +1 -0
  40. package/lib/extensions/MessageTranslation/MessageTranslationDecorator.d.ts +1 -0
  41. package/lib/extensions/SmartReplies/SmartRepliesDecorator.js +1 -1
  42. package/lib/extensions/SmartReplies/SmartRepliesDecorator.js.map +1 -1
  43. package/lib/extensions/Stickers/StickersExtensionDecorator.d.ts +1 -1
  44. package/lib/extensions/Stickers/StickersExtensionDecorator.js +2 -4
  45. package/lib/extensions/Stickers/StickersExtensionDecorator.js.map +1 -1
  46. package/lib/extensions/TextModeration/TextModerationExtensionDecorator.d.ts +1 -0
  47. package/lib/index.d.ts +0 -13
  48. package/lib/index.js +0 -14
  49. package/lib/index.js.map +1 -1
  50. package/lib/shared/CometChatUiKit/CometChatUIKit.d.ts +0 -2
  51. package/lib/shared/CometChatUiKit/CometChatUIKit.js +2 -13
  52. package/lib/shared/CometChatUiKit/CometChatUIKit.js.map +1 -1
  53. package/lib/shared/CometChatUiKit/UIKitSettings.d.ts +1 -5
  54. package/lib/shared/CometChatUiKit/UIKitSettings.js +1 -3
  55. package/lib/shared/CometChatUiKit/UIKitSettings.js.map +1 -1
  56. package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js +0 -2
  57. package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js.map +1 -1
  58. package/lib/shared/events/CometChatUIEventHandler/Listener.d.ts +1 -3
  59. package/lib/shared/events/CometChatUIEventHandler/Listener.js +1 -4
  60. package/lib/shared/events/CometChatUIEventHandler/Listener.js.map +1 -1
  61. package/lib/shared/events/CometChatUIEvents.d.ts +1 -2
  62. package/lib/shared/events/CometChatUIEvents.js +0 -1
  63. package/lib/shared/events/CometChatUIEvents.js.map +1 -1
  64. package/lib/shared/framework/DataSource.d.ts +2 -1
  65. package/lib/shared/framework/DataSourceDecorator.d.ts +2 -1
  66. package/lib/shared/framework/DataSourceDecorator.js +2 -2
  67. package/lib/shared/framework/DataSourceDecorator.js.map +1 -1
  68. package/lib/shared/framework/MessageDataSource.d.ts +1 -1
  69. package/lib/shared/framework/MessageDataSource.js +2 -2
  70. package/lib/shared/framework/MessageDataSource.js.map +1 -1
  71. package/lib/shared/helper/types/index.d.ts +1 -0
  72. package/lib/shared/modals/CometChatDetailsOption.d.ts +1 -0
  73. package/lib/shared/modals/CometChatMessageOption.d.ts +1 -0
  74. package/lib/shared/modals/CometChatMessageTemplate.d.ts +1 -0
  75. package/lib/shared/resources/CometChatLocalize/CometChatLocalize.d.ts +153 -230
  76. package/lib/shared/resources/CometChatLocalize/resources/ar/translation.json +0 -4
  77. package/lib/shared/resources/CometChatLocalize/resources/de/translation.json +0 -4
  78. package/lib/shared/resources/CometChatLocalize/resources/en/translation.json +0 -4
  79. package/lib/shared/resources/CometChatLocalize/resources/es/translation.json +0 -4
  80. package/lib/shared/resources/CometChatLocalize/resources/fr/translation.json +0 -4
  81. package/lib/shared/resources/CometChatLocalize/resources/hi/translation.json +0 -4
  82. package/lib/shared/resources/CometChatLocalize/resources/lt/translation.json +0 -4
  83. package/lib/shared/resources/CometChatLocalize/resources/ms/translation.json +0 -4
  84. package/lib/shared/resources/CometChatLocalize/resources/pt/translation.json +0 -4
  85. package/lib/shared/resources/CometChatLocalize/resources/ru/translation.json +0 -4
  86. package/lib/shared/resources/CometChatLocalize/resources/sv/translation.json +0 -4
  87. package/lib/shared/resources/CometChatLocalize/resources/zh/translation.json +0 -4
  88. package/lib/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +0 -4
  89. package/package.json +2 -2
  90. package/src/AI/AIConversationStarter/AIConversationStarterDecorator.tsx +3 -4
  91. package/src/CometChatConversations/CometChatConversations.tsx +56 -46
  92. package/src/CometChatMessageHeader/listners.ts +5 -4
  93. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +35 -35
  94. package/src/CometChatMessageList/CometChatMessageList.tsx +251 -142
  95. package/src/CometChatMessages/CometChatMessages.tsx +4 -3
  96. package/src/CometChatTabs/CometChatTabs.tsx +1 -1
  97. package/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +3 -9
  98. package/src/index.ts +59 -17
  99. package/src/shared/CometChatUiKit/CometChatUIKit.ts +98 -10
  100. package/src/shared/constants/UIKitConstants.ts +81 -47
  101. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +46 -2
  102. package/src/shared/events/CometChatUIEventHandler/Listener.ts +61 -2
  103. package/src/shared/events/ListenerInitializer.ts +73 -0
  104. package/src/shared/events/messages.ts +14 -0
  105. package/src/shared/framework/DataSource.ts +11 -0
  106. package/src/shared/framework/DataSourceDecorator.tsx +35 -0
  107. package/src/shared/framework/MessageDataSource.tsx +83 -3
  108. package/src/shared/index.ts +44 -0
  109. package/src/shared/modals/InteractiveData/InteractiveActions/APIAction.ts +118 -0
  110. package/src/shared/modals/InteractiveData/InteractiveActions/CustomAction.ts +19 -0
  111. package/src/shared/modals/InteractiveData/InteractiveActions/URLNavigationAction.ts +34 -0
  112. package/src/shared/modals/InteractiveData/InteractiveActions/index.ts +3 -0
  113. package/src/shared/modals/InteractiveData/InteractiveData/InteractiveCardData.ts +69 -0
  114. package/src/shared/modals/InteractiveData/InteractiveData/InteractiveFormData.ts +119 -0
  115. package/src/shared/modals/InteractiveData/InteractiveData/index.ts +2 -0
  116. package/src/shared/modals/InteractiveData/InteractiveElements/BaseInputElement.ts +102 -0
  117. package/src/shared/modals/InteractiveData/InteractiveElements/BaseInteractiveElement.ts +45 -0
  118. package/src/shared/modals/InteractiveData/InteractiveElements/ButtonElement.ts +61 -0
  119. package/src/shared/modals/InteractiveData/InteractiveElements/CheckboxElement.ts +75 -0
  120. package/src/shared/modals/InteractiveData/InteractiveElements/DropdownElement.ts +83 -0
  121. package/src/shared/modals/InteractiveData/InteractiveElements/LabelElement.ts +32 -0
  122. package/src/shared/modals/InteractiveData/InteractiveElements/OptionElement.ts +39 -0
  123. package/src/shared/modals/InteractiveData/InteractiveElements/RadioButtonElement.ts +76 -0
  124. package/src/shared/modals/InteractiveData/InteractiveElements/SingleSelectElement.ts +76 -0
  125. package/src/shared/modals/InteractiveData/InteractiveElements/TextInputElement.ts +101 -0
  126. package/src/shared/modals/InteractiveData/InteractiveElements/index.ts +10 -0
  127. package/src/shared/modals/InteractiveData/InteractiveEntities/ActionEntity.ts +41 -0
  128. package/src/shared/modals/InteractiveData/InteractiveEntities/ElementEntity.ts +64 -0
  129. package/src/shared/modals/InteractiveData/InteractiveEntities/index.ts +2 -0
  130. package/src/shared/modals/InteractiveData/InteractiveMessage/CardMessage.ts +142 -0
  131. package/src/shared/modals/InteractiveData/InteractiveMessage/CustomInteractiveMessage.ts +38 -0
  132. package/src/shared/modals/InteractiveData/InteractiveMessage/FormMessage.ts +152 -0
  133. package/src/shared/modals/InteractiveData/InteractiveMessage/index.ts +3 -0
  134. package/src/shared/modals/InteractiveData/index.ts +28 -0
  135. package/src/shared/modals/index.ts +19 -0
  136. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +4 -1
  137. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +4 -1
  138. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +4 -1
  139. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +4 -1
  140. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +4 -1
  141. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +4 -1
  142. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +4 -1
  143. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +4 -1
  144. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +4 -1
  145. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +4 -1
  146. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +4 -1
  147. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +4 -1
  148. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +4 -1
  149. package/src/shared/resources/CometChatSoundManager/CometChatSoundManager.js +2 -2
  150. package/src/shared/resources/CometChatSoundManager/sound.js +35 -35
  151. package/src/shared/utils/InteractiveMessageUtils.ts +20 -0
  152. package/src/shared/utils/NetworkUtils.tsx +20 -0
  153. package/src/shared/utils/conversationUtils.ts +9 -6
  154. package/src/shared/views/CometChatButton/CometChatButton.tsx +32 -22
  155. package/src/shared/views/CometChatCardBubble/CardBubbleStyle.tsx +47 -0
  156. package/src/shared/views/CometChatCardBubble/CometChatCardBubble.tsx +173 -0
  157. package/src/shared/views/CometChatCardBubble/index.tsx +1 -0
  158. package/src/shared/views/CometChatCheckBox/CheckBoxStyle.tsx +43 -0
  159. package/src/shared/views/CometChatCheckBox/CometChatCheckBox.tsx +79 -0
  160. package/src/shared/views/CometChatDate/CometChatDate.tsx +2 -3
  161. package/src/shared/views/CometChatDropDown/CometChatDropDown.tsx +126 -0
  162. package/src/shared/views/CometChatDropDown/DropDownStyle.tsx +39 -0
  163. package/src/shared/views/CometChatDropDown/resources/downArrowIcon.png +0 -0
  164. package/src/shared/views/CometChatDropDown/resources/index.js +5 -0
  165. package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +464 -0
  166. package/src/shared/views/CometChatFormBubble/FormBubbleStyle.tsx +91 -0
  167. package/src/shared/views/CometChatFormBubble/index.tsx +1 -0
  168. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +13 -5
  169. package/src/shared/views/CometChatImageBubble/ImageBubbleStyle.ts +14 -3
  170. package/src/shared/views/CometChatLabel/CometChatLabel.tsx +27 -0
  171. package/src/shared/views/CometChatLabel/LabelStyle.ts +19 -0
  172. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +5 -4
  173. package/src/shared/views/CometChatQuickView/CometChatQuickView.tsx +66 -0
  174. package/src/shared/views/CometChatQuickView/QuickViewStyle.ts +55 -0
  175. package/src/shared/views/CometChatRadioButton/CometChatRadioButton.tsx +67 -0
  176. package/src/shared/views/CometChatRadioButton/RadioButtonStyle.tsx +38 -0
  177. package/src/shared/views/CometChatSingleSelect/CometChatSingleSelect.tsx +63 -0
  178. package/src/shared/views/CometChatSingleSelect/SingleStyle.tsx +35 -0
  179. package/src/shared/views/CometChatTextInput/CometChatTextInput.tsx +67 -0
  180. package/src/shared/views/CometChatTextInput/TextInputStyle.tsx +26 -0
  181. package/src/shared/views/index.ts +7 -1
  182. package/lib/AI/AIConversationStarter/AIConversationStarter.d.ts +0 -12
  183. package/lib/AI/AIConversationStarter/AIConversationStarter.js +0 -31
  184. package/lib/AI/AIConversationStarter/AIConversationStarter.js.map +0 -1
  185. package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.d.ts +0 -25
  186. package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.js +0 -175
  187. package/lib/AI/AIConversationStarter/AIConversationStarterDecorator.js.map +0 -1
  188. package/lib/AI/AIConversationStarter/AIConversationStarterStyle.d.ts +0 -4
  189. package/lib/AI/AIConversationStarter/AIConversationStarterStyle.js +0 -8
  190. package/lib/AI/AIConversationStarter/AIConversationStarterStyle.js.map +0 -1
  191. package/lib/AI/AIConversationStarter/configuration.d.ts +0 -14
  192. package/lib/AI/AIConversationStarter/configuration.js +0 -16
  193. package/lib/AI/AIConversationStarter/configuration.js.map +0 -1
  194. package/lib/AI/AIConversationStarter/style.d.ts +0 -31
  195. package/lib/AI/AIConversationStarter/style.js +0 -62
  196. package/lib/AI/AIConversationStarter/style.js.map +0 -1
  197. package/lib/AI/AIEnabler.d.ts +0 -10
  198. package/lib/AI/AIEnabler.js +0 -102
  199. package/lib/AI/AIEnabler.js.map +0 -1
  200. package/lib/AI/AIEnablerDecorator.d.ts +0 -43
  201. package/lib/AI/AIEnablerDecorator.js +0 -251
  202. package/lib/AI/AIEnablerDecorator.js.map +0 -1
  203. package/lib/AI/AIExtensionDataSource.d.ts +0 -6
  204. package/lib/AI/AIExtensionDataSource.js +0 -10
  205. package/lib/AI/AIExtensionDataSource.js.map +0 -1
  206. package/lib/AI/AISmartReplies/AISmartReplies.d.ts +0 -10
  207. package/lib/AI/AISmartReplies/AISmartReplies.js +0 -23
  208. package/lib/AI/AISmartReplies/AISmartReplies.js.map +0 -1
  209. package/lib/AI/AISmartReplies/AISmartRepliesDecorator.d.ts +0 -7
  210. package/lib/AI/AISmartReplies/AISmartRepliesDecorator.js +0 -12
  211. package/lib/AI/AISmartReplies/AISmartRepliesDecorator.js.map +0 -1
  212. package/lib/AI/AISmartReplies/AISmartRepliesStyle.d.ts +0 -12
  213. package/lib/AI/AISmartReplies/AISmartRepliesStyle.js +0 -15
  214. package/lib/AI/AISmartReplies/AISmartRepliesStyle.js.map +0 -1
  215. package/lib/AI/AISmartReplies/configuration.d.ts +0 -14
  216. package/lib/AI/AISmartReplies/configuration.js +0 -16
  217. package/lib/AI/AISmartReplies/configuration.js.map +0 -1
  218. package/lib/AI/CardView.d.ts +0 -19
  219. package/lib/AI/CardView.js +0 -45
  220. package/lib/AI/CardView.js.map +0 -1
  221. package/lib/AI/CardViewStyle.d.ts +0 -29
  222. package/lib/AI/CardViewStyle.js +0 -36
  223. package/lib/AI/CardViewStyle.js.map +0 -1
  224. package/lib/AI/configuration.d.ts +0 -14
  225. package/lib/AI/configuration.js +0 -16
  226. package/lib/AI/configuration.js.map +0 -1
  227. package/lib/AI/resources/index.d.ts +0 -5
  228. package/lib/AI/resources/index.js +0 -6
  229. package/lib/AI/resources/index.js.map +0 -1
  230. package/lib/AI/style.d.ts +0 -115
  231. package/lib/AI/style.js +0 -139
  232. package/lib/AI/style.js.map +0 -1
  233. package/lib/AI/utils.d.ts +0 -38
  234. package/lib/AI/utils.js +0 -28
  235. package/lib/AI/utils.js.map +0 -1
@@ -0,0 +1,73 @@
1
+ import { CometChat } from "@cometchat/chat-sdk-react-native";
2
+ import { Platform } from 'react-native'
3
+ import { MessageTypeConstants } from "../constants/UIKitConstants";
4
+ import { CometChatUIEventHandler } from "./CometChatUIEventHandler/CometChatUIEventHandler";
5
+ import { MessageEvents } from "./messages";
6
+
7
+ export class ListenerInitializer {
8
+ private static messageListenerId = `ListenerInitializer_listener`;
9
+
10
+ public static attachListeners() {
11
+ CometChat.addMessageListener(
12
+ this.messageListenerId,
13
+ this.getMessageListenerObject()
14
+ );
15
+ }
16
+
17
+ public static detachListeners() {
18
+ CometChat.removeMessageListener(this.messageListenerId);
19
+ }
20
+
21
+ private static getMessageListenerObject() {
22
+ return new CometChat.MessageListener({
23
+ onTextMessageReceived: (textMessage: CometChat.TextMessage) => {
24
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onTextMessageReceived, textMessage);
25
+ },
26
+ onMediaMessageReceived: (mediaMessage: CometChat.MediaMessage) => {
27
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMediaMessageReceived, mediaMessage);
28
+ },
29
+ onCustomMessageReceived: (customMessage: CometChat.CustomMessage) => {
30
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onCustomMessageReceived, customMessage);
31
+ },
32
+ onTypingStarted: (typingIndicator: CometChat.TypingIndicator) => {
33
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onTypingStarted, typingIndicator);
34
+ },
35
+ onTypingEnded: (typingIndicator: CometChat.TypingIndicator) => {
36
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onTypingEnded, typingIndicator);
37
+ },
38
+ onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => {
39
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessagesDelivered, messageReceipt);
40
+ },
41
+ onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => {
42
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessagesRead, messageReceipt);
43
+ },
44
+ onMessageEdited: (message: CometChat.BaseMessage) => {
45
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessageEdited, message);
46
+ },
47
+ onMessageDeleted: (message: CometChat.BaseMessage) => {
48
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessageDeleted, message);
49
+ },
50
+ onTransientMessageReceived: (message: CometChat.TransientMessage) => {
51
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onTransientMessageReceived, message);
52
+ },
53
+ onInteractiveMessageReceived: (
54
+ message: CometChat.InteractiveMessage
55
+ ) => {
56
+ switch (message.getType()) {
57
+ case MessageTypeConstants.form:
58
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onFormMessageReceived, message);
59
+ break;
60
+ case MessageTypeConstants.card:
61
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onCardMessageReceived, message);
62
+ break;
63
+ default:
64
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onCustomInteractiveMessageReceived, message);
65
+ break;
66
+ }
67
+ },
68
+ onInteractionGoalCompleted: (reciept: CometChat.InteractionReceipt) => {
69
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onInteractionGoalCompleted, reciept);
70
+ }
71
+ });
72
+ }
73
+ }
@@ -8,4 +8,18 @@ export enum MessageEvents {
8
8
  ccMarkMessageAsRead = "ccMarkMessageAsRead",
9
9
  ccMessageError = "ccMessageError",
10
10
  ccActiveChatChanged = "ccActiveChatChanged",
11
+ onTextMessageReceived = "onTextMessageReceived",
12
+ onMediaMessageReceived = "onMediaMessageReceived",
13
+ onCustomMessageReceived = "onCustomMessageReceived",
14
+ onTypingStarted = "onTypingStarted",
15
+ onTypingEnded = "onTypingEnded",
16
+ onMessagesDelivered = "onMessagesDelivered",
17
+ onMessagesRead = "onMessagesRead",
18
+ onMessageEdited = "onMessageEdited",
19
+ onMessageDeleted = "onMessageDeleted",
20
+ onTransientMessageReceived = "onTransientMessageReceived",
21
+ onFormMessageReceived = "onFormMessageReceived",
22
+ onCardMessageReceived = "onCardMessageReceived",
23
+ onInteractionGoalCompleted = "onInteractionGoalCompleted",
24
+ onCustomInteractiveMessageReceived = "onCustomInteractiveMessageReceived",
11
25
  }
@@ -8,10 +8,15 @@ import { AudioBubbleStyleInterface } from "../views/CometChatAudioBubble";
8
8
  import { FileBubbleStyleInterface } from "../views/CometChatFileBubble";
9
9
  import { ImageBubbleStyleInterface } from "../views/CometChatImageBubble";
10
10
  import { VideoBubbleStyleInterface } from "../views/CometChatVideoBubble";
11
+ import { CardMessage, FormMessage } from "../modals/InteractiveData";
12
+ import { FormBubbleStyle } from "../views/CometChatFormBubble/FormBubbleStyle";
13
+ import { CardBubbleStyle } from "../views/CometChatCardBubble/CardBubbleStyle";
11
14
 
12
15
  export interface DataSource {
13
16
  //message options based on types
14
17
  getTextMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): Array<CometChatMessageOption>
18
+ getFormMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): Array<CometChatMessageOption>
19
+ getCardMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): Array<CometChatMessageOption>
15
20
  getAudioMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): Array<CometChatMessageOption>
16
21
  getVideoMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): Array<CometChatMessageOption>
17
22
  getImageMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): Array<CometChatMessageOption>
@@ -25,6 +30,8 @@ export interface DataSource {
25
30
  getDeleteMessageBubble(message: CometChat.BaseMessage, theme: CometChatTheme): JSX.Element
26
31
  getVideoMessageBubble(videoUrl: string, thumbnailUrl: string, message: CometChat.MediaMessage, theme: CometChatTheme, videoBubbleStyle: VideoBubbleStyleInterface)
27
32
  getTextMessageBubble(messageText: string, message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element
33
+ getFormMessageBubble(message: FormMessage, theme: CometChatTheme, style?: FormBubbleStyle, onSubmitClick?: (data: any) => void): JSX.Element
34
+ getCardMessageBubble(message: CardMessage, theme: CometChatTheme, style?: CardBubbleStyle, onSubmitClick?: (data: any) => void): JSX.Element
28
35
  getImageMessageBubble(imageUrl: string,caption: string,style: ImageBubbleStyleInterface,message: CometChat.MediaMessage, theme: CometChatTheme): JSX.Element
29
36
  getAudioMessageBubble(audioUrl: string, title: string, style: AudioBubbleStyleInterface, message: CometChat.MediaMessage, theme: CometChatTheme): JSX.Element
30
37
  getFileMessageBubble(fileUrl: string,title: string,style: FileBubbleStyleInterface, message: CometChat.MediaMessage , theme: CometChatTheme): JSX.Element
@@ -33,6 +40,8 @@ export interface DataSource {
33
40
 
34
41
  //content views
35
42
  getTextMessageContentView(message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element
43
+ getFormMessageContentView(message: FormMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element
44
+ getCardMessageContentView(message: CardMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element
36
45
  getAudioMessageContentView(message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element
37
46
  getVideoMessageContentView(message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element
38
47
  getImageMessageContentView(message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element
@@ -41,6 +50,8 @@ export interface DataSource {
41
50
 
42
51
  //templates
43
52
  getTextMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate
53
+ getFormMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate
54
+ getCardMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate
44
55
  getAudioMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate
45
56
  getVideoMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate
46
57
  getImageMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate
@@ -1,8 +1,11 @@
1
1
  import { MessageBubbleAlignmentType } from "../constants/UIKitConstants";
2
2
  import { CometChatMessageComposerActionInterface } from "../helper/types";
3
3
  import { CometChatMessageOption, CometChatMessageTemplate } from "../modals";
4
+ import { CardMessage, FormMessage } from "../modals/InteractiveData";
4
5
  import { CometChatTheme } from "../resources/CometChatTheme";
5
6
  import { VideoBubbleStyleInterface, ImageBubbleStyleInterface, AudioBubbleStyleInterface, FileBubbleStyleInterface } from "../views";
7
+ import { CardBubbleStyle } from "../views/CometChatCardBubble/CardBubbleStyle";
8
+ import { FormBubbleStyle } from "../views/CometChatFormBubble/FormBubbleStyle";
6
9
  import { DataSource } from "./DataSource";
7
10
  import { CometChat } from "@cometchat/chat-sdk-react-native";
8
11
 
@@ -22,6 +25,14 @@ export class DataSourceDecorator implements DataSource {
22
25
  return this.dataSource.getTextMessageOptions(loggedInUser, messageObject, group)
23
26
  }
24
27
 
28
+ getFormMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
29
+ return this.dataSource.getFormMessageOptions(loggedInUser, messageObject, group)
30
+ }
31
+
32
+ getCardMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
33
+ return this.dataSource.getCardMessageOptions(loggedInUser, messageObject, group)
34
+ }
35
+
25
36
  getAudioMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
26
37
  return this.dataSource.getAudioMessageOptions(loggedInUser, messageObject, group)
27
38
  }
@@ -62,6 +73,14 @@ export class DataSourceDecorator implements DataSource {
62
73
  return this.dataSource.getTextMessageBubble(messageText, message, alignment, theme);
63
74
  }
64
75
 
76
+ getFormMessageBubble(message: FormMessage, theme: CometChatTheme, style?: FormBubbleStyle, onSubmitClick?: (data: any) => void) {
77
+ return this.dataSource.getFormMessageBubble(message, theme, style, onSubmitClick);
78
+ }
79
+
80
+ getCardMessageBubble(message: CardMessage, theme: CometChatTheme, style?: CardBubbleStyle, onSubmitClick?: (data: any) => void) {
81
+ return this.dataSource.getCardMessageBubble(message, theme, style, onSubmitClick);
82
+ }
83
+
65
84
  getImageMessageBubble(imageUrl: string, caption: string, style: ImageBubbleStyleInterface, message: CometChat.MediaMessage, theme: CometChatTheme) {
66
85
  return this.dataSource.getImageMessageBubble(imageUrl, caption, style, message, theme);
67
86
  }
@@ -82,6 +101,14 @@ export class DataSourceDecorator implements DataSource {
82
101
  return this.dataSource.getTextMessageContentView(message, alignment, theme);
83
102
  }
84
103
 
104
+ getFormMessageContentView(message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme) {
105
+ return this.dataSource.getFormMessageContentView(message, alignment, theme);
106
+ }
107
+
108
+ getCardMessageContentView(message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme) {
109
+ return this.dataSource.getCardMessageContentView(message, alignment, theme);
110
+ }
111
+
85
112
  getAudioMessageContentView(message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme) {
86
113
  return this.dataSource.getAudioMessageContentView(message, alignment, theme);
87
114
  }
@@ -102,6 +129,14 @@ export class DataSourceDecorator implements DataSource {
102
129
  return this.dataSource.getTextMessageTemplate(theme)
103
130
  }
104
131
 
132
+ getFormMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate {
133
+ return this.dataSource.getFormMessageTemplate(theme)
134
+ }
135
+
136
+ getCardMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate {
137
+ return this.dataSource.getCardMessageTemplate(theme)
138
+ }
139
+
105
140
  getAudioMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate {
106
141
  return this.dataSource.getAudioMessageTemplate(theme)
107
142
  }
@@ -16,6 +16,10 @@ import { ChatConfigurator } from "./ChatConfigurator";
16
16
  import { CometChatMessageComposerActionInterface } from "../helper/types";
17
17
  import { ICONS } from "./resources";
18
18
  import { CometChatConversationUtils } from "../utils/conversationUtils";
19
+ import { CometChatFormBubble, CometChatCardBubble } from "../views";
20
+ import { CardMessage, FormMessage } from "../modals/InteractiveData";
21
+ import { FormBubbleStyle } from "../views/CometChatFormBubble/FormBubbleStyle";
22
+ import { CardBubbleStyle } from "../views/CometChatCardBubble/CardBubbleStyle";
19
23
 
20
24
  function isAudioMessage(message: CometChat.BaseMessage): message is CometChat.MediaMessage {
21
25
  return message.getCategory() == CometChat.CATEGORY_MESSAGE &&
@@ -139,6 +143,21 @@ export class MessageDataSource implements DataSource {
139
143
 
140
144
  return [...msgOptions, ...optionsList];
141
145
  }
146
+
147
+ getFormMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
148
+ let optionsList: Array<CometChatMessageOption> = [];
149
+ if (!isDeletedMessage(messageObject))
150
+ optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
151
+ return optionsList;
152
+ }
153
+
154
+ getCardMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
155
+ let optionsList: Array<CometChatMessageOption> = [];
156
+ if (!isDeletedMessage(messageObject))
157
+ optionsList.push(...ChatConfigurator.dataSource.getCommonOptions(loggedInUser, messageObject, group));
158
+ return optionsList;
159
+ }
160
+
142
161
  getAudioMessageOptions(loggedInUser: CometChat.User, messageObject: CometChat.BaseMessage, group: CometChat.Group): CometChatMessageOption[] {
143
162
  let optionsList: Array<CometChatMessageOption> = [];
144
163
  if (!isDeletedMessage(messageObject))
@@ -194,7 +213,7 @@ export class MessageDataSource implements DataSource {
194
213
  let optionsList: Array<CometChatMessageOption> = [];
195
214
  let _isSentByMe = this.isSentByMe(loggedInUser, messageObject);
196
215
  let canDelete = false;
197
- if (group?.getScope() != undefined && group?.getScope() != GroupMemberScope.participant) {
216
+ if ((group?.getScope() != undefined && group?.getScope() != GroupMemberScope.participant) || _isSentByMe) {
198
217
  canDelete = true;
199
218
  }
200
219
  if (!messageObject.getParentMessageId()) {
@@ -284,6 +303,21 @@ export class MessageDataSource implements DataSource {
284
303
  />
285
304
  }
286
305
 
306
+ getFormMessageBubble(message: FormMessage, theme: CometChatTheme, style?: FormBubbleStyle, onSubmitClick?: (data: any) => void): JSX.Element {
307
+ return <CometChatFormBubble
308
+ message={message}
309
+ onSubmitClick={onSubmitClick}
310
+ style={style}
311
+ />
312
+ }
313
+ getCardMessageBubble(message: CardMessage, theme: CometChatTheme, style?: CardBubbleStyle, onSubmitClick?: (data: any) => void): JSX.Element {
314
+ return <CometChatCardBubble
315
+ message={message}
316
+ onSubmitClick={onSubmitClick}
317
+ style={style}
318
+ />
319
+ }
320
+
287
321
  getImageMessageBubble(imageUrl: string, caption: string, style: ImageBubbleStyleInterface, message: CometChat.MediaMessage, theme: CometChatTheme): JSX.Element {
288
322
  if (isImageMessage(message)) {
289
323
  return <CometChatImageBubble
@@ -318,6 +352,12 @@ export class MessageDataSource implements DataSource {
318
352
  getTextMessageContentView(message: CometChat.TextMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element {
319
353
  return ChatConfigurator.dataSource.getTextMessageBubble(message.getText(), message, alignment, theme);
320
354
  }
355
+ getFormMessageContentView(message: FormMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element {
356
+ return ChatConfigurator.dataSource.getFormMessageBubble(message, theme);
357
+ }
358
+ getCardMessageContentView(message: CardMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element {
359
+ return ChatConfigurator.dataSource.getCardMessageBubble(message, theme);
360
+ }
321
361
  getAudioMessageContentView(message: CometChat.MediaMessage, alignment: MessageBubbleAlignmentType, theme: CometChatTheme): JSX.Element {
322
362
  let attachment = message.getAttachment();
323
363
  return ChatConfigurator.dataSource.getAudioMessageBubble(attachment.getUrl(), attachment.getName(), {
@@ -382,6 +422,36 @@ export class MessageDataSource implements DataSource {
382
422
  });
383
423
  }
384
424
 
425
+ getFormMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate {
426
+ return new CometChatMessageTemplate({
427
+ type: MessageTypeConstants.form,
428
+ category: MessageCategoryConstants.interactive,
429
+ ContentView: (message: CometChat.BaseMessage, _alignment: MessageBubbleAlignmentType) => {
430
+ if (isDeletedMessage(message)) {
431
+ return ChatConfigurator.dataSource.getDeleteMessageBubble(message, theme);
432
+ } else {
433
+ return ChatConfigurator.dataSource.getFormMessageContentView(message, _alignment, theme);
434
+ }
435
+ },
436
+ options: (loggedInuser, message, group) => ChatConfigurator.dataSource.getFormMessageOptions(loggedInuser, message, group),
437
+ });
438
+ }
439
+
440
+ getCardMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate {
441
+ return new CometChatMessageTemplate({
442
+ type: MessageTypeConstants.card,
443
+ category: MessageCategoryConstants.interactive,
444
+ ContentView: (message: CometChat.BaseMessage, _alignment: MessageBubbleAlignmentType) => {
445
+ if (isDeletedMessage(message)) {
446
+ return ChatConfigurator.dataSource.getDeleteMessageBubble(message, theme);
447
+ } else {
448
+ return ChatConfigurator.dataSource.getCardMessageContentView(message, _alignment, theme);
449
+ }
450
+ },
451
+ options: (loggedInuser, message, group) => ChatConfigurator.dataSource.getCardMessageOptions(loggedInuser, message, group),
452
+ });
453
+ }
454
+
385
455
  getAudioMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate {
386
456
  return new CometChatMessageTemplate({
387
457
  type: MessageTypeConstants.audio,
@@ -448,6 +518,8 @@ export class MessageDataSource implements DataSource {
448
518
  getAllMessageTemplates(theme: CometChatTheme): CometChatMessageTemplate[] {
449
519
  return [
450
520
  ChatConfigurator.dataSource.getTextMessageTemplate(theme),
521
+ ChatConfigurator.dataSource.getFormMessageTemplate(theme),
522
+ ChatConfigurator.dataSource.getCardMessageTemplate(theme),
451
523
  ChatConfigurator.dataSource.getAudioMessageTemplate(theme),
452
524
  ChatConfigurator.dataSource.getVideoMessageTemplate(theme),
453
525
  ChatConfigurator.dataSource.getFileMessageTemplate(theme),
@@ -480,6 +552,12 @@ export class MessageDataSource implements DataSource {
480
552
  case MessageTypeConstants.file:
481
553
  template = ChatConfigurator.dataSource.getFileMessageTemplate(theme)
482
554
  break;
555
+ case MessageTypeConstants.form:
556
+ template = ChatConfigurator.dataSource.getFormMessageTemplate(theme)
557
+ break;
558
+ case MessageTypeConstants.card:
559
+ template = ChatConfigurator.dataSource.getCardMessageTemplate(theme)
560
+ break;
483
561
  }
484
562
  return template;
485
563
  }
@@ -492,11 +570,13 @@ export class MessageDataSource implements DataSource {
492
570
  CometChatMessageTypes.video,
493
571
  CometChatMessageTypes.file,
494
572
  MessageTypeConstants.groupActions,
495
- MessageTypeConstants.groupMember
573
+ MessageTypeConstants.groupMember,
574
+ MessageTypeConstants.form,
575
+ MessageTypeConstants.card
496
576
  ];
497
577
  }
498
578
  getAllMessageCategories(): string[] {
499
- return [MessageCategoryConstants.message, MessageCategoryConstants.action];
579
+ return [MessageCategoryConstants.message, MessageCategoryConstants.action, MessageCategoryConstants.interactive];
500
580
  }
501
581
  getAuxiliaryOptions(user: CometChat.User, group: CometChat.Group, id: Map<string, any>, theme?:CometChatTheme): JSX.Element[] {
502
582
  return [];
@@ -24,6 +24,24 @@ import {
24
24
  CometChatMessageTemplate,
25
25
  CometChatDetailsTemplate,
26
26
  CometChatDetailsOption,
27
+ APIAction,
28
+ ActionEntity,
29
+ BaseInputElement,
30
+ BaseInteractiveElement,
31
+ ButtonElement,
32
+ CardMessage,
33
+ CheckboxElement,
34
+ CustomAction,
35
+ CustomInteractiveMessage,
36
+ DropdownElement,
37
+ ElementEntity,
38
+ FormMessage,
39
+ LabelElement,
40
+ OptionElement,
41
+ RadioButtonElement,
42
+ SingleSelectElement,
43
+ TextInputElement,
44
+ URLNavigationAction
27
45
  } from './modals';
28
46
  import { CometChatLocalize, localize } from './resources/CometChatLocalize';
29
47
  import { CometChatTheme, Palette, Typography } from './resources/CometChatTheme';
@@ -113,6 +131,10 @@ import {
113
131
  ReceiptConfigurationInterface,
114
132
  StatusIndicatorConfigurationInterface,
115
133
  StatusIndicatorStyleInterface,
134
+ CometChatFormBubble,
135
+ CometChatFormBubbleInterface,
136
+ CometChatCardBubble,
137
+ CometChatCardBubbleInterface
116
138
  } from './views';
117
139
 
118
140
  import {
@@ -259,4 +281,26 @@ export {
259
281
  CometChatMediaRecorderInterface,
260
282
  MediaRecorderStyleInterface,
261
283
  MediaRecorderStyle,
284
+ CometChatFormBubble,
285
+ CometChatFormBubbleInterface,
286
+ CometChatCardBubble,
287
+ CometChatCardBubbleInterface,
288
+ APIAction,
289
+ ActionEntity,
290
+ BaseInputElement,
291
+ BaseInteractiveElement,
292
+ ButtonElement,
293
+ CardMessage,
294
+ CheckboxElement,
295
+ CustomAction,
296
+ CustomInteractiveMessage,
297
+ DropdownElement,
298
+ ElementEntity,
299
+ FormMessage,
300
+ LabelElement,
301
+ OptionElement,
302
+ RadioButtonElement,
303
+ SingleSelectElement,
304
+ TextInputElement,
305
+ URLNavigationAction
262
306
  };
@@ -0,0 +1,118 @@
1
+ import { ButtonAction, HTTPSRequestMethods } from "../../../constants/UIKitConstants";
2
+
3
+ import { ActionEntity } from "../InteractiveEntities/ActionEntity";
4
+
5
+ /**
6
+ * Represents an API action that can be performed on a dynamic form.
7
+ */
8
+
9
+ export class APIAction extends ActionEntity {
10
+ /**
11
+ * The URL to which the API action should be performed.
12
+ */
13
+ private url: string;
14
+ /**
15
+ * The HTTP method to be used for the API action.
16
+ */
17
+ private method: string;
18
+ /**
19
+ * The payload to be sent with the API action.
20
+ */
21
+ private payload?: Object;
22
+ /**
23
+ * The headers to be sent with the API action.
24
+ */
25
+ private headers?: Object;
26
+ /**
27
+ * The key to be used to insert the data in the provided payload.
28
+ */
29
+ private dataKey?: string = "CometChatData";
30
+
31
+ /**
32
+ * Creates a new instance of the APIAction class.
33
+ * @param {string} url - The URL to which the API action should be performed.
34
+ * @param {string} method - The HTTP method to be used for the API action.
35
+ */
36
+ constructor(url: string, method: string) {
37
+ super(ButtonAction.apiAction);
38
+ this.url = url || "https://example.com";
39
+ this.method = method || HTTPSRequestMethods.POST;
40
+ }
41
+
42
+ /**
43
+ * Returns the URL to which the API action should be performed.
44
+ * @returns {string} The URL to which the API action should be performed.
45
+ */
46
+ getURL(): string {
47
+ return this.url;
48
+ }
49
+
50
+ /**
51
+ * Returns the HTTP method to be used for the API action.
52
+ * @returns {string} The HTTP method to be used for the API action.
53
+ */
54
+ getMethod(): string {
55
+ return this.method;
56
+ }
57
+
58
+ /**
59
+ * Returns the payload to be sent with the API action.
60
+ * @returns {Object} The payload to be sent with the API action.
61
+ */
62
+ getPayload(): Object | undefined {
63
+ return this.payload;
64
+ }
65
+
66
+ /**
67
+ * Sets the payload to be sent with the API action.
68
+ * @param {Object} payload - The payload to be sent with the API action.
69
+ */
70
+ setPayload(payload: Object): void {
71
+ this.payload = payload;
72
+ }
73
+
74
+ /**
75
+ * Returns the headers to be sent with the API action.
76
+ * @returns {Object} The headers to be sent with the API action.
77
+ */
78
+ getHeaders(): Object | undefined {
79
+ return this.headers;
80
+ }
81
+
82
+ /**
83
+ * Sets the headers to be sent with the API action.
84
+ * @param {Object} headers - The headers to be sent with the API action.
85
+ */
86
+ setHeaders(headers: Object): void {
87
+ this.headers = headers;
88
+ }
89
+
90
+ /**
91
+ * Returns the key to be used to insert the data in the provided payload.
92
+ * @returns {string} The key to be used to insert the data in the provided payload.
93
+ */
94
+ getDataKey(): string | undefined {
95
+ return this.dataKey;
96
+ }
97
+
98
+ /**
99
+ * Sets the key to be used to insert the data in the provided payload.
100
+ * @param {string} dataKey - The key to be used to insert the data in the provided payload.
101
+ */
102
+ setDataKey(dataKey: string): void {
103
+ this.dataKey = dataKey;
104
+ }
105
+
106
+ static fromJSON(json: any): APIAction {
107
+ const apiAction = new APIAction(json.url, json.method);
108
+
109
+ if (json.payload)
110
+ apiAction.setPayload(json.payload);
111
+ if (json.headers)
112
+ apiAction.setHeaders(json.headers);
113
+ if (json.dataKey)
114
+ apiAction.setDataKey(json.dataKey);
115
+
116
+ return apiAction;
117
+ }
118
+ }
@@ -0,0 +1,19 @@
1
+ import { ActionEntity } from "../InteractiveEntities/ActionEntity";
2
+ import { ButtonAction } from "../../../constants/UIKitConstants";
3
+
4
+ /**
5
+ * Represents a custom action entity.
6
+ */
7
+ export class CustomAction extends ActionEntity {
8
+ constructor() {
9
+ super(ButtonAction.custom);
10
+ }
11
+
12
+ /**
13
+ * Creates a new CustomAction object from a JSON object.
14
+ * @returns A new CustomAction object created from the JSON object.
15
+ */
16
+ static fromJSON(): CustomAction {
17
+ return new CustomAction();
18
+ }
19
+ }
@@ -0,0 +1,34 @@
1
+ import { ActionEntity } from "../InteractiveEntities/ActionEntity";
2
+ import { ButtonAction } from "../../../constants/UIKitConstants";
3
+
4
+ /**
5
+ * Represents a URL navigation action that can be performed on a dynamic form.
6
+ */
7
+
8
+ export class URLNavigationAction extends ActionEntity {
9
+ /**
10
+ * The URL to navigate to.
11
+ */
12
+ private url: string;
13
+
14
+ /**
15
+ * Creates a new instance of the URLNavigationAction class.
16
+ * @param {string} url - The URL to navigate to.
17
+ */
18
+ constructor(url: string) {
19
+ super(ButtonAction.urlNavigation);
20
+ this.url = url || "https://example.com";
21
+ }
22
+
23
+ /**
24
+ * Returns the URL to navigate to.
25
+ * @returns {string} The URL to navigate to.
26
+ */
27
+ getURL(): string {
28
+ return this.url;
29
+ }
30
+
31
+ static fromJSON(json: any): URLNavigationAction {
32
+ return new URLNavigationAction(json.url);
33
+ }
34
+ }
@@ -0,0 +1,3 @@
1
+ export { APIAction } from "./APIAction"
2
+ export { URLNavigationAction } from "./URLNavigationAction"
3
+ export { CustomAction } from "./CustomAction"
@@ -0,0 +1,69 @@
1
+ import { ButtonElement } from "../InteractiveElements/index";
2
+
3
+ /**
4
+ * Represents the data for an interactive card.
5
+ */
6
+ export class InteractiveCardData {
7
+ private imageUrl?: string;
8
+ private text: string;
9
+ private cardActions: Array<ButtonElement>;
10
+
11
+ /**
12
+ * Creates an instance of InteractiveCardData.
13
+ * @param text The text to display on the card.
14
+ * @param actions The actions to perform when the card is interacted with.
15
+ */
16
+ constructor(text: string, cardActions: Array<ButtonElement>) {
17
+ this.text = text;
18
+ this.cardActions = cardActions;
19
+ }
20
+
21
+ /**
22
+ * Gets the Url of the image for the card.
23
+ * @returns The Url of the image.
24
+ */
25
+ getImageUrl(): string {
26
+ return this.imageUrl || "";
27
+ }
28
+
29
+ /**
30
+ * Sets the image Url for the interactive card data.
31
+ * @param imageUrl - The Url of the image to be set.
32
+ */
33
+ setImageUrl(imageUrl: string) {
34
+ this.imageUrl = imageUrl;
35
+ }
36
+
37
+ /**
38
+ * Gets the text to display on the card.
39
+ * @returns The text to display.
40
+ */
41
+ getText(): string {
42
+ return this.text;
43
+ }
44
+
45
+ /**
46
+ * Gets the actions to perform when the card is interacted with.
47
+ * @returns The actions to perform.
48
+ */
49
+ getCardActions(): Array<ButtonElement> {
50
+ return this.cardActions;
51
+ }
52
+
53
+ /**
54
+ * Creates an instance of InteractiveCardData from a JSON object.
55
+ * @param json The JSON object to create the instance from.
56
+ * @returns The created instance of InteractiveCardData.
57
+ */
58
+ static fromJSON(json: any): InteractiveCardData {
59
+ const actions = json?.cardActions?.map((action: any) => {
60
+ return ButtonElement.fromJSON(action);
61
+ });
62
+ const interactiveCardData = new InteractiveCardData(
63
+ json.text,
64
+ actions
65
+ );
66
+ if (json.imageUrl) interactiveCardData.setImageUrl(json.imageUrl);
67
+ return interactiveCardData;
68
+ }
69
+ }