@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
@@ -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 "../../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
  })}
@@ -5,6 +5,8 @@ import { CometChat } from "@cometchat/chat-sdk-react-native";
5
5
  import { MessageBubbleAlignmentType } from "../../base/Types";
6
6
  import { CometChatTheme } from "../../../theme/type";
7
7
  import { DeepPartial } from "../../helper/types";
8
+ import { localizeDigits } from "../../helper/LocalizedDateHelper";
9
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew/useCometChatTranslationHook";
8
10
 
9
11
  /**
10
12
  * Props for rendering reactions on a message bubble.
@@ -51,6 +53,8 @@ export interface CometChatReactionsInterface {
51
53
  const CometChatReactions = (props: CometChatReactionsInterface) => {
52
54
  const { messageObject, style, onReactionPress, onReactionLongPress, alignment, maxContentWidth } =
53
55
  props;
56
+ // The context language: the provider sets the global one in an effect, a render later.
57
+ const { language } = useCometChatTranslation();
54
58
 
55
59
  const [reactionList, setReactionList] = React.useState<(JSX.Element | null)[]>([]);
56
60
  const reactionRef = React.useRef<CometChat.ReactionCount[]>([]);
@@ -86,7 +90,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
86
90
  : style?.emojiStyle?.emojiCountTextStyle
87
91
  }
88
92
  >
89
- {count}
93
+ {localizeDigits(String(count), language)}
90
94
  </Text>
91
95
  </TouchableOpacity>
92
96
  ) : null;
@@ -167,7 +171,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
167
171
  setReactionList(messageReactions);
168
172
  } else setReactionList(messageReactions);
169
173
  }
170
- }, [messageObject, maxContentWidth]);
174
+ }, [messageObject, maxContentWidth, language]);
171
175
 
172
176
  return reactionList.length ? (
173
177
  <View
@@ -18,6 +18,7 @@ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
18
18
  import { Icon } from "../../icons/Icon";
19
19
  import { CometChat } from "@cometchat/chat-sdk-react-native";
20
20
  import { useKeyboard } from "../../helper/useKeyboard";
21
+ import { directionStyle, useComponentLayoutDirection, useInputTextAlign } from "../../helper/layoutDirection";
21
22
 
22
23
  export interface CometChatReportDialogInterface {
23
24
  /** Controls modal visibility */
@@ -99,6 +100,9 @@ export const CometChatReportDialog = (props: CometChatReportDialogInterface) =>
99
100
  } = props;
100
101
 
101
102
  const theme = useTheme();
103
+ const inputAlign = useInputTextAlign(); // ENG-41384
104
+ // Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
105
+ const direction = useComponentLayoutDirection();
102
106
  const [flagReasons, setFlagReasons] = useState<CometChat.FlagReason[]>(reasons || []);
103
107
  const [isFetchingReasons, setIsFetchingReasons] = useState<boolean>(false);
104
108
  const [selectedReason, setSelectedReason] = useState<CometChat.FlagReason | null>(null);
@@ -208,7 +212,7 @@ export const CometChatReportDialog = (props: CometChatReportDialogInterface) =>
208
212
  onDismiss={onDismiss}
209
213
  >
210
214
  <KeyboardAvoidingView
211
- style={styles.keyboardAvoidingView}
215
+ style={[styles.keyboardAvoidingView, directionStyle(direction)]}
212
216
  behavior={Platform.OS === "ios" ? "padding" : "height"}
213
217
  >
214
218
  <ScrollView
@@ -242,7 +246,7 @@ export const CometChatReportDialog = (props: CometChatReportDialogInterface) =>
242
246
  <View style={[theme.reportDialogStyles.pillsContainerStyle, pillsContainerStyle]}>
243
247
  {isFetchingReasons && (
244
248
  <Text style={[theme.reportDialogStyles.messageTextStyle, { marginBottom: 8 }]}>
245
- {"Loading..."}
249
+ {t("LOADING")}
246
250
  </Text>
247
251
  )}
