@cometchat/chat-uikit-react-native 5.3.8 → 5.3.9

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 (42) hide show
  1. package/package.json +1 -1
  2. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +6 -3
  3. package/src/CometChatMessageList/CometChatMessageList.tsx +17 -1
  4. package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +478 -0
  5. package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +613 -0
  6. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +12 -4
  7. package/src/CometChatSearch/CometChatSearch.tsx +16 -0
  8. package/src/shared/constants/UIKitConstants.ts +5 -1
  9. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +5 -0
  10. package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -0
  11. package/src/shared/events/CometChatUIEvents.ts +1 -0
  12. package/src/shared/events/ListenerInitializer.ts +3 -0
  13. package/src/shared/framework/DataSource.ts +10 -0
  14. package/src/shared/framework/DataSourceDecorator.tsx +13 -0
  15. package/src/shared/framework/MessageDataSource.tsx +56 -1
  16. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +501 -500
  17. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +1 -0
  18. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +521 -520
  19. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +521 -520
  20. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +521 -520
  21. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +521 -520
  22. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +521 -520
  23. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +521 -520
  24. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +521 -520
  25. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +521 -520
  26. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +521 -520
  27. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +521 -520
  28. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +521 -520
  29. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +521 -520
  30. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +521 -520
  31. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +521 -520
  32. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +521 -520
  33. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +521 -520
  34. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +7 -0
  35. package/src/shared/utils/conversationUtils.ts +8 -0
  36. package/src/shared/utils/stripRichText.ts +41 -0
  37. package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +107 -48
  38. package/src/shared/views/CometChatCardBubble/CometChatCardBubble.tsx +118 -0
  39. package/src/shared/views/CometChatCardBubble/index.ts +2 -0
  40. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +63 -0
  41. package/src/shared/views/index.ts +2 -0
  42. package/src/CometChatMessageList/MANUAL_TEST_CASES.md +0 -154
@@ -159,6 +159,7 @@ export const MessageCategoryConstants = {
159
159
  call: CometChat.CATEGORY_CALL,
160
160
  interactive: CometChat.CATEGORY_INTERACTIVE,
161
161
  agentic: CometChat.CATEGORY_AGENTIC,
162
+ card: CometChat.CATEGORY_CARD,
162
163
  stream: "stream_message",
163
164
  };
164
165
 
@@ -207,7 +208,10 @@ export const streamMessageTypes = {
207
208
  tool_call_start: CometChat.AI_ASSISTANT_EVENTS.TOOL_CALL_STARTED,
208
209
  tool_call_end: CometChat.AI_ASSISTANT_EVENTS.TOOL_CALL_ENDED,
209
210
  tool_call_args: CometChat.AI_ASSISTANT_EVENTS.TOOL_CALL_ARGUMENT,
210
- tool_call_result: CometChat.AI_ASSISTANT_EVENTS.TOOL_CALL_RESULT
211
+ tool_call_result: CometChat.AI_ASSISTANT_EVENTS.TOOL_CALL_RESULT,
212
+ card_start: CometChat.AI_ASSISTANT_EVENTS.CARD_START,
213
+ card: CometChat.AI_ASSISTANT_EVENTS.CARD,
214
+ card_end: CometChat.AI_ASSISTANT_EVENTS.CARD_END,
211
215
  }
212
216
 
213
217
  export const ReceiverTypeConstants = {
@@ -400,6 +400,11 @@ export class CometChatUIEventHandler {
400
400
  param as { id: string; data: Array<SuggestionItem> }
401
401
  );
402
402
  break;
403
+ case listener._eventListener?.ccCardActionClicked?.name:
404
+ listener._eventListener?.ccCardActionClicked?.(
405
+ param as { message: any; action: any }
406
+ );
407
+ break;
403
408
  }
404
409
  });
405
410
  }
@@ -234,6 +234,7 @@ type UIEvents = {
234
234
  ccComposeMessage?: (item: any) => void;
235
235
  // ccMentionClick?:(item)=>void,
236
236
  ccSuggestionData?: (item: { id: string | number; data: Array<SuggestionItem> }) => void;
237
+ ccCardActionClicked?: (item: { message: any; action: any }) => void;
237
238
  };
