@cometchat/chat-uikit-react-native 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/CometChatKeyboardModule.kt +101 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
  3. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardDirectionWatcher.kt +64 -0
  4. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardLanguageDirection.kt +44 -0
  5. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +287 -49
  6. package/ios/CometChatKeyboardModule.m +9 -0
  7. package/ios/CometChatKeyboardModule.swift +71 -0
  8. package/ios/KeyboardLanguageDirection.swift +24 -0
  9. package/ios/RichTextEditorView.swift +253 -51
  10. package/ios/RichTextEditorViewManager.m +1 -0
  11. package/package.json +1 -1
  12. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +41 -57
  13. package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +4 -1
  14. package/src/CometChatAIAssistantChatHistory/style.ts +5 -2
  15. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +21 -8
  16. package/src/CometChatCompactMessageComposer/styles.ts +7 -7
  17. package/src/CometChatConversations/CometChatConversations.tsx +36 -30
  18. package/src/CometChatConversations/Skeleton.tsx +4 -1
  19. package/src/CometChatConversations/style.ts +1 -1
  20. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +35 -18
  21. package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
  22. package/src/CometChatGroupMembers/style.ts +6 -4
  23. package/src/CometChatGroups/CometChatGroups.tsx +13 -6
  24. package/src/CometChatGroups/GroupsStyle.ts +1 -1
  25. package/src/CometChatGroups/Skeleton.tsx +4 -1
  26. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +44 -30
  27. package/src/CometChatMessageComposer/styles.tsx +1 -1
  28. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +22 -13
  29. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
  30. package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
  31. package/src/CometChatMessageList/CometChatMessageList.tsx +97 -128
  32. package/src/CometChatMessageList/SwipeToReplyView.tsx +61 -0
  33. package/src/CometChatMessageList/style.ts +32 -32
  34. package/src/CometChatMessageList/swipeToReply.ts +25 -0
  35. package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +10 -3
  36. package/src/CometChatNotificationFeed/style.ts +1 -1
  37. package/src/CometChatNotificationFeed/utils.ts +17 -18
  38. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +8 -1
  39. package/src/CometChatPinnedMessages/style.ts +5 -5
  40. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +2 -0
  41. package/src/CometChatRichTextEditor/index.tsx +3 -0
  42. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +14 -11
  43. package/src/CometChatSavedMessages/style.ts +3 -3
  44. package/src/CometChatSearch/CometChatSearch.tsx +38 -35
  45. package/src/CometChatSearch/Skeleton.tsx +4 -1
  46. package/src/CometChatSearch/searchLabels.ts +26 -0
  47. package/src/CometChatSearch/style.ts +7 -7
  48. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +11 -7
  49. package/src/CometChatThreadHeader/Header.tsx +2 -2
  50. package/src/CometChatUsers/CometChatUsers.tsx +8 -1
  51. package/src/CometChatUsers/Skeleton.tsx +4 -1
  52. package/src/CometChatUsers/style.ts +1 -1
  53. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +8 -1
  54. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +16 -4
  55. package/src/calls/CometChatCallLogs/Skeleton.tsx +4 -1
  56. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +11 -3
  57. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +10 -2
  58. package/src/extensions/CollaborativeBubble/style.ts +4 -4
  59. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
  60. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
  61. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +11 -6
  62. package/src/extensions/LinkPreview/style.ts +6 -6
  63. package/src/extensions/Polls/Header.tsx +1 -1
  64. package/src/extensions/Polls/Polls.tsx +25 -12
  65. package/src/extensions/Polls/PollsBubble.tsx +10 -6
  66. package/src/extensions/Polls/style.ts +4 -4
  67. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +2 -2
  68. package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +1 -1
  69. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +1 -1
  70. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -2
  71. package/src/index.ts +5 -1
  72. package/src/shared/CometChatUiKit/CometChatUIKit.ts +17 -0
  73. package/src/shared/CometChatUiKit/UIKitSettings.ts +8 -0
  74. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +13 -10
  75. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +15 -7
  76. package/src/shared/formatters/CometChatTextFormatter.ts +11 -0
  77. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +7 -4
  78. package/src/shared/framework/MessageDataSource.tsx +17 -94
  79. package/src/shared/helper/LocalizedDateHelper.ts +64 -4
  80. package/src/shared/helper/helperFunctions.ts +71 -4
  81. package/src/shared/helper/keyboardDirection.ts +54 -0
  82. package/src/shared/helper/layoutDirection.ts +205 -0
  83. package/src/shared/helper/pluralRules.ts +67 -0
  84. package/src/shared/helper/textDirection.ts +118 -0
  85. package/src/shared/icons/Icon.tsx +37 -2
  86. package/src/shared/icons/components/format-list-numbered-rtl.tsx +15 -0
  87. package/src/shared/offline/OfflineViews.tsx +5 -1
  88. package/src/shared/offline/notices.ts +15 -21
  89. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +2 -0
  90. package/src/shared/resources/CometChatLocalizeNew/resources/ar/translation.json +720 -0
  91. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +50 -2
  92. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +51 -3
  93. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +50 -2
  94. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +51 -3
  95. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +50 -2
  96. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +50 -2
  97. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +50 -2
  98. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +50 -2
  99. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +50 -2
  100. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +58 -2
  101. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +50 -2
  102. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +50 -2
  103. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +50 -2
  104. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +66 -2
  105. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +50 -2
  106. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +50 -2
  107. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +50 -2
  108. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +50 -2
  109. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
  110. package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
  111. package/src/shared/utils/MessageUtils.tsx +14 -14
  112. package/src/shared/utils/PermissionUtil.ts +16 -5
  113. package/src/shared/utils/attachmentLimits.ts +3 -2
  114. package/src/shared/utils/conversationUtils.ts +3 -5
  115. package/src/shared/utils/fileIconFontSize.ts +10 -0
  116. package/src/shared/utils/fileSizeLabel.ts +16 -0
  117. package/src/shared/utils/groupActionText.ts +75 -0
  118. package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +12 -8
  119. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +1 -1
  120. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +5 -3
  121. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +22 -17
  122. package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +13 -9
  123. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
  124. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +10 -6
  125. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -4
  126. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +6 -2
  127. package/src/shared/views/CometChatComposerErrorBanner.tsx +3 -1
  128. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +8 -3
  129. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +2 -2
  130. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -3
  131. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -8
  132. package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
  133. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +5 -4
  134. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
  135. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +29 -23
  136. package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +41 -21
  137. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +7 -3
  138. package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +7 -3
  139. package/src/shared/views/CometChatList/CometChatList.tsx +10 -14
  140. package/src/shared/views/CometChatList/Header.tsx +5 -2
  141. package/src/shared/views/CometChatList/sectionLetter.ts +44 -0
  142. package/src/shared/views/CometChatList/styles.ts +7 -7
  143. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +6 -4
  144. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +16 -10
  145. package/src/shared/views/CometChatMediaRecorder/Timer.tsx +5 -1
  146. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +16 -11
  147. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
  148. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +18 -2
  149. package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
  150. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +3 -2
  151. package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +2 -2
  152. package/src/shared/views/CometChatReactionList/Skeleton.tsx +4 -1
  153. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +6 -2
  154. package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +7 -3
  155. package/src/shared/views/CometChatReportDialog/style.ts +1 -1
  156. package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +1 -1
  157. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +20 -13
  158. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -2
  159. package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +1 -1
  160. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +29 -3
  161. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +20 -30
  162. package/src/shared/views/CometChatTooltipMenu/tooltipPosition.ts +43 -0
  163. package/src/shared/views/CometChatVideoBubble/style.ts +2 -2
  164. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +4 -1
  165. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +22 -22
  166. package/src/shared/views/SenderLabel.tsx +41 -0
  167. package/src/theme/default/default.ts +1 -1