248
252
  {!isFetchingReasons &&
@@ -309,7 +313,7 @@ export const CometChatReportDialog = (props: CometChatReportDialogInterface) =>
309
313
  onBlur={() => setIsTextInputFocused(false)}
310
314
  onChangeText={(val) => setDescription(val.substring(0, 100))}
311
315
  editable={!isSubmitting}
312
- style={[theme.reportDialogStyles.descriptionTextStyle, descriptionTextStyle]}
316
+ style={[inputAlign, theme.reportDialogStyles.descriptionTextStyle, descriptionTextStyle]}
313
317
  />
314
318
  </View>
315
319
  </View>
@@ -67,7 +67,7 @@ export const getReportDialogStyleLight = (
67
67
  paddingVertical: 10,
68
68
  paddingHorizontal: 16,
69
69
  marginBottom: 8,
70
- marginRight: 8,
70
+ marginEnd: 8,
71
71
  },
72
72
  pillsTextStyle: {
73
73
  color: color.textPrimary,
@@ -145,7 +145,7 @@ const styles = (theme: ReturnType<typeof useTheme>) =>
145
145
  height: 34,
146
146
  borderRadius: 17,
147
147
  backgroundColor: theme.color.background4,
148
- marginRight: 8,
148
+ marginEnd: 8,
149
149
  },
150
150
  chip: {
151
151
  paddingHorizontal: 16,
@@ -4,6 +4,8 @@ import Markdown from 'react-native-markdown-display';
4
4
  import { CometChat } from '@cometchat/chat-sdk-react-native';
5
5
  import { CometChatCardView } from '@cometchat/cards-react-native';
6
6
  import { useTheme } from '../../../theme';
7
+ import { CODE_DIRECTION } from '../../helper/layoutDirection';
8
+ import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
7
9
  import { messageStream, streamingState$, IStreamData, getAIAssistantTools, stopStreamingForRunId, handleWebsocketMessage, startStreamingForRunId, streamConnection$, notifyStreamRenderComplete } from '../../services/stream-message.service';
8
10
  import { CometChatUiKitConstants } from '../../index';
9
11
  import { CometChatUIEventHandler, CometChatUIEvents } from '../../events';
@@ -18,6 +20,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
18
20
  message,
19
21
  style: bubbleStyle
20
22
  }) => {
23
+ const { t } = useCometChatTranslation();
21
24
  const initialMessageRef = useRef<any>(message);
22
25
  const [data, setData] = useState<any>(initialMessageRef.current || null);
23
26
  const [fullMessage, setFullMessage] = useState<string>('');
@@ -259,6 +262,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
259
262
  padding: theme.spacing.padding.p0_5,
260
263
  },
261
264
  code_block: {
265
+ ...CODE_DIRECTION,
262
266
  backgroundColor: theme.color.background3,
263
267
  color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
264
268
  borderRadius: theme.spacing.radius.r2,
@@ -266,6 +270,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
266
270
  fontFamily: 'monospace',
267
271
  },
268
272
  fence: {
273
+ ...CODE_DIRECTION,
269
274
  backgroundColor: theme.color.background3,
270
275
  color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
271
276
  borderRadius: theme.spacing.radius.r2,
@@ -296,7 +301,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
296
301
  padding: 0,
297
302
  },
298
303
  th: {
299
- borderRightWidth: 1,
304
+ borderEndWidth: 1,
300
305
  borderBottomWidth: 1,
301
306
  borderColor: theme.color.borderDefault,
302
307
  backgroundColor: theme.color.background3,
@@ -307,10 +312,10 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
307
312
  fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
308
313
  margin: 0,
309
314
  borderTopWidth: 0,
310
- borderLeftWidth: 0,
315
+ borderStartWidth: 0,
311
316
  },
312
317
  td: {
313
- borderRightWidth: 1,
318
+ borderEndWidth: 1,
314
319
  borderBottomWidth: 1,
315
320
  borderColor: theme.color.borderDefault,
316
321
  backgroundColor: theme.color.background1,
@@ -320,7 +325,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
320
325
  fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
321
326
  margin: 0,
322
327
  borderTopWidth: 0,
323
- borderLeftWidth: 0,
328
+ borderStartWidth: 0,
324
329
  },
