@cometchat/chat-uikit-react-native 5.6.0 → 5.7.0

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 (167) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/CometChatKeyboardModule.kt +101 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
  3. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardDirectionWatcher.kt +64 -0
  4. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardLanguageDirection.kt +44 -0
  5. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +287 -49
  6. package/ios/CometChatKeyboardModule.m +9 -0
  7. package/ios/CometChatKeyboardModule.swift +71 -0
  8. package/ios/KeyboardLanguageDirection.swift +24 -0
  9. package/ios/RichTextEditorView.swift +253 -51
  10. package/ios/RichTextEditorViewManager.m +1 -0
  11. package/package.json +1 -1
  12. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +41 -57
  13. package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +4 -1
  14. package/src/CometChatAIAssistantChatHistory/style.ts +5 -2
  15. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +21 -8
  16. package/src/CometChatCompactMessageComposer/styles.ts +7 -7
  17. package/src/CometChatConversations/CometChatConversations.tsx +36 -30
  18. package/src/CometChatConversations/Skeleton.tsx +4 -1
  19. package/src/CometChatConversations/style.ts +1 -1
  20. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +35 -18
  21. package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
  22. package/src/CometChatGroupMembers/style.ts +6 -4
  23. package/src/CometChatGroups/CometChatGroups.tsx +13 -6
  24. package/src/CometChatGroups/GroupsStyle.ts +1 -1
  25. package/src/CometChatGroups/Skeleton.tsx +4 -1
  26. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +44 -30
  27. package/src/CometChatMessageComposer/styles.tsx +1 -1
  28. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +22 -13
  29. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
  30. package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
  31. package/src/CometChatMessageList/CometChatMessageList.tsx +97 -128
  32. package/src/CometChatMessageList/SwipeToReplyView.tsx +61 -0
  33. package/src/CometChatMessageList/style.ts +32 -32
  34. package/src/CometChatMessageList/swipeToReply.ts +25 -0
  35. package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +10 -3
  36. package/src/CometChatNotificationFeed/style.ts +1 -1
  37. package/src/CometChatNotificationFeed/utils.ts +17 -18
  38. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +8 -1
  39. package/src/CometChatPinnedMessages/style.ts +5 -5
  40. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +2 -0
  41. package/src/CometChatRichTextEditor/index.tsx +3 -0
  42. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +14 -11
  43. package/src/CometChatSavedMessages/style.ts +3 -3
  44. package/src/CometChatSearch/CometChatSearch.tsx +38 -35
  45. package/src/CometChatSearch/Skeleton.tsx +4 -1
  46. package/src/CometChatSearch/searchLabels.ts +26 -0
  47. package/src/CometChatSearch/style.ts +7 -7
  48. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +11 -7
  49. package/src/CometChatThreadHeader/Header.tsx +2 -2
  50. package/src/CometChatUsers/CometChatUsers.tsx +8 -1
  51. package/src/CometChatUsers/Skeleton.tsx +4 -1
  52. package/src/CometChatUsers/style.ts +1 -1
  53. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +8 -1
  54. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +16 -4
  55. package/src/calls/CometChatCallLogs/Skeleton.tsx +4 -1
  56. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +11 -3
  57. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +10 -2
  58. package/src/extensions/CollaborativeBubble/style.ts +4 -4
  59. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
  60. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
  61. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +11 -6
  62. package/src/extensions/LinkPreview/style.ts +6 -6
  63. package/src/extensions/Polls/Header.tsx +1 -1
  64. package/src/extensions/Polls/Polls.tsx +25 -12
  65. package/src/extensions/Polls/PollsBubble.tsx +10 -6
  66. package/src/extensions/Polls/style.ts +4 -4
  67. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +2 -2
  68. package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +1 -1
  69. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +1 -1
  70. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -2
  71. package/src/index.ts +5 -1
  72. package/src/shared/CometChatUiKit/CometChatUIKit.ts +17 -0
  73. package/src/shared/CometChatUiKit/UIKitSettings.ts +8 -0
  74. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +13 -10
  75. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +15 -7
  76. package/src/shared/formatters/CometChatTextFormatter.ts +11 -0
  77. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +7 -4
  78. package/src/shared/framework/MessageDataSource.tsx +17 -94
  79. package/src/shared/helper/LocalizedDateHelper.ts +64 -4
  80. package/src/shared/helper/helperFunctions.ts +71 -4
  81. package/src/shared/helper/keyboardDirection.ts +54 -0
  82. package/src/shared/helper/layoutDirection.ts +205 -0
  83. package/src/shared/helper/pluralRules.ts +67 -0
  84. package/src/shared/helper/textDirection.ts +118 -0
  85. package/src/shared/icons/Icon.tsx +37 -2
  86. package/src/shared/icons/components/format-list-numbered-rtl.tsx +15 -0
  87. package/src/shared/offline/OfflineViews.tsx +5 -1
  88. package/src/shared/offline/notices.ts +15 -21
  89. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +2 -0
  90. package/src/shared/resources/CometChatLocalizeNew/resources/ar/translation.json +720 -0
  91. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +50 -2
  92. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +51 -3
  93. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +50 -2
  94. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +51 -3
  95. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +50 -2
  96. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +50 -2
  97. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +50 -2
  98. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +50 -2
  99. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +50 -2
  100. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +58 -2
  101. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +50 -2
  102. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +50 -2
  103. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +50 -2
  104. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +66 -2
  105. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +50 -2
  106. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +50 -2
  107. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +50 -2
  108. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +50 -2
  109. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
  110. package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
  111. package/src/shared/utils/MessageUtils.tsx +14 -14
  112. package/src/shared/utils/PermissionUtil.ts +16 -5
  113. package/src/shared/utils/attachmentLimits.ts +3 -2
  114. package/src/shared/utils/conversationUtils.ts +3 -5
  115. package/src/shared/utils/fileIconFontSize.ts +10 -0
  116. package/src/shared/utils/fileSizeLabel.ts +16 -0
  117. package/src/shared/utils/groupActionText.ts +75 -0
  118. package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +12 -8
  119. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +1 -1
  120. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +5 -3
  121. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +22 -17
  122. package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +13 -9
  123. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
  124. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +10 -6
  125. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -4
  126. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +6 -2
  127. package/src/shared/views/CometChatComposerErrorBanner.tsx +3 -1
  128. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +8 -3
  129. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +2 -2
  130. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -3
  131. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -8
  132. package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
  133. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +5 -4
  134. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
  135. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +29 -23
  136. package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +41 -21
  137. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +7 -3
  138. package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +7 -3
  139. package/src/shared/views/CometChatList/CometChatList.tsx +10 -14
  140. package/src/shared/views/CometChatList/Header.tsx +5 -2
  141. package/src/shared/views/CometChatList/sectionLetter.ts +44 -0
  142. package/src/shared/views/CometChatList/styles.ts +7 -7
  143. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +6 -4
  144. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +16 -10
  145. package/src/shared/views/CometChatMediaRecorder/Timer.tsx +5 -1
  146. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +16 -11
  147. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
  148. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +18 -2
  149. package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
  150. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +3 -2
  151. package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +2 -2
  152. package/src/shared/views/CometChatReactionList/Skeleton.tsx +4 -1
  153. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +6 -2
  154. package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +7 -3
  155. package/src/shared/views/CometChatReportDialog/style.ts +1 -1
  156. package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +1 -1
  157. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +20 -13
  158. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -2
  159. package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +1 -1
  160. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +29 -3
  161. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +20 -30
  162. package/src/shared/views/CometChatTooltipMenu/tooltipPosition.ts +43 -0
  163. package/src/shared/views/CometChatVideoBubble/style.ts +2 -2
  164. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +4 -1
  165. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +22 -22
  166. package/src/shared/views/SenderLabel.tsx +41 -0
  167. package/src/theme/default/default.ts +1 -1
