@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
@@ -12,6 +12,7 @@ import {
12
12
  getLinkConfirmPopupStyleLight,
13
13
  getLinkConfirmPopupStyleDark,
14
14
  } from "./style";
15
+ import { directionStyle, useComponentLayoutDirection, useInputTextAlign } from "../../helper/layoutDirection";
15
16
 
16
17
  export interface CometChatLinkConfirmPopupInterface {
17
18
  /** Whether the popup is visible */
@@ -46,6 +47,9 @@ export const CometChatLinkConfirmPopup = (props: CometChatLinkConfirmPopupInterf
46
47
  } = props;
47
48
 
48
49
  const theme = useTheme();
50
+ const inputAlign = useInputTextAlign(); // ENG-41384
51
+ // Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
52
+ const direction = useComponentLayoutDirection();
49
53
  const { t } = useCometChatTranslation();
50
54
  const styles = useMemo(
51
55
  () =>
@@ -87,7 +91,7 @@ export const CometChatLinkConfirmPopup = (props: CometChatLinkConfirmPopupInterf
87
91
  onRequestClose={handleDismiss}
88
92
  >
89
93
  <TouchableOpacity
90
- style={styles.overlayStyle}
94
+ style={[styles.overlayStyle, directionStyle(direction)]}
91
95
  activeOpacity={1}
92
96
  onPress={handleDismiss}
93
97
  >
@@ -107,7 +111,7 @@ export const CometChatLinkConfirmPopup = (props: CometChatLinkConfirmPopupInterf
107
111
  placeholderTextColor={theme.color.textTertiary as string}
108
112
  value={editText}
109
113
  onChangeText={setEditText}
110
- style={styles.inputStyle}
114
+ style={[inputAlign, styles.inputStyle]}
111
115
  autoFocus
112
116
  />
113
117
  <TextInput
@@ -117,7 +121,7 @@ export const CometChatLinkConfirmPopup = (props: CometChatLinkConfirmPopupInterf
117
121
  placeholderTextColor={theme.color.textTertiary as string}
118
122
  value={editUrl}
119
123
  onChangeText={setEditUrl}
120
- style={styles.inputStyle}
124
+ style={[inputAlign, styles.inputStyle]}
121
125
  keyboardType="url"
122
126
  autoCapitalize="none"
123
127
  />
@@ -31,6 +31,8 @@ import {
31
31
  import Header from "./Header";
32
32
  import styles from "./styles";
33
33
  import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
34
+ import { withSectionHeaders } from "./sectionLetter";
35
+ import { TEXT_START } from "../../helper/layoutDirection";
34
36
  import { isOfflineOn, offlineSdk, sdkConnected } from "../../offline/gate";
35
37
  import { OfflineHub } from "../../offline/OfflineHub";
36
38
  import { appendUnique, fetchTwoPhase, mergeSnapshotPage } from "../../offline/twoPhase";
@@ -1043,7 +1045,7 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
1043
1045
 
1044
1046
  return (
1045
1047
  <View key={`header_${headerLetter}_${index}`}>
1046
- <Text style={[styles.headerLetterStyle, listStyle?.sectionHeaderTextStyle]}>
1048
+ <Text style={[TEXT_START, styles.headerLetterStyle, listStyle?.sectionHeaderTextStyle]}>
1047
1049
  {headerLetter}
1048
1050
  </Text>
1049
1051
  </View>
@@ -1202,20 +1204,11 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
1202
1204
  </View>
1203
1205
  );
1204
1206
  } else {
1205
- let currentLetter = "";
1206
- const listWithHeaders: any[] = [];
1207
1207
  if (list.length) {
1208
- list.forEach((listItem: any) => {
1209
- const chr = listItem?.name && listItem.name[0].toUpperCase();
1210
- if (!hideStickyHeader && chr !== currentLetter && !ItemView) {
1211
- currentLetter = chr;
1212
- listWithHeaders.push({
1213
- value: currentLetter,
1214
- header: true,
1215
- });
1216
- }
1217
- listWithHeaders.push({ value: listItem, header: false });
1218
- });
1208
+ const listWithHeaders: any[] =
1209
+ hideStickyHeader || ItemView
1210
+ ? list.map((listItem: any) => ({ value: listItem, header: false }))
1211
+ : withSectionHeaders(list, (listItem: any) => listItem?.name);
1219
1212
 
1220
1213
  messageContainer = (
1221
1214
  <View style={styles.listContainerStyle}>
@@ -1271,6 +1264,9 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
1271
1264
  }
1272
1265
  keyboardShouldPersistTaps='always'
1273
1266
  keyboardDismissMode={Platform.OS === 'ios' ? 'on-drag' : 'none'}
1267
+ // ENG-40210: keep clipping off. FlatList defaults it ON for Android, where it detaches rows
1268
+ // outside Fabric's mount queue and crashes on cold start (addViewAt IndexOutOfBounds).
1269
+ removeClippedSubviews={false}
1274
1270
  />
1275
1271
  </View>
1276
1272
  );
@@ -15,6 +15,7 @@ import { useTheme } from "../../../theme";
15
15
  import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
16
16
  import { Icon } from "../../icons/Icon";
17
17
  import styles from "./styles";
18
+ import { TEXT_START, useInputTextAlign } from "../../helper/layoutDirection";
18
19
 
19
20
  /**
20
21
  * Props for the Header component.
@@ -170,11 +171,12 @@ export default function Header({
170
171
  titleSeparatorStyle = {},
171
172
  searchStyle,
172
173
  hideHeader = false,
173
- backButtonIconContainerStyle = { marginLeft: 10 },
174
+ backButtonIconContainerStyle = { marginStart: 10 },
174
175
  SearchView,
175
176
  onSearchBarClicked,
176
177
  }: HeaderProps) {
177
178
  const theme = useTheme();
179
+ const inputAlign = useInputTextAlign(); // ENG-41384
178
180
  const { t } = useCometChatTranslation();
179
181
  const inputRef = useRef<React.ComponentRef<typeof TextInput>>(null);
180
182
  // Callers that pass nothing used to get a hardcoded English "Search", which
@@ -209,7 +211,7 @@ export default function Header({
209
211
  ellipsizeMode='tail'
210
212
  numberOfLines={1}
211
213
  allowFontScaling={true}
212
- style={[{ color: theme.color.textPrimary }, titleStyle]}
214
+ style={[TEXT_START, { color: theme.color.textPrimary }, titleStyle]}
213
215
  >
214
216
  {title}
215
217
  </Text>
@@ -331,6 +333,7 @@ export default function Header({
331
333
  numberOfLines={1}
332
334
  allowFontScaling={false}
333
335
  style={[
336
+ inputAlign,
334
337
  {
335
338
  flex: 1,
336
339
  color: theme.color.textPrimary,
@@ -0,0 +1,44 @@
1
+ // Section headers for alphabetical lists (Users, Group Members, …). The list arrives sorted by the
2
+ // server, and a header row starts wherever the key changes — so only names that the server keeps
3
+ // next to each other may share a key, or a key reopens later in the list.
4
+
5
+ // Arabic writes one letter, alif, in several forms: ا, أ (hamza above), إ (hamza below), آ
6
+ // (madda). Arabic lists group them as one letter — the design (Users List, RTL) puts إيمان under
7
+ // أ — and their code points (U+0622–U+0627) keep them together in server order.
8
+ // Not ٱ (wasla, U+0671): it sorts after ي, so folding it would reopen أ at the end of the list.
9
+ const ALIF_FORMS = /^[آأإا]$/;
10
+ const ALIF_HEADER = "أ"; // أ — the label the design uses for the group
11
+ // A missing name has no first character; empty names sort first, so they stay one group.
12
+ const NO_NAME = "#";
13
+
14
+ /** The section header a list item falls under, from the first character of its name. */
15
+ export function sectionLetter(name: string | undefined): string {
16
+ // Whole first character: an emoji is two UTF-16 units, and half of one draws as "�".
17
+ const first = name ? Array.from(name)[0] : undefined;
18
+ if (!first) return NO_NAME;
19
+ // Symbols and emoji keep their own header. One shared "#" reopened: the server sorts "!" before
20
+ // digits, "_" between Z and a, and emoji after every script, so "#" showed up several times.
21
+ if (ALIF_FORMS.test(first)) return ALIF_HEADER;
22
+ // One character: "ß".toUpperCase() is "SS".
23
+ return Array.from(first.toUpperCase())[0];
24
+ // ponytail: Arabic-script variants the server doesn't keep adjacent (Persian ک/ی vs ك/ي) stay
25
+ // separate groups; folding them needs a locale-aware local sort (Intl.Collator), not a key map.
26
+ }
27
+
28
+ /** The list with a header row before each run of items that share a section letter. */
29
+ export function withSectionHeaders<T>(
30
+ list: T[],
31
+ nameOf: (item: T) => string | undefined
32
+ ): Array<{ value: T | string; header: boolean }> {
33
+ const rows: Array<{ value: T | string; header: boolean }> = [];
34
+ let current: string | undefined;
35
+ for (const item of list) {
36
+ const letter = sectionLetter(nameOf(item));
37
+ if (letter !== current) {
38
+ current = letter;
39
+ rows.push({ value: letter, header: true });
40
+ }
41
+ rows.push({ value: item, header: false });
42
+ }
43
+ return rows;
44
+ }
@@ -27,7 +27,7 @@ const styles = StyleSheet.create({
27
27
  width: "100%",
28
28
  },
29
29
  closeButton: {
30
- marginRight: 10,
30
+ marginEnd: 10,
31
31
  },
32
32
  headerRightContainer: {
33
33
  flexDirection: "row",
@@ -43,7 +43,7 @@ const styles = StyleSheet.create({
43
43
  paddingVertical:8,
44
44
  },
45
45
  selectedCountText: {
46
- paddingLeft: 10,
46
+ paddingStart: 10,
47
47
  },
48
48
  searchBox: {
49
49
  height: 40,
@@ -59,20 +59,20 @@ const styles = StyleSheet.create({
59
59
  backButtonStyle: {
60
60
  width: 20,
61
61
  height: 20,
62
- marginRight: 10,
62
+ marginEnd: 10,
63
63
  },
64
64
  searchTextStyle: {
65
65
  flex: 1,
66
66
  padding: 5,
67
67
  fontSize: 17,
68
68
  fontWeight: "400",
69
- marginLeft: 8,
69
+ marginStart: 8,
70
70
  alignSelf: "center",
71
71
  },
72
72
  searchButtonStyle: {
73
73
  width: 16,
74
74
  height: 16,
75
- marginLeft: 11,
75
+ marginStart: 11,
76
76
  marginTop: 10,
77
77
  marginBottom: 10,
78
78
  },
@@ -101,8 +101,8 @@ const styles = StyleSheet.create({
101
101
  dividerStyle: {
102
102
  height: 1,
103
103
  width: "100%",
104
- marginLeft: 16,
105
- marginRight: 16,
104
+ marginStart: 16,
105
+ marginEnd: 16,
106
106
  },
107
107
  listContainerStyle: {
108
108
  width: "100%",
@@ -19,6 +19,8 @@ import {
19
19
  } from "../CometChatStatusIndicator";
20
20
  import { Style } from "./style";
21
21
  import { DeepPartial } from "../../helper/types";
22
+ import { TEXT_START } from "../../helper/layoutDirection";
23
+ import { stripBidiControls } from "../../helper/textDirection";
22
24
 
23
25
  export interface CometChatListItemInterface {
24
26
  /** Forwarded to the row's root node so a caller can address a specific row. */
@@ -155,7 +157,7 @@ export const CometChatListItem = React.memo((props: CometChatListItemInterface)
155
157
  borderColor: theme.color.borderDefault,
156
158
  backgroundColor: selected ? theme.color.primary : theme.color.background1,
157
159
  borderRadius: 5,
158
- marginRight: 12,
160
+ marginEnd: 12,
159
161
  justifyContent: "center",
160
162
  alignItems: "center",
161
163
  zIndex: 2,
@@ -184,8 +186,8 @@ export const CometChatListItem = React.memo((props: CometChatListItemInterface)
184
186
  const getTitleView = () => {
185
187
  if (TitleView) return TitleView;
186
188
  return (
187
- <Text numberOfLines={1} ellipsizeMode='tail' style={titleStyle}>
188
- {title}
189
+ <Text numberOfLines={1} ellipsizeMode='tail' style={[TEXT_START, titleStyle]}>
190
+ {stripBidiControls(title)}
189
191
  </Text>
190
192
  );
191
193
  };
@@ -280,7 +282,7 @@ export const CometChatListItem = React.memo((props: CometChatListItemInterface)
280
282
  <View
281
283
  style={[
282
284
  Style.middleViewStyle,
283
- { padding: 0, paddingLeft: 0 },
285
+ { padding: 0, paddingStart: 0 },
284
286
  titleSubtitleContainerStyle ?? {},
285
287
  ]}
286
288
  >
@@ -3,12 +3,17 @@ import { NativeModules, Text, TouchableOpacity, View } from "react-native";
3
3
  import { useTheme } from "../../../theme";
4
4
  import { Icon } from "../../icons/Icon";
5
5
  import { AnimatedAudioWaves } from "../CometChatAudioBubble/AnimatedAudioWaves";
6
+ import { PLAYER_DIRECTION, PLAYER_TIME_ALIGN } from "../../helper/layoutDirection";
7
+ import { localizeDigits } from "../../helper/LocalizedDateHelper";
8
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew/useCometChatTranslationHook";
6
9
 
7
10
  export interface CometChatAudioPlayerInterface {
8
11
  totalDuration: number;
9
12
  }
10
13
 
11
14
  export const CometChatAudioPlayer = ({ totalDuration }: CometChatAudioPlayerInterface) => {
15
+ // The context language: the provider sets the global one in an effect, a render later.
16
+ const { language } = useCometChatTranslation();
12
17
  const [status, setStatus] = useState<"playing" | "paused" | "stopped">("stopped");
13
18
  const [currentTime, setCurrentTime] = useState(0);
14
19
  const audioBubbleStyles =
@@ -18,17 +23,18 @@ export const CometChatAudioPlayer = ({ totalDuration }: CometChatAudioPlayerInte
18
23
 
19
24
  const displayDuration = useCallback(
20
25
  () => (
21
- <Text style={audioBubbleStyles?.playProgressTextStyle}>
22
- {`${String(Math.floor((currentTime || 0) / 60)).padStart(2, "0")}:${String(
23
- Math.floor((currentTime || 0) % 60)
24
- ).padStart(2, "0")}`}
25
- /
26
- {`${String(Math.floor((totalDuration || 0) / 60)).padStart(2, "0")}:${String(
27
- Math.floor((totalDuration || 0) % 60)
28
- ).padStart(2, "0")}`}
26
+ <Text style={[PLAYER_TIME_ALIGN, audioBubbleStyles?.playProgressTextStyle]}>
27
+ {localizeDigits(
28
+ `${String(Math.floor((currentTime || 0) / 60)).padStart(2, "0")}:${String(
29
+ Math.floor((currentTime || 0) % 60)
30
+ ).padStart(2, "0")}/${String(Math.floor((totalDuration || 0) / 60)).padStart(2, "0")}:${String(
31
+ Math.floor((totalDuration || 0) % 60)
32
+ ).padStart(2, "0")}`,
33
+ language
34
+ )}
29
35
  </Text>
30
36
  ),
31
- [currentTime, totalDuration]
37
+ [currentTime, totalDuration, language]
32
38
  );
33
39
 
34
40
  function clearTimeInterval() {
@@ -74,7 +80,7 @@ export const CometChatAudioPlayer = ({ totalDuration }: CometChatAudioPlayerInte
74
80
  }, []);
75
81
 
76
82
  return (
77
- <View style={audioBubbleStyles?.playViewContainerStyle}>
83
+ <View style={[audioBubbleStyles?.playViewContainerStyle, PLAYER_DIRECTION]}>
78
84
  <TouchableOpacity
79
85
  style={audioBubbleStyles?.playIconContainerStyle}
80
86
  onPress={() => {
@@ -1,6 +1,8 @@
1
1
  import React, { useState, useEffect, useRef, useCallback } from "react";
2
2
  import { StyleSheet, Text, View } from "react-native";
3
3
  import { useTheme } from "../../../theme";
4
+ import { localizeDigits } from "../../helper/LocalizedDateHelper";
5
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew/useCometChatTranslationHook";
4
6
 
5
7
  interface TimerProps {
6
8
  startTime: number;
@@ -10,6 +12,8 @@ interface TimerProps {
10
12
 
11
13
  export const Timer = ({ resetKey, paused }: TimerProps) => {
12
14
  const theme = useTheme();
15
+ // The context language: the provider sets the global one in an effect, a render later.
16
+ const { language } = useCometChatTranslation();
13
17
  const [time, setTime] = useState(0);
14
18
 
15
19
  // We'll store our interval here so we can clear it whenever "paused" changes
@@ -69,7 +73,7 @@ export const Timer = ({ resetKey, paused }: TimerProps) => {
69
73
  },
70
74
  ]}
71
75
  >
72
- {formatTime(time)}
76
+ {localizeDigits(formatTime(time), language)}
73
77
  </Text>
74
78
  </View>
75
79
  );
@@ -26,6 +26,8 @@ import {
26
26
  import { CometChat } from '@cometchat/chat-sdk-react-native';
27
27
  import Video from 'react-native-video';
28
28
  import { Icon } from '../../icons/Icon';
29
+ import { fileSizeLabel } from '../../utils/fileSizeLabel';
30
+ import { localizeDigits } from '../../helper/LocalizedDateHelper';
29
31
  import { useTheme } from '../../../theme';
30
32
  import { useMediaOutOfReach, useOfflineMediaUri } from '../../offline/useOfflineMediaUri';
31
33
  import { mediaActionSource } from '../../offline/media';
@@ -33,6 +35,7 @@ import { MediaOutOfReachLabel } from '../../offline/OfflineViews';
33
35
  import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
34
36
  import { ReactNativeZoomableView } from '../../libs/ImageZoom';
35
37
  import { clampIndex, isImageMime, isVideoMime, nextIndexForSwipe } from './mediaViewerUtils';
38
+ import { directionStyle, useComponentLayoutDirection } from "../../helper/layoutDirection";
36
39
 
37
40
  /** Default: an item is previewable if it's an image or a video. A per-kind bubble (ImagesBubble /
38
41
  * VideosBubble) overrides this so anything outside its own kind renders the "No preview" page. */
@@ -62,9 +65,9 @@ const { width: SCREEN_W } = Dimensions.get('window');
62
65
 
63
66
  function formatFileSize(bytes: number): string {
64
67
  if (!(bytes > 0)) return ''; // undefined / 0 / NaN → show nothing (not "undefined B")
65
- if (bytes >= 1_048_576) return `${(bytes / 1_048_576).toFixed(1)} MB`;
66
- if (bytes >= 1_024) return `${(bytes / 1_024).toFixed(0)} KB`;
67
- return `${bytes} B`;
68
+ if (bytes >= 1_048_576) return fileSizeLabel('FILE_SIZE_MB', (bytes / 1_048_576).toFixed(1));
69
+ if (bytes >= 1_024) return fileSizeLabel('FILE_SIZE_KB', (bytes / 1_024).toFixed(0));
70
+ return fileSizeLabel('FILE_SIZE_BYTES', bytes);
68
71
  }
69
72
 
70
73
 
@@ -76,8 +79,10 @@ export const CometChatMediaViewer = ({
76
79
  message,
77
80
  canPreview = defaultCanPreview,
78
81
  }: CometChatMediaViewerProps) => {
79
- const { t } = useCometChatTranslation();
82
+ const { t, language } = useCometChatTranslation();
80
83
  const theme = useTheme();
84
+ // Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
85
+ const direction = useComponentLayoutDirection();
81
86
  const [currentIndex, setCurrentIndex] = useState(() => clampIndex(startIndex, mediaItems.length));
82
87
  const [mediaLoaded, setMediaLoaded] = useState(false);
83
88
  const [mediaError, setMediaError] = useState(false);
@@ -179,7 +184,7 @@ export const CometChatMediaViewer = ({
179
184
  ? `${current.getName().substring(0, 19)}…`
180
185
  : current.getName();
181
186
 
182
- const counterLabel = `${currentIndex + 1} / ${mediaItems.length}`;
187
+ const counterLabel = localizeDigits(`${currentIndex + 1} / ${mediaItems.length}`, language);
183
188
 
184
189
  return (
185
190
  <Modal
@@ -189,7 +194,7 @@ export const CometChatMediaViewer = ({
189
194
  onRequestClose={onClose}
190
195
  statusBarTranslucent
191
196
  >
192
- <View testID="media-viewer" style={styles.root}>
197
+ <View testID="media-viewer" style={[styles.root, directionStyle(direction)]}>
193
198
  {/* Header */}
194
199
  <View style={styles.header}>
195
200
  <TouchableOpacity
@@ -197,7 +202,7 @@ export const CometChatMediaViewer = ({
197
202
  onPress={onClose}
198
203
  style={styles.headerBtn}
199
204
  accessibilityRole="button"
200
- accessibilityLabel="Close viewer"
205
+ accessibilityLabel={t("CLOSE")}
201
206
  >
202
207
  <Icon name="arrow-back-fill" color="#fff" height={22} width={22} />
203
208
  </TouchableOpacity>
@@ -213,7 +218,7 @@ export const CometChatMediaViewer = ({
213
218
  onPress={handleDownload}
214
219
  style={styles.headerBtn}
215
220
  accessibilityRole="button"
216
- accessibilityLabel="Download"
221
+ accessibilityLabel={t("DOWNLOAD")}
217
222
  disabled={downloadState === 'DOWNLOADING'}
218
223
  >
219
224
  {downloadState === 'DOWNLOADING' ? (
@@ -255,7 +260,7 @@ export const CometChatMediaViewer = ({
255
260
  disabled={downloadState === 'DOWNLOADING'}
256
261
  style={[styles.downloadBtn, { backgroundColor: theme.color.primary }]}
257
262
  accessibilityRole="button"
258
- accessibilityLabel="Download"
263
+ accessibilityLabel={t("DOWNLOAD")}
259
264
  >
260
265
  {downloadState === 'DOWNLOADING' ? (
261
266
  <ActivityIndicator color="#fff" size="small" />
@@ -346,7 +351,7 @@ export const CometChatMediaViewer = ({
346
351
  style={[styles.navArrow, styles.navLeft]}
347
352
  onPress={() => goTo(currentIndex - 1)}
348
353
  accessibilityRole="button"
349
- accessibilityLabel="Previous"
354
+ accessibilityLabel={t("MEDIA_PREVIOUS")}
350
355
  >
351
356
  <Icon name="arrow-back-fill" color="#fff" height={24} width={24} />
352
357
  </TouchableOpacity>
@@ -356,7 +361,7 @@ export const CometChatMediaViewer = ({
356
361
  style={[styles.navArrow, styles.navRight]}
357
362
  onPress={() => goTo(currentIndex + 1)}
358
363
  accessibilityRole="button"
359
- accessibilityLabel="Next"
364
+ accessibilityLabel={t("MEDIA_NEXT")}
360
365
  >
361
366
  <Icon name="arrow-forward-fill" color="#fff" height={24} width={24} />
362
367
  </TouchableOpacity>
@@ -73,6 +73,11 @@ export interface CometChatMessageBubbleInterface {
73
73
  * @type {BubbleStyles}
74
74
  */
75
75
  style?: BubbleStyles;
76
+ /**
77
+ * Grow the bubble to its max width (80% of the row) instead of sizing it to its content.
78
+ * For content with no natural width, such as markdown AI replies.
79
+ */
80
+ fillWidth?: boolean;
76
81
  }
77
82
 
78
83
  /**
@@ -96,6 +101,7 @@ export const CometChatMessageBubble = memo(
96
101
  alignment,
97
102
  id,
98
103
  style,
104
+ fillWidth,
99
105
  }: CometChatMessageBubbleInterface) => {
100
106
  const [_width, setWidth] = useState<number | undefined>();
101
107
 
@@ -126,11 +132,11 @@ export const CometChatMessageBubble = memo(
126
132
  alignItems: alignItems,
127
133
  }}
128
134
  >
129
- <View style={styles.row}>
135
+ <View style={fillWidth ? styles.rowFill : styles.row}>
130
136
  {LeadingView && LeadingView}
131
- <View style={styles.reactionWrap}>
137
+ <View style={fillWidth ? styles.reactionWrapFill : styles.reactionWrap}>
132
138
  {HeaderView && HeaderView}
133
- <View style={{ ...style?.containerStyle, overflow: 'hidden', padding: 0, paddingHorizontal: 0, paddingVertical: 0, paddingTop: 0, paddingBottom: 0, paddingLeft: 0, paddingRight: 0 }} onLayout={handleLayout}>
139
+ <View style={{ ...style?.containerStyle, ...(fillWidth && FILL_SELF), overflow: 'hidden', padding: 0, paddingHorizontal: 0, paddingVertical: 0, paddingTop: 0, paddingBottom: 0, paddingLeft: 0, paddingRight: 0, paddingStart: 0, paddingEnd: 0 }} onLayout={handleLayout}>
134
140
  {ReplyView && ReplyView}
135
141
  <View style={{
136
142
  padding: style?.containerStyle?.padding,
@@ -139,7 +145,9 @@ export const CometChatMessageBubble = memo(
139
145
  paddingTop: style?.containerStyle?.paddingTop,
140
146
  paddingBottom: style?.containerStyle?.paddingBottom,
141
147
  paddingLeft: style?.containerStyle?.paddingLeft,
142
- paddingRight: style?.containerStyle?.paddingRight
148
+ paddingRight: style?.containerStyle?.paddingRight,
149
+ paddingStart: style?.containerStyle?.paddingStart,
150
+ paddingEnd: style?.containerStyle?.paddingEnd
143
151
  }}>
144
152
  {ContentView && ContentView}
145
153
  {StatusInfoView && StatusInfoView}
@@ -171,4 +179,16 @@ const styles = StyleSheet.create({
171
179
  marginStart: 4,
172
180
  maxWidth: "80%",
173
181
  },
182
+ // fillWidth: a definite width from the row down to the content, so percentage widths inside
183
+ // (markdown paragraphs) resolve instead of collapsing the bubble to its minWidth.
184
+ rowFill: {
185
+ flexDirection: "row",
186
+ alignSelf: "stretch",
187
+ },
188
+ reactionWrapFill: {
189
+ marginStart: 4,
190
+ maxWidth: "80%",
191
+ flex: 1,
192
+ },
174
193
  });
194
+ const FILL_SELF = { alignSelf: "stretch" } as const;
@@ -1,4 +1,4 @@
1
- import React, { JSX, RefObject } from "react";
1
+ import React, { JSX, RefObject, useState } from "react";
2
2
  import {
3
3
  ColorValue,
4
4
  TextInput,
@@ -12,6 +12,8 @@ import { CometChatTheme } from "../../../theme/type";
12
12
  import { CometChatUIEventHandler, CometChatUIEvents } from "../../events";
13
13
  import { ViewAlignment } from "../../constants/UIKitConstants";
14
14
  import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
15
+ import { composerHasLetters, useComposerTextAlign } from "../../helper/layoutDirection";
16
+ import { useKeyboardDirection } from "../../helper/keyboardDirection";
15
17
 
16
18
  /**
17
19
  * Props for the CometChatMessageInput component.
@@ -23,6 +25,11 @@ export interface CometChatMessageInputInterface {
23
25
  * @type {string}
24
26
  */
25
27
  text?: string;
28
+ /**
29
+ * The raw input string behind `text` (the composer passes its formatted element as `text`).
30
+ * Decides whether the input has a letter yet, for the caret side when it has none.
31
+ */
32
+ plainText?: string;
26
33
  /**
27
34
  * Placeholder text for the input.
28
35
  *
@@ -107,6 +114,7 @@ export const CometChatMessageInput = (props: CometChatMessageInputInterface) =>
107
114
  const { t } = useCometChatTranslation()
108
115
  const {
109
116
  text = "",
117
+ plainText,
110
118
  placeHolderText = t("ENTER_YOUR_MESSAGE_HERE"),
111
119
  onChangeText,
112
120
  style,
@@ -119,13 +127,19 @@ export const CometChatMessageInput = (props: CometChatMessageInputInterface) =>
119
127
  VoiceRecordingButtonView,
120
128
  selection,
121
129
  } = props;
130
+ // ENG-57281: typed text by its own language; with no letter yet, the keyboard language's side
131
+ // while focused, else the kit's start edge (ENG-41384).
132
+ const [focused, setFocused] = useState(false);
133
+ const hasLetters = composerHasLetters(plainText ?? text);
134
+ const keyboard = useKeyboardDirection(focused && !hasLetters);
135
+ const inputAlign = useComposerTextAlign(hasLetters, keyboard);
122
136
 
123
137
  return (
124
138
  <View style={style?.containerStyle as ViewStyle}>
125
139
  <TextInput
126
140
  testID="cc-composer-input"
127
141
  ref={messageInputRef}
128
- style={style?.textStyle as TextStyle}
142
+ style={[inputAlign, style?.textStyle as TextStyle]}
129
143
  onChangeText={onChangeText}
130
144
  placeholderTextColor={style?.placeHolderTextColor as ColorValue}
131
145
  multiline
@@ -134,11 +148,13 @@ export const CometChatMessageInput = (props: CometChatMessageInputInterface) =>
134
148
  onSelectionChange={onSelectionChange}
135
149
  selection={selection}
136
150
  onFocus={() => {
151
+ setFocused(true);
137
152
  CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
138
153
  alignment: ViewAlignment.composerBottom,
139
154
  child: () => null, // Hide the panel content.
140
155
  });
141
156
  }}
157
+ onBlur={() => setFocused(false)}
142
158
  >
143
159
  {text}
144
160
  </TextInput>
@@ -27,7 +27,9 @@ export interface CometChatNewMessageIndicatorInterface {
27
27
  /**
28
28
  * CometChatNewMessageIndicator is a component for displaying a "New Messages" separator.
29
29
  *
30
- * It renders a horizontal line with a text label in the center.
30
+ * It renders a line that runs from the start edge with the label at the end edge (design:
31
+ * Action Bubble › Divider › New Message Divider — label at the right in LTR, at the left in RTL;
32
+ * the row mirrors by itself, ENG-41392).
31
33
  * The component is fully customizable via styles or by providing a custom view.
32
34
  */
33
35
  export const CometChatNewMessageIndicator = React.memo((props: CometChatNewMessageIndicatorInterface) => {
@@ -49,7 +51,6 @@ export const CometChatNewMessageIndicator = React.memo((props: CometChatNewMessa
49
51
  <View style={indicatorStyles.containerStyle}>
50
52
  <View style={indicatorStyles.lineStyle} />
51
53
  <Text style={indicatorStyles.textStyle} numberOfLines={1}>{text || t("NEW")}</Text>
52
- <View style={indicatorStyles.lineStyle} />
53
54
  </View>
54
55
  );
55
56
  });
@@ -18,6 +18,7 @@ import { Icon } from "../../icons/Icon";
18
18
  import { CometChatUIEventHandler, MessageEvents } from "../../events";
19
19
  import { messageStatus } from "../../utils/CometChatMessageHelper";
20
20
  import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
21
+ import { localizeDigits } from "../../helper/LocalizedDateHelper";
21
22
  import { readListPage } from "../../offline/twoPhase";
22
23
  import { useOfflineReconnect } from "../../offline/useOfflineReconnect";
23
24
  import { ConnectStateView } from "../../offline/OfflineViews";
@@ -81,7 +82,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
81
82
  onListEmpty,
82
83
  } = props;
83
84
  const theme = useTheme();
84
- const {t} =useCometChatTranslation()
85
+ const { t, language } = useCometChatTranslation();
85
86
  const reactionListStyleFromTheme = theme.reactionListStyles.reactionListItemStyle;
86
87
  const tabStyleFromTheme = theme.reactionListStyles.tabStyle;
87
88
 
@@ -501,7 +502,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
501
502
  : tabStyleFromTheme.itemTextStyle
502
503
  }
503
504
  >
504
- {reactionObject?.getCount()}
505
+ {localizeDigits(String(reactionObject?.getCount() ?? ""), language)}
505
506
  </Text>
506
507
  </TouchableOpacity>
507
508
  );
@@ -41,12 +41,12 @@ export const getReactionListStyleLight = (
41
41
  },
42
42
  itemTextStyle: {
43
43
  color: color.textSecondary,
44
- marginLeft: spacing.margin.m1,
44
+ marginStart: spacing.margin.m1,
45
45
  ...typography.body.medium,
46
46
  },
47
47
  selectedItemTextStyle: {
48
48
  color: color.primary,
49
- marginLeft: spacing.margin.m1,
49
+ marginStart: spacing.margin.m1,
50
50
  ...typography.body.medium,
51
51
  },
52
52
  },