@@ -20,6 +20,8 @@ import { DeepPartial } from "../../shared/helper/types";
20
20
  import { JSX } from "react";
21
21
  import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
22
22
  import { SafeAreaView } from "react-native-safe-area-context";
23
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection } from "../../shared/helper/layoutDirection";
24
+ import { stripBidiControls } from "../../shared/helper/textDirection";
23
25
 
24
26
  const listnerID = "CALL_LISTENER_" + Date.now() + "_" + (++__listenerIdCounter);
25
27
  const CometChatCalls = CallingPackage.CometChatCalls;
@@ -30,6 +32,8 @@ const CometChatCalls = CallingPackage.CometChatCalls;
30
32
  * @interface CometChatIncomingCallInterface
31
33
  */
32
34
  export interface CometChatIncomingCallInterface {
35
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
36
+ layoutDirection?: "ltr" | "rtl";
33
37
  /** The incoming call object, which can be a Call or a CustomMessage */
34
38
  call: CometChat.Call | CometChat.CustomMessage | any;
35
39
  /** Custom view for the entire call item */
@@ -84,6 +88,8 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
84
88
  callSettingsBuilder,
85
89
  style,
86
90
  } = props;
91
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
92
+ const direction = useComponentLayoutDirection(props.layoutDirection);
87
93
 
88
94
  const theme = useTheme();
89
95
  const { t } = useCometChatTranslation();
@@ -255,7 +261,8 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
255
261
  * Render the default incoming call overlay with header and action buttons.
256
262
  */