@@ -8,6 +8,7 @@ import { GroupTypeConstants, UserStatusConstants } from "../shared/constants/UIK
8
8
  import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
9
9
  import { CometChatUIEvents } from "../shared/events/CometChatUIEvents";
10
10
  import { deepMerge } from "../shared/helper/helperFunctions";
11
+ import { sentenceWithNames, stripBidiControls } from "../shared/helper/textDirection";
11
12
  import { Icon } from "../shared/icons/Icon";
12
13
  import { CometChatAvatar } from "../shared/views/CometChatAvatar";
13
14
  import { CometChatStatusIndicator } from "../shared/views/CometChatStatusIndicator";
@@ -27,8 +28,12 @@ import {
27
28
  } from "../shared/utils/ThreadSubscriptionHelper";
28
29
  import { useToast } from "../shared/helper/useToast";
29
30
  import { skipNextAgentAutoLoad } from "../CometChatMessageList/CometChatMessageList";
31
+ import { pluralCountLabel } from "../shared/helper/pluralRules";
32
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection, TEXT_START } from "../shared/helper/layoutDirection";
30
33
 
31
34
  export type CometChatMessageHeaderInterface = {
35
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
36
+ layoutDirection?: "ltr" | "rtl";
32
37
  /**
33
38
  * Custom item view. Receives { user, group }.
34
39
  */
@@ -195,7 +200,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
195
200
  const msgTypingListenerId = "message_typing_" + Date.now() + "_" + (++__listenerIdCounter);
196
201
  const groupListenerId = "head_group_" + Date.now() + "_" + (++__listenerIdCounter);
197
202
  const theme = useTheme();
198
- const { t } = useCometChatTranslation();
203
+ const { t, language } = useCometChatTranslation();
199
204
 
200
205
  const {
201
206
  TitleView,
@@ -226,6 +231,8 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
226
231
  showPinnedMessagesButton = false,
227
232
  onPinnedMessagesPress,
228
233
  } = props;
234
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
235
+ const direction = useComponentLayoutDirection(props.layoutDirection);
229
236
 
230
237
  const [groupObj, setGroupObj] = useState(group);
231
238
  const [userObj, setUserObj] = useState<CometChat.User | undefined>(user);
@@ -458,7 +465,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
458
465
  <Text
459
466
  numberOfLines={1}
460
467
  ellipsizeMode='tail'
461
- style={[messageHeaderStyles.typingIndicatorTextStyle]}
468
+ style={[TEXT_START, messageHeaderStyles.typingIndicatorTextStyle]}
462
469
  >
463
470
  {typingText}
464
471
  </Text>
@@ -468,7 +475,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
468
475
  if (groupObj) {
469
476
  const count = groupObj.getMembersCount?.() ?? groupObj?.["membersCount"];
470
477
  if (count != null) {
471
- subtitle = `${count} ${t(count === 1 ? "MEMBER" : "MEMBERS")}`;
478
+ subtitle = pluralCountLabel(t, "MEMBER_COUNT", count, language);
472
479
  }
473
480
  }
474
481
 
@@ -486,7 +493,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
486
493
  }
