@cometchat/chat-uikit-react-native 5.5.4 → 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 (215) 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/FileManager.java +78 -3
  4. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardDirectionWatcher.kt +64 -0
  5. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardLanguageDirection.kt +44 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +287 -49
  7. package/android/src/main/java/com/reactnativecometchatuikit/SafeFileName.java +78 -0
  8. package/ios/CCLocalFileGuard.h +19 -0
  9. package/ios/CCLocalFileGuard.m +34 -0
  10. package/ios/CometChatKeyboardModule.m +9 -0
  11. package/ios/CometChatKeyboardModule.swift +71 -0
  12. package/ios/FileManager.m +70 -6
  13. package/ios/KeyboardLanguageDirection.swift +24 -0
  14. package/ios/RichTextEditorView.swift +253 -51
  15. package/ios/RichTextEditorViewManager.m +1 -0
  16. package/ios/VideoManager.m +1 -1
  17. package/package.json +18 -3
  18. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +41 -57
  19. package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +4 -1
  20. package/src/CometChatAIAssistantChatHistory/style.ts +5 -2
  21. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +145 -63
  22. package/src/CometChatCompactMessageComposer/styles.ts +7 -7
  23. package/src/CometChatConversations/CometChatConversations.tsx +276 -147
  24. package/src/CometChatConversations/Skeleton.tsx +4 -1
  25. package/src/CometChatConversations/style.ts +1 -1
  26. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +39 -18
  27. package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
  28. package/src/CometChatGroupMembers/style.ts +6 -4
  29. package/src/CometChatGroups/CometChatGroups.tsx +74 -58
  30. package/src/CometChatGroups/GroupsStyle.ts +1 -1
  31. package/src/CometChatGroups/Skeleton.tsx +4 -1
  32. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +190 -96
  33. package/src/CometChatMessageComposer/styles.tsx +1 -1
  34. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +28 -15
  35. package/src/CometChatMessageHeader/listners.ts +76 -56
  36. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
  37. package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
  38. package/src/CometChatMessageList/CometChatMessageList.tsx +1465 -313
  39. package/src/CometChatMessageList/SwipeToReplyView.tsx +61 -0
  40. package/src/CometChatMessageList/style.ts +32 -32
  41. package/src/CometChatMessageList/swipeToReply.ts +25 -0
  42. package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +81 -10
  43. package/src/CometChatNotificationFeed/style.ts +1 -1
  44. package/src/CometChatNotificationFeed/utils.ts +17 -18
  45. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +82 -3
  46. package/src/CometChatPinnedMessages/style.ts +5 -5
  47. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +2 -0
  48. package/src/CometChatRichTextEditor/index.tsx +3 -0
  49. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +83 -15
  50. package/src/CometChatSavedMessages/style.ts +3 -3
  51. package/src/CometChatSearch/CometChatSearch.tsx +391 -136
  52. package/src/CometChatSearch/Skeleton.tsx +4 -1
  53. package/src/CometChatSearch/searchLabels.ts +26 -0
  54. package/src/CometChatSearch/style.ts +7 -7
  55. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +34 -8
  56. package/src/CometChatThreadHeader/Header.tsx +2 -2
  57. package/src/CometChatUsers/CometChatUsers.tsx +10 -1
  58. package/src/CometChatUsers/Skeleton.tsx +4 -1
  59. package/src/CometChatUsers/style.ts +1 -1
  60. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +27 -1
  61. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +16 -4
  62. package/src/calls/CometChatCallLogs/Skeleton.tsx +4 -1
  63. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +11 -3
  64. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +10 -2
  65. package/src/extensions/CollaborativeBubble/style.ts +4 -4
  66. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
  67. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
  68. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +11 -6
  69. package/src/extensions/LinkPreview/style.ts +6 -6
  70. package/src/extensions/Polls/Header.tsx +1 -1
  71. package/src/extensions/Polls/Polls.tsx +25 -12
  72. package/src/extensions/Polls/PollsBubble.tsx +10 -6
  73. package/src/extensions/Polls/style.ts +4 -4
  74. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +2 -2
  75. package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +1 -1
  76. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +1 -1
  77. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +4 -2
  78. package/src/index.ts +11 -1
  79. package/src/shared/CometChatUiKit/CometChatUIKit.ts +102 -2
  80. package/src/shared/CometChatUiKit/UIKitSettings.ts +28 -0
  81. package/src/shared/events/CometChatUIEventHandler/Listener.ts +10 -0
  82. package/src/shared/events/index.ts +4 -0
  83. package/src/shared/events/offline.ts +28 -0
  84. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +18 -13
  85. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +15 -7
  86. package/src/shared/formatters/CometChatTextFormatter.ts +11 -0
  87. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +7 -4
  88. package/src/shared/framework/MessageDataSource.tsx +51 -108
  89. package/src/shared/helper/LocalizedDateHelper.ts +64 -4
  90. package/src/shared/helper/helperFunctions.ts +71 -4
  91. package/src/shared/helper/keyboardDirection.ts +54 -0
  92. package/src/shared/helper/layoutDirection.ts +205 -0
  93. package/src/shared/helper/pluralRules.ts +67 -0
  94. package/src/shared/helper/textDirection.ts +118 -0
  95. package/src/shared/icons/Icon.tsx +37 -2
  96. package/src/shared/icons/components/format-list-numbered-rtl.tsx +15 -0
  97. package/src/shared/index.ts +2 -0
  98. package/src/shared/offline/OfflineHub.ts +651 -0
  99. package/src/shared/offline/OfflineMediaBubble.tsx +49 -0
  100. package/src/shared/offline/OfflineViews.tsx +222 -0
  101. package/src/shared/offline/conversationPins.ts +137 -0
  102. package/src/shared/offline/conversations.ts +325 -0
  103. package/src/shared/offline/frameProbe.ts +24 -0
  104. package/src/shared/offline/gate.ts +94 -0
  105. package/src/shared/offline/groupActions.ts +81 -0
  106. package/src/shared/offline/identity.ts +162 -0
  107. package/src/shared/offline/index.ts +76 -0
  108. package/src/shared/offline/media.ts +247 -0
  109. package/src/shared/offline/notices.ts +84 -0
  110. package/src/shared/offline/reconcile.ts +296 -0
  111. package/src/shared/offline/searchOutcome.ts +62 -0
  112. package/src/shared/offline/send.ts +430 -0
  113. package/src/shared/offline/stateContract.ts +85 -0
  114. package/src/shared/offline/threadReplies.ts +125 -0
  115. package/src/shared/offline/twoPhase.ts +372 -0
  116. package/src/shared/offline/unsentActions.ts +168 -0
  117. package/src/shared/offline/useOfflineMediaUri.ts +87 -0
  118. package/src/shared/offline/useOfflineReconnect.ts +25 -0
  119. package/src/shared/offline/useOfflineSessionEnded.ts +22 -0
  120. package/src/shared/offline/useOfflineUploadTray.ts +76 -0
  121. package/src/shared/offline/usePresenceHidden.ts +33 -0
  122. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +2 -0
  123. package/src/shared/resources/CometChatLocalizeNew/resources/ar/translation.json +720 -0
  124. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -3
  125. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +75 -4
  126. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +74 -3
  127. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +75 -4
  128. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +74 -3
  129. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +74 -3
  130. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +74 -3
  131. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +74 -3
  132. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +74 -3
  133. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +82 -3
  134. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +74 -3
  135. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +74 -3
  136. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +74 -3
  137. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +90 -3
  138. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +74 -3
  139. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +74 -3
  140. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +74 -3
  141. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +74 -3
  142. package/src/shared/services/UploadQueueService.ts +106 -1
  143. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
  144. package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
  145. package/src/shared/utils/MessageReceiptUtils.ts +8 -0
  146. package/src/shared/utils/MessageUtils.tsx +14 -14
  147. package/src/shared/utils/PermissionUtil.ts +16 -5
  148. package/src/shared/utils/SavedMessagesHelper.ts +18 -1
  149. package/src/shared/utils/attachmentLimits.ts +3 -2
  150. package/src/shared/utils/catchUpCursor.ts +36 -0
  151. package/src/shared/utils/conversationUtils.ts +3 -5
  152. package/src/shared/utils/failedMessageRetry.ts +73 -0
  153. package/src/shared/utils/fileIconFontSize.ts +10 -0
  154. package/src/shared/utils/fileSizeLabel.ts +16 -0
  155. package/src/shared/utils/groupActionText.ts +75 -0
  156. package/src/shared/utils/messageIdentity.ts +38 -0
  157. package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +12 -8
  158. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +1 -1
  159. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +5 -3
  160. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +22 -17
  161. package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +45 -12
  162. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
  163. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +20 -8
  164. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -4
  165. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +6 -2
  166. package/src/shared/views/CometChatComposerErrorBanner.tsx +3 -1
  167. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +8 -3
  168. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +2 -2
  169. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -3
  170. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -8
  171. package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
  172. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +13 -27
  173. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +65 -15
  174. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
  175. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +56 -25
  176. package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +41 -21
  177. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +7 -3
  178. package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +7 -3
  179. package/src/shared/views/CometChatList/CometChatList.tsx +478 -21
  180. package/src/shared/views/CometChatList/Header.tsx +5 -2
  181. package/src/shared/views/CometChatList/sectionLetter.ts +44 -0
  182. package/src/shared/views/CometChatList/styles.ts +7 -7
  183. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +6 -4
  184. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +16 -10
  185. package/src/shared/views/CometChatMediaRecorder/Timer.tsx +5 -1
  186. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +43 -16
  187. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
  188. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +19 -2
  189. package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
  190. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +59 -12
  191. package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +2 -2
  192. package/src/shared/views/CometChatReactionList/Skeleton.tsx +4 -1
  193. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +6 -2
  194. package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +7 -3
  195. package/src/shared/views/CometChatReportDialog/style.ts +1 -1
  196. package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +1 -1
  197. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -0
  198. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +20 -13
  199. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -2
  200. package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +1 -1
  201. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +29 -3
  202. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +20 -30
  203. package/src/shared/views/CometChatTooltipMenu/tooltipPosition.ts +43 -0
  204. package/src/shared/views/CometChatVideoBubble/style.ts +2 -2
  205. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +4 -1
  206. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +58 -24
  207. package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +24 -12
  208. package/src/shared/views/SenderLabel.tsx +41 -0
  209. package/src/theme/default/default.ts +1 -1
  210. package/src/theme/type.ts +17 -0
  211. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  212. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  213. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  214. package/android/.gradle/7.4/gc.properties +0 -0
  215. package/android/.gradle/vcs-1/gc.properties +0 -0
