@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
@@ -14,6 +14,7 @@ import { CometChatTheme } from "../../../theme/type";
14
14
  import { deepMerge } from "../../helper/helperFunctions";
15
15
  import { unescapeTypedMentionTokensInTree } from "../../utils/mentionTokens";
16
16
  import { getCometChatTranslation } from "../../resources/CometChatLocalizeNew/LocalizationManager";
17
+ import { isolateText, stripBidiControls } from "../../helper/textDirection";
17
18
  import { readListPage } from "../../offline/twoPhase";
18
19
 
19
20
  const t = getCometChatTranslation();
@@ -338,8 +339,9 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
338
339
  return users.map((item: CometChat.User) => {
339
340
  return new SuggestionItem({
340
341
  id: item?.getUid(),
341
- name: item?.getName(),
342
- promptText: "@" + item?.getName(),
342
+ // ENG-41456: the name is shown in the list AND inserted into the composer when picked.
343
+ name: stripBidiControls(item?.getName()),
344
+ promptText: "@" + stripBidiControls(item?.getName()),
343
345
  trackingCharacter: "@",
344
346
  underlyingText: `<@uid:${item?.getUid()}>`,
345
347
  leadingIconUrl: item?.getAvatar(),
@@ -658,17 +660,18 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
658
660
  paddingHorizontal: 2,
659
661
  } : {};
660
662
 
661
- if (this.target === MentionsTargetElement.textbubble) {
662
- return (
663
- <Text suppressHighlighting={true} key={index} {...onPressProp} style={[textStyle, mentionContainerStyle]}>
664
- {userRegistry[id]}
665
- </Text>
666
- );
667
- }
663
+ // ENG-41314: an isolated "@name" keeps its own direction and can't reorder the words
664
+ // around it. Not in the composer input, where the marks would become typed text.
665
+ // A label that is empty once bidi controls are stripped falls back to the uid, so the
666
+ // chip is never an invisible, still-pressable span.
667
+ const label =
668
+ this.target === MentionsTargetElement.textinput
669
+ ? userRegistry[id]
670
+ : isolateText(userRegistry[id]) || isolateText("@" + id);
668
671
 
669
672
  return (
670
673
  <Text suppressHighlighting={true} key={index} {...onPressProp} style={[textStyle, mentionContainerStyle]}>
671
- {userRegistry[id]}
674
+ {label}
672
675
  </Text>
673
676
  );
674
677
  } else {
@@ -4,6 +4,8 @@ import { Text, TextStyle, ViewStyle, Platform, Linking, View } from "react-nativ
4
4
  import { CometChatTextFormatter } from "../CometChatTextFormatter";
5
5
  import { COLOR_OPEN_TAG, HEX_COLOR_REGEX, findColorTag, stripColorTags } from "../richTextWireFormat";
6
6
  import { markCode } from "../codeElements";
7
+ import { LRM, pinLtr } from "../../helper/textDirection";
8
+ import { CODE_DIRECTION } from "../../helper/layoutDirection";
7
9
  import { isTextElement, isViewElement } from "../../utils/elementType";
8
10
  import { urlPattern, emailPattern, markdownLinkPattern } from "../../constants/textPatterns";
9
11
 
@@ -113,7 +115,7 @@ const BQ_BAR_STYLE = {
113
115
  backgroundColor: 'rgba(255,255,255,0.6)',
114
116
  borderRadius: 2,
115
117
  marginVertical: 4,
116
- marginLeft: 4,
118
+ marginStart: 4,
117
119
  };
118
120
  const BQ_CONTENT_STYLE = {
119
121
  flexShrink: 1 as const,
@@ -284,6 +286,7 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
284
286
  backgroundColor: "transparent",
285
287
  borderRadius: 4,
286
288
  padding: 12,
289
+ direction: "ltr",
287
290
  },
288
291
  this.style.codeBlockContainerStyle,
289
292
  ]}
@@ -292,7 +295,7 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
292
295
  style here — but it must never reach the reader as literal markup either.
293
296
  Messages sent before the serializer fix still carry the token inside the
294
297
  fence, so strip rather than render (ENG-38253). */}
295
- {markCode(<Text style={[this.style.codeBlockStyle]}>{stripColorTags(content)}</Text>)}
298
+ {markCode(<Text style={[CODE_DIRECTION, this.style.codeBlockStyle]}>{stripColorTags(content)}</Text>)}
296
299
  </View>
297
300
  );