325
330
  tr: {
326
331
  borderBottomWidth: 0,
@@ -378,9 +383,9 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
378
383
  color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
379
384
  },
380
385
  blockquote: {
381
- borderLeftWidth: 3,
382
- borderLeftColor: theme.color.borderDefault,
383
- paddingLeft: theme.spacing.padding.p2,
386
+ borderStartWidth: 3,
387
+ borderStartColor: theme.color.borderDefault,
388
+ paddingStart: theme.spacing.padding.p2,
384
389
  color: theme.color.textSecondary,
385
390
  },
386
391
  link: {
@@ -439,9 +444,10 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
439
444
  display: 'flex',
440
445
  paddingVertical: bubbleStyle?.containerStyle?.paddingVertical || 0,
441
446
  paddingHorizontal: bubbleStyle?.containerStyle?.paddingHorizontal || 0,
442
- alignItems: 'flex-start',
447
+ // Fill the bubble (it gets fillWidth): markdown has no natural width to shrink to.
448
+ alignItems: 'stretch',
443
449
  justifyContent: 'flex-start',
444
- alignSelf: 'flex-start',
450
+ alignSelf: 'stretch',
445
451
  backgroundColor: bubbleStyle?.containerStyle?.backgroundColor || 'transparent',
446
452
  borderRadius: bubbleStyle?.containerStyle?.borderRadius || theme.spacing.radius.r3,
447
453
  maxWidth: '100%',
@@ -474,8 +480,9 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
474
480
  fontStyle: 'italic',
475
481
  },
476
482
  errorContainer: {
477
- borderLeftWidth: 3,
478
- borderLeftColor: theme.color.error,
483
+ alignSelf: 'flex-start', // its own size: the container stretches children for markdown
484
+ borderStartWidth: 3,
485
+ borderStartColor: theme.color.error,
479
486
  backgroundColor: bubbleStyle?.errorContainerStyle?.backgroundColor || theme.color.error,
480
487
  padding: bubbleStyle?.errorContainerStyle?.padding || theme.spacing.padding.p2,
481
488
  borderRadius: bubbleStyle?.errorContainerStyle?.borderRadius || theme.spacing.radius.r2,
@@ -517,7 +524,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
517
524
  },
518
525
  ]}
519
526
  >
520
- Thinking...
527
+ {t('THINKING')}
521
528
  </ShimmerText>
522
529
  )}
523
530
 
@@ -557,7 +564,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
557
564
 
558
565
  {hasError && (
559
566
  <View style={styles.errorContainer}>
560
- <Text style={styles.errorText}>No internet connection. Please check your connection and try again.</Text>
567
+ <Text style={styles.errorText}>{t('NO_INTERNET_CONNECTION_RETRY')}</Text>
561
568
  </View>
562
569
  )}
563
570
  </View>
@@ -6,6 +6,7 @@ import { SuggestionListStyle } from "../../../theme/type";
6
6
  import { Skeleton } from "./Skeleton";
7
7
  import { useTheme } from "../../../theme";
8
8
  import { useCometChatTranslation } from "../..";
9
+ import { TEXT_START } from "../../helper/layoutDirection";
9
10
 
