@cometchat/chat-uikit-react-native 5.0.0-beta.1 → 5.0.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 (98) hide show
  1. package/README.md +2 -3
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +29 -44
  5. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +12 -0
  6. package/ios/FileManager.m +26 -9
  7. package/package.json +11 -36
  8. package/src/CometChatConversations/CometChatConversations.tsx +287 -147
  9. package/src/CometChatConversations/Skeleton.tsx +116 -73
  10. package/src/CometChatConversations/style.ts +17 -22
  11. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +439 -227
  12. package/src/CometChatGroupMembers/style.ts +2 -4
  13. package/src/CometChatGroups/CometChatGroups.tsx +239 -135
  14. package/src/CometChatGroups/GroupsStyle.ts +20 -17
  15. package/src/CometChatGroups/Skeleton.tsx +198 -288
  16. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +208 -73
  17. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +97 -43
  18. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -2
  19. package/src/CometChatMessageList/CometChatMessageList.tsx +200 -76
  20. package/src/CometChatMessageList/style.ts +4 -4
  21. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +77 -11
  22. package/src/CometChatThreadHeader/style.ts +2 -2
  23. package/src/CometChatUsers/CometChatUsers.tsx +203 -51
  24. package/src/CometChatUsers/Skeleton.tsx +174 -159
  25. package/src/CometChatUsers/style.ts +21 -18
  26. package/src/calls/CallingConfiguration.ts +4 -3
  27. package/src/calls/CallingExtensionDecorator.tsx +5 -3
  28. package/src/calls/CometChatCallButtons/CometChatCallButtonConfiguration.ts +4 -2
  29. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +10 -8
  30. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +240 -97
  31. package/src/calls/CometChatCallLogs/Skeleton.tsx +175 -91
  32. package/src/calls/CometChatCallLogs/index.ts +1 -0
  33. package/src/calls/CometChatCallLogs/style.ts +85 -43
  34. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +42 -29
  35. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +36 -10
  36. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +39 -12
  37. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -4
  38. package/src/extensions/Polls/PollsDecorator.tsx +30 -9
  39. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +34 -16
  40. package/src/index.ts +3 -1
  41. package/src/shared/base/Types.ts +31 -1
  42. package/src/shared/framework/DataSource.ts +64 -20
  43. package/src/shared/framework/DataSourceDecorator.tsx +46 -37
  44. package/src/shared/framework/MessageDataSource.tsx +518 -316
  45. package/src/shared/index.ts +3 -1
  46. package/src/shared/resources/CometChatLocalize/resources/ar/translation.json +3 -2
  47. package/src/shared/resources/CometChatLocalize/resources/de/translation.json +3 -2
  48. package/src/shared/resources/CometChatLocalize/resources/en/translation.json +3 -2
  49. package/src/shared/resources/CometChatLocalize/resources/es/translation.json +3 -2
  50. package/src/shared/resources/CometChatLocalize/resources/fr/translation.json +3 -2
  51. package/src/shared/resources/CometChatLocalize/resources/hi/translation.json +3 -2
  52. package/src/shared/resources/CometChatLocalize/resources/hu/translation.json +3 -2
  53. package/src/shared/resources/CometChatLocalize/resources/lt/translation.json +3 -2
  54. package/src/shared/resources/CometChatLocalize/resources/ms/translation.json +3 -2
  55. package/src/shared/resources/CometChatLocalize/resources/pt/translation.json +3 -2
  56. package/src/shared/resources/CometChatLocalize/resources/ru/translation.json +3 -2
  57. package/src/shared/resources/CometChatLocalize/resources/sv/translation.json +3 -2
  58. package/src/shared/resources/CometChatLocalize/resources/zh/translation.json +3 -2
  59. package/src/shared/resources/CometChatLocalize/resources/zh-tw/translation.json +3 -2
  60. package/src/shared/utils/MessageUtils.tsx +41 -20
  61. package/src/shared/utils/conversationUtils.ts +2 -2
  62. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +22 -1
  63. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +20 -8
  64. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +177 -123
  65. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +76 -10
  66. package/src/shared/views/CometChatConfirmDialog/style.ts +2 -2
  67. package/src/shared/views/CometChatDate/CometChatDate.tsx +26 -18
  68. package/src/shared/views/CometChatDateSeperator/CometChatDateSeparator.tsx +22 -16
  69. package/src/shared/views/CometChatDeletedBubble/CometChatDeletedBubble.tsx +17 -5
  70. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +65 -35
  71. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +22 -11
  72. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +47 -18
  73. package/src/shared/views/CometChatList/CometChatList.tsx +70 -46
  74. package/src/shared/views/CometChatList/Header.tsx +122 -37
  75. package/src/shared/views/CometChatList/styles.ts +1 -0
  76. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +116 -30
  77. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +52 -30
  78. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +36 -22
  79. package/src/shared/views/CometChatQuickReactions/CometChatQuickReactions.tsx +41 -13
  80. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +132 -17
  81. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +30 -2
  82. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +10 -6
  83. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +20 -13
  84. package/src/shared/views/CometChatStatusIndicator/styles.ts +26 -13
  85. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +25 -2
  86. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +94 -14
  87. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +52 -16
  88. package/src/shared/views/CometChatTooltipMenu/index.ts +2 -1
  89. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +29 -9
  90. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +20 -2
  91. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +29 -14
  92. package/src/shared/views/index.ts +2 -0
  93. package/src/theme/default/index.ts +5 -5
  94. package/src/theme/type.ts +2 -2
  95. package/src/shared/views/CometChatPanel/CometChatPanel.tsx +0 -57
  96. package/src/shared/views/CometChatPanel/PanelStyle.tsx +0 -43
  97. package/src/shared/views/CometChatPanel/resources/CloseIcon.png +0 -0
  98. package/src/shared/views/CometChatPanel/resources/index.ts +0 -3
