@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
@@ -19,10 +19,15 @@ import { CometChatTooltipMenu } from "../shared/views/CometChatTooltipMenu";
19
19
  import { CometChatConfirmDialog } from "../shared/views/CometChatConfirmDialog";
20
20
  import Delete from "../shared/icons/components/delete";
21
21
  import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
22
+ import { useLocalizedDate } from "../shared/helper/useLocalizedDateHook";
23
+ import { LocalizedDateHelper } from "../shared/helper/LocalizedDateHelper";
22
24
  import { skipNextAgentAutoLoad } from "../CometChatMessageList/CometChatMessageList";
25
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection } from "../shared/helper/layoutDirection";
23
26
 
24
27
 
25
28
  interface CometChatAIAssistantChatHistoryProps {
29
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
30
+ layoutDirection?: "ltr" | "rtl";
26
31
  /**
27
32
  * A `CometChat.User` object representing the participant of the chat whose message history is displayed.
28
33
  */
@@ -86,9 +91,12 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
86
91
  style = {},
87
92
  LoadingStateView
88
93
  } = props;
94
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
95
+ const direction = useComponentLayoutDirection(props.layoutDirection);
89
96
 
90
97
  const theme = useTheme();
91
98
  const {t}=useCometChatTranslation();
99
+ const { formatDate } = useLocalizedDate();
92
100
 
93
101
  // Create fallback styles if theme.chatHistoryStyles doesn't exist
94
102
  const defaultStyles = useMemo(() => {
@@ -157,66 +165,33 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
157
165
  /**
158
166
  * Function to get formatted date label
159
167
  */
168
+ // Today / Yesterday / weekday / date in the kit language — the same labels as the message
169
+ // list's date separators (was hard-coded English and 'en-US' dates).
160
170
  const getDateLabel = useCallback((timestamp: number): string => {
161
- const messageDate = new Date(timestamp * 1000);
162
- const today = new Date();
163
- const yesterday = new Date(today);
164
- yesterday.setDate(yesterday.getDate() - 1);
165
-
166
- if (messageDate.toDateString() === today.toDateString()) {
167
- return 'Today';
168
- } else if (messageDate.toDateString() === yesterday.toDateString()) {
169
- return 'Yesterday';
170
- } else {
171
- // Check if it's within the last week
172
- const oneWeekAgo = new Date(today);
173
- oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
174
-
175
- if (messageDate >= oneWeekAgo) {
176
- return messageDate.toLocaleDateString('en-US', { weekday: 'long' });
177
- } else {
178
- return messageDate.toLocaleDateString('en-US', {
179
- month: 'long',
180
- day: 'numeric',
181
- year: messageDate.getFullYear() !== today.getFullYear() ? 'numeric' : undefined
182
- });
183
- }
184
- }
185
- }, []);
171
+ return formatDate(timestamp * 1000, LocalizedDateHelper.patterns.dayDateFormat);
172
+ }, [formatDate]);
186
173
 
187
174
  /**
188
175
  * Function to group messages by date
189
176
  */