10
11
  /**
11
12
  * Props for the CometChatSuggestionList component.
@@ -59,9 +60,9 @@ export const CometChatSuggestionList = (props: CometChatSuggestionListInterface)
59
60
  <Text
60
61
  numberOfLines={1}
61
62
  ellipsizeMode='tail'
62
- style={[listStyle?.listItemStyle.titleStyle, { flexShrink: 1 }]}
63
+ style={[TEXT_START, listStyle?.listItemStyle.titleStyle, { flexShrink: 1 }]}
63
64
  >
64
- <Text style={[listStyle?.listItemStyle.titleStyle, { fontWeight: '700' }]}>@{item.name} </Text>
65
+ <Text style={[TEXT_START, listStyle?.listItemStyle.titleStyle, { fontWeight: '700' }]}>@{item.name} </Text>
65
66
  <Text style={[theme.typography.caption1.regular, { opacity: 0.7 }]}>{t('MESSAGE_COMPOSER_MENTION_NOTIFY_EVERYONE_LABEL')}</Text>
66
67
  </Text>
67
68
  ) : undefined;
@@ -151,7 +151,7 @@ const styles = StyleSheet.create({
151
151
  circleShimmerContainer: {
152
152
  position: "absolute",
153
153
  top: 5,
154
- left: 15, // Start shimmer from the left
154
+ start: 15, // start edge, mirrors under RTL
155
155
  height: 40, // Match the SVG height
156
156
  width: 40, // Ensure shimmer is wide enough to cover the circle
157
157
  overflow: "hidden", // Hide anything that goes outside this container
@@ -18,6 +18,10 @@ import {
18
18
  } from "../../formatters";
19
19
  import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
20
20
  import { isTextElement, isViewElement } from "../../utils/elementType";
21
+ import { hasVisibleDigit, messageDirection } from "../../helper/textDirection";
22
+
23
+ // A mention token (<@uid:x> / <@all:x>): drawn as a name the raw text doesn't hold.
24
+ const MENTION_TOKEN = /<@(?:uid|all):/;
21
25
 
22
26
  // Pre-allocated style for view-based content wrapper (blockquotes, lists).
23
27
  const VIEW_BASED_WRAPPER_STYLE = { flexShrink: 1 as const };
@@ -139,9 +143,29 @@ export const CometChatTextBubbleText = (
139
143
  return finalText as string | JSX.Element;
140
144
  }, [text, textFormatters]);
141
145
 
146
+ // ENG-41314: the message aligns by its own language (first strong character), not by the
147
+ // chat's direction — an English message stays left in an RTL chat, Arabic goes right.
148
+ // Android ENG-58494: no letter but digits ("1123 + 456 = 579 !") reads LTR; with no direction
149
+ // Android laid the numbers out right to left in an RTL chat. Emoji / punctuation only: unchanged.
150
+ // Not with a mention: the token draws as a name (maybe Arabic) that `text` doesn't hold.
151
+ const dir = useMemo(
152
+ () => {
153
+ // An explicit text={null} skips the "" default.
154
+ const raw = text ?? "";
155
+ return messageDirection(raw) ?? (!MENTION_TOKEN.test(raw) && hasVisibleDigit(raw) ? "ltr" : null);
156
+ },
157
+ [text]
158
+ );
142
159
  const contentTextStyle = useMemo(
143
- () => withMeasurableLineHeight(textStyle, formattedText),
144
- [textStyle, formattedText]
160
+ () => {
161
+ const base = withMeasurableLineHeight(textStyle, formattedText);
162
+ if (!dir) return base;
163
+ // Defaults first: a caller's own textAlign (the group action pill centres) still wins.
164
+ // ENG-41385: "left" is the start edge — RN resolves it against the Yoga direction, and the
165
+ // container below already carries `direction: dir`. "right" here put Arabic at the left.
166
+ return [{ writingDirection: dir, textAlign: "left" } as TextStyle, base];
167
+ },
168
+ [textStyle, formattedText, dir]
145
169
  );
146
170
 
147
171
  // Reset state only when text actually changes
@@ -232,7 +256,9 @@ export const CometChatTextBubbleText = (
232
256
  const needsMeasurement = containerWidth !== null && !isViewBased && !measuredCacheRef.current[hiddenTextKey];
233
257
 
234
258
  return (
235
- <View onLayout={onContainerLayout}>
259
+ // direction on the container too: textAlign alone can't move a content-sized Text that
260
+ // the RTL bubble lays out from the right (seen: "Quoted reply" stayed right on Android).
261
+ <View onLayout={onContainerLayout} style={dir ? { direction: dir } : undefined}>
236
262
  {/* Hidden measurement text - only render if we need to measure */}