@@ -349,6 +349,91 @@ export interface CometChatMessageComposerInterface {
349
349
  * @type {IntRange<1, 100>}
350
350
  */
351
351
  imageQuality?: IntRange<1, 100>;
352
+
353
+ /**
354
+ * If true, hides the camera option from the attachment options.
355
+ */
356
+ hideCameraOption?: boolean;
357
+
358
+ /**
359
+ * If true, hides the image attachment option from the attachment options.
360
+ */
361
+ hideImageAttachmentOption?: boolean;
362
+
363
+ /**
364
+ * If true, hides the video attachment option from the attachment options.
365
+ */
366
+ hideVideoAttachmentOption?: boolean;
367
+
368
+ /**
369
+ * If true, hides the audio attachment option from the attachment options.
370
+ */
371
+ hideAudioAttachmentOption?: boolean;
372
+
373
+ /**
374
+ * If true, hides the file/document attachment option from the attachment options.
375
+ */
376
+ hideFileAttachmentOption?: boolean;
377
+
378
+ /**
379
+ * If true, hides the polls option from the attachment options.
380
+ */
381
+ hidePollsAttachmentOption?: boolean;
382
+
383
+ /**
384
+ * If true, hides the collaborative document option (e.g., shared document editing).
385
+ */
386
+ hideCollaborativeDocumentOption?: boolean;
387
+
388
+ /**
389
+ * If true, hides the collaborative whiteboard option.
390
+ */
391
+ hideCollaborativeWhiteboardOption?: boolean;
392
+
393
+ /**
394
+ * If true, hides the entire attachment button from the composer.
395
+ */
396
+ hideAttachmentButton?: boolean;
397
+
398
+ /**
399
+ * If true, hides the stickers button from the composer.
400
+ */
401
+ hideStickersButton?: boolean;
402
+
403
+ /**
404
+ * If true, hides the send button from the composer.
405
+ */
406
+ hideSendButton?: boolean;
407
+
408
+ /**
409
+ * If true, hides all auxiliary buttons (such as voice input, GIFs, or other plugin buttons).
410
+ */
411
+ hideAuxiliaryButtons?: boolean;
412
+ /**
413
+ * Returns the attachment options for the composer.
414
+ *
415
+ * @param {Object} props - The function properties.
416
+ * @param {CometChat.User} [props.user] - The user object.
417
+ * @param {CometChat.Group} [props.group] - The group object.
418
+ * @param {Map<any, any>} props.composerId - The composer identifier as a Map.
419
+ * @returns {CometChatMessageComposerAction[]} An array of composer actions.
420
+ */
421
+ addAttachmentOptions?: ({
422
+ user,
423
+ group,
424
+ composerId,
425
+ }: {
426
+ user?: CometChat.User;
427
+ group?: CometChat.Group;
428
+ composerId: Map<any, any>;
429
+ }) => CometChatMessageComposerAction[];
430
+ /**
431
+ * Determines the alignment of auxiliary buttons (e.g., sticker button).
432
+ * Can be either "left" or "right".
433
+ *
434
+ * @default "left"
435
+ */
436
+ auxiliaryButtonsAlignment?: "left" | "right";
352
437
  }