@@ -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,10 +26,16 @@ 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';
32
+ import { useMediaOutOfReach, useOfflineMediaUri } from '../../offline/useOfflineMediaUri';
33
+ import { mediaActionSource } from '../../offline/media';
34
+ import { MediaOutOfReachLabel } from '../../offline/OfflineViews';
30
35
  import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
31
36
  import { ReactNativeZoomableView } from '../../libs/ImageZoom';
32
37
  import { clampIndex, isImageMime, isVideoMime, nextIndexForSwipe } from './mediaViewerUtils';
38
+ import { directionStyle, useComponentLayoutDirection } from "../../helper/layoutDirection";
33
39
 
34
40
  /** Default: an item is previewable if it's an image or a video. A per-kind bubble (ImagesBubble /
35
41
  * VideosBubble) overrides this so anything outside its own kind renders the "No preview" page. */
@@ -52,16 +58,16 @@ export interface CometChatMediaViewerProps {
52
58
  canPreview?: (att: CometChat.Attachment) => boolean;
53
59
  }
54
60
 
55
- type DownloadState = 'IDLE' | 'DOWNLOADING' | 'DONE' | 'FAILED';
61
+ type DownloadState = 'IDLE' | 'DOWNLOADING' | 'DONE' | 'FAILED' | 'OUT_OF_REACH';
56
62
 