237
263
  {needsMeasurement && (
238
264
  <Text
@@ -1,7 +1,6 @@
1
1
  import { JSX, useMemo } from "react";
2
2
  import {
3
3
  ColorValue,
4
- Dimensions,
5
4
  ImageSourcePropType,
6
5
  ImageStyle,
7
6
  Modal,
@@ -10,13 +9,14 @@ import {
10
9
  TextStyle,
11
10
  TouchableOpacity,
12
11
  TouchableWithoutFeedback,
12
+ useWindowDimensions,
13
13
  View,
14
14
  ViewStyle,
15
15
  } from "react-native";
16
16
  import { useTheme } from "../../../theme";
17
17
  import { Icon } from "../../icons/Icon";
18
-
19
- const { width: screenWidth, height: screenHeight } = Dimensions.get("window");
18
+ import { tooltipPosition } from "./tooltipPosition";
19
+ import { directionStyle, useComponentLayoutDirection, useKitRTL } from "../../helper/layoutDirection";
20
20
 
21
21
  /**
22
22
  * Interface for the menu items (tooltip actions).
@@ -72,29 +72,16 @@ type CometChatTooltipMenuProps = {
72
72
  export const CometChatTooltipMenu = (props: CometChatTooltipMenuProps) => {
73
73
  const { visible = false, onDismiss = () => null, onClose = () => null, event, menuItems } = props;
74
74
  const theme = useTheme();
75
+ // The live window size: it changes on rotation, split screen and foldables.
76
+ const { width, height } = useWindowDimensions();
77
+ const isRTL = useKitRTL();
78
+ // Modal content is a new native root: give it the opener's direction (§4.7).
79
+ const direction = useComponentLayoutDirection();
75
80
 
76
- const position = useMemo(() => {
77
- let x = event.nativeEvent.pageX;
78
- let y = event.nativeEvent.pageY;
79
- const position: {
80
- left?: number;
81
- right?: number;
82
- top?: number;
83
- bottom?: number;
84
- } = {};
85
- if (x <= screenWidth / 3) {
86
- position.left = x + 10;
87
- } else {
88
- position.right = 12;
89
- }
90
-
91
- if (y <= screenHeight / 2) {
92
- position.top = y + 20;
93
- } else if (y >= screenHeight / 2) {
94
- position.bottom = Math.max(screenHeight - y + 10, 40);
95
- }
96
- return position;
97
- }, [event]);
81
+ const position = useMemo(
82
+ () => tooltipPosition(event.nativeEvent.pageX, event.nativeEvent.pageY, width, height, isRTL),
83
+ [event, width, height, isRTL]
84
+ );
98
85
 
99
86
  return (
100
87
  <Modal
@@ -106,7 +93,7 @@ export const CometChatTooltipMenu = (props: CometChatTooltipMenuProps) => {
106
93
  animationType='none'
107
94
  >
108
95
  <TouchableWithoutFeedback onPress={onClose}>
109
- <View style={tooltipStyles.overlay}>
96
+ <View style={[tooltipStyles.overlay, directionStyle(direction)]}>
110
97
  <View
111
98
  style={[
112
99
  tooltipStyles.menu,
@@ -140,14 +127,14 @@ export const CometChatTooltipMenu = (props: CometChatTooltipMenuProps) => {
140
127
  },
141
128
  i === 0
142
129
  ? {
143
- borderTopLeftRadius: theme.spacing.radius.r2,
144
- borderTopRightRadius: theme.spacing.radius.r2,
130
+ borderTopStartRadius: theme.spacing.radius.r2,
131
+ borderTopEndRadius: theme.spacing.radius.r2,
145
132
  }
146
133
  : {},
147
134
  i === menuItems.length - 1
148
135
  ? {
149
- borderBottomLeftRadius: theme.spacing.radius.r2,
150
- borderBottomRightRadius: theme.spacing.radius.r2,
136
+ borderBottomStartRadius: theme.spacing.radius.r2,
137
+ borderBottomEndRadius: theme.spacing.radius.r2,
151
138
  }
152
139
  : {},
153
140
  ]}
@@ -162,6 +149,9 @@ export const CometChatTooltipMenu = (props: CometChatTooltipMenuProps) => {
162
149
  />
163
150
  <Text
164
151
  style={{
152
+ // Shrinks inside the menu's maxWidth, so a long label wraps instead of
153
+ // overflowing the menu.
154
+ flexShrink: 1,
165
155
  color: theme.color.textPrimary,
166
156
  ...theme.typography.heading4.regular,
167
157
  ...item?.textStyle,
@@ -0,0 +1,43 @@
1
+ // Gap from the screen edge, and from the touch point when the menu opens beside it.
2
+ const EDGE = 12;
3
+ const TOUCH_GAP = 10;
4
+
5
+ export type TooltipPosition = {
6
+ start?: number;
7
+ end?: number;
8
+ top?: number;
9
+ bottom?: number;
10
+ maxWidth?: number;
11
+ };
12
+
13
+ /**
14
+ * Where the menu sits for a touch at (x, y). Horizontal placement is in start/end terms: x is a
15
+ * physical page coordinate, but React Native swaps absolute `left`/`right` in RTL, so a trigger
16
+ * at the left edge opened its menu at the right (ENG-41389). Near the start edge the menu opens
17
+ * just past the touch; otherwise it hugs the end edge — so it stays on screen at both edges.
18
+ */
19
+ export function tooltipPosition(
20
+ x: number,
21
+ y: number,
22
+ width: number,
23
+ height: number,
24
+ isRTL: boolean
25
+ ): TooltipPosition {
26
+ const position: TooltipPosition = {};
27
+ // Clamped: a touch outside the window (stale size, multi-window) still lands on screen.
28
+ const fromStart = Math.min(Math.max(isRTL ? width - x : x, 0), width);
29
+ if (fromStart <= width / 3) {
30
+ position.start = fromStart + TOUCH_GAP;
31
+ // Long or translated labels wrap instead of running past the end edge.
32
+ position.maxWidth = width - position.start - EDGE;
33
+ } else {
34
+ position.end = EDGE;
35
+ position.maxWidth = width - 2 * EDGE;
36
+ }
37
+ if (y <= height / 2) {
38
+ position.top = y + 20;
39
+ } else {
40
+ position.bottom = Math.max(height - y + 10, 40);
41
+ }
42
+ return position;
43
+ }
@@ -51,7 +51,7 @@ export const getVideoBubbleStylesLight = (
51
51
  top: 50
52
52
  },
53
53
  dateReceiptContainerStyle: {
54
- paddingRight: spacing.padding.p1
54
+ paddingEnd: spacing.padding.p1
55
55
  }
56
56
  },
57
57
  outgoingBubbleStyle: {
@@ -88,7 +88,7 @@ export const getVideoBubbleStylesLight = (
88
88
  top: 50
89
89
  },
90
90
  dateReceiptContainerStyle: {
91
- paddingRight: spacing.padding.p1
91
+ paddingEnd: spacing.padding.p1
92
92
  }
93
93
  },
94
94
  };
@@ -10,6 +10,7 @@ import {
10
10
  } from "react-native";
11
11
  import Video from "react-native-video";
12
12
  import { Icon } from "../../icons/Icon";
13
+ import { directionStyle, useComponentLayoutDirection } from "../../helper/layoutDirection";
13
14
 
14
15
  /**
15
16
  * Props for the CometChatVideoPlayer component.
@@ -39,6 +40,8 @@ export interface CometChatVideoPlayerProps {
39
40
 
40
41
  export const CometChatVideoPlayer = (props: CometChatVideoPlayerProps) => {
41
42
  const { videoUri, isVisible, onClose, onLoad, loadingIconColor } = props;
43
+ // Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
44
+ const direction = useComponentLayoutDirection();
42
45
  const [isPaused, setPaused] = useState(false);
43
46
  const [isLoading, setIsLoading] = useState(true);
44
47
  const [showCloseButton, setShowCloseButton] = useState(true);
@@ -112,7 +115,7 @@ export const CometChatVideoPlayer = (props: CometChatVideoPlayerProps) => {
112
115
  visible={isVisible}
113
116
  onRequestClose={handleClose}
114
117
  >
115
- <View style={styles.modalBackground}>
118
+ <View style={[styles.modalBackground, directionStyle(direction)]}>
116
119
  <TouchableWithoutFeedback onPress={handleVideoTap}>
117
120
  <View style={styles.playerContainer}>
118
121
  <Video
@@ -26,10 +26,10 @@ import { AdditionalParams } from "../../base/Types";
26
26
  // ---------------------------------------------------------------------------
27
27
 
28
28
  interface BorderRadii {
29
- topLeft?: number;
30
- topRight?: number;
31
- bottomLeft?: number;
32
- bottomRight?: number;
29
+ topStart?: number;
30
+ topEnd?: number;
31
+ bottomStart?: number;
32
+ bottomEnd?: number;
33
33
  }
34
34
 
35
35
  function formatDurationSecs(secs: number): string {
@@ -140,10 +140,10 @@ const VideoCell = ({
140
140
  const unsupported = mime.includes('/') && !isVideoMime(mime);
141
141
 
142
142
  const borderStyle = {
143
- borderTopLeftRadius: radii.topLeft ?? 0,
144
- borderTopRightRadius: radii.topRight ?? 0,
145
- borderBottomLeftRadius: radii.bottomLeft ?? 0,
146
- borderBottomRightRadius: radii.bottomRight ?? 0,
143
+ borderTopStartRadius: radii.topStart ?? 0,
144
+ borderTopEndRadius: radii.topEnd ?? 0,
145
+ borderBottomStartRadius: radii.bottomStart ?? 0,
146
+ borderBottomEndRadius: radii.bottomEnd ?? 0,
147
147
  };
148
148
  const outOfReach = useMediaOutOfReach(attachment);
149
149
  const handlePress = () => {
@@ -328,25 +328,25 @@ const VideoGrid = ({
328
328
  if (count === 1) {
329
329
  return (
330
330
  <View style={{ flexDirection: 'row' }}>
331
- {cell(0, { topLeft: CORNER, topRight: CORNER, bottomLeft: CORNER, bottomRight: CORNER }, 4 / 3)}
331
+ {cell(0, { topStart: CORNER, topEnd: CORNER, bottomStart: CORNER, bottomEnd: CORNER }, 4 / 3)}
332
332
  </View>
333
333
  );
334
334
  }
335
335
  if (count === 2) {
336
336
  return (
337
337
  <View style={{ flexDirection: 'row', gap: GAP }}>
338
- {cell(0, { topLeft: CORNER, bottomLeft: CORNER })}
339
- {cell(1, { topRight: CORNER, bottomRight: CORNER })}
338
+ {cell(0, { topStart: CORNER, bottomStart: CORNER })}
339
+ {cell(1, { topEnd: CORNER, bottomEnd: CORNER })}
340
340
  </View>
341
341
  );
342
342
  }
343
343
  if (count === 3) {
344
344
  return (
345
345
  <View style={{ gap: GAP }}>
346
- <View style={{ flexDirection: 'row' }}>{cell(0, { topLeft: CORNER, topRight: CORNER }, 4 / 3)}</View>
346
+ <View style={{ flexDirection: 'row' }}>{cell(0, { topStart: CORNER, topEnd: CORNER }, 4 / 3)}</View>
347
347
  <View style={{ flexDirection: 'row', gap: GAP }}>
348
- {cell(1, { bottomLeft: CORNER })}
349
- {cell(2, { bottomRight: CORNER })}
348
+ {cell(1, { bottomStart: CORNER })}
349
+ {cell(2, { bottomEnd: CORNER })}
350
350
  </View>
351
351
  </View>
352
352
  );
@@ -355,12 +355,12 @@ const VideoGrid = ({
355
355
  return (
356
356
  <View style={{ gap: GAP }}>
357
357
  <View style={{ flexDirection: 'row', gap: GAP }}>
358
- {cell(0, { topLeft: CORNER })}
359
- {cell(1, { topRight: CORNER })}
358
+ {cell(0, { topStart: CORNER })}
359
+ {cell(1, { topEnd: CORNER })}
360
360
  </View>
361
361
  <View style={{ flexDirection: 'row', gap: GAP }}>
362
- {cell(2, { bottomLeft: CORNER })}
363
- {cell(3, { bottomRight: CORNER })}
362
+ {cell(2, { bottomStart: CORNER })}
363
+ {cell(3, { bottomEnd: CORNER })}
364
364
  </View>
365
365
  </View>
366
366
  );
@@ -370,12 +370,12 @@ const VideoGrid = ({
370
370
  return (
371
371
  <View style={{ gap: GAP }}>
372
372
  <View style={{ flexDirection: 'row', gap: GAP }}>
373
- {cell(0, { topLeft: CORNER })}
374
- {cell(1, { topRight: CORNER })}
373
+ {cell(0, { topStart: CORNER })}
374
+ {cell(1, { topEnd: CORNER })}
375
375
  </View>
376
376
  <View style={{ flexDirection: 'row', gap: GAP }}>
377
- {cell(2, { bottomLeft: CORNER })}
378
- {cell(3, { bottomRight: CORNER }, undefined, overflowCount)}
377
+ {cell(2, { bottomStart: CORNER })}
378
+ {cell(3, { bottomEnd: CORNER }, undefined, overflowCount)}
379
379
  </View>
380
380
  </View>
381
381
  );
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import { StyleProp, Text, TextStyle, View, ViewStyle } from "react-native";
3
+ import { TEXT_START } from "../helper/layoutDirection";
4
+ import { isolateText } from "../helper/textDirection";
5
+
6
+ /**
7
+ * "Name:" before a message preview (ENG-41391 and its reviews). The colon is its own Text right
8
+ * after the name, so the row layout puts it between the name and the message in both directions
9
+ * and for a name in any script, and a long name ellipsizes without taking the colon with it.
10
+ * Name and colon share a gap-free row (the caller's row may space its children); the gap before
11
+ * the message is a logical margin, not a trailing space (that one isn't drawn at the end of an
12
+ * RTL label).
13
+ */
14
+ export const SenderLabel = ({
15
+ name,
16
+ textStyle,
17
+ containerStyle,
18
+ }: {
19
+ name?: string | null;
20
+ /** Font and colour, shared by the name and the colon. */
21
+ textStyle?: StyleProp<TextStyle>;
22
+ /** Layout limits for the label in the caller's row (max width, shrink). */
23
+ containerStyle?: StyleProp<ViewStyle>;
24
+ }) => {
25
+ if (!name) return null;
26
+ return (
27
+ // One accessibility stop for "Name:", as the single Text it replaces was.
28
+ <View style={[ROW, containerStyle]} accessible accessibilityLabel={`${name}:`}>
29
+ <Text style={[TEXT_START, textStyle, SHRINKS]} numberOfLines={1} ellipsizeMode='tail'>
30
+ {isolateText(name)}
31
+ </Text>
32
+ <Text style={[textStyle, KEEPS]}>:</Text>
33
+ </View>
34
+ );
35
+ };
36
+
37
+ // No shrink by default, like a plain Text in a row; callers that should yield pass flexShrink/maxWidth.
38
+ const ROW: ViewStyle = { flexDirection: "row", alignItems: "center", flexShrink: 0, marginEnd: 4 };
39
+ // The caller's text style may carry a width (e.g. 90%); inside the label both parts hug their text.
40
+ const SHRINKS: TextStyle = { width: undefined, maxWidth: undefined, flexGrow: 0, flexShrink: 1 };
41
+ const KEEPS: TextStyle = { width: undefined, maxWidth: undefined, flexGrow: 0, flexShrink: 0 };