353
438
 
354
439
  export const CometChatMessageComposer = React.forwardRef(
@@ -379,6 +464,20 @@ export const CometChatMessageComposer = React.forwardRef(
379
464
  textFormatters,
380
465
  disableMentions,
381
466
  imageQuality = 20,
467
+ hideCameraOption = false,
468
+ hideImageAttachmentOption = false,
469
+ hideVideoAttachmentOption = false,
470
+ hideAudioAttachmentOption = false,
471
+ hideFileAttachmentOption = false,
472
+ hidePollsAttachmentOption = false,
473
+ hideCollaborativeDocumentOption = false,
474
+ hideCollaborativeWhiteboardOption = false,
475
+ hideAttachmentButton = false,
476
+ hideStickersButton = false,
477
+ hideSendButton = false,
478
+ hideAuxiliaryButtons = false,
479
+ addAttachmentOptions,
480
+ auxiliaryButtonsAlignment = "left",
382
481
  } = props;
383
482
 
384
483
  const composerIdMap = new Map().set("parentMessageId", parentMessageId);
@@ -388,14 +487,16 @@ export const CometChatMessageComposer = React.forwardRef(
388
487
  }, [theme, style]);
389
488
 
390
489
  const defaultAuxiliaryButtonOptions = useMemo(() => {
490
+ if (hideAuxiliaryButtons) return [];
391
491
  return ChatConfigurator.getDataSource().getAuxiliaryOptions(user, group, composerIdMap, {
392
492
  stickerIcon: mergedComposerStyle.stickerIcon as ImageSourcePropType | JSX.Element,
393
493
  stickerIconStyle: mergedComposerStyle.stickerIconStyle as {
394
494
  active: ImageStyle;
395
495
  inactive: ImageStyle;
396
496
  },
497
+ hideStickersButton,
397
498
  });
398
- }, [mergedComposerStyle]);
499
+ }, [mergedComposerStyle, hideStickersButton, hideAuxiliaryButtons]);
399
500
 
400
501
  const loggedInUser = React.useRef<any>({});
401
502
  const chatWith = React.useRef<any>(null);