190
177
  const groupedMessages = useMemo((): GroupedMessage[] => {
191
178
  const groups: { [key: string]: CometChat.TextMessage[] } = {};
192
-
179
+ const newest: { [key: string]: number } = {};
180
+
193
181
  messageList.forEach(message => {
194
182
  const label = getDateLabel(message.getSentAt());
195
183
  if (!groups[label]) {
196
184
  groups[label] = [];
185
+ newest[label] = 0;
197
186
  }
198
187
  groups[label].push(message);
188
+ newest[label] = Math.max(newest[label], message.getSentAt() ?? 0);
199
189
  });
200
-
201
- // Sort groups by date priority
202
- const sortOrder = ['Today', 'Yesterday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
203
-
190
+
191
+ // Newest group first, by its newest message. The labels are translated now, so the old sort
192
+ // by English label text ('Today', 'Yesterday', 'Monday', …) no longer applies.
204
193
  return Object.entries(groups)
205
- .sort(([a], [b]) => {
206
- const aIndex = sortOrder.indexOf(a);
207
- const bIndex = sortOrder.indexOf(b);
208
-
209
- if (aIndex !== -1 && bIndex !== -1) {
210
- return aIndex - bIndex;
211
- } else if (aIndex !== -1) {
212
- return -1;
213
- } else if (bIndex !== -1) {
214
- return 1;
215
- } else {
216
- // Both are dates, sort by most recent first
217
- return b.localeCompare(a);
218
- }
219
- })
194
+ .sort(([a], [b]) => newest[b] - newest[a])
220
195
  .map(([title, data]) => ({ title, data }));
221
196
  }, [messageList, getDateLabel]);
222
197
 
@@ -230,7 +205,14 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
230
205
  // **bold**) so titles read cleanly instead of showing raw tags/markers.
231
206
  return stripRichText(message.getText());
232
207
  } else if (message instanceof CometChat.MediaMessage) {
233
- return `${message.getType()} message`;
208
+ const type = message.getType();
209
+ return t(
210
+ type === 'image' ? 'MESSAGE_IMAGE'
211
+ : type === 'video' ? 'MESSAGE_VIDEO'
212
+ : type === 'audio' ? 'MESSAGE_AUDIO'
213
+ : type === 'file' ? 'MESSAGE_FILE'
214
+ : 'MESSAGE'
215
+ );
234
216
  } else if (message instanceof CometChat.CustomMessage) {
235
217
  // Handle assistant messages
236
218
  if (message.getType() === 'assistant' && message.getData()) {
@@ -241,17 +223,17 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
241
223
  return stripRichText(data.text);
242
224
  }
243
225
  }
244
- return 'Custom message';
226
+ return t('MESSAGE');
245
227
  } else if (message.getType() === 'groupMember') {
246
- return 'Group action message';
228
+ return t('MESSAGE');
247
229
  } else {
248
- return 'Message';
230
+ return t('MESSAGE');
249
231
  }
250
232
  } catch (error) {
251
233
  errorHandler(error, "getMessageText");
252
- return 'Message';
234
+ return t('MESSAGE');
253
235
  }
254
- }, [errorHandler]);
236
+ }, [errorHandler, t]);
255
237
 
256
238
  /**
257
239
  * Function to check if message can be deleted
@@ -532,7 +514,8 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
532
514
  }, []);
533
515
 
534
516
  return (
535
- <View style={mergedStyle.containerStyle}>
517
+ <LayoutDirectionContext.Provider value={direction}>
518
+ <View style={[mergedStyle.containerStyle, directionStyle(direction)]}>
536
519
  {/* Tooltip Menu for Delete Option */}
537
520
  {/* Only show tooltip menu if the message is deletable */}
538
521
  {longPressedMessage.current && canDeleteMessage(longPressedMessage.current) && (
@@ -545,7 +528,7 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
545
528
  nativeEvent: tooltipPosition.current,
546
529
  }}