257
263
  return (
258
- <SafeAreaView style={styles.overlay}>
264
+ <LayoutDirectionContext.Provider value={direction}>
265
+ <SafeAreaView style={[styles.overlay, directionStyle(direction)]}>
259
266
  <View style={[incomingCallStyle.containerStyle, { width: "100%" }]}>
260
267
  {/* Top row: LeadingView, Title/Subtitle, TrailingView */}
261
268
  <View style={styles.topRow}>
@@ -265,7 +272,7 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
265
272
  TitleView(call)
266
273
  ) : (
267
274
  <Text style={incomingCallStyle.titleTextStyle}>
268
- {call["sender"]?.["name"] ?? t("INCOMING_CALL")}
275
+ {stripBidiControls(call["sender"]?.["name"]) || t("INCOMING_CALL")}
269
276
  </Text>
270
277
  )}
271
278
 
@@ -276,7 +283,7 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
276
283
  <Icon
277
284
  name='call-fill'
278
285
  size={16}
279
- containerStyle={{ marginTop: 4, marginRight: 4 }}
286
+ containerStyle={{ marginTop: 4, marginEnd: 4 }}
280
287
  />
281
288
  <Text style={incomingCallStyle.subtitleTextStyle}>
282
289
  {call?.["type"] === CallTypeConstants.audio
@@ -310,6 +317,7 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface): JS
310
317
  </View>
311
318
  </View>
312
319
  </SafeAreaView>
320
+ </LayoutDirectionContext.Provider>
313
321
  );
314
322
  };
315
323
 
@@ -19,6 +19,8 @@ import { OutgoingCallStyle } from "./styles";
19
19
  import { DeepPartial } from "../../shared/helper/types";
20
20
  import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
21
21
  import { SafeAreaView } from "react-native-safe-area-context";
22
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection } from "../../shared/helper/layoutDirection";
23
+ import { stripBidiControls } from "../../shared/helper/textDirection";
22
24
 
23
25
  const listenerId = "callListener_" + Date.now() + "_" + (++__listenerIdCounter);
24
26
  const CometChatCalls = CallingPackage.CometChatCalls;
@@ -29,6 +31,8 @@ const CometChatCalls = CallingPackage.CometChatCalls;
29
31
  * @interface CometChatOutgoingCallInterface
30
32
  */
31
33
  export interface CometChatOutgoingCallInterface {
34
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
35
+ layoutDirection?: "ltr" | "rtl";
32
36
  /**
33
37
  * The outgoing call object, can be a CometChat.Call or CometChat.CustomMessage.
34
38
  */
@@ -101,6 +105,8 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
101
105
  EndCallView,
102
106
  onError,
103
107
  } = props;
108
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
109
+ const direction = useComponentLayoutDirection(props.layoutDirection);
104
110
 
105
111
  // State to track whether the call is connected.
106
112
  const [isCallConnected, setCallConnected] = useState(false);
@@ -272,9 +278,10 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
272
278
  setModalVisible(false);
273
279
  };
274
280
 
275
- const callReceiverName = call?.getReceiver?.().getName?.() ?? "Unknown";
281
+ const callReceiverName = stripBidiControls(call?.getReceiver?.().getName?.()) || "Unknown";
276
282
 
277
283
  return (
284
+ <LayoutDirectionContext.Provider value={direction}>
278
285
  <Modal
279
286
  transparent
280
287
  animationType='fade'
@@ -290,7 +297,7 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
290
297
  callSettingsBuilder={callSettings.current!}
291
298
  />
292
299
  ) : (
293
- <SafeAreaView style={{ flex: 1 }}>
300
+ <SafeAreaView style={[{ flex: 1 }, directionStyle(direction)]}>
294
301
  <View style={outgoingCallStyle.containerStyle}>
295
302
  {TitleView ? (
296
303
  TitleView(call)
@@ -337,5 +344,6 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
337
344
  </SafeAreaView>
338
345
  )}
339
346
  </Modal>
347
+ </LayoutDirectionContext.Provider>
340
348
  );
341
349
  };
@@ -49,8 +49,8 @@ export const getCollabBubbleStyleLight = (
49
49
  height: 1,
50
50
  backgroundColor: color.borderDark,
51
51
  width: 240,
52
- marginLeft: -4, // Negative margin equal to parent's padding
53
- marginRight: -4, // Negative margin equal to parent's padding
52
+ marginStart: -4, // Negative margin equal to parent's padding
53
+ marginEnd: -4, // Negative margin equal to parent's padding
54
54
  }
55
55
  },
56
56
  outgoingBubbleStyle: {
@@ -93,8 +93,8 @@ export const getCollabBubbleStyleLight = (
93
93
  backgroundColor: color.extendedPrimary800,
94
94
  width: 240,
95
95
  //position: 'absolute',
96
- marginLeft: -4, // Negative margin equal to parent's padding
97
- marginRight: -4, // Negative margin equal to parent's padding
96
+ marginStart: -4, // Negative margin equal to parent's padding
97
+ marginEnd: -4, // Negative margin equal to parent's padding
98
98
  }
99
99
  },