@@ -403,7 +504,7 @@ export const CometChatMessageComposer = React.forwardRef(
403
504
  const messageInputRef = React.useRef<any>(null);
404
505
  const chatRef = React.useRef<any>(chatWith);
405
506
  const inputValueRef = React.useRef<any>(null);
406
- const plainTextInput = React.useRef<string>("");
507
+ const plainTextInput = React.useRef<string>(initialComposertext || "");
407
508
  let mentionMap = React.useRef<Map<string, SuggestionItem>>(new Map());
408
509
  let trackingCharacters = React.useRef<string[]>([]);
409
510
  let allFormatters = React.useRef<
@@ -416,13 +517,9 @@ export const CometChatMessageComposer = React.forwardRef(
416
517
  const [inputMessage, setInputMessage] = React.useState<string | JSX.Element>(
417
518
  initialComposertext || ""
418
519
  );
419
- const [showReaction, setShowReaction] = React.useState(false);
420
520
  const [showActionSheet, setShowActionSheet] = React.useState(false);
421
521
  const [showRecordAudio, setShowRecordAudio] = React.useState(false);
422
- const [showAIOptions, setShowAIOptions] = React.useState(false);
423
- const [AIOptionItems, setAIOptionItems] = React.useState([]);
424
- const [rootAIOptionItems, setRootAIOptionItems] = React.useState([]);
425
- const [actionSheetItems, setActionSheetItems] = React.useState([]);
522
+ const [actionSheetItems, setActionSheetItems] = React.useState<any[]>([]);
426
523
  const [messagePreview, setMessagePreview] = React.useState<any>();
427
524
  const [CustomView, setCustomView] = React.useState(null);
428
525
  const [CustomViewHeader, setCustomViewHeader] = React.useState<React.FC | React.ReactNode>(
@@ -635,6 +732,7 @@ export const CometChatMessageComposer = React.forwardRef(
635
732
  const clearInputBox = () => {
636
733
  inputValueRef.current = "";
637
734
  setInputMessage("");
735
+ setWarningMessage("");
638
736
  };
639
737
 
640
738
  const sendTextMessage = () => {
@@ -721,7 +819,7 @@ export const CometChatMessageComposer = React.forwardRef(
721
819
  parentMessageId && textMessage.setParentMessageId(parentMessageId as number);
722
820
 
723
821
  inputValueRef.current = "";
724
- setInputMessage("");
822
+ clearInputBox();
725
823
  messageInputRef.current.textContent = "";
726
824
 
727
825
  setMessagePreview(null);
@@ -884,6 +982,7 @@ export const CometChatMessageComposer = React.forwardRef(
884
982
  };
885
983
 
886
984
  const SecondaryButtonViewElem = useMemo(() => {
985
+ if (hideAttachmentButton || !actionSheetItems.length) return <></>;
887
986
  return (
888
987
  <AttachIconButton
889
988
  onPress={() => setShowActionSheet(true)}
@@ -914,6 +1013,15 @@ export const CometChatMessageComposer = React.forwardRef(
914
1013
  );
915
1014
  };
916
1015
 
1016
+ const voiceRecoringButtonElem = useMemo(() => {
1017
+ return hideVoiceRecordingButton ? undefined : (
1018
+ <RecordAudioButtonView
1019
+ icon={mergedComposerStyle.voiceRecordingIcon as ImageSourcePropType | JSX.Element}
1020
+ iconStyle={mergedComposerStyle.voiceRecordingIconStyle as ImageStyle}
1021
+ />
1022
+ );
1023
+ }, [hideVoiceRecordingButton, mergedComposerStyle]);
1024
+
917
1025
  const AuxiliaryButtonViewElem = useCallback(() => {
918
1026
  if (AuxiliaryButtonView)
919
1027
  return <AuxiliaryButtonView user={user} group={group} composerId={id!} />;
@@ -926,26 +1034,15 @@ export const CometChatMessageComposer = React.forwardRef(
926
1034
  gap: theme.spacing.spacing.s2,
927
1035
  }}
928
1036
  >
929
- {!hideVoiceRecordingButton && (
930
- <RecordAudioButtonView
931
- icon={mergedComposerStyle.voiceRecordingIcon as ImageSourcePropType | JSX.Element}
932
- iconStyle={mergedComposerStyle.voiceRecordingIconStyle as ImageStyle}
933
- />
934
- )}
935
1037
  {defaultAuxiliaryButtonOptions}
936
- {AIOptionItems.length > 0 && mentionsSearchData.length == 0 && <AIOptionsButtonView />}
937
1038
  </View>
938
1039
  );
939
1040
 
940
- return hideVoiceRecordingButton ? undefined : (
941
- <RecordAudioButtonView
942
- icon={mergedComposerStyle.voiceRecordingIcon as ImageSourcePropType | JSX.Element}
943
- iconStyle={mergedComposerStyle.voiceRecordingIconStyle as ImageStyle}
944
- />
945
- );
946
- }, [AIOptionItems, mentionsSearchData, mergedComposerStyle, defaultAuxiliaryButtonOptions]);
1041
+ return <></>;
1042
+ }, [defaultAuxiliaryButtonOptions]);
947
1043
 
948
1044
  const SendButtonViewElem = useCallback(() => {
1045
+ if (hideSendButton) return <></>;
949
1046
  if (SendButtonView) return <SendButtonView user={user} group={group} composerId={id!} />;
950
1047
  const disabled = typeof inputMessage === "string" && inputMessage.length === 0;
951
1048
  return (
@@ -974,26 +1071,7 @@ export const CometChatMessageComposer = React.forwardRef(
974
1071
  />
975
1072
  </TouchableOpacity>
976
1073
  );
977
- }, [mergedComposerStyle]);
978
-
979
- const AIOptionsButtonView = () => {
980
- return (
981
- <TouchableOpacity
982
- onPress={() => {
983
- setShowAIOptions(true);
984
- setAIOptionItems(rootAIOptionItems);
985
- }}
986
- >
987
- <Icon
988
- name='ai'
989
- height={24}
990
- width={24}
991
- color={theme.color.iconSecondary}
992
- containerStyle={{ paddingBottom: 2 }}
993
- />
994
- </TouchableOpacity>
995
- );
996
- };
1074
+ }, [mergedComposerStyle, inputMessage]);
997
1075
 
998
1076
  //fetch logged in user
999
1077
  useEffect(() => {
@@ -1071,7 +1149,17 @@ export const CometChatMessageComposer = React.forwardRef(
1071
1149
  theme,
1072
1150
  user,
1073
1151
  group,
1074
- composerIdMap
1152
+ composerIdMap,
1153
+ {
1154
+ hideCameraOption,
1155
+ hideImageAttachmentOption,
1156
+ hideVideoAttachmentOption,
1157
+ hideAudioAttachmentOption,
1158
+ hideFileAttachmentOption,
1159
+ hidePollsAttachmentOption,
1160
+ hideCollaborativeDocumentOption,
1161
+ hideCollaborativeWhiteboardOption,
1162
+ }
1075
1163
  );
1076
1164
  setActionSheetItems(() =>
1077
1165
  attachmentOptions && typeof attachmentOptions === "function"
@@ -1094,27 +1182,64 @@ export const CometChatMessageComposer = React.forwardRef(
1094
1182
  onPress: () => fileInputHandler(item.id),
1095
1183
  };
1096
1184
  })
1097
- : defaultAttachmentOptions.map((item: any) => {
1098
- if (typeof item.CustomView === "function")
1099
- return {
1100
- ...item,
1101
- onPress: () => handleOnClick(item.CustomView),
1102
- };
1103
- if (typeof item.onPress === "function")
1185
+ : [
1186
+ ...defaultAttachmentOptions.map((item: any) => {
1187
+ if (typeof item.CustomView === "function")
1188
+ return {
1189
+ ...item,
1190
+ onPress: () => handleOnClick(item.CustomView),
1191
+ };
1192
+ if (typeof item.onPress === "function")
1193
+ return {
1194
+ ...item,
1195
+ onPress: () => {
1196
+ setShowActionSheet(false);
1197
+ item.onPress?.(user, group);
1198
+ },
1199
+ };
1104
1200
  return {
1105
1201
  ...item,
1106
- onPress: () => {
1107
- setShowActionSheet(false);
1108
- item.onPress?.(user, group);
1109
- },
1202
+ onPress: () => fileInputHandler(item.id),
1110
1203
  };
1111
- return {
1112
- ...item,
1113
- onPress: () => fileInputHandler(item.id),
1114
- };
1115
- })
1204
+ }),
1205
+ ...(addAttachmentOptions && typeof addAttachmentOptions === "function"
1206
+ ? addAttachmentOptions({ user, group, composerId: composerIdMap })?.map((item) => {
1207
+ if (typeof item.CustomView === "function")
1208
+ return {
1209
+ ...item,
1210
+ onPress: () => handleOnClick(item.CustomView),
1211
+ };
1212
+ if (typeof item.onPress == "function")
1213
+ return {
1214
+ ...item,
1215
+ onPress: () => {
1216
+ setShowActionSheet(false);
1217
+ item.onPress?.(user, group);
1218
+ },
1219
+ };
1220
+ return {
1221
+ ...item,
1222
+ onPress: () => fileInputHandler(item.id),
1223
+ };
1224
+ })
1225
+ : []),
1226
+ ]
1116
1227
  );
1117
- }, [user, group, id, parentMessageId]);
1228
+ }, [
1229
+ user,
1230
+ group,
1231
+ id,
1232
+ parentMessageId,
1233
+ hideCameraOption,
1234
+ hideImageAttachmentOption,
1235
+ hideVideoAttachmentOption,
1236
+ hideAudioAttachmentOption,
1237
+ hideFileAttachmentOption,
1238
+ hidePollsAttachmentOption,
1239
+ hideCollaborativeDocumentOption,
1240
+ hideCollaborativeWhiteboardOption,
1241
+ addAttachmentOptions,
1242
+ ]);
1118
1243
 