547
530
  menuItems={[{
548
- text: "Delete",
531
+ text: t("DELETE"),
549
532
  onPress: () => {
550
533
  setConfirmDelete(longPressedMessage.current?.getId());
551
534
  setTooltipVisible(false);
@@ -564,11 +547,11 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
564
547
 
565
548
  {/* Confirm Delete Dialog */}
566
549
  <CometChatConfirmDialog
567
- titleText="Delete Message"
550
+ titleText={t("DELETE_MESSAGE")}
568
551
  icon={<Icon name='delete' size={theme.spacing.spacing.s12} color={theme.color.error} />}
569
- cancelButtonText="Cancel"
570
- confirmButtonText="Delete"
571
- messageText="Are you sure you want to delete this message?"
552
+ cancelButtonText={t("CANCEL")}
553
+ confirmButtonText={t("DELETE")}
554
+ messageText={t("DELETE_MESSAGE_CONFIRM")}
572
555
  isOpen={confirmDelete !== undefined}
573
556
  onCancel={() => setConfirmDelete(undefined)}
574
557
  onConfirm={() => {
@@ -629,6 +612,7 @@ const CometChatAIAssistantChatHistory: React.FC<CometChatAIAssistantChatHistoryP
629
612
  />
630
613
  )}
631
614
  </View>
615
+ </LayoutDirectionContext.Provider>
632
616
  );
633
617
  };
634
618
 
@@ -4,6 +4,7 @@ import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
4
4
  import { useTheme } from "../theme";
5
5
  import type { ColorValue } from "react-native";
6
6
  import { CometChatTheme } from "../theme/type";
7
+ import { useRtlMirror } from "../shared/helper/layoutDirection";
7
8
 
8
9
  /**
9
10
  * Animated skeleton placeholder mimicking chat history in CometChat UI‑Kit.
@@ -116,6 +117,8 @@ const useHistoryElements = (fill: ColorValue) =>
116
117
 
117
118
  export const Skeleton: React.FC<SkeletonProps> = ({ style }) => {
118
119
  const theme = useTheme();
120
+ // ENG-41390: SVG shapes and the shimmer use fixed x positions; flip the whole skeleton in RTL.
121
+ const rtlMirror = useRtlMirror();
119
122
  const get = <K extends keyof SkeletonStyle>(key: K) => getStyleValue(key, style, theme);
120
123
 
121
124
  // Shimmer animation ------------------------------------------
@@ -150,7 +153,7 @@ export const Skeleton: React.FC<SkeletonProps> = ({ style }) => {
150
153
  <ScrollView
151
154
  scrollEnabled={false}
152
155
  showsVerticalScrollIndicator={false}
153
- style={{ backgroundColor: get("containerBackgroundColor") }}
156
+ style={[{ backgroundColor: get("containerBackgroundColor") }, rtlMirror]}
154
157
  >
155
158
  {/* Bottom layer (gradient fill) */}
156
159
  <Svg
@@ -2,6 +2,7 @@ import { ColorValue, ViewStyle, TextStyle } from "react-native";
2
2
  import { deepMerge } from "../shared/helper/helperFunctions";
3
3
  import { CometChatTheme } from "../theme/type";
4
4
  import { DeepPartial } from "../shared/helper/types";
5
+ import { TEXT_START } from "../shared/helper/layoutDirection";
5
6
 
6
7
  export type ChatHistoryStyle = {
7
8
  containerStyle: ViewStyle;
@@ -57,7 +58,7 @@ export const getChatHistoryStyleLight = (
57
58
  fontSize: typography.heading4.medium.fontSize,
58
59
  fontWeight: typography.heading4.medium.fontWeight,
59
60
  color: color.textPrimary,
60
- marginLeft: spacing.margin.m2,
61
+ marginStart: spacing.margin.m2,
61
62
  ...typography.heading4.medium,
62
63
  fontFamily: typography.heading4.medium.fontFamily,
63
64
  },
@@ -81,7 +82,7 @@ export const getChatHistoryStyleLight = (
81
82
  },
82
83
  newChatTextStyle: {
83
84
  fontSize: typography.body.regular.fontSize,
84
- marginLeft: spacing.margin.m3,
85
+ marginStart: spacing.margin.m3,
85
86
  fontWeight: typography.body.regular.fontWeight,
86
87
  color: color.textPrimary,
87
88
  ...typography.body.regular,
@@ -96,6 +97,7 @@ export const getChatHistoryStyleLight = (
96
97
  borderBottomColor: color.borderLight,
97
98
  },
98
99
  sectionHeaderTextStyle: {
100
+ ...TEXT_START,
99
101
  fontSize: typography.caption1.medium.fontSize,
100
102
  fontWeight: typography.caption1.medium.fontWeight,
101
103
  textTransform: 'capitalize',
@@ -106,6 +108,7 @@ export const getChatHistoryStyleLight = (
106
108
  paddingVertical: spacing.padding.p3,
107
109
  },
108
110
  messageTextStyle: {
111
+ ...TEXT_START,
109
112
  fontSize: typography.body.regular.fontSize,
110
113
  lineHeight: 20,
111
114
  color: color.textPrimary,
@@ -141,6 +141,7 @@ import { CometChatComposerErrorBanner } from '../shared/views/CometChatComposerE
141
141
  import { CometChatAttachmentTray } from '../shared/views/CometChatAttachmentPreview';
142
142
  import { CometChatMediaViewer } from '../shared/views/CometChatMediaViewer';
143
143
  import { StagedVideoDurationProbe } from '../shared/views/CometChatAttachmentPreview/StagedVideoDurationProbe';
144
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection, useIosRtlScrollStart } from "../shared/helper/layoutDirection";
144
145
 
145
146
  const { FileManager, CommonUtil } = NativeModules;
146
147
 
@@ -351,6 +352,7 @@ interface EmojiButtonProps {
351
352
  }
352
353
 
353
354
  const EmojiButton = ({ user, group, composerIdMap, replyToMessage, closeReplyPreview, editorRef }: EmojiButtonProps) => {
355
+ const { t } = useCometChatTranslation();
354
356
  const [isPanelOpen, setIsPanelOpen] = React.useState(false);
355
357
  const [keyboardOpen, setKeyboardOpen] = React.useState(false);
356
358
  const theme = useTheme();
@@ -522,7 +524,7 @@ const EmojiButton = ({ user, group, composerIdMap, replyToMessage, closeReplyPre
522
524
  <TouchableOpacity
523
525
  onPress={togglePanel}
524
526
  style={Style.iconButton}
525
- accessibilityHint='Opens the sticker panel'
527
+ accessibilityHint={t('OPEN_STICKER_PANEL')}
526
528
  >
527
529
  <Icon
528
530
  name={isPanelOpen ? "sticker-fill" : "sticker"}
@@ -608,6 +610,8 @@ export interface ComposerInputHandle {
608
610
  }
609
611
 
610
612
  export interface CometChatCompactMessageComposerInterface {
613
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
614
+ layoutDirection?: "ltr" | "rtl";
611
615
  /**
612
616
  * Message composer identifier.
613
617
  * @type {string | number}
@@ -1252,6 +1256,10 @@ export const CometChatCompactMessageComposer = React.forwardRef(
1252
1256
  // path (no staging tray, no multi-upload/fan-out). Default true = multi-attachment.
1253
1257
  enableMultipleAttachments = true,
1254
1258
  } = props;
1259
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
1260
+ const direction = useComponentLayoutDirection(props.layoutDirection);
1261
+ // The rich-text toolbar opens at its start edge on iOS in RTL, recycled native view or not.
1262
+ const toolbarScrollStart = useIosRtlScrollStart(direction);
1255
1263
 
1256
1264
  // The documented names (…ForOutgoingMessage[s]) were declared but never read, so only the
1257
1265
  // aliases had any effect. Honour both, documented name first. Sound is on by default:
@@ -2077,6 +2085,8 @@ export const CometChatCompactMessageComposer = React.forwardRef(
2077
2085
 
2078
2086
  // Clone and store formatter using tracking character as key (matching MessageComposer pattern)
2079
2087
  const newFormatter = CommonUtils.clone(formatter);
2088
+ // Only the composer's copy draws the input box; the app's instance may also draw the list.
2089
+ newFormatter.markAsComposerInput?.();
2080
2090
  // A formatter with no tracking character has no suggestion list, but it still takes part in
2081
2091
  // the send and edit-preview lifecycle — so key it by id instead of dropping it. The prefix
2082
2092
  // keeps it out of reach of the single-character lookup that opens the suggestion list.
@@ -3473,7 +3483,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3473
3483
  flexDirection: 'row',
3474
3484
  alignItems: 'center',
3475
3485
  paddingTop: 5,
3476
- paddingLeft: 5,
3486
+ paddingStart: 5,
3477
3487
  borderTopWidth: 1,
3478
3488
  borderTopColor: theme.color.borderDefault,
3479
3489
  }}
@@ -3486,7 +3496,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3486
3496
  />
3487
3497
  <Text
3488
3498
  style={{
3489
- marginLeft: 5,
3499
+ marginStart: 5,
3490
3500
  color: theme.color.textSecondary,
3491
3501
  ...theme.typography.caption1.regular,
3492
3502
  }}
@@ -3823,7 +3833,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3823
3833
  <Icon name='info-fill' color={theme.color.error} height={16} width={16} />
3824
3834
  <Text
3825
3835
  style={{
3826
- marginLeft: 5,
3836
+ marginStart: 5,
3827
3837
  color: theme.color.error,
3828
3838
  ...theme.typography.caption1.regular,
3829
3839
  }}
@@ -4998,7 +5008,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
4998
5008
  <Animated.View
4999
5009
  style={{
5000
5010
  width: micWidthAnim.interpolate({ inputRange: [0, 1], outputRange: [0, 24] }),
5001
- marginLeft: micWidthAnim.interpolate({ inputRange: [0, 1], outputRange: [-16, 0] }),
5011
+ marginStart: micWidthAnim.interpolate({ inputRange: [0, 1], outputRange: [-16, 0] }),
5002
5012
  overflow: 'hidden' as const,
5003
5013
  }}
5004
5014
  >
@@ -5062,6 +5072,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
5062
5072
  ];
5063
5073
 
5064
5074
  return (
5075
+ <LayoutDirectionContext.Provider value={direction}>
5065
5076
  <>
5066
5077
  {/* Modal for custom views */}
5067
5078
  <Modal
@@ -5088,7 +5099,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
5088
5099
  {...keyboardAvoidingViewProps}
5089
5100
  >
5090
5101
  {/* Outer wrapper with padding (matches Figma: Message Composer) */}
5091
- <View style={wrapperStyle}>
5102
+ <View style={[wrapperStyle, directionStyle(direction)]}>
5092
5103
  {/* Error banner floats ABOVE the composer, over the message list. Anchored to the outer
5093
5104
  wrapper (bottom:100%), NOT the bordered container which clips via overflow:hidden. */}
5094
5105
  <View
@@ -5185,8 +5196,8 @@ export const CometChatCompactMessageComposer = React.forwardRef(
5185
5196
  titleStyle={{ color: theme.color.textHighlight as string }}
5186
5197
  style={{
5187
5198
  borderRadius: 8,
5188
- borderLeftWidth: 3,
5189
- borderLeftColor: theme.color.borderHighlight as string,
5199
+ borderStartWidth: 3,
5200
+ borderStartColor: theme.color.borderHighlight as string,
5190
5201
  margin: theme.spacing?.padding?.p1 || 4,
5191
5202
  }}
5192
5203
  />
@@ -5377,6 +5388,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
5377
5388
  }}>
5378
5389
  <ScrollView
5379
5390
  testID="toolbar-scrollview"
5391
+ {...toolbarScrollStart}
5380
5392
  horizontal
5381
5393
  showsHorizontalScrollIndicator={false}
5382
5394
  contentContainerStyle={richTextToolbarStyles.toolbarScrollContent}
@@ -5516,6 +5528,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
5516
5528
  }}
5517
5529
  />
5518
5530
  </>
5531
+ </LayoutDirectionContext.Provider>
5519
5532
  );
5520
5533
  }
5521
5534
  );
@@ -51,27 +51,27 @@ export const Style = StyleSheet.create({
51
51
  leftIconsContainer: {
52
52
  flexDirection: 'row',
53
53
  alignItems: 'center',
54
- marginRight: 12,
54
+ marginEnd: 12,
55
55
  },
56
56
  // Left icons container - top aligned for expanded state
57
57
  leftIconsContainerTop: {
58
58
  flexDirection: 'row',
59
59
  alignItems: 'flex-start',
60
- marginRight: 12,
60
+ marginEnd: 12,
61
61
  paddingTop: 0,
62
62
  },
63
63
  // Right icons container with spacing (matches Figma: Icons right - gap 16px)
64
64
  rightIconsContainer: {
65
65
  flexDirection: 'row',
66
66
  alignItems: 'center',
67
- marginLeft: 12,
67
+ marginStart: 12,
68
68
  gap: 16,
69
69
  },
70
70
  // Right icons container - top aligned for expanded state
71
71
  rightIconsContainerTop: {
72
72
  flexDirection: 'row',
73
73
  alignItems: 'flex-start',
74
- marginLeft: 12,
74
+ marginStart: 12,
75
75
  paddingTop: 0,
76
76
  gap: 16,
77
77
  },
@@ -156,7 +156,7 @@ export const Style = StyleSheet.create({
156
156
  flexDirection: 'row',
157
157
  alignItems: 'center',
158
158
  paddingTop: 5,
159
- paddingLeft: 5,
159
+ paddingStart: 5,
160
160
  borderTopWidth: 1,
161
161
  },
162
162
  // Mention limit icon
@@ -166,7 +166,7 @@ export const Style = StyleSheet.create({
166
166
  },
167
167
  // Mention limit text
168
168
  mentionLimitText: {
169
- marginLeft: 5,
169
+ marginStart: 5,
170
170
  },
171
171
  });
172
172
 
@@ -188,7 +188,7 @@ const getAttachmentOptionsStyle = (
188
188
  titleStyle: {
189
189
  ...typography.body.regular,
190
190
  color: color.textPrimary,
191
- paddingLeft: spacing.padding.p1,
191
+ paddingStart: spacing.padding.p1,
192
192
  },
193
193
  iconStyle: {
194
194
  height: 24,
@@ -84,12 +84,15 @@ import { conversationRowTestID } from "../shared/offline/stateContract";
84
84
  import { onRemotePinEvent } from "../shared/offline/conversationPins";
85
85
  import { OfflineNoticeView, useOfflineNotice } from "../shared/offline/OfflineViews";
86
86
  import { deepMerge } from "../shared/helper/helperFunctions";
87
+ import { sentenceWithNames, stripBidiControls } from "../shared/helper/textDirection";
88
+ import { SenderLabel } from "../shared/views/SenderLabel";
87
89
  import Delete from "../shared/icons/components/delete";
88
90
  import { DeepPartial } from "../shared/helper/types";
89
91
  import { CometChatTheme } from "../theme/type";
90
92
  import { MenuItemInterface } from "../shared/views/CometChatTooltipMenu/CometChatTooltipMenu";
91
93
  import { JSX } from "react";
92
94
  import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
95
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection, TEXT_START } from "../shared/helper/layoutDirection";
93
96
 
94
97
  let __listenerIdCounter = 0;
95
98
 
@@ -107,6 +110,8 @@ const conversationRichTextFormatter = new CometChatRichTextFormatter();
107
110
  * Interface defining props for the CometChatConversations component.
108
111
  */
109
112
  export interface ConversationInterface {
113
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
114
+ layoutDirection?: "ltr" | "rtl";
110
115
  /**
111
116
  * Hide the submit (selection) button.
112
117
  */
@@ -340,6 +345,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
340
345
  searchText = "",
341
346
  SearchView,
342
347
  } = props;
348
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
349
+ const direction = useComponentLayoutDirection(props.layoutDirection);
343
350
 
344
351
  // Reference for accessing CometChatList methods
345
352
  const conversationListRef = React.useRef<CometChatListActionsInterface>(null);
@@ -682,7 +689,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
682
689
  if (isTyping && !newConversation?.["lastMessage"]?.["typing"]) {
683
690
  newConversation["lastMessage"]["typing"] =
684
691
  args[0]?.receiverType === "group"
685
- ? `${args[0].sender.name} ${t("IS_TYPING")}`
692
+ ? sentenceWithNames(`\${name} ${t("IS_TYPING")}`, { name: args[0].sender.name })
686
693
  : t("IS_TYPING");
687
694
  } else {
688
695
  delete newConversation["lastMessage"]["typing"];
@@ -876,7 +883,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
876
883
  if (message.hasOwnProperty("deletedAt")) return;
877
884
 
878
885
  if (shouldMarkAsDelivered(message)) {
879
- CometChat.markAsDelivered(message);
886
+ CometChat.markAsDelivered(message).catch((error: any) => {
887
+ console.log("Error marking message as delivered", error);
888
+ });
880
889
  playNotificationSound();
881
890
  }
882
891
  };
@@ -1190,7 +1199,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1190
1199
  messageText = (
1191
1200
  <View style={conversationPreviewStyles.blockquoteRow}>
1192
1201
  <View style={[conversationPreviewStyles.blockquoteBar, { backgroundColor: theme?.color?.primary as string }]} />
1193
- <Text numberOfLines={1} ellipsizeMode='tail' style={[mergedStyles.itemStyle.subtitleStyle, conversationPreviewStyles.blockquoteText]}>
1202
+ <Text numberOfLines={1} ellipsizeMode='tail' style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle, conversationPreviewStyles.blockquoteText]}>
1194
1203
  {messageText}
1195
1204
  </Text>
1196
1205
  </View>
@@ -1198,7 +1207,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1198
1207
  } else if (blockType === 'list') {
1199
1208
  messageText = (
1200
1209
  <Text
1201
- style={[mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
1210
+ style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
1202
1211
  numberOfLines={1}
1203
1212
  ellipsizeMode='tail'
1204
1213
  >
@@ -1208,7 +1217,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1208
1217
  } else if (messageText && typeof messageText === 'string') {
1209
1218
  messageText = (
1210
1219
  <Text
1211
- style={[mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
1220
+ style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
1212
1221
  numberOfLines={1}
1213
1222
  ellipsizeMode='tail'
1214
1223
  >
@@ -1219,7 +1228,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1219
1228
  // JSX element from rich text formatter — wrap with truncation
1220
1229
  messageText = (
1221
1230
  <Text
1222
- style={[mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
1231
+ style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
1223
1232
  numberOfLines={1}
1224
1233
  ellipsizeMode='tail'
1225
1234
  >
@@ -1228,28 +1237,23 @@ export const CometChatConversations = (props: ConversationInterface) => {
1228
1237
  );
1229
1238
  }
1230
1239
 
1231
- let groupText = "";
1240
+ let groupSender = "";
1232
1241
  if (!(lastMessage instanceof CometChat.Action)) {
1233
1242
  if (lastMessage.getReceiverType() == ReceiverTypeConstants.group) {
1234
- if (lastMessage.getSender().getUid() == loggedInUserId) {
1235
- groupText = t("YOU") + ": ";
1236
- } else {
1237
- groupText = lastMessage.getSender().getName() + ": ";
1238
- }
1243
+ groupSender =
1244
+ lastMessage.getSender().getUid() == loggedInUserId
1245
+ ? t("YOU")
1246
+ : lastMessage.getSender().getName();
1239
1247
  }
1240
1248
  }
1241
1249
 
1242
1250
  return (
1243
1251
  <>
1244
- {groupText && (
1245
- <Text
1246
- style={[mergedStyles.itemStyle.subtitleStyle, conversationPreviewStyles.subtitleClamp]}
1247
- numberOfLines={1}
1248
- ellipsizeMode='tail'
1249
- >
1250
- {groupText}
1251
- </Text>
1252
- )}
1252
+ <SenderLabel
1253
+ name={groupSender}
1254
+ textStyle={mergedStyles.itemStyle.subtitleStyle}
1255
+ containerStyle={conversationPreviewStyles.subtitleClamp}
1256
+ />
1253
1257
  {messageText}
1254
1258
  </>
1255
1259
  );
@@ -1323,7 +1327,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1323
1327
  if (!lastMessage)
1324
1328
  return (
1325
1329
  <Text
1326
- style={[mergedStyles.itemStyle.subtitleStyle]}
1330
+ style={[TEXT_START, mergedStyles.itemStyle.subtitleStyle]}
1327
1331
  numberOfLines={1}
1328
1332
  ellipsizeMode={"tail"}
1329
1333
  >
@@ -1337,7 +1341,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1337
1341
  <Text
1338
1342
  numberOfLines={1}
1339
1343
  ellipsizeMode={"tail"}
1340
- style={[mergedStyles.typingIndicatorStyle]}
1344
+ style={[TEXT_START, mergedStyles.typingIndicatorStyle]}
1341
1345
  >
1342
1346
  {params.typingText}
1343
1347
  </Text>
@@ -1416,7 +1420,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1416
1420
  <View
1417
1421
  accessible={true}
1418
1422
  accessibilityLabel={t("PINNED") ?? "Pinned"}
1419
- style={{ marginRight: theme.spacing.margin.m1 }}
1423
+ style={{ marginEnd: theme.spacing.margin.m1 }}
1420
1424
  >
1421
1425
  <Icon name='keep-fill' color={theme.color.iconSecondary} height={14} width={14} />
1422
1426
  </View>
@@ -1452,7 +1456,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1452
1456
  <View
1453
1457
  accessible={true}
1454
1458
  accessibilityLabel={t("PINNED") ?? "Pinned"}
1455
- style={{ marginRight: theme.spacing.margin.m1 }}
1459
+ style={{ marginEnd: theme.spacing.margin.m1 }}
1456
1460
  >
1457
1461
  <Icon name='keep-fill' color={theme.color.iconSecondary} height={14} width={14} />
1458
1462
  </View>
@@ -2152,9 +2156,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
2152
2156
  <Text
2153
2157
  numberOfLines={1}
2154
2158
  ellipsizeMode='tail'
2155
- style={mergedStyles.itemStyle.titleStyle}
2159
+ style={[TEXT_START, mergedStyles.itemStyle.titleStyle]}
2156
2160
  >
2157
- {conversationWith.getName()}
2161
+ {stripBidiControls(conversationWith.getName())}
2158
2162
  </Text>
2159
2163
  </View>
2160
2164
  );
@@ -2184,7 +2188,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
2184
2188
  }, [getTrailingView, getPinOnlyTrailingView]);
2185
2189
 
2186
2190
  return (
2187
- <View style={mergedStyles.containerStyle}>
2191
+ <LayoutDirectionContext.Provider value={direction}>
2192
+ <View style={[mergedStyles.containerStyle, directionStyle(direction)]}>
2188
2193
  <CometChatList
2189
2194
  AppBarOptions={AppBarOptions}
2190
2195
  onError={onError}
@@ -2311,7 +2316,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
2311
2316
  ...(deleteConversationOptionVisibility
2312
2317
  ? [
2313
2318
  {
2314
- text: "Delete",
2319
+ text: t("DELETE"),
2315
2320
  onPress: () => {
2316
2321
  setConfirmDelete(longPressId.current);
2317
2322
  setTooltipVisible(false);
@@ -2377,6 +2382,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
2377
2382
  />
2378
2383
  ) : null}
2379
2384
  </View>
2385
+ </LayoutDirectionContext.Provider>
2380
2386
  );
2381
2387
  };
2382
2388
 
@@ -2412,7 +2418,7 @@ const conversationPreviewStyles = StyleSheet.create({
2412
2418
  width: 3,
2413
2419
  borderRadius: 1.5,
2414
2420
  marginVertical: 3,
2415
- marginLeft: 4,
2421
+ marginStart: 4,
2416
2422
  },
2417
2423
  blockquoteText: {
2418
2424
  flex: 1,