100
100
  };
@@ -296,7 +296,7 @@ export class CollaborativeDocumentExtensionDecorator extends DataSourceDecorator
296
296
 
297
297
  return (
298
298
  <View>
299
- <Text>{"no match"}</Text>
299
+ <Text>{t("NOT_SUPPORTED")}</Text>
300
300
  </View>
301
301
  );
302
302
  }
@@ -374,7 +374,7 @@ export class CollaborativeWhiteboardExtensionDecorator extends DataSourceDecorat
374
374
  }
375
375
  return (
376
376
  <View>
377
- <Text>{"no match"}</Text>
377
+ <Text>{t("NOT_SUPPORTED")}</Text>
378
378
  </View>
379
379
  );
380
380
  }
@@ -13,6 +13,7 @@ import { DefaultLinkPreview } from "./resources";
13
13
  import { useTheme } from "../../theme";
14
14
  import { CometChatTheme } from "../../theme/type";
15
15
  import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew";
16
+ import { ownLanguageTextStyle } from "../../shared/helper/textDirection";
16
17
 
17
18
  /**
18
19
  * Props for the LinkPreviewBubble component.
@@ -109,9 +110,13 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
109
110
  if (onPress) {
110
111
  onPress();
111
112
  } else {
112
- const opened: unknown = await Linking.openURL(link);
113
- if (!opened) {
114
- Alert.alert(t("SOMETHING_WRONG"));
113
+ // openURL resolves true or rejects when the link cannot open; it never resolves false.
114
+ try {
115
+ await Linking.openURL(link);
116
+ } catch {
117
+ // Our own translated button (ENG-57297): with none, Android shows a hard-coded English
118
+ // 'OK' and iOS shows UIKit's OK in the phone's language, not the kit's.
119
+ Alert.alert(t("SOMETHING_WRONG"), undefined, [{ text: t("OK") }]);
115
120
  }
116
121
  }
117
122
  }
@@ -186,7 +191,7 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
186
191
  <View style={style?.bodyStyle?.containerStyle}>
187
192
  <View style={{ flexDirection: "row" }}>
188
193
  <View style={style?.bodyStyle?.titleContainerStyle}>
189
- <Text style={style?.bodyStyle?.titleStyle} ellipsizeMode='tail'>
194
+ <Text style={[ownLanguageTextStyle(title), style?.bodyStyle?.titleStyle]} ellipsizeMode='tail'>
190
195
  {title}
191
196
  </Text>
192
197
  </View>
@@ -204,10 +209,10 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
204
209
  )}
205
210
  </View>
206
211
  <View style={style?.bodyStyle?.subtitleContainerStyle}>
207
- <Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
212
+ <Text style={[ownLanguageTextStyle(description), style?.bodyStyle?.subtitleTitle]} numberOfLines={2} ellipsizeMode='tail'>
208
213
  {description}
209
214
  </Text>
210
- <Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
215
+ <Text style={[ownLanguageTextStyle(link), style?.bodyStyle?.subtitleTitle]} numberOfLines={2} ellipsizeMode='tail'>
211
216
  {link}
212
217
  </Text>
213
218
  </View>
@@ -15,8 +15,8 @@ const getLinkPreviewBubbleStyle = (
15
15
  bodyStyle: {
16
16
  containerStyle: {
17
17
  //borderRadius: spacing.radius.r2,
18
- borderBottomLeftRadius: spacing.radius.r2,
19
- borderBottomRightRadius: spacing.radius.r2,
18
+ borderBottomStartRadius: spacing.radius.r2,
19
+ borderBottomEndRadius: spacing.radius.r2,
20
20
  padding: spacing.padding.p2,
21
21
  backgroundColor: color.extendedPrimary900,
22
22
  flex: 1,
@@ -39,8 +39,8 @@ const getLinkPreviewBubbleStyle = (
39
39
  },
40
40
  headerImageStyle: {
41
41
  alignSelf: "center",
42
- borderTopLeftRadius: spacing.radius.r2,
43
- borderTopRightRadius: spacing.radius.r2,
42
+ borderTopStartRadius: spacing.radius.r2,
43
+ borderTopEndRadius: spacing.radius.r2,
44
44
  },
45
45
  headerImageContainerStyle: {
46
46
  flex: 1,
@@ -48,8 +48,8 @@ const getLinkPreviewBubbleStyle = (
48
48
  flexDirection: 'row',
49
49
  justifyContent: "center",
50
50
  backgroundColor: color.extendedPrimary900,
51
- borderTopLeftRadius: spacing.radius.r2,
52
- borderTopRightRadius: spacing.radius.r2,
51
+ borderTopStartRadius: spacing.radius.r2,
52
+ borderTopEndRadius: spacing.radius.r2,
53
53
  },
54
54
  };
55
55
  };
@@ -94,7 +94,7 @@ const styles = StyleSheet.create({
94
94
  alignItems: "center",
95
95
  },
96
96
  iconContainer: {
97
- paddingRight: 15,
97
+ paddingEnd: 15,
98
98
  },
99
99
  headingText: {
100
100
  fontSize: 20,
@@ -21,6 +21,12 @@ import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context"
21
21
  import { CometChatMessageEvents } from "../../shared/events/CometChatMessageEvents";
22
22
  import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
23
23
  import { runAfterInteractions } from "../../shared/utils/runAfterInteractions";
24
+ import {
25
+ TEXT_START,
26
+ directionStyle,
27
+ useComponentLayoutDirection,
28
+ useInputTextAlign,
29
+ } from "../../shared/helper/layoutDirection";
24
30
 
25
31
  const { CommonUtil } = NativeModules;
26
32
 
@@ -124,14 +130,16 @@ export interface CometChatCreatePollInterface {
124
130
  * @returns {JSX.Element} The rendered poll creation UI.
125
131
  */