238
239
  export class UIEventListener {
239
240
  showPanel?: (item: any) => void;
@@ -243,6 +244,7 @@ export class UIEventListener {
243
244
  ccComposeMessage?: (item: any) => void;
244
245
  // ccMentionClick?:(item)=>void;
245
246
  ccSuggestionData?: (item: { id: string | number; data: Array<SuggestionItem> }) => void;
247
+ ccCardActionClicked?: (item: { message: any; action: any }) => void;
246
248
  constructor({
247
249
  showPanel,
248
250
  hidePanel,
@@ -251,6 +253,7 @@ export class UIEventListener {
251
253
  ccComposeMessage,
252
254
  // ccMentionClick,
253
255
  ccSuggestionData,
256
+ ccCardActionClicked,
254
257
  }: UIEvents) {
255
258
  if (!isFalsy(hidePanel)) this.hidePanel = hidePanel;
256
259
  if (!isFalsy(showPanel)) this.showPanel = showPanel;
@@ -259,6 +262,7 @@ export class UIEventListener {
259
262
  if (!isFalsy(ccComposeMessage)) this.ccComposeMessage = ccComposeMessage;
260
263
  // if (!isFalsy(ccMentionClick)) this.ccMentionClick = ccMentionClick;
261
264
  if (!isFalsy(ccSuggestionData)) this.ccSuggestionData = ccSuggestionData;
265
+ if (!isFalsy(ccCardActionClicked)) this.ccCardActionClicked = ccCardActionClicked;
262
266
  }
263
267
  }
264
268
  export class GroupUIEventListener {
@@ -17,4 +17,5 @@ export enum CometChatUIEvents {
17
17
  ccComposeMessage = "ccComposeMessage",
18
18
  // ccMentionClick = "ccMentionClick",
19
19
  ccSuggestionData = "ccSuggestionData",
20
+ ccCardActionClicked = "ccCardActionClicked",
20
21
  }
@@ -97,6 +97,9 @@ export class ListenerInitializer {
97
97
  },
98
98
  onMessagesReadByAll: (messageReceipt: CometChat.MessageReceipt) => {
99
99
  CometChatUIEventHandler.emitMessageEvent(MessageEvents.onMessagesReadByAll, messageReceipt);
100
+ },
101
+ onCardMessageReceived: (cardMessage: any) => {
102
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.onCardMessageReceived, cardMessage);
100
103
  }
101
104
  });
102
105
  }
@@ -192,6 +192,16 @@ export interface DataSource {
192
192
  theme: CometChatTheme,
193
193
  additionalParams?: AdditionalParams
194
194
  ): CometChatMessageTemplate;
195
+ getCardBubbleTemplate(
196
+ theme: CometChatTheme,
197
+ additionalParams?: AdditionalParams
198
+ ): CometChatMessageTemplate;
199
+ getCardBubbleContentView(
200
+ message: CometChat.BaseMessage,
201
+ alignment: MessageBubbleAlignmentType,
202
+ theme: CometChatTheme,
203
+ additionalParams?: AdditionalParams
204
+ ): JSX.Element;
195
205
 
196
206
  //attachment options
197
207
  // getAttachmentOptions(theme: CometChatTheme, conversation: CometChat.User | CometChat.Group): Array<CometChatMessageComposerAction>
@@ -225,6 +225,19 @@ export class DataSourceDecorator implements DataSource {
225
225
  return this.dataSource.getCardMessageTemplate(theme, additionalParams);
226
226
  }
227
227
 
228
+ getCardBubbleTemplate(theme: CometChatTheme, additionalParams?: AdditionalParams): CometChatMessageTemplate {
229
+ return this.dataSource.getCardBubbleTemplate(theme, additionalParams);
230
+ }
231
+
232
+ getCardBubbleContentView(
233
+ message: CometChat.BaseMessage,
234
+ alignment: MessageBubbleAlignmentType,
235
+ theme: CometChatTheme,
236
+ additionalParams?: AdditionalParams
237
+ ): JSX.Element {
238
+ return this.dataSource.getCardBubbleContentView(message, alignment, theme, additionalParams);
239
+ }
240
+
228
241
  getAudioMessageTemplate(theme: CometChatTheme, additionalParams?: AdditionalParams): CometChatMessageTemplate {
229
242
  return this.dataSource.getAudioMessageTemplate(theme, additionalParams);
230
243
  }
@@ -38,6 +38,7 @@ import { CometChatTextBubble } from "../views/CometChatTextBubble";
38
38
  import { CometChatVideoBubble } from "../views/CometChatVideoBubble";
39
39
  import CometChatAIAssistantMessageBubble from '../views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble';
40
40
  import CometChatStreamMessageBubble from '../views/CometChatStreamMessageBubble/CometChatStreamMessageBubble';
41
+ import { CometChatCardBubble } from "../views/CometChatCardBubble";
41
42
  import { ChatConfigurator } from "./ChatConfigurator";