487
494
 
488
495
  if (subtitle) {
489
- return <Text style={[messageHeaderStyles.subtitleTextStyle]}>{subtitle}</Text>;
496
+ return <Text style={[TEXT_START, messageHeaderStyles.subtitleTextStyle]}>{subtitle}</Text>;
490
497
  }
491
498
 
492
499
  return <></>;
@@ -494,7 +501,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
494
501
  errorHandler(error);
495
502
  return <></>;
496
503
  }
497
- }, [userObj, groupObj, messageHeaderStyles, usersStatusVisibility, userStatus, presenceHidden]);
504
+ }, [userObj, groupObj, messageHeaderStyles, usersStatusVisibility, userStatus, presenceHidden, t, language]);
498
505
 
499
506
  /**
500
507
  * Error handler to call onError with a proper CometChatException.
@@ -528,7 +535,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
528
535
  groupObj?.getGuid() === typist.getReceiverId()
529
536
  ) {
530
537
  setTypingText(
531
- status === "typing" ? `${typist.getSender()?.getName()}: ${t("IS_TYPING")}` : ""
538
+ status === "typing" ? sentenceWithNames(`\${name}: ${t("IS_TYPING")}`, { name: typist.getSender()?.getName() ?? "" }) : ""
532
539
  );
533
540
  } else if (
534
541
  receiverTypeRef.current === CometChat.RECEIVER_TYPE.USER &&
@@ -683,11 +690,12 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
683
690
  const menuItems = buildMenuItems();
684
691
 
685
692
  return (
693
+ <LayoutDirectionContext.Provider value={direction}>
686
694
  <>
687
695
  {ItemView ? (
688
696
  ItemView({ user: userObj, group })
689
697
  ) : (
690
- <View style={[messageHeaderStyles.containerStyle]}>
698
+ <View style={[messageHeaderStyles.containerStyle, directionStyle(direction)]}>
691
699
  {showBackButton === true && <BackButton />}
692
700
  {LeadingView ? LeadingView({ user: userObj, group }) : <AvatarWithStatusView />}
693
701
  <View style={{ flex: 1, justifyContent: "center" }}>
@@ -697,9 +705,9 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
697
705
  <Text
698
706
  numberOfLines={1}
699
707
  ellipsizeMode='tail'
700
- style={[messageHeaderStyles.titleTextStyle]}
708
+ style={[TEXT_START, messageHeaderStyles.titleTextStyle]}
701
709
  >
702
- {userObj ? userObj.getName() : groupObj ? groupObj.getName() : ""}
710
+ {stripBidiControls(userObj ? userObj.getName() : groupObj ? groupObj.getName() : "")}
703
711
  </Text>
704
712
  )}
705
713
  {SubtitleView ? SubtitleView({ user: userObj, group }) : <SubtitleViewFnc />}
@@ -709,7 +717,7 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
709
717
  flexDirection: "row",
710
718
  alignItems: "center"
711
719
  }}>
712
- <View style={{ marginLeft: "auto", flexDirection: "row" }}>
720
+ <View style={{ marginStart: "auto", flexDirection: "row" }}>
713
721
  {(() => {
714
722
  const isAgenticUser = userObj?.getRole?.() === '@agentic';
715
723
 
@@ -726,19 +734,19 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
726
734
  });
727
735
  })()}
728
736
  {showThreadSubscription && (
729
- <View style={{ marginLeft: theme.spacing.padding.p4 }}>
737
+ <View style={{ marginStart: theme.spacing.padding.p4 }}>
730
738
  <ThreadSubscriptionButton />
731
739
  </View>
732
740
  )}
733
741
  {TrailingView && !isAgenticUser() && (
734
- <View style={{ marginLeft: theme.spacing.padding.p4 }}>
742
+ <View style={{ marginStart: theme.spacing.padding.p4 }}>
735
743
  {TrailingView({ user: userObj, group })}
736
744
  </View>
737
745
  )}
738
746
  {menuItems.length > 0 && (
739
747
  <TouchableOpacity
740
748
  testID='MessageHeader.optionsMenu'
741
- style={{ marginLeft: theme.spacing.padding.p2 }}
749
+ style={{ marginStart: theme.spacing.padding.p2 }}
742
750
  onPress={(e) => {
743
751
  if (e.nativeEvent) {
744
752
  setTooltipPosition({
@@ -787,5 +795,6 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
787
795
  "the toast never appeared" bug. */}