57
63
  const { FileManager } = NativeModules;
58
64
  const { width: SCREEN_W } = Dimensions.get('window');
59
65
 
60
66
  function formatFileSize(bytes: number): string {
61
67
  if (!(bytes > 0)) return ''; // undefined / 0 / NaN → show nothing (not "undefined B")
62
- if (bytes >= 1_048_576) return `${(bytes / 1_048_576).toFixed(1)} MB`;
63
- if (bytes >= 1_024) return `${(bytes / 1_024).toFixed(0)} KB`;
64
- 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);
65
71
  }
66
72
 
67
73
 
@@ -73,8 +79,10 @@ export const CometChatMediaViewer = ({
73
79
  message,
74
80
  canPreview = defaultCanPreview,
75
81
  }: CometChatMediaViewerProps) => {
76
- const { t } = useCometChatTranslation();
82
+ const { t, language } = useCometChatTranslation();
77
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();
78
86
  const [currentIndex, setCurrentIndex] = useState(() => clampIndex(startIndex, mediaItems.length));
79
87
  const [mediaLoaded, setMediaLoaded] = useState(false);
80
88
  const [mediaError, setMediaError] = useState(false);
@@ -102,6 +110,11 @@ export const CometChatMediaViewer = ({
102
110
  // previewable → they render the "No preview available" page instead of the image/video.
103
111
  const previewable = current ? canPreview(current) : false;
104
112
  const isVideo = previewable && current ? isVideoMime(current.getMimeType?.() ?? '') : false;
113
+ // Offline ON: the SDK's cached copy (a playable copy for video), else the URL as today.
114
+ const currentUri = useOfflineMediaUri(current, { playable: isVideo });
115
+ // Offline ON, no saved copy, no connection: nothing to show or download (BEH-MEDIA-18).
116
+ const outOfReachRaw = useMediaOutOfReach(current);
117
+ const outOfReach = !!current && outOfReachRaw;
105
118
 
106
119
  const mediaItemsRef = useRef(mediaItems);
107
120
  // Keep the ref in sync outside render (not during it) so the PanResponder closure reads the latest list.
@@ -147,8 +160,14 @@ export const CometChatMediaViewer = ({
147
160
 
148
161
  const handleDownload = () => {
149
162
  if (!current || downloadState === 'DOWNLOADING' || downloadState === 'DONE') return;
163
+ // Offline ON: the saved file, never the URL; offline with no copy there is nothing to download.
164
+ const source = mediaActionSource(current);
165
+ if (source.kind === 'unavailable') {
166
+ setDownloadState('OUT_OF_REACH');
167
+ return;
168
+ }
150
169
  setDownloadState('DOWNLOADING');
151
- FileManager?.checkAndDownload(current.getUrl(), current.getName(), (result: string) => {
170
+ FileManager?.checkAndDownload(source.uri, current.getName(), (result: string) => {
152
171
  try {
153
172
  const parsed = JSON.parse(result);
154
173
  setDownloadState(parsed.success ? 'DONE' : 'FAILED');
@@ -165,7 +184,7 @@ export const CometChatMediaViewer = ({
165
184
  ? `${current.getName().substring(0, 19)}…`
166
185
  : current.getName();
167
186
 
168
- const counterLabel = `${currentIndex + 1} / ${mediaItems.length}`;
187
+ const counterLabel = localizeDigits(`${currentIndex + 1} / ${mediaItems.length}`, language);
169
188
 
170
189
  return (
171
190
  <Modal
@@ -175,7 +194,7 @@ export const CometChatMediaViewer = ({
175
194
  onRequestClose={onClose}
176
195
  statusBarTranslucent
177
196
  >
178
- <View testID="media-viewer" style={styles.root}>
197
+ <View testID="media-viewer" style={[styles.root, directionStyle(direction)]}>
179
198
  {/* Header */}
180
199
  <View style={styles.header}>
181
200
  <TouchableOpacity
@@ -183,7 +202,7 @@ export const CometChatMediaViewer = ({
183
202
  onPress={onClose}
184
203
  style={styles.headerBtn}
185
204
  accessibilityRole="button"
186
- accessibilityLabel="Close viewer"
205
+ accessibilityLabel={t("CLOSE")}
187
206
  >
188
207
  <Icon name="arrow-back-fill" color="#fff" height={22} width={22} />
189
208
  </TouchableOpacity>
@@ -199,7 +218,7 @@ export const CometChatMediaViewer = ({
199
218
  onPress={handleDownload}
200
219
  style={styles.headerBtn}
201
220
  accessibilityRole="button"
202
- accessibilityLabel="Download"
221
+ accessibilityLabel={t("DOWNLOAD")}
203
222
  disabled={downloadState === 'DOWNLOADING'}
204
223
  >
205
224
  {downloadState === 'DOWNLOADING' ? (
@@ -214,7 +233,7 @@ export const CometChatMediaViewer = ({
214
233
 
215
234
  {/* Media area — swipeable */}
216
235
  <View style={styles.mediaArea} {...panResponder.panHandlers}>
217
- {previewable && !mediaLoaded && !mediaError && (
236
+ {previewable && !mediaLoaded && !mediaError && !outOfReach && (
218
237
  <ActivityIndicator
219
238
  color="#fff"
220
239
  size="large"
@@ -241,7 +260,7 @@ export const CometChatMediaViewer = ({
241
260
  disabled={downloadState === 'DOWNLOADING'}
242
261
  style={[styles.downloadBtn, { backgroundColor: theme.color.primary }]}
243
262
  accessibilityRole="button"
244
- accessibilityLabel="Download"
263
+ accessibilityLabel={t("DOWNLOAD")}
245
264
  >
246
265
  {downloadState === 'DOWNLOADING' ? (
247
266
  <ActivityIndicator color="#fff" size="small" />
@@ -259,6 +278,14 @@ export const CometChatMediaViewer = ({
259
278
  : t('DOWNLOAD') || 'Download'}
260
279
  </Text>
261
280
  </TouchableOpacity>
281
+ {downloadState === 'OUT_OF_REACH' ? (
282
+ <MediaOutOfReachLabel t={t} textStyle={styles.errorText} />
283
+ ) : null}
284
+ </View>
285
+ ) : outOfReach ? (
286
+ // "Available when online": the file is not on the device and there is no connection.
287
+ <View style={styles.errorBox}>
288
+ <MediaOutOfReachLabel t={t} textStyle={styles.errorText} />
262
289
  </View>
263
290
  ) : mediaError ? (
264
291
  <View style={styles.errorBox}>
@@ -272,7 +299,7 @@ export const CometChatMediaViewer = ({
272
299
  // fight the control taps (B3).
273
300
  <View style={styles.videoWrapper}>
274
301
  <Video
275
- source={{ uri: current.getUrl() }}
302
+ source={{ uri: currentUri }}
276
303
  controls={true}
277
304
  // The <Modal> keeps its children mounted when hidden, so without this the video would
278
305
  // keep playing (audio too) after the viewer closes. Pause whenever the viewer isn't visible.
@@ -308,7 +335,7 @@ export const CometChatMediaViewer = ({
308
335
  onPanResponderTerminationRequest={() => !zoomedRef.current}
309
336
  >
310
337
  <Image
311
- source={{ uri: current.getUrl() }}
338
+ source={{ uri: currentUri }}
312
339
  style={styles.fullMedia}
313
340
  resizeMode="contain"
314
341
  onLoad={() => setMediaLoaded(true)}
@@ -324,7 +351,7 @@ export const CometChatMediaViewer = ({
324
351
  style={[styles.navArrow, styles.navLeft]}
325
352
  onPress={() => goTo(currentIndex - 1)}
326
353
  accessibilityRole="button"
327
- accessibilityLabel="Previous"
354
+ accessibilityLabel={t("MEDIA_PREVIOUS")}
328
355
  >
329
356
  <Icon name="arrow-back-fill" color="#fff" height={24} width={24} />
330
357
  </TouchableOpacity>
@@ -334,7 +361,7 @@ export const CometChatMediaViewer = ({
334
361
  style={[styles.navArrow, styles.navRight]}
335
362
  onPress={() => goTo(currentIndex + 1)}
336
363
  accessibilityRole="button"
337
- accessibilityLabel="Next"
364
+ accessibilityLabel={t("MEDIA_NEXT")}
338
365
  >
339
366
  <Icon name="arrow-forward-fill" color="#fff" height={24} width={24} />
340
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,12 +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
140
+ testID="cc-composer-input"
126
141
  ref={messageInputRef}
127
- style={style?.textStyle as TextStyle}
142
+ style={[inputAlign, style?.textStyle as TextStyle]}
128
143
  onChangeText={onChangeText}
129
144
  placeholderTextColor={style?.placeHolderTextColor as ColorValue}
130
145
  multiline
@@ -133,11 +148,13 @@ export const CometChatMessageInput = (props: CometChatMessageInputInterface) =>
133
148
  onSelectionChange={onSelectionChange}
134
149
  selection={selection}
135
150
  onFocus={() => {
151
+ setFocused(true);
136
152
  CometChatUIEventHandler.emitUIEvent(CometChatUIEvents.hidePanel, {
137
153
  alignment: ViewAlignment.composerBottom,
138
154
  child: () => null, // Hide the panel content.
139
155
  });
140
156
  }}
157
+ onBlur={() => setFocused(false)}
141
158
  >
142
159
  {text}
143
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
  });