126
132
  export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
133
+ // Before the destructure: the placeholder defaults below are translated.
134
+ const { t } = useCometChatTranslation();
127
135
  const {
128
136
  title,
129
- questionPlaceholderText = "Ask question",
137
+ questionPlaceholderText = t("ASK_QUESTION"),
130
138
  onError,
131
139
  user,
132
140
  group,
133
141
  onClose,
134
- answerPlaceholderText = "Answers",
142
+ answerPlaceholderText = t("ANSWERS"),
135
143
  answerHelpText,
136
144
  addAnswerText,
137
145
  defaultAnswers = 2,
@@ -146,7 +154,9 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
146
154
  const [loader, setLoader] = useState(false);
147
155
  const loggedInUser = useRef<CometChat.User | null>(null);
148
156
  const theme = useTheme();
149
- const { t } = useCometChatTranslation();
157
+ const inputAlign = useInputTextAlign(); // ENG-41384
158
+ // ENG-57304: Modal content (the composer opens it) starts a new native root; re-apply the kit direction.
159
+ const direction = useComponentLayoutDirection();
150
160
  const answerRefs = useRef<(React.ComponentRef<typeof TextInput> | null)[]>([]);
151
161
  const [lastRemovedIndex, setLastRemovedIndex] = useState<number | null>(null);
152
162
  const [newlyAddedIndex, setNewlyAddedIndex] = useState<number | null>(null);
@@ -242,7 +252,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
242
252
  >
243
253
  <Icon name='info' color={theme.color.error} size={20} />
244
254
  <Text
245
- style={[theme.typography.caption1.regular, { color: theme.color.error, marginLeft: 10 }]}
255
+ style={[theme.typography.caption1.regular, { color: theme.color.error, marginStart: 10 }]}
246
256
  >
247
257
  {error}
248
258
  </Text>
@@ -338,15 +348,15 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
338
348
  onChangeText={(text) => handleAnswerTextChange(text, index)}
339
349
  placeholder={answerPlaceholderText}
340
350
  placeholderTextColor={theme.color.textTertiary}
341
- style={{
351
+ style={[inputAlign, {
342
352
  flex: 1,
343
353
  padding: Platform.select({ android: 5, ios: 10 }),
344
354
  borderWidth: 1,
345
355
  borderColor: theme.color.borderLight,
346
356
  borderRadius: 8,
347
- paddingLeft: 10,
357
+ paddingStart: 10,
348
358
  color: theme.color.textPrimary,
349
- }}
359
+ }]}
350
360
  />
351
361
  </View>
352
362
  );
@@ -368,7 +378,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
368
378
  width: "100%",
369
379
  justifyContent: "center",
370
380
  alignItems: "flex-start",
371
- paddingLeft: 10,
381
+ paddingStart: 10,
372
382
  }}
373
383
  >
374
384
  <Text
@@ -468,7 +478,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
468
478
 