1119
1244
  useEffect(() => {
1120
1245
  CometChatUIEventHandler.addMessageListener(editMessageListenerID, {
@@ -1307,9 +1432,9 @@ export const CometChatMessageComposer = React.forwardRef(
1307
1432
  };
1308
1433
 
1309
1434
  const textChangeHandler = (txt: string) => {
1310
- let removing = plainTextInput.current.length > txt.length;
1311
- let adding = plainTextInput.current.length < txt.length;
1312
- let textDiff = txt.length - plainTextInput.current.length;
1435
+ let removing = plainTextInput.current?.length ?? 0 > txt.length;
1436
+ let adding = plainTextInput.current?.length < txt.length;
1437
+ let textDiff = txt.length - (plainTextInput.current?.length ?? 0);
1313
1438
  let notAtLast = selectionPosition.start + textDiff < txt.length;
1314
1439
 
1315
1440
  plainTextInput.current = txt;
@@ -1345,7 +1470,7 @@ export const CometChatMessageComposer = React.forwardRef(
1345
1470
  }
1346
1471
 
1347
1472
  // Code to delete mention from hashmap 👇
1348
- let expctedMentionPos = plainTextInput.current.substring(position.start, position.end);
1473
+ let expctedMentionPos = plainTextInput.current?.substring(position.start, position.end);
1349
1474
 
1350
1475
  if (expctedMentionPos !== `${value.promptText}`) {
1351
1476
  let newKey = `${position.start}_${position.end}`;
@@ -1381,13 +1506,13 @@ export const CometChatMessageComposer = React.forwardRef(
1381
1506
  setShowMentionList(false);
1382
1507
  setMentionsSearchData([]);
1383
1508
 
1384
- let notAtLast = selectionPosition.start < plainTextInput.current.length;
1509
+ let notAtLast = selectionPosition.start < (plainTextInput.current?.length ?? 0);
1385
1510
 
1386
1511
  let textDiff =
1387
- plainTextInput.current.length +
1512
+ (plainTextInput.current?.length ?? 0) +
1388
1513
  (item.promptText?.length ?? 0) -
1389
1514
  searchStringRef.current.length -
1390
- plainTextInput.current.length;
1515
+ (plainTextInput.current?.length ?? 0);
1391
1516
 
1392
1517
  let incr = 0;
1393
1518
  let mentionPos = 0;
@@ -1432,12 +1557,12 @@ export const CometChatMessageComposer = React.forwardRef(
1432
1557
  mentionMap.current = newMentionMap;
1433
1558
 
1434
1559
  // When updating the input text, just get the latest plain text input and replace the selected text with the new mention
1435
- const updatedPlainTextInput = `${plainTextInput.current.substring(
1560
+ const updatedPlainTextInput = `${plainTextInput.current?.substring(
1436
1561
  0,
1437
1562
  selectionPosition.start - (1 + searchStringRef.current.length)
1438
- )}${item.promptText + " "}${plainTextInput.current.substring(
1563
+ )}${item.promptText + " "}${plainTextInput.current?.substring(
1439
1564
  selectionPosition.end,
1440
- plainTextInput.current.length
1565
+ plainTextInput.current?.length
1441
1566
  )}`;
1442
1567
  plainTextInput.current = updatedPlainTextInput;
1443
1568
 
@@ -1454,7 +1579,16 @@ export const CometChatMessageComposer = React.forwardRef(
1454
1579
  trackingCharacter: activeCharacter.current,
1455
1580
  });
1456
1581
  mentionMap.current = updatedMap;
1457
-
1582
+ setSelectionPosition({
1583
+ start:
1584
+ selectionPosition.start -
1585
+ (searchStringRef.current.length + 1) +
1586
+ (item.promptText?.length ?? 0),
1587
+ end:
1588
+ selectionPosition.start -
1589
+ (searchStringRef.current.length + 1) +
1590
+ (item.promptText?.length ?? 0),
1591
+ });
1458
1592
  setFormattedInputMessage();
1459
1593
  };
1460
1594
 
@@ -1616,7 +1750,7 @@ export const CometChatMessageComposer = React.forwardRef(
1616
1750
  mediaRecorderStyle={mergedComposerStyle.mediaRecorderStyle}
1617
1751
  />
1618
1752
 
1619
- {mentionsSearchData.length > 0 && plainTextInput.current.length > 0 && (
1753
+ {mentionsSearchData.length > 0 && (plainTextInput.current?.length ?? 0) > 0 && (
1620
1754
  <View
1621
1755
  style={[
1622
1756
  theme.mentionsListStyle.containerStyle,
@@ -1665,10 +1799,11 @@ export const CometChatMessageComposer = React.forwardRef(
1665
1799
  openList(selection);
1666
1800
  }}
1667
1801
  onChangeText={textChangeHandler}
1802
+ VoiceRecordingButtonView={voiceRecoringButtonElem}
1668
1803
  SecondaryButtonView={SecondaryButtonViewElem}
1669
1804
  AuxiliaryButtonView={AuxiliaryButtonViewElem()}
1670
1805
  PrimaryButtonView={SendButtonViewElem}
1671
- auxiliaryButtonAlignment={"left"}
1806
+ auxiliaryButtonAlignment={auxiliaryButtonsAlignment}
1672
1807
  />
1673
1808
  {CustomViewFooter ? (
1674
1809
  // If CustomViewFooter is a function component (React.FC)