788
796
  {ToastElement}
789
797
  </>
798
+ </LayoutDirectionContext.Provider>
790
799
  );
791
800
  };
@@ -22,6 +22,7 @@ import { CometChatTheme } from "../theme/type";
22
22
  import { deepMerge } from "../shared/helper/helperFunctions";
23
23
  import { DeepPartial } from "../shared/helper/types";
24
24
  import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
25
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection } from "../shared/helper/layoutDirection";
25
26
 
26
27
  const listenerId = "uiEvents_" + Date.now() + "_" + (++__listenerIdCounter);
27
28
 
@@ -33,6 +34,8 @@ type Recipient = {
33
34
  };
34
35
 
35
36
  export interface CometChatMessageInformationInterface {
37
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
38
+ layoutDirection?: "ltr" | "rtl";
36
39
  title?: string;
37
40
  /**
38
41
  * Text formatters, only needed when this screen is used on its own — opened from the message
@@ -79,6 +82,8 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
79
82
  LoadingStateView,
80
83
  style,
81
84
  } = props;
85
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
86
+ const direction = useComponentLayoutDirection(props.layoutDirection);
82
87
 
83
88
  const defaultReceiptTimestampForUser = "----";
84
89
  const theme = useTheme();
@@ -346,7 +351,8 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
346
351
  }, [message, receipts]);
347
352
 
348
353
  return (
349
- <View style={mergedStyle.containerStyle}>
354
+ <LayoutDirectionContext.Provider value={direction}>
355
+ <View style={[mergedStyle.containerStyle, directionStyle(direction)]}>
350
356
  <View style={mergedStyle.titleContainerStyle}>
351
357
  <View style={{ flex: 1, alignItems: "center" }}>
352
358
  <Text style={mergedStyle.titleStyle}>{title}</Text>
@@ -384,5 +390,6 @@ export const CometChatMessageInformation = (props: CometChatMessageInformationIn
384
390
  />
385
391
  )}
386
392
  </View>
393
+ </LayoutDirectionContext.Provider>
387
394
  );
388
395
  };
@@ -2,6 +2,7 @@ import React, { useEffect, useRef } from "react";
2
2
  import { Animated, Dimensions, Easing, ScrollView, StyleSheet, View } from "react-native";
3
3
  import Svg, { Defs, G, LinearGradient, Path, Stop } from "react-native-svg";
4
4
  import { useTheme } from "../theme";
5
+ import { useRtlMirror } from "../shared/helper/layoutDirection";
5
6
 
6
7
  const { width: screenWidth } = Dimensions.get("window");
7
8
 
@@ -56,6 +57,8 @@ const SkeletonItemTop = () => {
56
57
 
57
58
  export const Skeleton = () => {
58
59
  const theme = useTheme();
60
+ // ENG-41390: SVG shapes and the shimmer use fixed x positions; flip the whole skeleton in RTL.
61
+ const rtlMirror = useRtlMirror();
59
62
  const animatedValue = useRef(new Animated.Value(0)).current;
60
63
 
61
64
  useEffect(() => {
@@ -80,7 +83,7 @@ export const Skeleton = () => {
80
83
  });
81
84
 
82
85
  return (
83
- <ScrollView>
86
+ <ScrollView style={rtlMirror}>
84
87
  {new Array(20).fill(0).map((_, i) => {
85
88
  return <SkeletonItemBottom key={i} />;
86
89
  })}
@@ -32,12 +32,7 @@ import {
32
32
  StyleSheet,
33
33
  StyleProp,
34
34
  } from "react-native";
35
- import {
36
- PanGestureHandler,
37
- State,
38
- PanGestureHandlerGestureEvent,
39
- PanGestureHandlerStateChangeEvent,
40
- } from "react-native-gesture-handler";
35
+ import { SwipeToReplyView } from "./SwipeToReplyView";
41
36
  import { CometChatMessageEvents } from "../shared/events/CometChatMessageEvents";
42
37
  import { CometChatConversationEvents } from "../shared/events/conversations";
43
38
  import {
@@ -180,6 +175,9 @@ import {
180
175
  pinSaveNeedsConfirm,
181
176
  carryPinSaveAttrs,
182
177
  } from "../shared/utils/PinSaveHelper";
178
+ import { pluralCountLabel } from "../shared/helper/pluralRules";
179
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection } from "../shared/helper/layoutDirection";
180
+ import { stripBidiControls } from "../shared/helper/textDirection";
183
181
 
184
182
  let _defaultRequestBuilder: CometChat.MessagesRequestBuilder;
185
183
  const AVERAGE_ITEM_LENGTH = 120;
@@ -294,6 +292,8 @@ function batchStateUpdates(callback: () => void): void {
294
292
  * Properties for rendering the CometChat message list component.
295
293
  */
296
294
  export interface CometChatMessageListProps {
295
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
296
+ layoutDirection?: "ltr" | "rtl";
297
297
  /**
298
298
  * ID of the parent message when rendering threaded messages.
299
299
  *
@@ -902,6 +902,8 @@ export const CometChatMessageList = memo(
902
902
  newMessageIndicatorText,
903
903
  loadLastAgentConversation = false,
904
904
  } = props;
905
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
906
+ const direction = useComponentLayoutDirection(props.layoutDirection);
905
907
 
906
908
  // §5.6 — `parentMessage` supersedes `parentMessageId`, and the id is derived from it so
907
909
  // every existing scoping path below is untouched. The deprecated prop is still honoured
@@ -1033,7 +1035,7 @@ export const CometChatMessageList = memo(
1033
1035
  const theme = useTheme();
1034
1036
  const themeInternal = useThemeInternal();
1035
1037
  const themeMode = themeInternal.mode; // 'light' or 'dark' - used for FlatList extraData
1036
- const { t } = useCometChatTranslation();
1038
+ const { t, language } = useCometChatTranslation();
1037
1039
 
1038
1040
  const mergedTheme: CometChatTheme = useMemo(() => {
1039
1041
  const themeClone = deepClone(theme);
@@ -1577,7 +1579,9 @@ export const CometChatMessageList = memo(
1577
1579
  !message.hasOwnProperty("readAt") &&
1578
1580
  loggedInUser.current?.getUid() != message?.getSender()?.getUid()
1579
1581
  ) {
1580
- CometChat.markAsRead(message);
1582
+ CometChat.markAsRead(message).catch((error: any) => {
1583
+ console.log("Error marking message as read", error);
1584
+ });
1581
1585
  if (index == 0)
1582
1586
  CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageRead, {
1583
1587
  message,
@@ -3146,7 +3150,9 @@ export const CometChatMessageList = memo(
3146
3150
  (String(baseMessage.getParentMessageId()) === String(agenticParentId) ||
3147
3151
  String(baseMessage.getId()) === String(agenticParentId))))
3148
3152
  ) {
3149
- CometChat.markAsDelivered(newMessage);
3153
+ CometChat.markAsDelivered(newMessage).catch((error: any) => {
3154
+ console.log("Error marking message as delivered", error);
3155
+ });
3150
3156
  bottomHandler(newMessage, isReceived);
3151
3157
  } else {
3152
3158
  return;
@@ -3158,9 +3164,13 @@ export const CometChatMessageList = memo(
3158
3164
  messageToSameConversation(baseMessage);
3159
3165
  if (inSameConversation) {
3160
3166
  if (user) {
3161
- CometChat.markConversationAsDelivered(user.getUid(), CometChat.RECEIVER_TYPE.USER);
3167
+ CometChat.markConversationAsDelivered(user.getUid(), CometChat.RECEIVER_TYPE.USER).catch((error: any) => {
3168
+ console.log("Error marking conversation as delivered", error);
3169
+ });
3162
3170
  } else if (group) {
3163
- CometChat.markConversationAsDelivered(group.getGuid(), CometChat.RECEIVER_TYPE.GROUP);
3171
+ CometChat.markConversationAsDelivered(group.getGuid(), CometChat.RECEIVER_TYPE.GROUP).catch((error: any) => {
3172
+ console.log("Error marking conversation as delivered", error);
3173
+ });
3164
3174
  }
3165
3175
  if (!parentMessageId && newMessage.getParentMessageId()) {
3166
3176
  const parentId = String(
@@ -4949,7 +4959,7 @@ export const CometChatMessageList = memo(
4949
4959
  item.getCategory()
4950
4960
  )
4951
4961
  ) {
4952
- const senderName = (item.getSender()?.getName() || "").trim();
4962
+ const senderName = stripBidiControls(item.getSender()?.getName()).trim();
4953
4963
  return (
4954
4964
  <View style={staticStyles.flexRow}>
4955
4965
  {Boolean(senderName) && (
@@ -5219,7 +5229,7 @@ export const CometChatMessageList = memo(
5219
5229
  testID="cc.message.status.not-sent-yet"
5220
5230
  style={[
5221
5231
  _style.dateStyles.textStyle,
5222
- { textTransform: "none", marginLeft: 4 },
5232
+ { textTransform: "none", marginStart: 4 },
5223
5233
  mergedTheme.messageListStyles?.offlineStyles?.notSentYetTextStyle,
5224
5234
  ]}
5225
5235
  >
@@ -5261,7 +5271,7 @@ export const CometChatMessageList = memo(
5261
5271
  <Text
5262
5272
  style={[
5263
5273
  _style.dateStyles.textStyle,
5264
- { textTransform: "none", marginLeft: 4, color: mergedTheme.color.error },
5274
+ { textTransform: "none", marginStart: 4, color: mergedTheme.color.error },
5265
5275
  offlineReceipt === "error" ? mergedTheme.messageListStyles?.offlineStyles?.retryTextStyle : null,
5266
5276
  ]}
5267
5277
  >
@@ -5575,8 +5585,7 @@ export const CometChatMessageList = memo(
5575
5585
 
5576
5586
  <Text
5577
5587
  style={_style.threadedMessageStyles?.indicatorTextStyle}
5578
- >{`${item.getReplyCount()} ${item.getReplyCount() > 1 ? t("REPLIES") : t("REPLY")
5579
- }`}</Text>
5588
+ >{pluralCountLabel(t, "REPLY_COUNT", item.getReplyCount(), language)}</Text>
5580
5589
  <CometChatBadge
5581
5590
  style={{
5582
5591
  containerStyle: _style.threadedMessageStyles?.unreadCountStyle?.containerStyle,
@@ -5587,7 +5596,7 @@ export const CometChatMessageList = memo(
5587
5596
  </TouchableOpacity>
5588
5597
  );
5589
5598
  },
5590
- [mergedTheme]
5599
+ [mergedTheme, t, language]
5591
5600
  );
5592
5601
 
5593
5602
  const privateMessage = (item: CometChat.BaseMessage) => {
@@ -5934,89 +5943,48 @@ export const CometChatMessageList = memo(
5934
5943
  return hasTemplate?.ReplyView?.(message, bubbleAlignment) || null;
5935
5944
  }, [hasTemplate, message, bubbleAlignment, mergedTheme, templates]);
5936
5945
 
5937
- if (hasTemplate) {
5938
- if (hasTemplate?.BubbleView) return hasTemplate?.BubbleView(message);
5939
-
5940
- const onLongPress = useCallback(() => {
5941
- // Ensure the keyboard is dismissed before showing options so the action sheet / menu isn't obscured
5942
- Keyboard.dismiss();
5943
-
5944
- if (message.getDeletedBy() != null) return;
5945
-
5946
- if (!message.getId()) {
5947
- // Offline: an unsent row offers Retry and Delete (R162).
5948
- if (offlineReceiptOf(message) !== null) openUnsentMessageOptions(message);
5949
- return;
5950
- }
5951
- // console.log({hasTemplate});
5952
-
5953
- setSelectedMessage(message);
5954
- hasTemplate && openOptionsForMessage(message, hasTemplate);
5955
- }, [hasTemplate, message, openOptionsForMessage]);
5956
-
5957
- const onPress = useCallback(() => {
5958
- Keyboard.dismiss();
5959
- }, []);
5960
-
5961
- // Swipe-to-reply functionality
5962
- const onReply = useCallback(() => {
5963
- if (message.getDeletedBy() != null) return;
5964
- if (!message.getId()) return;
5965
-
5966
- CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
5967
- message: message,
5968
- status: messageStatus.inprogress,
5969
- });
5970
- }, [message]);
5971
-
5972
- const swipeAnimatedValue = useRef(new Animated.Value(0)).current;
5973
- const replyIconOpacity = useRef(new Animated.Value(0)).current;
5946
+ // Hooks run before the template check so every render calls the same hooks.
5947
+ const onLongPress = useCallback(() => {
5948
+ // Ensure the keyboard is dismissed before showing options so the action sheet / menu isn't obscured
5949
+ Keyboard.dismiss();
5974
5950
 
5975
- const handlePanGesture = useCallback((event: PanGestureHandlerGestureEvent) => {
5976
- const { translationX, velocityX } = event.nativeEvent;
5951
+ if (message.getDeletedBy() != null) return;
5977
5952
 
5978
- // Only allow swiping from left to right for replies
5979
- if (translationX <= 0) return;
5980
-
5981
- const swipeThreshold = 80; // Threshold to trigger reply
5982
- const maxSwipeDistance = 120; // Maximum swipe distance
5983
-
5984
- // Calculate progress (0 to 1)
5985
- const progress = Math.min(translationX / maxSwipeDistance, 1);
5953
+ if (!message.getId()) {
5954
+ // Offline: an unsent row offers Retry and Delete (R162).
5955
+ if (offlineReceiptOf(message) !== null) openUnsentMessageOptions(message);
5956
+ return;
5957
+ }
5958
+ // console.log({hasTemplate});
5986
5959
 
5987
- // Update animated values
5988
- swipeAnimatedValue.setValue(Math.min(translationX, maxSwipeDistance));
5989
- replyIconOpacity.setValue(progress);
5990
- }, []);
5960
+ setSelectedMessage(message);
5961
+ hasTemplate && openOptionsForMessage(message, hasTemplate);
5962
+ }, [hasTemplate, message, openOptionsForMessage]);
5991
5963
 
5992
- const handlePanStateChange = useCallback((event: PanGestureHandlerStateChangeEvent) => {
5993
- const { state, translationX, velocityX } = event.nativeEvent;
5964
+ const onPress = useCallback(() => {
5965
+ Keyboard.dismiss();
5966
+ }, []);
5994
5967
 
5995
- if (state === State.END) {
5996
- const swipeThreshold = 80;
5968
+ // Swipe-to-reply functionality
5969
+ const onReply = useCallback(() => {
5970
+ if (message.getDeletedBy() != null) return;
5971
+ if (!message.getId()) return;
5997
5972
 
5998
- // Reset animations
5999
- Animated.parallel([
6000
- Animated.spring(swipeAnimatedValue, {
6001
- toValue: 0,
6002
- useNativeDriver: true,
6003
- }),
6004
- Animated.spring(replyIconOpacity, {
6005
- toValue: 0,
6006
- useNativeDriver: true,
6007
- }),
6008
- ]).start();
5973
+ CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
5974
+ message: message,
5975
+ status: messageStatus.inprogress,
5976
+ });
5977
+ }, [message]);
6009
5978
 
6010
- const moderationStatus = getModerationStatus(message);
6011
- const isOutgoing = message.getSender()?.getUid() === loggedInUser.current?.getUid();
6012
- if (isOutgoing && moderationStatus && moderationStatus !== "approved" && moderationStatus !== "unmoderated") return;
5979
+ // Moderation gate for swipe-to-reply, read on release.
5980
+ const canReply = useCallback(() => {
5981
+ const moderationStatus = getModerationStatus(message);
5982
+ const isOutgoing = message.getSender()?.getUid() === loggedInUser.current?.getUid();
5983
+ return !(isOutgoing && moderationStatus && moderationStatus !== "approved" && moderationStatus !== "unmoderated");
5984
+ }, [message]);
6013
5985
 
6014
- // Trigger reply if threshold is met
6015
- if (translationX > swipeThreshold || velocityX > 500) {
6016
- onReply();
6017
- }
6018
- }
6019
- }, [onReply, message]);
5986
+ if (hasTemplate) {
5987
+ if (hasTemplate?.BubbleView) return hasTemplate?.BubbleView(message);
6020
5988
 
6021
5989
  // Disable swipe-to-reply for agent ("@agentic") messages. Covers both the
6022
5990
  // 1:1 AI chat (isAgenticUser, whole conversation) and agent messages inside a
@@ -6026,6 +5994,10 @@ export const CometChatMessageList = memo(
6026
5994
  isAgenticUser ||
6027
5995
  message.getSender?.()?.getRole?.() === "@agentic" ||
6028
5996
  message.getCategory?.() === MessageCategoryConstants.agentic;
5997
+ // The agent's own replies are markdown, which has no natural width: let them fill.
5998
+ const fillWidth =
5999
+ message.getCategory?.() === MessageCategoryConstants.agentic ||
6000
+ message.getCategory?.() === MessageCategoryConstants.stream;
6029
6001
 
6030
6002
  return (
6031
6003
  message.getCategory() === MessageCategoryConstants.action || isAgenticMessage ? (
@@ -6047,40 +6019,34 @@ export const CometChatMessageList = memo(
6047
6019
  BottomView={BottomView}
6048
6020
  StatusInfoView={StatusInfoView}
6049
6021
  style={getCurrentBubbleStyle(message)}
6022
+ fillWidth={fillWidth}
6050
6023
  />
6051
6024
  </TouchableOpacity>
6052
6025
  </View>
6053
6026
  ) : (
6054
- <PanGestureHandler
6055
- onGestureEvent={handlePanGesture}
6056
- onHandlerStateChange={handlePanStateChange}
6057
- activeOffsetX={[-10, 10]}
6058
- failOffsetY={[-50, 50]}
6059
- >
6060
- <Animated.View style={{ transform: [{ translateX: swipeAnimatedValue }] }}>
6061
- <View style={staticStyles.positionRelative}>
6062
- <TouchableOpacity
6063
- activeOpacity={1}
6064
- onPress={Platform.OS === "ios" ? onPress : undefined}
6065
- onLongPress={() => (showOptions ? onLongPress() : undefined)}
6066
- >
6067
- <CometChatMessageBubble
6068
- id={`${message.getId()}`}
6069
- LeadingView={LeadingView}
6070
- HeaderView={HeaderView}
6071
- FooterView={FooterView}
6072
- ReplyView={ReplyView}
6073
- alignment={isThreaded ? "left" : bubbleAlignment}
6074
- ContentView={ContentView}
6075
- ThreadView={ThreadedView}
6076
- BottomView={BottomView}
6077
- StatusInfoView={StatusInfoView}
6078
- style={getCurrentBubbleStyle(message)}
6079
- />
6080
- </TouchableOpacity>
6081
- </View>
6082
- </Animated.View>
6083
- </PanGestureHandler>
6027
+ <SwipeToReplyView onReply={onReply} canReply={canReply}>
6028
+ <View style={staticStyles.positionRelative}>
6029
+ <TouchableOpacity
6030
+ activeOpacity={1}
6031
+ onPress={Platform.OS === "ios" ? onPress : undefined}
6032
+ onLongPress={() => (showOptions ? onLongPress() : undefined)}
6033
+ >
6034
+ <CometChatMessageBubble
6035
+ id={`${message.getId()}`}
6036
+ LeadingView={LeadingView}
6037
+ HeaderView={HeaderView}
6038
+ FooterView={FooterView}
6039
+ ReplyView={ReplyView}
6040
+ alignment={isThreaded ? "left" : bubbleAlignment}
6041
+ ContentView={ContentView}
6042
+ ThreadView={ThreadedView}
6043
+ BottomView={BottomView}
6044
+ StatusInfoView={StatusInfoView}
6045
+ style={getCurrentBubbleStyle(message)}
6046
+ />
6047
+ </TouchableOpacity>
6048
+ </View>
6049
+ </SwipeToReplyView>
6084
6050
  )
6085
6051
  );
6086
6052
  } else {
@@ -6307,7 +6273,8 @@ export const CometChatMessageList = memo(
6307
6273
  color: textPrimary,
6308
6274
  }}
6309
6275
  >
6310
- {userMetadata?.greetingMessage ?? `Hi, I'm ${user.getName()}`}
6276
+ {userMetadata?.greetingMessage ??
6277
+ t("AI_AGENT_GREETING").replace("{name}", () => user.getName())}
6311
6278
  </Text>
6312
6279
  )}
6313
6280
 
@@ -6323,8 +6290,7 @@ export const CometChatMessageList = memo(
6323
6290
  color: textTertiary,
6324
6291
  }}
6325
6292
  >
6326
- {userMetadata?.introductoryMessage ??
6327
- "I'm here to help! Ask me anything or choose from the suggestions below."}
6293
+ {userMetadata?.introductoryMessage ?? t("AI_AGENT_INTRO")}
6328
6294
  </Text>
6329
6295
  )}
6330
6296
 
@@ -6362,7 +6328,7 @@ export const CometChatMessageList = memo(
6362
6328
  fontWeight: theme.typography.body.regular.fontWeight,
6363
6329
  fontSize: theme.typography.body.regular.fontSize,
6364
6330
  color: textSecondary,
6365
- paddingRight: mergedTheme.spacing.padding.p2,
6331
+ paddingEnd: mergedTheme.spacing.padding.p2,
6366
6332
  flexShrink: 1,
6367
6333
  }}
6368
6334
  >
@@ -6385,6 +6351,7 @@ export const CometChatMessageList = memo(
6385
6351
  emptyChatImageView,
6386
6352
  onSuggestedMessageClick,
6387
6353
  mergedTheme,
6354
+ t,
6388
6355
  ]);
6389
6356
 
6390
6357
  const fetchConversationStarters = (): Promise<string[]> => {
@@ -6928,8 +6895,9 @@ export const CometChatMessageList = memo(
6928
6895
  messagesContentListRef.current = orderedMessagesList;
6929
6896
 
6930
6897
  return (
6898
+ <LayoutDirectionContext.Provider value={direction}>
6931
6899
  <CometChatBatchMediaContext.Provider value={batchMediaContextValue}>
6932
- <View style={mergedTheme.messageListStyles.containerStyle}>
6900
+ <View style={[mergedTheme.messageListStyles.containerStyle, directionStyle(direction)]}>
6933
6901
  {listState == "loading" && messagesList.length == 0 ? (
6934
6902
  getLoadingStateView()
6935
6903
  ) : listState == "error" ? (
@@ -7191,6 +7159,7 @@ export const CometChatMessageList = memo(
7191
7159
  {ToastElement}
7192
7160
  </View>
7193
7161
  </CometChatBatchMediaContext.Provider>
7162
+ </LayoutDirectionContext.Provider>
7194
7163
  );
7195
7164
 
7196
7165
  }
@@ -7292,7 +7261,7 @@ const staticStyles = StyleSheet.create({
7292
7261
  textAlignVertical: "center",
7293
7262
  },
7294
7263
  receiptContainer: {
7295
- marginLeft: 2,
7264
+ marginStart: 2,
7296
7265
  alignItems: "center",
7297
7266
  justifyContent: "center",
7298
7267
  },