@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
@@ -18,6 +18,12 @@ 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";
22
+ import { readListPage } from "../../offline/twoPhase";
23
+ import { useOfflineReconnect } from "../../offline/useOfflineReconnect";
24
+ import { ConnectStateView } from "../../offline/OfflineViews";
25
+ import { OFFLINE_STRING_KEYS } from "../../offline/notices";
26
+ import { CONTRACT_IDS } from "../../offline/stateContract";
21
27
 
22
28
  /**
23
29
  * Props for the CometChatReactionList component.
@@ -76,7 +82,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
76
82
  onListEmpty,
77
83
  } = props;
78
84
  const theme = useTheme();
79
- const {t} =useCometChatTranslation()
85
+ const { t, language } = useCometChatTranslation();
80
86
  const reactionListStyleFromTheme = theme.reactionListStyles.reactionListItemStyle;
81
87
  const tabStyleFromTheme = theme.reactionListStyles.tabStyle;
82
88
 
@@ -84,6 +90,11 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
84
90
  const [currentSelectedReaction, setCurrentSelectedReaction] = useState(selectedReaction || "All");
85
91
  const [reactionList, setReactionList] = useState<CometChat.Reaction[]>();
86
92
  const [state, setState] = useState<"loading" | "error" | "done" | "fetchNextOnScroll">("loading");
93
+ // Offline ON (D84): the device was not connected and has no saved reactions: "Connect to load
94
+ // reactions" shows (the app's own error view instead, if it passed one) and the reactions load
95
+ // again once, by themselves, when the connection is back. Any other error is not loaded again.
96
+ const reloadOnConnectRef = useRef(false);
97
+ const [offlineMiss, setOfflineMiss] = useState(false);
87
98
  const loggedInUser = useRef<CometChat.User | null>(undefined);
88
99
  const newMessageObj = useRef<CometChat.BaseMessage>(CommonUtils.clone(message));
89
100
 
@@ -108,6 +119,13 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
108
119
  showReactions();
109
120
  }, [currentSelectedReaction]);
110
121
 
122
+ // D84 rule 8: the one reload of the offline state.
123
+ useOfflineReconnect(() => {
124
+ if (!reloadOnConnectRef.current) return;
125
+ reloadOnConnectRef.current = false;
126
+ void showReactions();
127
+ });
128
+
111
129
  const _setAllReactions = (_messageReactions: any) => {
112
130
  let totalCount = _messageReactions.reduce((acc: any, curr: any) => acc + curr.count, 0);
113
131
  const allReactionCountObject = new CometChat.ReactionCount("All", totalCount, false);
@@ -152,13 +170,26 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
152
170
  }
153
171
 
154
172
  try {
155
- const list = await requestBuilder.fetchNext();
173
+ // Offline ON: two-phase; offline past the cache the device's reactions show (U6).
174
+ const page = await readListPage<any>(requestBuilder, "next");
175
+ if (page.offline && page.rows.length === 0) {
176
+ // Nothing on the device and not connected: the offline state, loaded again on reconnect (D84 rule 3).
177
+ reloadOnConnectRef.current = true;
178
+ setOfflineMiss(true);
179
+ setState("error");
180
+ return [];
181
+ }
182
+ reloadOnConnectRef.current = false;
183
+ setOfflineMiss(false);
184
+ const list = page.rows;
156
185
  reactionListMap.current[reaction] = list;
157
186
  setState("done");
158
187
  return list;
159
188
  } catch (error: any) {
160
189
  //console.log("error while fetching reactions", error);
161
190
  if (error?.code === "REQUEST_IN_PROGRESS") return null;
191
+ reloadOnConnectRef.current = false;
192
+ setOfflineMiss(false);
162
193
  setState("error");
163
194
  return [];
164
195
  }
@@ -170,11 +201,12 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
170
201
  if (reactionListMap.current[currentSelectedReaction]?.length === 0) {
171
202
  return;
172
203
  } else {
173
- const newList = await requestBuilder.fetchNext();
174
- reactionListMap.current[currentSelectedReaction] = [
175
- ...(reactionListMap.current?.[currentSelectedReaction] || []),
176
- ...newList,
177
- ];
204
+ const page = await readListPage<any>(requestBuilder, "next");
205
+ // A cached page can repeat rows past the last page (SDK known issue): dedupe by id.
206
+ const shown = reactionListMap.current?.[currentSelectedReaction] || [];
207
+ const seen = new Set(shown.map((r: any) => String(r?.getReactionId?.() ?? r?.id ?? "")));
208
+ const newList = page.rows.filter((r: any) => !seen.has(String(r?.getReactionId?.() ?? r?.id ?? "")));
209
+ reactionListMap.current[currentSelectedReaction] = [...shown, ...newList];
178
210
  setReactionList(reactionListMap.current[currentSelectedReaction]);
179
211
  }
180
212
  setState("done");
@@ -189,6 +221,9 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
189
221
  (emoji: string) => {
190
222
  const msgObj = CommonUtils.clone(messageObject);
191
223
 
224
+ // The untouched copy a failed write rolls back to (UIK-MUT-01). The optimistic update below
225
+ // mutates msgObj's own reaction objects, so rolling back to msgObj left the change on screen.
226
+ const rollbackMessage = CommonUtils.clone(msgObj);
192
227
  const messageId = msgObj?.getId();
193
228
  const reactions = msgObj?.getReactions() || [];
194
229
  const emojiObject = reactions?.find((reaction: any) => {
@@ -221,7 +256,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
221
256
  .then((message: any) => {})
222
257
  .catch((error: any) => {
223
258
  CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, {
224
- message: msgObj,
259
+ message: rollbackMessage,
225
260
  status: messageStatus.success,
226
261
  });
227
262
  //console.log(error);
@@ -259,7 +294,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
259
294
  .catch((error: any) => {
260
295
  //console.log(error);
261
296
  CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageEdited, {
262
- message: msgObj,
297
+ message: rollbackMessage,
263
298
  status: messageStatus.success,
264
299
  });
265
300
  });
@@ -375,6 +410,17 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
375
410
 
376
411
  const ErrorView = () => {
377
412
  if (ErrorStateView) return <ErrorStateView />;
413
+ if (offlineMiss) {
414
+ return (
415
+ <ConnectStateView
416
+ testID={CONTRACT_IDS.emptyConnectToLoad}
417
+ title={t(OFFLINE_STRING_KEYS.connectToLoadReactions)}
418
+ containerStyle={theme.reactionListStyles.errorStateStyle?.containerStyle}
419
+ titleStyle={theme.reactionListStyles.errorStateStyle?.titleStyle}
420
+ subtitleStyle={theme.reactionListStyles.errorStateStyle?.subtitleStyle}
421
+ />
422
+ );
423
+ }
378
424
  return (
379
425
  <ErrorEmptyView
380
426
  title={errorStateText ?? "Oops!"}
@@ -413,8 +459,9 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
413
459
 
414
460
  return (
415
461
  <View style={{ flex: 1 }}>
416
- {/* Slider for reactions */}
417
- {state != "error" && (
462
+ {/* Slider for reactions. Offline with nothing loaded (D84), the tabs stay with the message's
463
+ own counts above "Connect to load reactions", as on Android; other errors hide them. */}
464
+ {(state != "error" || offlineMiss) && (
418
465
  <View>
419
466
  <ScrollView
420
467
  showsHorizontalScrollIndicator={false}
@@ -455,7 +502,7 @@ export const CometChatReactionList = (props: CometChatReactionListInterface) =>
455
502
  : tabStyleFromTheme.itemTextStyle
456
503
  }
457
504
  >
458
- {reactionObject?.getCount()}
505
+ {localizeDigits(String(reactionObject?.getCount() ?? ""), language)}
459
506
  </Text>
460
507
  </TouchableOpacity>
461
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
  },
@@ -2,6 +2,7 @@ import React, { useEffect, useRef } from "react";
2
2
  import { Animated, Dimensions, Easing, ScrollView, StyleSheet, View } from "react-native";
3
3
  import Svg, { Defs, G, LinearGradient, Path, Stop } from "react-native-svg";
4
4
  import { useTheme } from "../../../theme";
5
+ import { useRtlMirror } from "../../helper/layoutDirection";
5
6
 
6
7
  const { width: screenWidth } = Dimensions.get("window");
7
8
 
@@ -56,6 +57,8 @@ const SkeletonItemTop = () => {
56
57
 
57
58
  export const Skeleton = () => {
58
59
  const theme = useTheme();
60
+ // ENG-41390: SVG shapes and the shimmer use fixed x positions; flip the whole skeleton in RTL.
61
+ const rtlMirror = useRtlMirror();
59
62
  const animatedValue = useRef(new Animated.Value(0)).current;
60
63
 
61
64
  useEffect(() => {
@@ -80,7 +83,7 @@ export const Skeleton = () => {
80
83
  });
81
84
 
82
85
  return (
83
- <ScrollView>
86
+ <ScrollView style={rtlMirror}>
84
87
  {new Array(20).fill(0).map((_, i) => {
85
88
  return <SkeletonItemBottom key={i} />;
86
89
  })}
@@ -5,6 +5,8 @@ import { CometChat } from "@cometchat/chat-sdk-react-native";
5
5
  import { MessageBubbleAlignmentType } from "../../base/Types";
6
6
  import { CometChatTheme } from "../../../theme/type";
7
7
  import { DeepPartial } from "../../helper/types";
8
+ import { localizeDigits } from "../../helper/LocalizedDateHelper";
9
+ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew/useCometChatTranslationHook";
8
10
 
9
11
  /**
10
12
  * Props for rendering reactions on a message bubble.
@@ -51,6 +53,8 @@ export interface CometChatReactionsInterface {
51
53
  const CometChatReactions = (props: CometChatReactionsInterface) => {
52
54
  const { messageObject, style, onReactionPress, onReactionLongPress, alignment, maxContentWidth } =
53
55
  props;
56
+ // The context language: the provider sets the global one in an effect, a render later.
57
+ const { language } = useCometChatTranslation();
54
58
 
55
59
  const [reactionList, setReactionList] = React.useState<(JSX.Element | null)[]>([]);
56
60
  const reactionRef = React.useRef<CometChat.ReactionCount[]>([]);
@@ -86,7 +90,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
86
90
  : style?.emojiStyle?.emojiCountTextStyle
87
91
  }
88
92
  >
89
- {count}
93
+ {localizeDigits(String(count), language)}
90
94
  </Text>
91
95
  </TouchableOpacity>
92
96
  ) : null;
@@ -167,7 +171,7 @@ const CometChatReactions = (props: CometChatReactionsInterface) => {
167
171
  setReactionList(messageReactions);
168
172
  } else setReactionList(messageReactions);
169
173
  }
170
- }, [messageObject, maxContentWidth]);
174
+ }, [messageObject, maxContentWidth, language]);
171
175
 
172
176
  return reactionList.length ? (
173
177
  <View
@@ -18,6 +18,7 @@ import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
18
18
  import { Icon } from "../../icons/Icon";
19
19
  import { CometChat } from "@cometchat/chat-sdk-react-native";
20
20
  import { useKeyboard } from "../../helper/useKeyboard";
21
+ import { directionStyle, useComponentLayoutDirection, useInputTextAlign } from "../../helper/layoutDirection";
21
22
 
22
23
  export interface CometChatReportDialogInterface {
23
24
  /** Controls modal visibility */
@@ -99,6 +100,9 @@ export const CometChatReportDialog = (props: CometChatReportDialogInterface) =>
99
100
  } = props;
100
101
 
101
102
  const theme = useTheme();
103
+ const inputAlign = useInputTextAlign(); // ENG-41384
104
+ // Modal content is a new native root: give it the opener's direction (ENG-41333, §4.7).
105
+ const direction = useComponentLayoutDirection();
102
106
  const [flagReasons, setFlagReasons] = useState<CometChat.FlagReason[]>(reasons || []);
103
107
  const [isFetchingReasons, setIsFetchingReasons] = useState<boolean>(false);
104
108
  const [selectedReason, setSelectedReason] = useState<CometChat.FlagReason | null>(null);
@@ -208,7 +212,7 @@ export const CometChatReportDialog = (props: CometChatReportDialogInterface) =>
208
212
  onDismiss={onDismiss}
209
213
  >
210
214
  <KeyboardAvoidingView
211
- style={styles.keyboardAvoidingView}
215
+ style={[styles.keyboardAvoidingView, directionStyle(direction)]}
212
216
  behavior={Platform.OS === "ios" ? "padding" : "height"}
213
217
  >
214
218
  <ScrollView
@@ -242,7 +246,7 @@ export const CometChatReportDialog = (props: CometChatReportDialogInterface) =>
242
246
  <View style={[theme.reportDialogStyles.pillsContainerStyle, pillsContainerStyle]}>
243
247
  {isFetchingReasons && (
244
248
  <Text style={[theme.reportDialogStyles.messageTextStyle, { marginBottom: 8 }]}>
245
- {"Loading..."}
249
+ {t("LOADING")}
246
250
  </Text>
247
251
  )}
248
252
  {!isFetchingReasons &&
@@ -309,7 +313,7 @@ export const CometChatReportDialog = (props: CometChatReportDialogInterface) =>
309
313
  onBlur={() => setIsTextInputFocused(false)}
310
314
  onChangeText={(val) => setDescription(val.substring(0, 100))}
311
315
  editable={!isSubmitting}
312
- style={[theme.reportDialogStyles.descriptionTextStyle, descriptionTextStyle]}
316
+ style={[inputAlign, theme.reportDialogStyles.descriptionTextStyle, descriptionTextStyle]}
313
317
  />
314
318
  </View>
315
319
  </View>
@@ -67,7 +67,7 @@ export const getReportDialogStyleLight = (
67
67
  paddingVertical: 10,
68
68
  paddingHorizontal: 16,
69
69
  marginBottom: 8,
70
- marginRight: 8,
70
+ marginEnd: 8,
71
71
  },
72
72
  pillsTextStyle: {
73
73
  color: color.textPrimary,
@@ -145,7 +145,7 @@ const styles = (theme: ReturnType<typeof useTheme>) =>
145
145
  height: 34,
146
146
  borderRadius: 17,
147
147
  backgroundColor: theme.color.background4,
148
- marginRight: 8,
148
+ marginEnd: 8,
149
149
  },
150
150
  chip: {
151
151
  paddingHorizontal: 16,
@@ -4,6 +4,7 @@ import { Image, View } from "react-native";
4
4
  import { useTheme } from "../../../theme";
5
5
  import { useCompTheme } from "../../../theme/hook";
6
6
  import { deepMerge } from "../../helper/helperFunctions";
7
+ import { usePresenceHidden } from "../../offline/usePresenceHidden";
7
8
  import { StatusIndicatorStyles } from "./styles";
8
9
 
9
10
  /**
@@ -34,11 +35,14 @@ export const CometChatStatusIndicator = ({
34
35
  }: CometChatStatusIndicatorInterface) => {
35
36
  const theme = useTheme();
36
37
  const compTheme = useCompTheme();
38
+ // Offline ON, SDK not connected: no presence anywhere (groups' private / protected badges stay).
39
+ const presenceHidden = usePresenceHidden();
37
40
  const statusIndicatorStyles = useMemo(() => {
38
41
  return deepMerge(theme.statusIndicatorStyle, compTheme.statusIndicatorStyle ?? {}, style ?? {});
39
42
  }, [theme, compTheme, style]);
40
43
 
41
44
  if (type === CometChat.USER_STATUS.ONLINE) {
45
+ if (presenceHidden) return null;
42
46
  return (
43
47
  <View
44
48
  style={[ statusIndicatorStyles.containerStyleOnline]}
@@ -4,6 +4,8 @@ import Markdown from 'react-native-markdown-display';
4
4
  import { CometChat } from '@cometchat/chat-sdk-react-native';
5
5
  import { CometChatCardView } from '@cometchat/cards-react-native';
6
6
  import { useTheme } from '../../../theme';
7
+ import { CODE_DIRECTION } from '../../helper/layoutDirection';
8
+ import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
7
9
  import { messageStream, streamingState$, IStreamData, getAIAssistantTools, stopStreamingForRunId, handleWebsocketMessage, startStreamingForRunId, streamConnection$, notifyStreamRenderComplete } from '../../services/stream-message.service';
8
10
  import { CometChatUiKitConstants } from '../../index';
9
11
  import { CometChatUIEventHandler, CometChatUIEvents } from '../../events';
@@ -18,6 +20,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
18
20
  message,
19
21
  style: bubbleStyle
20
22
  }) => {
23
+ const { t } = useCometChatTranslation();
21
24
  const initialMessageRef = useRef<any>(message);
22
25
  const [data, setData] = useState<any>(initialMessageRef.current || null);
23
26
  const [fullMessage, setFullMessage] = useState<string>('');
@@ -259,6 +262,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
259
262
  padding: theme.spacing.padding.p0_5,
260
263
  },
261
264
  code_block: {
265
+ ...CODE_DIRECTION,
262
266
  backgroundColor: theme.color.background3,
263
267
  color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
264
268
  borderRadius: theme.spacing.radius.r2,
@@ -266,6 +270,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
266
270
  fontFamily: 'monospace',
267
271
  },
268
272
  fence: {
273
+ ...CODE_DIRECTION,
269
274
  backgroundColor: theme.color.background3,
270
275
  color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
271
276
  borderRadius: theme.spacing.radius.r2,
@@ -296,7 +301,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
296
301
  padding: 0,
297
302
  },
298
303
  th: {
299
- borderRightWidth: 1,
304
+ borderEndWidth: 1,
300
305
  borderBottomWidth: 1,
301
306
  borderColor: theme.color.borderDefault,
302
307
  backgroundColor: theme.color.background3,
@@ -307,10 +312,10 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
307
312
  fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
308
313
  margin: 0,
309
314
  borderTopWidth: 0,
310
- borderLeftWidth: 0,
315
+ borderStartWidth: 0,
311
316
  },
312
317
  td: {
313
- borderRightWidth: 1,
318
+ borderEndWidth: 1,
314
319
  borderBottomWidth: 1,
315
320
  borderColor: theme.color.borderDefault,
316
321
  backgroundColor: theme.color.background1,
@@ -320,7 +325,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
320
325
  fontSize: bubbleStyle?.textStyle?.fontSize || theme.typography.body.regular.fontSize,
321
326
  margin: 0,
322
327
  borderTopWidth: 0,
323
- borderLeftWidth: 0,
328
+ borderStartWidth: 0,
324
329
  },
325
330
  tr: {
326
331
  borderBottomWidth: 0,
@@ -378,9 +383,9 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
378
383
  color: bubbleStyle?.textStyle?.color || theme.color.receiveBubbleText,
379
384
  },
380
385
  blockquote: {
381
- borderLeftWidth: 3,
382
- borderLeftColor: theme.color.borderDefault,
383
- paddingLeft: theme.spacing.padding.p2,
386
+ borderStartWidth: 3,
387
+ borderStartColor: theme.color.borderDefault,
388
+ paddingStart: theme.spacing.padding.p2,
384
389
  color: theme.color.textSecondary,
385
390
  },
386
391
  link: {
@@ -439,9 +444,10 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
439
444
  display: 'flex',
440
445
  paddingVertical: bubbleStyle?.containerStyle?.paddingVertical || 0,
441
446
  paddingHorizontal: bubbleStyle?.containerStyle?.paddingHorizontal || 0,
442
- alignItems: 'flex-start',
447
+ // Fill the bubble (it gets fillWidth): markdown has no natural width to shrink to.
448
+ alignItems: 'stretch',
443
449
  justifyContent: 'flex-start',
444
- alignSelf: 'flex-start',
450
+ alignSelf: 'stretch',
445
451
  backgroundColor: bubbleStyle?.containerStyle?.backgroundColor || 'transparent',
446
452
  borderRadius: bubbleStyle?.containerStyle?.borderRadius || theme.spacing.radius.r3,
447
453
  maxWidth: '100%',
@@ -474,8 +480,9 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
474
480
  fontStyle: 'italic',
475
481
  },
476
482
  errorContainer: {
477
- borderLeftWidth: 3,
478
- borderLeftColor: theme.color.error,
483
+ alignSelf: 'flex-start', // its own size: the container stretches children for markdown
484
+ borderStartWidth: 3,
485
+ borderStartColor: theme.color.error,
479
486
  backgroundColor: bubbleStyle?.errorContainerStyle?.backgroundColor || theme.color.error,
480
487
  padding: bubbleStyle?.errorContainerStyle?.padding || theme.spacing.padding.p2,
481
488
  borderRadius: bubbleStyle?.errorContainerStyle?.borderRadius || theme.spacing.radius.r2,
@@ -517,7 +524,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
517
524
  },
518
525
  ]}
519
526
  >
520
- Thinking...
527
+ {t('THINKING')}
521
528
  </ShimmerText>
522
529
  )}
523
530
 
@@ -557,7 +564,7 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
557
564
 
558
565
  {hasError && (
559
566
  <View style={styles.errorContainer}>
560
- <Text style={styles.errorText}>No internet connection. Please check your connection and try again.</Text>
567
+ <Text style={styles.errorText}>{t('NO_INTERNET_CONNECTION_RETRY')}</Text>
561
568
  </View>
562
569
  )}
563
570
  </View>
@@ -6,6 +6,7 @@ import { SuggestionListStyle } from "../../../theme/type";
6
6
  import { Skeleton } from "./Skeleton";
7
7
  import { useTheme } from "../../../theme";
8
8
  import { useCometChatTranslation } from "../..";
9
+ import { TEXT_START } from "../../helper/layoutDirection";
9
10
 
10
11
  /**
11
12
  * Props for the CometChatSuggestionList component.
@@ -59,9 +60,9 @@ export const CometChatSuggestionList = (props: CometChatSuggestionListInterface)
59
60
  <Text
60
61
  numberOfLines={1}
61
62
  ellipsizeMode='tail'
62
- style={[listStyle?.listItemStyle.titleStyle, { flexShrink: 1 }]}
63
+ style={[TEXT_START, listStyle?.listItemStyle.titleStyle, { flexShrink: 1 }]}
63
64
  >
64
- <Text style={[listStyle?.listItemStyle.titleStyle, { fontWeight: '700' }]}>@{item.name} </Text>
65
+ <Text style={[TEXT_START, listStyle?.listItemStyle.titleStyle, { fontWeight: '700' }]}>@{item.name} </Text>
65
66
  <Text style={[theme.typography.caption1.regular, { opacity: 0.7 }]}>{t('MESSAGE_COMPOSER_MENTION_NOTIFY_EVERYONE_LABEL')}</Text>
66
67
  </Text>
67
68
  ) : undefined;
@@ -151,7 +151,7 @@ const styles = StyleSheet.create({
151
151
  circleShimmerContainer: {
152
152
  position: "absolute",
153
153
  top: 5,
154
- left: 15, // Start shimmer from the left
154
+ start: 15, // start edge, mirrors under RTL
155
155
  height: 40, // Match the SVG height
156
156
  width: 40, // Ensure shimmer is wide enough to cover the circle
157
157
  overflow: "hidden", // Hide anything that goes outside this container
@@ -18,6 +18,10 @@ import {
18
18
  } from "../../formatters";
19
19
  import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
20
20
  import { isTextElement, isViewElement } from "../../utils/elementType";
21
+ import { hasVisibleDigit, messageDirection } from "../../helper/textDirection";
22
+
23
+ // A mention token (<@uid:x> / <@all:x>): drawn as a name the raw text doesn't hold.
24
+ const MENTION_TOKEN = /<@(?:uid|all):/;
21
25
 
22
26
  // Pre-allocated style for view-based content wrapper (blockquotes, lists).
23
27
  const VIEW_BASED_WRAPPER_STYLE = { flexShrink: 1 as const };
@@ -139,9 +143,29 @@ export const CometChatTextBubbleText = (
139
143
  return finalText as string | JSX.Element;
140
144
  }, [text, textFormatters]);
141
145
 
146
+ // ENG-41314: the message aligns by its own language (first strong character), not by the
147
+ // chat's direction — an English message stays left in an RTL chat, Arabic goes right.
148
+ // Android ENG-58494: no letter but digits ("1123 + 456 = 579 !") reads LTR; with no direction
149
+ // Android laid the numbers out right to left in an RTL chat. Emoji / punctuation only: unchanged.
150
+ // Not with a mention: the token draws as a name (maybe Arabic) that `text` doesn't hold.
151
+ const dir = useMemo(
152
+ () => {
153
+ // An explicit text={null} skips the "" default.
154
+ const raw = text ?? "";
155
+ return messageDirection(raw) ?? (!MENTION_TOKEN.test(raw) && hasVisibleDigit(raw) ? "ltr" : null);
156
+ },
157
+ [text]
158
+ );
142
159
  const contentTextStyle = useMemo(
143
- () => withMeasurableLineHeight(textStyle, formattedText),
144
- [textStyle, formattedText]
160
+ () => {
161
+ const base = withMeasurableLineHeight(textStyle, formattedText);
162
+ if (!dir) return base;
163
+ // Defaults first: a caller's own textAlign (the group action pill centres) still wins.
164
+ // ENG-41385: "left" is the start edge — RN resolves it against the Yoga direction, and the
165
+ // container below already carries `direction: dir`. "right" here put Arabic at the left.
166
+ return [{ writingDirection: dir, textAlign: "left" } as TextStyle, base];
167
+ },
168
+ [textStyle, formattedText, dir]
145
169
  );
146
170
 
147
171
  // Reset state only when text actually changes
@@ -232,7 +256,9 @@ export const CometChatTextBubbleText = (
232
256
  const needsMeasurement = containerWidth !== null && !isViewBased && !measuredCacheRef.current[hiddenTextKey];
233
257
 
234
258
  return (
235
- <View onLayout={onContainerLayout}>
259
+ // direction on the container too: textAlign alone can't move a content-sized Text that
260
+ // the RTL bubble lays out from the right (seen: "Quoted reply" stayed right on Android).
261
+ <View onLayout={onContainerLayout} style={dir ? { direction: dir } : undefined}>
236
262
  {/* Hidden measurement text - only render if we need to measure */}
237
263
  {needsMeasurement && (
238
264
  <Text
@@ -1,7 +1,6 @@
1
1
  import { JSX, useMemo } from "react";
2
2
  import {
3
3
  ColorValue,
4
- Dimensions,
5
4
  ImageSourcePropType,
6
5
  ImageStyle,
7
6
  Modal,
@@ -10,13 +9,14 @@ import {
10
9
  TextStyle,
11
10
  TouchableOpacity,
12
11
  TouchableWithoutFeedback,
12
+ useWindowDimensions,
13
13
  View,
14
14
  ViewStyle,
15
15
  } from "react-native";
16
16
  import { useTheme } from "../../../theme";
17
17
  import { Icon } from "../../icons/Icon";
18
-
19
- const { width: screenWidth, height: screenHeight } = Dimensions.get("window");
18
+ import { tooltipPosition } from "./tooltipPosition";
19
+ import { directionStyle, useComponentLayoutDirection, useKitRTL } from "../../helper/layoutDirection";
20
20
 
21
21
  /**
22
22
  * Interface for the menu items (tooltip actions).
@@ -72,29 +72,16 @@ type CometChatTooltipMenuProps = {
72
72
  export const CometChatTooltipMenu = (props: CometChatTooltipMenuProps) => {
73
73
  const { visible = false, onDismiss = () => null, onClose = () => null, event, menuItems } = props;
74
74
  const theme = useTheme();
75
+ // The live window size: it changes on rotation, split screen and foldables.
76
+ const { width, height } = useWindowDimensions();
77
+ const isRTL = useKitRTL();
78
+ // Modal content is a new native root: give it the opener's direction (§4.7).
79
+ const direction = useComponentLayoutDirection();
75
80
 
76
- const position = useMemo(() => {
77
- let x = event.nativeEvent.pageX;
78
- let y = event.nativeEvent.pageY;
79
- const position: {
80
- left?: number;
81
- right?: number;
82
- top?: number;
83
- bottom?: number;
84
- } = {};
85
- if (x <= screenWidth / 3) {
86
- position.left = x + 10;
87
- } else {
88
- position.right = 12;
89
- }
90
-
91
- if (y <= screenHeight / 2) {
92
- position.top = y + 20;
93
- } else if (y >= screenHeight / 2) {
94
- position.bottom = Math.max(screenHeight - y + 10, 40);
95
- }
96
- return position;
97
- }, [event]);
81
+ const position = useMemo(
82
+ () => tooltipPosition(event.nativeEvent.pageX, event.nativeEvent.pageY, width, height, isRTL),
83
+ [event, width, height, isRTL]
84
+ );
98
85
 
99
86
  return (
100
87
  <Modal
@@ -106,7 +93,7 @@ export const CometChatTooltipMenu = (props: CometChatTooltipMenuProps) => {
106
93
  animationType='none'
107
94
  >
108
95
  <TouchableWithoutFeedback onPress={onClose}>
109
- <View style={tooltipStyles.overlay}>
96
+ <View style={[tooltipStyles.overlay, directionStyle(direction)]}>
110
97
  <View
111
98
  style={[
112
99
  tooltipStyles.menu,
@@ -140,14 +127,14 @@ export const CometChatTooltipMenu = (props: CometChatTooltipMenuProps) => {
140
127
  },
141
128
  i === 0
142
129
  ? {
143
- borderTopLeftRadius: theme.spacing.radius.r2,
144
- borderTopRightRadius: theme.spacing.radius.r2,
130
+ borderTopStartRadius: theme.spacing.radius.r2,
131
+ borderTopEndRadius: theme.spacing.radius.r2,
145
132
  }
146
133
  : {},
147
134
  i === menuItems.length - 1
148
135
  ? {
149
- borderBottomLeftRadius: theme.spacing.radius.r2,
150
- borderBottomRightRadius: theme.spacing.radius.r2,
136
+ borderBottomStartRadius: theme.spacing.radius.r2,
137
+ borderBottomEndRadius: theme.spacing.radius.r2,
151
138
  }
152
139
  : {},
153
140
  ]}
@@ -162,6 +149,9 @@ export const CometChatTooltipMenu = (props: CometChatTooltipMenuProps) => {
162
149
  />
163
150
  <Text
164
151
  style={{
152
+ // Shrinks inside the menu's maxWidth, so a long label wraps instead of
153
+ // overflowing the menu.
154
+ flexShrink: 1,
165
155
  color: theme.color.textPrimary,
166
156
  ...theme.typography.heading4.regular,
167
157
  ...item?.textStyle,