42
43
  import { DataSource } from "./DataSource";
43
44
  import { CommonUtils } from "../utils/CommonUtils";
@@ -1733,6 +1734,53 @@ export class MessageDataSource implements DataSource {
1733
1734
  });
1734
1735
  }
1735
1736
 
1737
+ // --- Developer card (category: "card") ----------------------------------
1738
+ getCardBubbleContentView(
1739
+ message: CometChat.BaseMessage,
1740
+ alignment: MessageBubbleAlignmentType,
1741
+ theme: CometChatTheme,
1742
+ additionalParams?: AdditionalParams
1743
+ ): JSX.Element {
1744
+ return <CometChatCardBubble message={message} theme={theme} />;
1745
+ }
1746
+
1747
+ getCardBubbleTemplate(
1748
+ theme: CometChatTheme,
1749
+ additionalParams?: AdditionalParams
1750
+ ): CometChatMessageTemplate {
1751
+ return new CometChatMessageTemplate({
1752
+ // Sentinel type; developer card `type` is arbitrary and resolved on category alone.
1753
+ type: MessageTypeConstants.card,
1754
+ category: MessageCategoryConstants.card,
1755
+ ContentView: (message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
1756
+ if (isDeletedMessage(message)) {
1757
+ return ChatConfigurator.dataSource.getDeleteMessageBubble(message, theme);
1758
+ }
1759
+ return ChatConfigurator.dataSource.getCardBubbleContentView(
1760
+ message,
1761
+ alignment,
1762
+ theme,
1763
+ additionalParams
1764
+ );
1765
+ },
1766
+ // Same option set as the text bubble, minus edit and copy.
1767
+ options: (loggedInuser, message, theme, group) =>
1768
+ ChatConfigurator.dataSource
1769
+ .getTextMessageOptions(loggedInuser, message, theme, group, additionalParams)
1770
+ .filter(
1771
+ (o: CometChatMessageOption) =>
1772
+ o.id !== MessageOptionConstants.editMessage &&
1773
+ o.id !== MessageOptionConstants.copyMessage
1774
+ ),
1775
+ ReplyView: (message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
1776
+ return ChatConfigurator.dataSource.getReplyView?.(message, theme, additionalParams) || null;
1777
+ },
1778
+ BottomView: (message: CometChat.BaseMessage, alignment: MessageBubbleAlignmentType) => {
1779
+ return ChatConfigurator.dataSource.getBottomView(message, alignment);
1780
+ },
1781
+ });
1782
+ }
1783
+
1736
1784
  getAllMessageTemplates(
1737
1785
  theme: CometChatTheme,
1738
1786
  additionalParams?: AdditionalParams
@@ -1748,6 +1796,7 @@ export class MessageDataSource implements DataSource {
1748
1796
  ChatConfigurator.dataSource.getFormMessageTemplate(theme, additionalParams),
1749
1797
  ChatConfigurator.dataSource.getSchedulerMessageTemplate(theme, additionalParams),
1750
1798
  ChatConfigurator.dataSource.getCardMessageTemplate(theme, additionalParams),
1799
+ ChatConfigurator.dataSource.getCardBubbleTemplate(theme, additionalParams),
1751
1800
  ChatConfigurator.dataSource.getAgentAssistantMessageTemplate(theme, additionalParams),
1752
1801
  ];
1753
1802
  }
@@ -1764,6 +1813,11 @@ export class MessageDataSource implements DataSource {
1764
1813
  //in case of call message return undefined
1765
1814
  if (MessageCategory == MessageCategoryConstants.call) return null;
1766
1815
 
1816
+ // Developer card: resolve on category alone (developer `type` is arbitrary).
1817
+ if (MessageCategory == MessageCategoryConstants.card) {
1818
+ return ChatConfigurator.dataSource.getCardBubbleTemplate(theme, additionalParams);
1819
+ }
1820
+
1767
1821
  switch (messageType) {
1768
1822
  case MessageTypeConstants.text:
1769
1823
  template = ChatConfigurator.dataSource.getTextMessageTemplate(theme, additionalParams);
@@ -1819,7 +1873,8 @@ export class MessageDataSource implements DataSource {
1819
1873
  MessageCategoryConstants.message,
1820
1874
  MessageCategoryConstants.action,
1821
1875
  MessageCategoryConstants.interactive,
1822
- MessageCategoryConstants.agentic
1876
+ MessageCategoryConstants.agentic,
1877
+ MessageCategoryConstants.card
1823
1878
  ];
1824
1879
  }
1825
1880
  getAuxiliaryOptions(