469
479
  return (
470
480
  <SafeAreaView
471
- style={{ flex: 1, backgroundColor: theme.color.background1 }}
481
+ style={[{ flex: 1, backgroundColor: theme.color.background1 }, directionStyle(direction)]}
472
482
  edges={["top", "left", "right"]}
473
483
  >
474
484
  <KeyboardAvoidingView
@@ -488,14 +498,14 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
488
498
  >
489
499
  <TouchableOpacity
490
500
  onPress={onClose}
491
- style={{ flexDirection: "row", paddingVertical: 20, paddingLeft: 10 }}
501
+ style={{ flexDirection: "row", paddingVertical: 20, paddingStart: 10 }}
492
502
  >
493
503
  <Icon name='arrow-back' />
494
504
  </TouchableOpacity>
495
505
  <Text
496
506
  style={[
497
507
  theme.typography.heading2.bold,
498
- { color: theme.color.iconPrimary, paddingLeft: 10 },
508
+ { color: theme.color.iconPrimary, paddingStart: 10 },
499
509
  ]}
500
510
  >
501
511
  {title ? title : t("CREATE_POLL")}
@@ -506,6 +516,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
506
516
  <View style={{ paddingHorizontal: 20 }}>
507
517
  <Text
508
518
  style={[
519
+ TEXT_START,
509
520
  theme.typography.heading4.medium,
510
521
  { marginTop: 15, color: theme.color.textPrimary },
511
522
  ]}
@@ -518,19 +529,21 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
518
529
  placeholder={questionPlaceholderText}
519
530
  placeholderTextColor={theme.color.textTertiary}
520
531
  style={[
532
+ inputAlign,
521
533
  {
522
534
  padding: Platform.select({ android: 5, ios: 10 }),
523
535
  borderWidth: 1,
524
536
  borderColor: theme.color.borderLight,
525
537
  borderRadius: 8,
526
538
  marginTop: 10,
527
- paddingLeft: 10,
539
+ paddingStart: 10,
528
540
  color: theme.color.textPrimary,
529
541
  },
530
542
  ]}
531
543
  />
532
544
  <Text
533
545
  style={[
546
+ TEXT_START,
534
547
  theme.typography.heading4.medium,
535
548
  { marginTop: 25, color: theme.color.textPrimary, marginBottom: 2 },
536
549
  ]}
@@ -17,6 +17,8 @@ import { CometChatTheme } from "../../theme/type";
17
17
  import { CometChatAvatar } from "../../shared/views/CometChatAvatar";
18
18
  import { useTheme } from "../../theme";
19
19
  import { Icon } from "../../shared/icons/Icon";
20
+ import { localizeDigits } from "../../shared/helper/LocalizedDateHelper";
21
+ import { useCometChatTranslation } from "../../shared/resources/CometChatLocalizeNew/useCometChatTranslationHook";
20
22
 
21
23
  /**
22
24
  *
@@ -152,6 +154,8 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
152
154
  activeProgressBarTint,
153
155
  } = props;
154
156
  const theme = useTheme();
157
+ // The context language: the provider sets the global one in an effect, a render later.
158
+ const { language } = useCometChatTranslation();
155
159
  const [optionsList, setOptionsList] = useState<Array<{ id: any; value: any }>>([]);
156
160
  const [optionsMetaData, setOptionsMetaData] = useState<any>({});
157
161
  const [isLoading, setIsLoading] = useState(false);
@@ -227,10 +231,10 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
227
231
  const secondavatarStyle = voteravatarStyle;
228
232
  const thirdavatarStyle = voteravatarStyle;
229
233
  if (secondavatarStyle && secondavatarStyle.containerStyle) {
230
- Object.assign(secondavatarStyle.containerStyle, { marginLeft: -10 });
234
+ Object.assign(secondavatarStyle.containerStyle, { marginStart: -10 });
231
235
  }
232
236
  if (thirdavatarStyle && thirdavatarStyle.containerStyle) {
233
- Object.assign(thirdavatarStyle.containerStyle, { marginLeft: -10 });
237
+ Object.assign(thirdavatarStyle.containerStyle, { marginStart: -10 });
234
238
  }
235
239
  // Ensure value is a string for rendering
236
240
  let optionText = typeof value === 'string' ? value : (value && value.value ? value.value : String(value));
@@ -292,7 +296,7 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
292
296
  </View>
293
297
 
294
298
  <Text style={voteCountTextStyle}>
295
- {optionsMetaData?.results?.options?.[id]?.count ?? 0}
299
+ {localizeDigits(String(optionsMetaData?.results?.options?.[id]?.count ?? 0), language)}
296
300
  </Text>
297
301
  </View>
298
302
  </View>
@@ -366,7 +370,7 @@ const style = StyleSheet.create({
366
370
  height: 20,
367
371
  width: 20,
368
372
  borderRadius: 20,
369
- marginLeft: 10,
373
+ marginStart: 10,
370
374
  alignItems: "center",
371
375
  justifyContent: "center",
372
376
  },
@@ -378,8 +382,8 @@ const style = StyleSheet.create({
378
382
  flexDirection: "row",
379
383
  position: "absolute",
380
384
  height: "100%",
381
- borderTopLeftRadius: 6,
382
- borderBottomLeftRadius: 6,
385
+ borderTopStartRadius: 6,
386
+ borderBottomStartRadius: 6,
383
387
  },
384
388
  centerPosition: {
385
389
  position: "absolute",
@@ -67,7 +67,7 @@ export const getPollBubbleStyleLight = (
67
67
  color: color.receiveBubbleText,
68
68
  flex: 1,
69
69
  maxWidth: "80%",
70
- marginRight: 10,
70
+ marginEnd: 10,
71
71
  //alignSelf: 'flex-end'
72
72
  },
73
73
  voteCountTextStyle: {
@@ -96,7 +96,7 @@ export const getPollBubbleStyleLight = (
96
96
  },
97
97
  activeProgressBarTint: color.iconHighlight,
98
98
  dateReceiptContainerStyle: {
99
- paddingRight: spacing.padding.p0,
99
+ paddingEnd: spacing.padding.p0,
100
100
  },
101
101
  voteravatarStyle: {
102
102
  containerStyle: {
@@ -139,7 +139,7 @@ export const getPollBubbleStyleLight = (
139
139
  color: color.sendBubbleText,
140
140
  flex: 1,
141
141
  maxWidth: "80%",
142
- marginRight: 10
142
+ marginEnd: 10
143
143
  },
144
144
  voteCountTextStyle: {
145
145
  ...typography.body.regular,
@@ -167,7 +167,7 @@ export const getPollBubbleStyleLight = (
167
167
  marginBottom: spacing.margin.m0,
168
168
  },
169
169
  dateReceiptContainerStyle: {
170
- paddingRight: spacing.padding.p0,
170
+ paddingEnd: spacing.padding.p0,
171
171
  },
172
172
  voteravatarStyle: {
173
173
  containerStyle: {
@@ -231,7 +231,7 @@ export const CometChatStickerKeyboard = (props: CometChatStickerKeyboardInterfac
231
231
  <Text
232
232
  style={[
233
233
  theme?.typography?.body.regular,
234
- { color: theme.color.textTertiary, paddingLeft: 10 },
234
+ { color: theme.color.textTertiary, paddingStart: 10 },
235
235
  ]}
236
236
  >
237
237
  {activeStickerSetName}
@@ -258,7 +258,7 @@ export const CometChatStickerKeyboard = (props: CometChatStickerKeyboardInterfac
258
258
  <TouchableOpacity
259
259
  style={Styles.sectionListItemStyle}
260
260
  onPress={() => onStickerSetClicked(item)}
261
- accessibilityLabel={`Sticker category ${item}`}
261
+ accessibilityLabel={t('STICKER_CATEGORY_NAMED').replace('{name}', item)}
262
262
  accessibilityRole='button'
263
263
  >
264
264
  {isActive && (
@@ -20,7 +20,7 @@ const SkeletonBox = ({ index, boxSize, gradientColors }: any) => {
20
20
  {
21
21
  width: boxSize,
22
22
  height: boxSize,
23
- marginRight: isLastInRow ? 0 : 8,
23
+ marginEnd: isLastInRow ? 0 : 8,
24
24
  },
25
25
  ]}
26
26
  >
@@ -34,7 +34,7 @@ export const Styles = StyleSheet.create({
34
34
  position: "absolute",
35
35
  top: "50%",
36
36
  left: "50%",
37
- marginLeft: -10,
37
+ marginStart: -10,
38
38
  marginTop: -10,
39
39
  zIndex: 2,
40
40
  borderRadius: 10,
@@ -240,8 +240,8 @@ const StickerButton = ({ user, group, id, stickerIconStyle, stickerIcon, replyTo
240
240
  key={"sticker"}
241
241
  onPress={togglePanel}
242
242
  style={{ justifyContent: "center", alignItems: "center", padding: 10 }}
243
- accessibilityLabel='Sticker Button'
244
- accessibilityHint='Opens the sticker panel'
243
+ accessibilityLabel={t('STICKER')}
244
+ accessibilityHint={t('OPEN_STICKER_PANEL')}
245
245
  >
246
246
  <Icon
247
247
  name='sticker-fill'
package/src/index.ts CHANGED
@@ -414,8 +414,12 @@ export type {
414
414
  } from "./shared";
415
415
 
416
416
  export {CometChatI18nProvider,useCometChatTranslation} from "./shared/resources/CometChatLocalizeNew"
417
- export {localizedDateHelperInstance,LocalizedDateHelper} from "./shared/helper/LocalizedDateHelper"
417
+ export {localizedDateHelperInstance,LocalizedDateHelper,localizeDigits} from "./shared/helper/LocalizedDateHelper"
418
+ // "{count} …" in the kit language's plural form (MEMBER_COUNT, REPLY_COUNT, …), for apps that use the kit bundles.
419
+ export { pluralCountLabel } from "./shared/helper/pluralRules";
418
420
  export { useLocalizedDate } from "./shared/helper/useLocalizedDateHook";
421
+ export { useCometChatLayoutDirection } from "./shared/helper/layoutDirection";
422
+ export type { CometChatLayoutDirection } from "./shared/helper/layoutDirection";
419
423
 
420
424
  export { CometChatMessageHeader } from "./CometChatMessageHeader";
421
425
  export {getLastSeenTime}
@@ -24,6 +24,7 @@ import { applyOfflineSetting, prepareOfflineSupport, startOfflineSupport } from
24
24
  import { isOfflineOn } from "../offline/gate";
25
25
  import { sendWithStatePromise } from "../offline/send";
26
26
  import { UIKitSettings } from "./UIKitSettings";
27
+ import { CometChatLayoutDirection, setGlobalLayoutDirection } from "../helper/layoutDirection";
27
28
 
28
29
  export class CometChatUIKit {
29
30
  static uiKitSettings: UIKitSettings;
@@ -42,6 +43,8 @@ export class CometChatUIKit {
42
43
  CometChatUIKit.uiKitSettings = {
43
44
  ...uiKitSettings,
44
45
  };
46
+ // Only when given: an init without one must not undo an earlier setLayoutDirection().
47
+ if (uiKitSettings.layoutDirection !== undefined) setGlobalLayoutDirection(uiKitSettings.layoutDirection);
45
48
  // Plain init(): clear any ai-agent settings so the Calls SDK uses plain init().
46
49
  CometChatUIKit.callsInitSettings = null;
47
50
  var appSetting = new CometChat.AppSettingsBuilder()
@@ -129,6 +132,11 @@ export class CometChatUIKit {
129
132
  (settings.uiKit as { subscribePresenceForAllUsers?: boolean })
130
133
  ?.subscribePresenceForAllUsers ?? true;
131
134
 
135
+ // The file's uiKit.layoutDirection, as init()'s layoutDirection: applied only when given.
136
+ const layoutDirection = (settings.uiKit as { layoutDirection?: CometChatLayoutDirection } | undefined)
137
+ ?.layoutDirection;
138
+ if (layoutDirection !== undefined) setGlobalLayoutDirection(layoutDirection);
139
+
132
140
  // Store internally so login/createUser/updateUser keep working
133
141
  CometChatUIKit.uiKitSettings = {
134
142
  appId: settings.appId,
@@ -139,6 +147,7 @@ export class CometChatUIKit {
139
147
  : undefined,
140
148
  // Same as init(): the kit's settings carry the offline setting the SDK was given.
141
149
  offline: (settings.chatSDK as { offline?: UIKitSettings["offline"] } | undefined)?.offline,
150
+ layoutDirection,
142
151
  };
143
152
 
144
153
  // Capture raw settings so the Calls SDK routes through initFromSettings (ai-agent).
@@ -183,6 +192,14 @@ export class CometChatUIKit {
183
192
  );
184
193
  }
185
194
 
195
+ /**
196
+ * Change the kit's layout direction after init. Applies to components created afterwards
197
+ * (reopen the screen); mounted components keep the direction they were created with.
198
+ */
199
+ static setLayoutDirection(layoutDirection: CometChatLayoutDirection) {
200
+ setGlobalLayoutDirection(layoutDirection);
201
+ }
202
+
186
203
  static defaultExtensions: ExtensionsDataSource[] = [
187
204
  new StickersExtension(),
188
205
  new CollaborativeWhiteboardExtension(),
@@ -1,5 +1,6 @@
1
1
  import { CallingExtension } from "../../calls";
2
2
  import { ExtensionsDataSource } from "../framework";
3
+ import type { CometChatLayoutDirection } from "../helper/layoutDirection";
3
4
 
4
5
  /**
5
6
  * Offline settings handed through to the Chat SDK's `OfflineConfig` (README §4). The kit's own
@@ -27,6 +28,11 @@ export type UIKitSettings = {
27
28
  extensions?: ExtensionsDataSource[];
28
29
  roles?: string[];
29
30
  callingExtension?: CallingExtension;
31
+ /**
32
+ * The kit's layout direction: `'auto'` (default, follow the app), `'ltr'` or `'rtl'`. Needs no
33
+ * `I18nManager.forceRTL` and no reload; the app's own screens are not affected.
34
+ */
35
+ layoutDirection?: CometChatLayoutDirection;
30
36
  /**
31
37
  * Offline messaging (Chat SDK 4.2.1 or later). `true`, an options object, or an SDK
32
38
  * `OfflineConfig`. Absent ⇒ offline off and the kit behaves exactly as before. Ignored by an
@@ -49,6 +55,7 @@ export function UIKitSettings({
49
55
  extensions,
50
56
  roles,
51
57
  callingExtension,
58
+ layoutDirection,
52
59
  offline,
53
60
  }: UIKitSettings): UIKitSettings {
54
61
  return {
@@ -65,6 +72,7 @@ export function UIKitSettings({
65
72
  extensions,
66
73
  roles,
67
74
  callingExtension,
75
+ layoutDirection,
68
76
  offline,
69
77
  };
70
78
  }