@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
@@ -0,0 +1,118 @@
1
+ import { COLOR_CLOSE_TAG, COLOR_OPEN_TAG, HEX_COLOR_REGEX } from "../formatters/richTextWireFormat";
2
+
3
+ // ENG-41314: direction of a piece of user text, by its first strong character (what HTML's
4
+ // dir="auto" does). Used so a message aligns by its own language, not the chat's direction.
5
+
6
+ // Hebrew, Arabic, Syriac, Thaana, NKo, Samaritan, Mandaic, Arabic Extended, and the
7
+ // Hebrew/Arabic presentation forms.
8
+ // Arabic-Indic digits (U+0660-0669, U+06F0-06F9) and U+FEFF are bidi-weak, not strong RTL: left out.
9
+ const RTL_CHAR = /[\u0590-\u065F\u066A-\u06EF\u06FA-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFE]/;
10
+ // Any letter in another script counts as a strong left-to-right character.
11
+ const STRONG_CHAR = /\p{L}/u;
12
+ // hasVisibleDigit: a 0-9 the reader sees. A keycap emoji ("1️⃣", "#️⃣") is an emoji, not a digit.
13
+ const KEYCAP = /[0-9#*]\uFE0F?\u20E3/g;
14
+ const DIGIT = /[0-9]/;
15
+
16
+ // ENG-41314 part 2: wrap a name, file name or number before dropping it into a translated
17
+ // sentence, so it keeps its own direction and can't reorder the words around it
18
+ // (FSI U+2068 … PDI U+2069, invisible).
19
+ const FSI = "\u2068";
20
+ const PDI = "\u2069";
21
+ // Bidi controls a display name must not carry into a sentence: an embedded PDI would close our
22
+ // isolate early, an override (RLO U+202E) would reverse the words after it — a spoofing vector.
23
+ const BIDI_CONTROLS = /[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g;
24
+ /**
25
+ * ENG-41456: a display name drawn on its own (list titles, headers, sender names) must not carry
26
+ * bidi controls either — an override (RLO) reverses the text after it, so "Eve" + RLO + "evil"
27
+ * renders as "Evelive" ("Trojan Source"). Strips them; no isolates added (LRI/FSI around a
28
+ * standalone iOS title truncated it before, see pinLtr).
29
+ */
30
+ export function stripBidiControls(text?: string | null): string {
31
+ return (text || "").replace(BIDI_CONTROLS, "");
32
+ }
33
+
34
+ export function isolateText(text: string): string {
35
+ const clean = stripBidiControls(text);
36
+ return clean ? FSI + clean + PDI : "";
37
+ }
38
+
39
+ // ENG-41314: URLs, emails and code are left-to-right whatever the message language. Inside an
40
+ // Arabic message the bidi algorithm otherwise moves their edge punctuation: "/https://x.com/docs"
41
+ // and ";()x = foo" (seen on iOS and Android). A left-to-right mark (LRM U+200E) on each side
42
+ // pins the edges. Not LRI…PDI: in a forced-RTL iOS bubble that truncated the text to one line
43
+ // ("user…"), seen on device and gone with the isolates removed (A/B).
44
+ export const LRM = "\u200E";
45
+ export function pinLtr(text: string): string {
46
+ if (!text || (text.startsWith(LRM) && text.endsWith(LRM))) return text;
47
+ return LRM + text + LRM;
48
+ }
49
+
50
+ // ENG-41314: a sentence built from a translated template takes the template's direction, not the
51
+ // direction of an isolated name at its start. iOS let the name decide: "joined the group أحمد علي"
52
+ // in an English UI (Android skipped the isolate correctly). LRM/RLM in front sets it explicitly.
53
+ const RLM = "\u200F";
54
+ export function withSentenceDirection(sentence: string): string {
55
+ const dir = firstStrongDirection(sentence);
56
+ return dir === "rtl" ? RLM + sentence : dir === "ltr" ? LRM + sentence : sentence;
57
+ }
58
+
59
+ /**
60
+ * Fills `${key}` placeholders with isolated names and gives the sentence the template's own
61
+ * direction — the one call every name-in-a-sentence site needs (ENG-41314).
62
+ */
63
+ export function sentenceWithNames(template: string, names: Record<string, string>): string {
64
+ // One pass: a name that literally contains "${onName}" is never expanded again.
65
+ const out = template.replace(/\$\{(\w+)\}/g, (match, key: string) =>
66
+ Object.prototype.hasOwnProperty.call(names, key) ? isolateText(names[key]) : match
67
+ );
68
+ return withSentenceDirection(out);
69
+ }
70
+
71
+ // Unicode bidi P2/P3: LRM is a strong LTR character, RLM and ALM strong RTL, and anything inside
72
+ // an isolate (LRI/RLI/FSI … PDI) is skipped — so the result agrees with withSentenceDirection().
73
+ const LRI = "\u2066";
74
+ const RLI = "\u2067";
75
+ export function firstStrongDirection(text: string): "ltr" | "rtl" | null {
76
+ let depth = 0;
77
+ for (const ch of text) {
78
+ if (ch === LRI || ch === RLI || ch === FSI) { depth++; continue; }
79
+ if (ch === PDI) { if (depth > 0) depth--; continue; }
80
+ if (depth > 0) continue;
81
+ if (ch === LRM) return "ltr";
82
+ if (ch === RLM || ch === "\u061C") return "rtl";
83
+ if (RTL_CHAR.test(ch)) return "rtl";
84
+ if (STRONG_CHAR.test(ch)) return "ltr";
85
+ }
86
+ return null;
87
+ }
88
+
89
+ // Wire markup the reader never sees: mention tokens (<@uid:x>, <@all:x>) and colour tags
90
+ // (<color=#hex>…</color>). Read raw, "<@uid:" made a message starting with a mention LTR.
91
+ // The colour tag comes from the wire format, so it matches exactly what the rich-text formatter draws.
92
+ // ponytail: the tags ("<color=", "</color>") hold no regex metacharacters, so they go in unescaped.
93
+ const HIDDEN_MARKUP = new RegExp(
94
+ "<@(?:uid|all):[^>]*>|" +
95
+ COLOR_OPEN_TAG + HEX_COLOR_REGEX.source.replace(/^\^|\$$/g, "") + ">|" +
96
+ COLOR_CLOSE_TAG,
97
+ "gi"
98
+ );
99
+
100
+ /** Direction of a message by its first strong character, ignoring markup the reader never sees. */
101
+ export function messageDirection(text: string): "ltr" | "rtl" | null {
102
+ return firstStrongDirection(text.replace(HIDDEN_MARKUP, ""));
103
+ }
104
+
105
+ /** Whether the reader sees a 0-9 digit (a mention's uid, a colour tag's hex or a keycap emoji does not count). */
106
+ export function hasVisibleDigit(text: string): boolean {
107
+ return DIGIT.test(text.replace(HIDDEN_MARKUP, "").replace(KEYCAP, ""));
108
+ }
109
+
110
+ /**
111
+ * ENG-41385: style that aligns a piece of user text (a link preview's title or description) by
112
+ * its own language. `direction` on the Text node makes `textAlign: "left"` its own start edge:
113
+ * React Native resolves "left" against the node's Yoga direction. Nothing for text without letters.
114
+ */
115
+ export function ownLanguageTextStyle(text?: string | null) {
116
+ const dir = messageDirection(text ?? "");
117
+ return dir ? ({ direction: dir, writingDirection: dir, textAlign: "left" } as const) : undefined;
118
+ }
@@ -3,6 +3,7 @@ import {
3
3
  ColorValue,
4
4
  DimensionValue,
5
5
  Image,
6
+ Platform,
6
7
  ImageSourcePropType,
7
8
  ImageStyle,
8
9
  StyleProp,
@@ -11,9 +12,38 @@ import {
11
12
  } from "react-native";
12
13
  import { useTheme } from "../../theme";
13
14
  import { ICONS } from "./icon-mapping";
15
+ import FormatListNumberedRtl from "./components/format-list-numbered-rtl";
16
+ import { useKitRTL } from "../helper/layoutDirection";
14
17
 
15
18
  export type IconName = keyof typeof ICONS;
16
19
 
20
+ // ENG-41312: directional icons flip horizontally in RTL (design: Storybook RTL, measured
21
+ // scaleX(-1); per-OS column from decision D-RTL-1). Names are matched without "-fill".
22
+ const MIRROR_ALWAYS = new Set([
23
+ "arrow-back", "arrow-forward", "chevron-left", "chevron-right",
24
+ "send", "ai-send-button", "reply", "reply-all", "forward",
25
+ "subdirectory-arrow-right", "subdirectory-arrow-left", "right-arrow",
26
+ "call-made", "call-received", "call-missed", "call-missed-outgoing",
27
+ "phone-incoming", "phone-outgoing", "phone-missed",
28
+ "incoming-audio", "outgoing-audio", "incoming-video", "outgoing-video", "missed-video-call",
29
+ "format-list-bulleted", "logout",
30
+ ]);
31
+ // Android/web flip these; iOS draws real-world objects as-is (Apple's rule).
32
+ const MIRROR_ANDROID_ONLY = new Set(["videocam", "content-copy", "ai-copy-option", "chat", "sticker"]);
33
+ // "format-list-numbered" isn't flipped (that would mirror the digits): RTL swaps in its own
34
+ // drawing with the numbers on the right (ENG-41386).
35
+ const RTL_DRAWINGS: Partial<Record<string, React.ComponentType<any>>> = {
36
+ "format-list-numbered": FormatListNumberedRtl,
37
+ };
38
+
39
+ export function shouldMirrorIcon(name: string, isRTL: boolean, os: string): boolean {
40
+ if (!isRTL) return false;
41
+ const base = name.endsWith("-fill") ? name.slice(0, -5) : name;
42
+ return MIRROR_ALWAYS.has(base) || (os === "android" && MIRROR_ANDROID_ONLY.has(base));
43
+ }
44
+
45
+ const MIRROR_STYLE: ViewStyle = { transform: [{ scaleX: -1 }] };
46
+
17
47
  type IconProps = {
18
48
  name?: IconName;
19
49
  color?: ColorValue;
@@ -27,6 +57,7 @@ type IconProps = {
27
57
 
28
58
  export const Icon = (props: IconProps) => {
29
59
  const theme = useTheme();
60
+ const isRTL = useKitRTL();
30
61
  const {
31
62
  name,
32
63
  color = theme.color.textSecondary,
@@ -56,10 +87,14 @@ export const Icon = (props: IconProps) => {
56
87
  );
57
88
  }
58
89
  if ("name" in props && name) {
59
- const IconComponent = ICONS[name];
90
+ const IconComponent = (isRTL && RTL_DRAWINGS[name]) || ICONS[name];
60
91
  if (IconComponent) {
92
+ const mirror = shouldMirrorIcon(name, isRTL, Platform.OS);
93
+ // The flip goes on the icon's own container, after containerStyle so it wins. No extra
94
+ // wrapper view: an added non-collapsable child under a flattened container crashed
95
+ // Fabric on Android ("addViewAt: failed to insert view", ENG-41312 A/B, 5/5 vs 0/5).
61
96
  return (
62
- <View style={[containerStyle]}>
97
+ <View style={[containerStyle, mirror && MIRROR_STYLE]}>
63
98
  <IconComponent
64
99
  color={color as any}
65
100
  height={typeof height === "number" ? height : (size as number)}
@@ -0,0 +1,15 @@
1
+ import Svg, { Path } from "react-native-svg";
2
+ import type { SvgProps } from "react-native-svg";
3
+ // ENG-41386: RTL drawing of format-list-numbered (design: numbers on the right). The digits move,
4
+ // they are not mirrored; the lines move to the left.
5
+ const SvgComponent = ({ height, width, color }: SvgProps) => (
6
+ <Svg width={width} height={height} fill='none' viewBox='0 0 24 24'>
7
+ <Path
8
+ fill={color}
9
+ transform='translate(17 0)'
10
+ d='M2 17h2v.5H3v1h1v.5H2v1h3v-4H2zm1-9h1V4H2v1h1zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2z'
11
+ />
12
+ <Path fill={color} d='M3 5v2h14V5zM3 19h14v-2H3zM3 13h14v-2H3z' />
13
+ </Svg>
14
+ );
15
+ export default SvgComponent;
@@ -18,7 +18,9 @@ export {
18
18
  CometChatUIEventHandler,
19
19
  CometChatUIEvents,
20
20
  MessageEvents,
21
+ OfflineMessageEvents,
21
22
  } from "./events";
23
+ export type { MessageSendState, MessageSendStateChangedEvent, OfflineCacheResetEvent } from "./events";
22
24
 
23
25
  export type { DataSource } from "./framework";
24
26