298
301
  lineIndex++;
@@ -332,6 +335,8 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
332
335
  backgroundColor: "transparent",
333
336
  borderRadius: 4,
334
337
  padding: 12,
338
+ // Code reads left to right in an RTL layout too (CODE_DIRECTION).
339
+ direction: "ltr",
335
340
  },
336
341
  this.style.codeBlockContainerStyle,
337
342
  ]}
@@ -339,6 +344,7 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
339
344
  {markCode(
340
345
  <Text
341
346
  style={[
347
+ CODE_DIRECTION,
342
348
  this.style.codeBlockStyle,
343
349
  ]}
344
350
  >
@@ -392,7 +398,7 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
392
398
  quoteLevelCounters.set(level, currentCount);
393
399
  const indent = level * NESTED_LIST_INDENT;
394
400
  quoteContent.push(
395
- <View key={`ql-${i}`} style={[LIST_ROW_STYLE, indent > 0 ? { marginLeft: indent } : undefined]}>
401
+ <View key={`ql-${i}`} style={[LIST_ROW_STYLE, indent > 0 ? { marginStart: indent } : undefined]}>
396
402
  <Text style={ORDERED_MARKER_STYLE}>{formatListMarker(currentCount, level)}</Text>
397
403
  <Text style={LIST_CONTENT_STYLE}>
398
404
  {orderedMatch[3].trim() === '' ? ' ' : this.parseInlineFormats(orderedMatch[3])}
@@ -452,7 +458,7 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
452
458
  const { text: itemText, level } = listItems[i];
453
459
  const indent = level * NESTED_LIST_INDENT;
454
460
  elements.push(
455
- <View key={`bullet-${elements.length}`} style={[LIST_ROW_STYLE, indent > 0 ? { marginLeft: indent } : undefined]}>
461
+ <View key={`bullet-${elements.length}`} style={[LIST_ROW_STYLE, indent > 0 ? { marginStart: indent } : undefined]}>
456
462
  <Text style={BULLET_MARKER_STYLE}>{"‧ "}</Text>
457
463
  <Text style={LIST_CONTENT_STYLE}>
458
464
  {itemText.trim() === '' ? ' ' : this.parseInlineFormats(itemText)}
@@ -494,7 +500,7 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
494
500
  levelCounters.set(level, currentCount);
495
501
  const indent = level * NESTED_LIST_INDENT;
496
502
  elements.push(
497
- <View key={`ordered-${elements.length}`} style={[LIST_ROW_STYLE, indent > 0 ? { marginLeft: indent } : undefined]}>
503
+ <View key={`ordered-${elements.length}`} style={[LIST_ROW_STYLE, indent > 0 ? { marginStart: indent } : undefined]}>
498
504
  <Text style={ORDERED_MARKER_STYLE}>{formatListMarker(currentCount, level)}</Text>
499
505
  <Text style={LIST_CONTENT_STYLE}>
500
506
  {itemText.trim() === '' ? ' ' : this.parseInlineFormats(itemText)}
@@ -656,8 +662,10 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
656
662
  // Use a single Text element (not View) so inline code stays on the
657
663
  // same text baseline as surrounding content (mentions, plain text).
658
664
  // Text supports backgroundColor, borderRadius, and padding in RN.
665
+ // ENG-41314: an LRM on each side keeps code LTR in an RTL message — pinLtr() takes a
666
+ // string, this content can be elements.
659
667
  elements.push(markCode(
660
- <Text key={`fmt-${keyCounter++}`} style={[this.style.inlineCodeContainerStyle, this.style.inlineCodeStyle]}>{innerContent}</Text>
668
+ <Text key={`fmt-${keyCounter++}`} style={[this.style.inlineCodeContainerStyle, this.style.inlineCodeStyle]}>{LRM}{innerContent}{LRM}</Text>
661
669
  ));
662
670
  } else if (match.type === "codeBlock") {
663
671
  // Inline ```text``` — render identically to single-backtick inline code
@@ -667,7 +675,7 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
667
675
  <Text
668
676
  key={`fmt-${keyCounter++}`}
669
677
  style={[this.style.inlineCodeContainerStyle, this.style.inlineCodeStyle]}
670
- >{restoredContent}</Text>
678
+ >{pinLtr(restoredContent)}</Text>
671
679
  ));
672
680
  } else if (match.type === "textColor" && match.color) {
673
681
  // Re-validate at render time: the hex reaching here came off the wire, and an
@@ -82,6 +82,17 @@ export abstract class CometChatTextFormatter {
82
82
  return this.composerId;
83
83
  };
84
84
 
85
+ // ENG-41314: true only on the composer's own copy of a formatter — the instance that draws the
86
+ // input box. Not the composer id: the app's instance carries that too and may also draw the
87
+ // message list. Read it from a prototype method (this = the copy), never from an arrow property,
88
+ // which CommonUtils.clone carries over still bound to the original instance.
89
+ protected composerInput = false;
90
+
91
+ /** Marks this formatter as the composer's own copy (called by the composers after cloning). */
92
+ markAsComposerInput() {
93
+ this.composerInput = true;
94
+ }
95
+
85
96
  /**
86
97
  * Gets the formatter ID.
87
98
  * @returns The formatter ID.
@@ -4,6 +4,7 @@ import { ColorValue, Linking, Text, TextStyle } from "react-native";
4
4
  import { emailPattern, phoneNumPattern, urlPattern } from "../../constants/UIKitConstants";
5
5
  import { CometChatTextFormatter } from "../CometChatTextFormatter";
6
6
  import { isCode } from "../codeElements";
7
+ import { pinLtr } from "../../helper/textDirection";
7
8
 
8
9
  export class CometChatUrlsFormatter extends CometChatTextFormatter {
9
10
  protected style: {
@@ -77,7 +78,8 @@ export class CometChatUrlsFormatter extends CometChatTextFormatter {
77
78
  return null;
78
79
  }
79
80
  try {
80
- let formattedText = this.getFormatTextForLinks({ str: inputText, style: this.style });
81
+ // Decided here, a method running on the composer's copy: no invisible marks in the input box.
82
+ let formattedText = this.getFormatTextForLinks({ str: inputText, style: this.style, pin: !this.composerInput });
81
83
  return formattedText;
82
84
  } catch {
83
85
  // Gracefully handle regex stack overflow on Android Hermes for very long messages.
@@ -86,7 +88,7 @@ export class CometChatUrlsFormatter extends CometChatTextFormatter {
86
88
  }
87
89
  }
88
90
 
89
- getFormatTextForLinks = ({ str, style }: any): any => {
91
+ getFormatTextForLinks = ({ str, style, pin = true }: any): any => {
90
92
  if (typeof str === "string") {
91
93
  let res = str.matchAll(
92
94
  (phoneNumPattern + "|" + emailPattern + "|" + urlPattern) as unknown as RegExp
@@ -103,13 +105,14 @@ export class CometChatUrlsFormatter extends CometChatTextFormatter {
103
105
  <Text>
104
106
  <Text>{pre}</Text>
105
107
  {this.Link({
106
- text: resPart[0].trim(),
108
+ text: pin ? pinLtr(resPart[0].trim()) : resPart[0].trim(),
107
109
  url: urlLink.trim() + resPart[0].trim(),
108
110
  style: { ...this.style },
109
111
  })}
110
112
  {this.getFormatTextForLinks({
111
113
  str: post,
112
114
  style: style,
115
+ pin,
113
116
  })}
114
117
  </Text>
115
118
  );
@@ -130,7 +133,7 @@ export class CometChatUrlsFormatter extends CometChatTextFormatter {
130
133
  // and call addMentionsSpan recursively for each child.
131
134
  return React.cloneElement(str as React.ReactElement<any>, {
132
135
  children: React.Children.map((str as React.ReactElement<any>).props.children, (child) => {
133
- return this.getFormatTextForLinks({ str: child, style: style });
136
+ return this.getFormatTextForLinks({ str: child, style: style, pin });
134
137
  }),
135
138
  });
136
139
  } else {
@@ -27,6 +27,7 @@ import {
27
27
  } from "../constants/UIKitConstants";
28
28
  import { CometChatUiKitConstants } from "../index";
29
29
  import { CometChatMessageComposerAction } from "../helper/types";
30
+ import { groupActionText } from "../utils/groupActionText";
30
31
  import { Icon, IconName } from "../icons/Icon";
31
32
  import { getMessagePreviewInternal } from "../utils/MessageUtils";
32
33
  import { canPin, isPinned, isPinSaveEligible, isSaved, PinSaveConfig } from "../utils/PinSaveHelper";
@@ -1342,9 +1343,6 @@ export class MessageDataSource implements DataSource {
1342
1343
  * Returns a localized group action message string for group events (added, kicked, banned, etc.)
1343
1344
  */
1344
1345
  getActionMessage(message: any): string {
1345
-
1346
- let actionMessage = "";
1347
-
1348
1346
  if (!message || typeof message !== "object") {
1349
1347
  return "";
1350
1348
  }
@@ -1364,94 +1362,19 @@ export class MessageDataSource implements DataSource {
1364
1362
  return message.message || "";
1365
1363
  }
1366
1364
 
1367
- // Names (JOINED/LEFT only need byName)
1368
- const byName = actionBy?.name || "User";
1369
- const onName = requiresActionOn ? (actionOn?.name || "User") : "";
1370
-
1371
- const GroupMemberAction = {
1372
- ADDED: "added",
1373
- JOINED: "joined",
1374
- LEFT: "left",
1375
- KICKED: "kicked",
1376
- BANNED: "banned",
1377
- UNBANNED: "unbanned",
1378
- SCOPE_CHANGE: "scopeChanged",
1379
- } as const;
1380
-
1381
- switch (action) {
1382
- case GroupMemberAction.ADDED:
1383
- // Use template string with placeholders for names
1384
- actionMessage = t("MESSAGE_LIST_ACTION_ADDED").replace("${byName}", byName).replace("${onName}", onName);
1385
- // Fallback to simpler format if template is missing
1386
- if (actionMessage === "MESSAGE_LIST_ACTION_ADDED") {
1387
- actionMessage = `${byName} ${t("ADDED")} ${onName}`;
1388
- }
1389
- break;
1390
-
1391
- case GroupMemberAction.JOINED:
1392
- // No onName needed
1393
- actionMessage = t("MESSAGE_LIST_ACTION_JOINED").replace("${byName}", byName);
1394
- if (actionMessage === "MESSAGE_LIST_ACTION_JOINED") {
1395
- actionMessage = `${byName} ${t("JOINED")}`;
1396
- }
1397
- break;
1398
-
1399
- case GroupMemberAction.LEFT:
1400
- // No onName needed
1401
- actionMessage = t("MESSAGE_LIST_ACTION_LEFT").replace("${byName}", byName);
1402
- if (actionMessage === "MESSAGE_LIST_ACTION_LEFT") {
1403
- actionMessage = `${byName} ${t("LEFT")}`;
1404
- }
1405
- break;
1406
-
1407
- case GroupMemberAction.KICKED:
1408
- actionMessage = t("MESSAGE_LIST_ACTION_KICKED").replace("${byName}", byName).replace("${onName}", onName);
1409
- if (actionMessage === "MESSAGE_LIST_ACTION_KICKED") {
1410
- actionMessage = `${byName} ${t("KICKED")} ${onName}`;
1411
- }
1412
- break;
1413
-
1414
- case GroupMemberAction.BANNED:
1415
- actionMessage = t("MESSAGE_LIST_ACTION_BANNED").replace("${byName}", byName).replace("${onName}", onName);
1416
- if (actionMessage === "MESSAGE_LIST_ACTION_BANNED") {
1417
- actionMessage = `${byName} ${t("BANNED")} ${onName}`;
1418
- }
1419
- break;
1420
-
1421
- case GroupMemberAction.UNBANNED:
1422
- actionMessage = t("MESSAGE_LIST_ACTION_UNBANNED").replace("${byName}", byName).replace("${onName}", onName);
1423
- if (actionMessage === "MESSAGE_LIST_ACTION_UNBANNED") {
1424
- actionMessage = `${byName} ${t("UNBANNED")} ${onName}`;
1425
- }
1426
- break;
1427
-
1428
- case GroupMemberAction.SCOPE_CHANGE: {
1429
- const newScope =
1430
- message.newScope ||
1431
- message.data?.extras?.scope?.new ||
1432
- message.rawMessage?.data?.extras?.scope?.new ||
1433
- "";
1434
-
1435
- const translatedRole = newScope ? t(newScope.toUpperCase()) : "";
1436
-
1437
- // Template with three placeholders
1438
- actionMessage = t("MESSAGE_LIST_ACTION_SCOPE_CHANGED")
1439
- .replace("${byName}", byName)
1440
- .replace("${onName}", onName)
1441
- .replace("${role}", translatedRole);
1442
-
1443
- if (actionMessage === "MESSAGE_LIST_ACTION_SCOPE_CHANGED") {
1444
- actionMessage = `${byName} ${t("MADE")} ${onName} ${translatedRole}`.trim();
1445
- }
1446
- break;
1447
- }
1448
-
1449
- default:
1450
- actionMessage = message.message || "";
1451
- break;
1452
- }
1453
-
1454
- return actionMessage;
1365
+ const newScope =
1366
+ message.newScope ||
1367
+ message.data?.extras?.scope?.new ||
1368
+ message.rawMessage?.data?.extras?.scope?.new ||
1369
+ "";
1370
+ // RTL parity (Android GroupActionText.kt): "You …" / "… you" for the logged-in user. The
1371
+ // action's users can be SDK objects or raw JSON (conversation list preview), so read both.
1372
+ const myUid = CometChatUIKit.loggedInUser?.getUid?.();
1373
+ const uidOf = (user: any) => user?.getUid?.() ?? user?.uid;
1374
+ const self = myUid
1375
+ ? { actor: uidOf(actionBy) === myUid, target: !!actionOn && uidOf(actionOn) === myUid }
1376
+ : {};
1377
+ return groupActionText(action, actionBy?.name, actionOn?.name, t, newScope, message.message || "", self);
1455
1378
  }
1456
1379
 
1457
1380
  getGroupActionBubble(message: CometChat.BaseMessage, theme: CometChatTheme): JSX.Element | null {
@@ -1537,8 +1460,8 @@ export class MessageDataSource implements DataSource {
1537
1460
  backgroundColor: isOutgoingMessage ? theme.color.extendedPrimary800 : theme.color.neutral400,
1538
1461
  borderRadius: 8,
1539
1462
  borderWidth: 0,
1540
- borderLeftWidth: 3,
1541
- borderLeftColor: isOutgoingMessage ? theme.color.staticWhite : theme.color.borderHighlight,
1463
+ borderStartWidth: 3,
1464
+ borderStartColor: isOutgoingMessage ? theme.color.staticWhite : theme.color.borderHighlight,
1542
1465
  margin:2,
1543
1466
  width:"98%"
1544
1467
  }}
@@ -2819,7 +2742,7 @@ export const internalMessageDataSource = new MessageDataSource();
2819
2742
 
2820
2743
  const styles = StyleSheet.create({
2821
2744
  aiCopyIcon: {
2822
- marginLeft: 10,
2745
+ marginStart: 10,
2823
2746
  marginBottom: -20,
2824
2747
  },
2825
2748
  });
@@ -1,5 +1,5 @@
1
1
  import { Language } from "../resources/CometChatLocalizeNew/type";
2
- import { getCometChatTranslation } from "../resources/CometChatLocalizeNew/LocalizationManager";
2
+ import { getCometChatTranslation, getCurrentLanguage } from "../resources/CometChatLocalizeNew/LocalizationManager";
3
3
  import dayjs from 'dayjs';
4
4
  import 'dayjs/locale/en'; // English
5
5
  import 'dayjs/locale/hi'; // Hindi
@@ -19,6 +19,8 @@ import 'dayjs/locale/sv'; // Swedish
19
19
  import 'dayjs/locale/lt'; // Lithuanian
20
20
  import 'dayjs/locale/hu'; // Hungarian
21
21
  import 'dayjs/locale/nl'; // Dutch
22
+ import 'dayjs/locale/ar'; // Arabic (ENG-41314)
23
+ import 'dayjs/locale/he'; // Hebrew (ENG-41314)
22
24
  // Import other languages as needed
23
25
 
24
26
  // Dayjs plugins
@@ -42,6 +44,7 @@ export class LocalizedDateHelper {
42
44
  callLogs: "callLogs",
43
45
  relativeMinutes: "relativeMinutes",
44
46
  conversationDate: "conversationDate",
47
+ monthYear: "monthYear",
45
48
  } as const;
46
49
 
47
50
  /**
@@ -96,7 +99,8 @@ export class LocalizedDateHelper {
96
99
  const twelveHourLocales = [
97
100
  'en-US', 'en-GB', 'en',
98
101
  'hi-IN', 'hi',
99
- 'ms-MY', 'ms'
102
+ 'ms-MY', 'ms',
103
+ 'ar'
100
104
  ];
101
105
 
102
106
  const { localeCode, dayJsLocale } = this.getLocaleConfig(locale);
@@ -163,6 +167,10 @@ export class LocalizedDateHelper {
163
167
  'sv': 'sv-SE',
164
168
  'lt': 'lt-LT',
165
169
  'hu': 'hu-HU',
170
+ // ENG-41314: bare 'ar' resolves to Western digits in current ICU and 'ar-SA' switches
171
+ // to the Hijri calendar; ar-EG is Gregorian with Arabic-Indic digits (٤:٥٦ م).
172
+ 'ar': 'ar-EG',
173
+ 'he': 'he-IL',
166
174
  };
167
175
 
168
176
  // Return the mapped region or construct a default one
@@ -213,6 +221,28 @@ export class LocalizedDateHelper {
213
221
  }
214
222
  }
215
223
 
224
+ /**
225
+ * Month and year ("November 2026", "نوفمبر ٢٠٢٦"), in the locale's own order (ja "2026年11月").
226
+ * It is a section title, so the first letter is capitalised (Intl gives es "noviembre de 2026").
227
+ */
228
+ private formatMonthYear(date: Date, locale: Language): string {
229
+ const { dateFormattingLocale, dayJsLocale } = this.getLocaleConfig(locale);
230
+ let label: string;
231
+ try {
232
+ label = new Intl.DateTimeFormat(dateFormattingLocale, { month: 'long', year: 'numeric' }).format(date);
233
+ } catch {
234
+ dayjs.locale(dayJsLocale);
235
+ label = dayjs(date).format('MMMM YYYY');
236
+ }
237
+ let first: string;
238
+ try {
239
+ first = label.charAt(0).toLocaleUpperCase(dateFormattingLocale);
240
+ } catch {
241
+ first = label.charAt(0).toUpperCase();
242
+ }
243
+ return first + label.slice(1);
244
+ }
245
+
216
246
  /**
217
247
  * Format date for date separators (more detailed than conversation list)
218
248
  */
@@ -285,7 +315,10 @@ export class LocalizedDateHelper {
285
315
  * Public method to get formatted date according to pattern
286
316
  */
287
317
  getFormattedDate(timestamp: number, pattern: string, locale: Language = "en"): string {
288
- const date = new Date(timestamp);
318
+ return localizeDigits(this.formatByPattern(new Date(timestamp), pattern, locale), locale);
319
+ }
320
+
321
+ private formatByPattern(date: Date, pattern: string, locale: Language): string {
289
322
 
290
323
  switch (pattern) {
291
324
  case LocalizedDateHelper.patterns.timeFormat:
@@ -301,6 +334,9 @@ export class LocalizedDateHelper {
301
334
  case LocalizedDateHelper.patterns.conversationDate:
302
335
  return this.formatConversationDate(date, locale);
303
336
 
337
+ case LocalizedDateHelper.patterns.monthYear:
338
+ return this.formatMonthYear(date, locale);
339
+
304
340
  case LocalizedDateHelper.patterns.callBubble:
305
341
  case LocalizedDateHelper.patterns.callLogs:
306
342
  const { dayJsLocale } = this.getLocaleConfig(locale);
@@ -314,4 +350,28 @@ export class LocalizedDateHelper {
314
350
  }
315
351
  }
316
352
 
317
- export const localizedDateHelperInstance = new LocalizedDateHelper();
353
+ export const localizedDateHelperInstance = new LocalizedDateHelper();
354
+
355
+ // ENG-41314 part 3: the locale's own digits (Arabic-Indic for ar, Persian for fa), read from
356
+ // Intl so no table is kept here; null for locales that write 0-9, which leaves them untouched.
357
+ const digitCache: Record<string, string[] | null> = {};
358
+ function nativeDigits(locale: string): string[] | null {
359
+ if (!(locale in digitCache)) {
360
+ let digits: string[] | null = null;
361
+ try {
362
+ const nf = new Intl.NumberFormat(locale, { useGrouping: false });
363
+ const d = Array.from({ length: 10 }, (_, i) => nf.format(i));
364
+ if (d[1] !== "1") digits = d;
365
+ } catch {
366
+ // No Intl data for this locale: keep 0-9.
367
+ }
368
+ digitCache[locale] = digits;
369
+ }
370
+ return digitCache[locale];
371
+ }
372
+
373
+ /** Rewrites 0-9 in a date, time or count into the kit language's digits. */
374
+ export function localizeDigits(text: string, language: Language = getCurrentLanguage()): string {
375
+ const digits = nativeDigits(LocalizedDateHelper.getFullLocaleForDateFormatting(language));
376
+ return digits ? text.replace(/[0-9]/g, (c) => digits[Number(c)]) : text;
377
+ }
@@ -1,9 +1,31 @@
1
1
  import React from "react";
2
2
  import { DeepPartial } from "./types";
3
3
  import { useCometChatTranslation } from "../resources/CometChatLocalizeNew";
4
- import { localizedDateHelperInstance } from "./LocalizedDateHelper";
4
+ import { localizedDateHelperInstance, localizeDigits } from "./LocalizedDateHelper";
5
+ import { pluralCategory } from "./pluralRules";
5
6
  import dayjs from "dayjs";
6
7
 
8
+ // ENG-41311: kit default styles use start/end so they mirror under RTL. Yoga gives start/end
9
+ // priority over left/right, so an override written as left/right would be ignored. Margin,
10
+ // padding and border keys are always written as start/end (same result in LTR and under
11
+ // forceRTL, which already swaps left/right). Bare left/right are also used by hitSlop and
12
+ // plain data, so they move only when the target already holds start/end.
13
+ const BARE_EDGE: Record<string, string> = { left: "start", right: "end" };
14
+ const LOGICAL_EDGE: Record<string, string> = {
15
+ marginLeft: "marginStart",
16
+ marginRight: "marginEnd",
17
+ paddingLeft: "paddingStart",
18
+ paddingRight: "paddingEnd",
19
+ borderLeftWidth: "borderStartWidth",
20
+ borderRightWidth: "borderEndWidth",
21
+ borderLeftColor: "borderStartColor",
22
+ borderRightColor: "borderEndColor",
23
+ borderTopLeftRadius: "borderTopStartRadius",
24
+ borderTopRightRadius: "borderTopEndRadius",
25
+ borderBottomLeftRadius: "borderBottomStartRadius",
26
+ borderBottomRightRadius: "borderBottomEndRadius",
27
+ };
28
+
7
29
  export function deepMerge<
8
30
  T extends Record<string, any>,
9
31
  U extends DeepPartial<T> & Record<string, any>
@@ -30,7 +52,11 @@ export function deepMerge<
30
52
  output[key] = merge({}, source[key]);
31
53
  }
32
54
  } else if (source[key] !== undefined) {
33
- output[key] = source[key];
55
+ const bare = BARE_EDGE[key];
56
+ const twin = LOGICAL_EDGE[key] ?? (bare !== undefined && bare in output ? bare : undefined);
57
+ if (twin === undefined) output[key] = source[key];
58
+ // An explicit start/end in the same override wins over its left/right twin.
59
+ else if (source[twin] === undefined) output[twin] = source[key];
34
60
  }
35
61
  }
36
62
 
@@ -74,6 +100,38 @@ export function deepClone<T>(obj: T, seen = new WeakMap()): T {
74
100
  return clone as T;
75
101
  }
76
102
 
103
+ // ENG-57310: dayjs's ar locale writes one plural for every count ("%d ساعات"), so 17 hours read
104
+ // "17 ساعات". Arabic takes the dual for 2, the plural for 3-10 and the singular from 11. These
105
+ // forms go in a kit-only copy of the locale, so dayjs's own "ar" (a host app may use it) is untouched.
106
+ const KIT_ARABIC_LOCALE = "ar-x-cometchat";
107
+ const arabicCount = (dual: string, plural: string, singular: string) => (n: number) => {
108
+ const category = pluralCategory(n, "ar");
109
+ return category === "two" ? dual : `${n} ${category === "few" ? plural : singular}`;
110
+ };
111
+ function arabicRelativeTimeLocale(): string {
112
+ if (!dayjs.Ls[KIT_ARABIC_LOCALE]) {
113
+ const ar = dayjs.Ls.ar as any;
114
+ dayjs.locale(
115
+ {
116
+ ...ar,
117
+ name: KIT_ARABIC_LOCALE,
118
+ // No digit hooks: with a host app's preParsePostFormat plugin, relativeTime would hand
119
+ // mm / hh the count as "٥" (NaN to pluralCategory). localizeDigits converts afterwards.
120
+ postformat: undefined,
121
+ preparse: undefined,
122
+ relativeTime: {
123
+ ...ar.relativeTime,
124
+ mm: arabicCount("دقيقتين", "دقائق", "دقيقة"),
125
+ hh: arabicCount("ساعتين", "ساعات", "ساعة"),
126
+ },
127
+ },
128
+ undefined,
129
+ true
130
+ );
131
+ }
132
+ return KIT_ARABIC_LOCALE;
133
+ }
134
+
77
135
  export function getLastSeenTime(timestamp: number | null | undefined): string {
78
136
  try {
79
137
  // Hook must be called unconditionally (Rules of Hooks)
@@ -98,17 +156,26 @@ export function getLastSeenTime(timestamp: number | null | undefined): string {
98
156
  const diffInMinutes = now.diff(lastSeenTime, "minute");
99
157
  const diffInHours = now.diff(lastSeenTime, "hour");
100
158
  const diffInDays = now.diff(lastSeenTime, "day");
159
+ // "X minutes ago" in the kit language's digits, with the Arabic plural forms (ENG-57310).
160
+ const fromNow = () =>
161
+ localizeDigits(
162
+ (language.split("-")[0].toLowerCase() === "ar"
163
+ ? lastSeenTime.locale(arabicRelativeTimeLocale())
164
+ : lastSeenTime
165
+ ).fromNow(),
166
+ language
167
+ );
101
168
 
102
169
  // For very recent times (< 1 min) → "a few seconds ago"
103
170
  if (diffInMinutes < 1) {
104
- const relativeTimeString = lastSeenTime.fromNow();
171
+ const relativeTimeString = fromNow();
105
172
  // Day.js will give "a few seconds ago" localized
106
173
  return `${t("LAST_SEEN")} ${relativeTimeString}`;
107
174
  }
108
175
 
109
176
  // For times less than 24 hours → relative ("X minutes ago", "X hours ago")
110
177
  if (diffInHours < 24) {
111
- const relativeTimeString = lastSeenTime.fromNow();
178
+ const relativeTimeString = fromNow();
112
179
  return `${t("LAST_SEEN")} ${relativeTimeString}`;
113
180
  }
114
181
 
@@ -0,0 +1,54 @@
1
+ import { useEffect, useState } from "react";
2
+ import { NativeEventEmitter, NativeModules } from "react-native";
3
+
4
+ type Direction = "ltr" | "rtl";
5
+
6
+ /**
7
+ * Native CometChatKeyboardModule (ios/CometChatKeyboardModule.swift, android CometChatKeyboardModule.kt):
8
+ * the direction of the current keyboard's language. `null` when the keyboard gives no language
9
+ * (emoji keyboard, dictation, a keyboard that reports none).
10
+ */
11
+ interface NativeCometChatKeyboardModuleSpec {
12
+ getKeyboardDirection(): Promise<string | null>;
13
+ addListener(eventName: string): void;
14
+ removeListeners(count: number): void;
15
+ }
16
+
17
+ /** Sent with `{ direction: "ltr" | "rtl" | null }` when the user switches keyboards. */
18
+ export const KEYBOARD_DIRECTION_EVENT = "keyboardDirectionChange";
19
+
20
+ const asDirection = (value: unknown): Direction | undefined =>
21
+ value === "ltr" || value === "rtl" ? value : undefined;
22
+
23
+ /**
24
+ * ENG-57281: the direction of the keyboard's language, for putting an empty composer's caret on that
25
+ * side. JS cannot see the keyboard, so it asks the native module, and listens only while `active`
26
+ * (the input is focused and has no letter yet): on Android the module polls while someone listens.
27
+ * A keyboard with no language (emoji panel, dictation) keeps the last direction seen, so opening
28
+ * the emoji keyboard doesn't move the caret. `undefined` while inactive, before any language was
29
+ * reported, or when the module is missing (an older native build, Expo Go); callers then keep the
30
+ * kit's start edge.
31
+ */
32
+ export function useKeyboardDirection(active: boolean): Direction | undefined {
33
+ const [direction, setDirection] = useState<Direction>();
34
+ useEffect(() => {
35
+ const native = NativeModules.CometChatKeyboardModule as NativeCometChatKeyboardModuleSpec | undefined;
36
+ if (!active || !native?.getKeyboardDirection) return;
37
+ let live = true;
38
+ // No language (null, or anything unexpected) keeps what we had.
39
+ const keep = (value: unknown) => {
40
+ const next = asDirection(value);
41
+ if (live && next) setDirection(next);
42
+ };
43
+ const subscription = new NativeEventEmitter(native as any).addListener(
44
+ KEYBOARD_DIRECTION_EVENT,
45
+ (event?: { direction?: unknown }) => keep(event?.direction)
46
+ );
47
+ native.getKeyboardDirection().then(keep).catch(() => {});
48
+ return () => {
49
+ live = false;
50
+ subscription.remove();
51
+ };
52
+ }, [active]);
53
+ return active ? direction : undefined;
54
+ }