@cometchat/chat-uikit-react-native 4.3.20 → 4.3.22

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 (47) hide show
  1. package/package.json +1 -1
  2. package/src/AI/AIConversationSummary/AIConversationSummaryView.tsx +171 -167
  3. package/src/AI/CardView.tsx +55 -53
  4. package/src/CometChatCreateGroup/CometChatCreateGroup.tsx +8 -13
  5. package/src/CometChatGroups/CometChatGroups.tsx +545 -514
  6. package/src/CometChatJoinProtectedGroup/CometChatJoinProtectedGroup.tsx +5 -8
  7. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +544 -378
  8. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +90 -72
  9. package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +3 -8
  10. package/src/CometChatTransferOwnership/CometChatTransferOwnership.tsx +11 -13
  11. package/src/CometChatUsers/CometChatUsers.tsx +24 -23
  12. package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +24 -25
  13. package/src/extensions/Polls/Polls.tsx +8 -16
  14. package/src/extensions/Polls/PollsBubble.tsx +5 -10
  15. package/src/extensions/SmartReplies/SmartRepliesView.tsx +16 -22
  16. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +51 -51
  17. package/src/shared/libs/datePickerModal/DateTimePickerModal.android.js +1 -7
  18. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.js +38 -46
  19. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +19 -19
  20. package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +8 -20
  21. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -14
  22. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +141 -140
  23. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +47 -51
  24. package/src/shared/views/CometChatDate/CometChatDate.tsx +18 -17
  25. package/src/shared/views/CometChatDateTimePicker/CometChatDateTimePicker.tsx +65 -51
  26. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +76 -72
  27. package/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +3 -8
  28. package/src/shared/views/CometChatList/CometChatList.tsx +133 -134
  29. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +62 -61
  30. package/src/shared/views/CometChatMediaRecorder/CometChatMediaRecorder.tsx +20 -10
  31. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +3 -8
  32. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +24 -23
  33. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +107 -53
  34. package/src/shared/views/CometChatReceipt/CometChatReceipt.tsx +22 -14
  35. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +15 -8
  36. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +2 -6
  37. package/src/shared/views/SwipeRow/SwipeRow.tsx +6 -14
  38. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  39. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  40. package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
  41. package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
  42. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  43. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  44. package/android/.gradle/7.4/gc.properties +0 -0
  45. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  46. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  47. package/android/.gradle/vcs-1/gc.properties +0 -0
@@ -16,11 +16,11 @@ import {
16
16
  ListRenderItem,
17
17
  ViewProps,
18
18
  TextStyle,
19
- ActivityIndicator
19
+ ActivityIndicator,
20
20
  //@ts-ignore
21
21
  } from 'react-native';
22
22
  import { CometChatContext } from '../../CometChatContext';
23
- import { localize } from "../../resources/CometChatLocalize";
23
+ import { localize } from '../../resources/CometChatLocalize';
24
24
  import {
25
25
  LOADING,
26
26
  NO_DATA_FOUND,
@@ -30,7 +30,7 @@ import {
30
30
  import { ICONS } from './resources';
31
31
  import styles from './styles';
32
32
  import { CometChatOptions } from '../../modals';
33
- import { CometChatListItem } from "../../views/CometChatListItem";
33
+ import { CometChatListItem } from '../../views/CometChatListItem';
34
34
  import Header from './Header';
35
35
  import { ImageType } from '../../base';
36
36
  import { BorderStyleInterface, FontStyleInterface } from '../../base';
@@ -48,9 +48,9 @@ export interface CometChatListActionsInterface {
48
48
  addItemToList: (item: any, position?: number) => void;
49
49
  removeItemFromList: (itemId: string | number) => void;
50
50
  getListItem: (itemId: string | number) => void;
51
- getSelectedItems: () => Array<any>,
52
- getAllListItems: () => Array<any>,
53
- clearSelection: () => void,
51
+ getSelectedItems: () => Array<any>;
52
+ getAllListItems: () => Array<any>;
53
+ clearSelection: () => void;
54
54
  }
55
55
 
56
56
  export interface CometChatListStylesInterface {
@@ -115,7 +115,7 @@ export interface CometChatListProps {
115
115
  bodyViewContainerStyle?: StyleProp<ViewStyle>;
116
116
  tailViewContainerStyle?: StyleProp<ViewStyle>;
117
117
  listStyle?: CometChatListStylesInterface;
118
- hideSubmitIcon?: boolean
118
+ hideSubmitIcon?: boolean;
119
119
  }
120
120
  let lastCall: any;
121
121
  let lastReject: Function;
@@ -132,7 +132,6 @@ export const CometChatList = React.forwardRef<
132
132
  CometChatListActionsInterface,
133
133
  CometChatListProps
134
134
  >((props, ref) => {
135
-
136
135
  const connectionListenerId = 'connectionListener_' + new Date().getTime();
137
136
  const { theme } = useContext<CometChatContextType>(CometChatContext);
138
137
 
@@ -147,33 +146,33 @@ export const CometChatList = React.forwardRef<
147
146
  searchPlaceholderText,
148
147
  backButtonIcon,
149
148
  showBackButton,
150
- selectionMode,
151
- onSelection,
152
149
  searchBoxIcon,
153
- hideSearch,
154
- title,
155
150
  EmptyStateView,
156
- emptyStateText,
157
- errorStateText,
158
151
  ErrorStateView,
159
152
  LoadingStateView,
160
- requestBuilder,
161
- searchRequestBuilder,
162
- hideError,
163
- onItemPress,
164
- onItemLongPress,
165
153
  onError,
166
154
  onBack,
167
155
  selectionIcon,
168
- listItemKey,
169
156
  statusIndicatorStyle,
170
157
  avatarStyle,
171
158
  listItemStyle,
172
159
  headViewContainerStyle,
173
160
  bodyViewContainerStyle,
174
161
  tailViewContainerStyle,
175
- listStyle,
176
162
  hideSubmitIcon,
163
+ title = '',
164
+ hideSearch = false,
165
+ requestBuilder = undefined,
166
+ searchRequestBuilder = undefined,
167
+ emptyStateText = '',
168
+ errorStateText = localize('SOMETHING_WRONG'),
169
+ hideError = false,
170
+ onItemPress = () => {},
171
+ onItemLongPress = () => {},
172
+ onSelection = () => {},
173
+ selectionMode = 'none',
174
+ listItemKey = 'uid',
175
+ listStyle = {},
177
176
  } = props;
178
177
 
179
178
  // functions which can be access by parents
@@ -186,7 +185,7 @@ export const CometChatList = React.forwardRef<
186
185
  updateAndMoveToFirst,
187
186
  getSelectedItems,
188
187
  getAllListItems,
189
- clearSelection
188
+ clearSelection,
190
189
  };
191
190
  });
192
191
 
@@ -196,31 +195,31 @@ export const CometChatList = React.forwardRef<
196
195
  ? searchRequestBuilder.searchKeyword
197
196
  : ''
198
197
  : requestBuilder
198
+ ? requestBuilder.searchKeyword
199
199
  ? requestBuilder.searchKeyword
200
- ? requestBuilder.searchKeyword
201
- : ''
202
- : searchRequestBuilder
203
- ? searchRequestBuilder.searchKeyword
204
- ? searchRequestBuilder.searchKeyword
205
- : ''
206
- : ''
200
+ : ''
201
+ : searchRequestBuilder
202
+ ? searchRequestBuilder.searchKeyword
203
+ ? searchRequestBuilder.searchKeyword
204
+ : ''
205
+ : ''
207
206
  );
208
207
  const searchInputRef = useRef(
209
208
  requestBuilder && searchRequestBuilder
210
- ? searchRequestBuilder.searchKeyword
211
209
  ? searchRequestBuilder.searchKeyword
212
- : ''
213
- : requestBuilder
210
+ ? searchRequestBuilder.searchKeyword
211
+ : ''
212
+ : requestBuilder
214
213
  ? requestBuilder.searchKeyword
215
214
  ? requestBuilder.searchKeyword
216
215
  : ''
217
216
  : searchRequestBuilder
217
+ ? searchRequestBuilder.searchKeyword
218
218
  ? searchRequestBuilder.searchKeyword
219
- ? searchRequestBuilder.searchKeyword
220
- : ''
221
219
  : ''
220
+ : ''
222
221
  );
223
-
222
+
224
223
  const [shouldSelect, setShouldSelect] = React.useState(
225
224
  selectionMode !== 'none' ? true : false
226
225
  );
@@ -265,18 +264,18 @@ export const CometChatList = React.forwardRef<
265
264
 
266
265
  const getSelectedItems = () => {
267
266
  let markedItems: any[] = [];
268
- Object.keys(selectedItems).forEach(item => {
267
+ Object.keys(selectedItems).forEach((item) => {
269
268
  return markedItems.push(getListItem(item));
270
- })
269
+ });
271
270
  return markedItems;
272
- }
271
+ };
273
272
 
274
273
  useEffect(() => {
275
274
  CometChat.addConnectionListener(
276
275
  connectionListenerId,
277
276
  new CometChat.ConnectionListener({
278
277
  onConnected: () => {
279
- console.log("ConnectionListener => On Connected");
278
+ console.log('ConnectionListener => On Connected');
280
279
  if (requestBuilder) {
281
280
  if (searchInputRef.current)
282
281
  listHandlerRef.current = requestBuilder
@@ -298,19 +297,18 @@ export const CometChatList = React.forwardRef<
298
297
  });
299
298
  },
300
299
  inConnecting: () => {
301
- console.log("ConnectionListener => In connecting");
300
+ console.log('ConnectionListener => In connecting');
302
301
  },
303
302
  onDisconnected: () => {
304
- console.log("ConnectionListener => On Disconnected");
305
- }
303
+ console.log('ConnectionListener => On Disconnected');
304
+ },
306
305
  })
307
306
  );
308
307
  return () => {
309
308
  CometChat.removeConnectionListener(connectionListenerId);
310
- }
309
+ };
311
310
  }, []);
312
311
 
313
-
314
312
  useEffect(() => {
315
313
  if (initialRunRef.current === true) {
316
314
  if (requestBuilder) {
@@ -330,7 +328,7 @@ export const CometChatList = React.forwardRef<
330
328
  }, [selectionMode]);
331
329
 
332
330
  useEffect(() => {
333
- searchInputRef.current = searchInput
331
+ searchInputRef.current = searchInput;
334
332
  }, [searchInput]);
335
333
 
336
334
  /**
@@ -362,7 +360,7 @@ export const CometChatList = React.forwardRef<
362
360
  newList.splice(itemKey, 1);
363
361
  }
364
362
  setList([item, ...newList]);
365
- }
363
+ };
366
364
 
367
365
  const addItemToList = (item: any, position?: number) => {
368
366
  setList((prev: [any]) => {
@@ -448,7 +446,7 @@ export const CometChatList = React.forwardRef<
448
446
  setSelectedItems((prev: any) => {
449
447
  let newState = { ...prev };
450
448
  if (Object.keys(prev).includes(listItem.value[listItemKey])) {
451
- delete newState[listItem.value[listItemKey]]
449
+ delete newState[listItem.value[listItemKey]];
452
450
  return newState;
453
451
  } else {
454
452
  newState[listItem.value[listItemKey]] = listItem.value;
@@ -460,9 +458,9 @@ export const CometChatList = React.forwardRef<
460
458
  };
461
459
 
462
460
  const onSelectionHandler = () => {
463
- if(onSelection) {
461
+ if (onSelection) {
464
462
  onSelection(Object.values(selectedItems));
465
- return
463
+ return;
466
464
  }
467
465
  setShouldSelect(false);
468
466
  setSelectedItems({});
@@ -471,7 +469,7 @@ export const CometChatList = React.forwardRef<
471
469
  const clearSelection = () => {
472
470
  setShouldSelect(false);
473
471
  setSelectedItems({});
474
- }
472
+ };
475
473
 
476
474
  const onListItemPress = (item: any) => {
477
475
  if (shouldSelect) {
@@ -479,7 +477,7 @@ export const CometChatList = React.forwardRef<
479
477
  setSelectedItems((prev: any) => {
480
478
  let newState = { ...prev };
481
479
  if (Object.keys(prev).includes(item.value[listItemKey])) {
482
- delete newState[item.value[listItemKey]]
480
+ delete newState[item.value[listItemKey]];
483
481
  return newState;
484
482
  } else {
485
483
  newState[item.value[listItemKey]] = item.value;
@@ -514,15 +512,17 @@ export const CometChatList = React.forwardRef<
514
512
  ]}
515
513
  ></View>
516
514
  <Text
517
- style={[
518
- styles.headerLetterStyle,
519
- {
520
- color:
521
- listStyle?.sectionHeaderTextColor ??
522
- theme.palette.getAccent500(),
523
- },
524
- listStyle?.sectionHeaderTextFont ?? theme.typography.text2,
525
- ] as TextStyle}
515
+ style={
516
+ [
517
+ styles.headerLetterStyle,
518
+ {
519
+ color:
520
+ listStyle?.sectionHeaderTextColor ??
521
+ theme.palette.getAccent500(),
522
+ },
523
+ listStyle?.sectionHeaderTextFont ?? theme.typography.text2,
524
+ ] as TextStyle[]
525
+ }
526
526
  >
527
527
  {headerLetter}
528
528
  </Text>
@@ -551,13 +551,14 @@ export const CometChatList = React.forwardRef<
551
551
  Object.keys(selectedItems).includes(item.value[listItemKey])
552
552
  ? theme.palette.getBackgroundColor()
553
553
  : !disableUsersPresence && item.value.status === 'online'
554
+ ? listStyle?.onlineStatusColor
554
555
  ? listStyle?.onlineStatusColor
555
- ? listStyle?.onlineStatusColor
556
- : theme.palette.getSuccess()
557
- : ''
556
+ : theme.palette.getSuccess()
557
+ : ''
558
558
  }
559
559
  statusIndicatorIcon={
560
- Object.keys(selectedItems).includes(item.value[listItemKey]) && ICONS.CHECK
560
+ Object.keys(selectedItems).includes(item.value[listItemKey]) &&
561
+ ICONS.CHECK
561
562
  }
562
563
  {...(SubtitleView
563
564
  ? { SubtitleView: () => SubtitleView(item.value) }
@@ -566,23 +567,23 @@ export const CometChatList = React.forwardRef<
566
567
  statusIndicatorStyle={
567
568
  selectedItems[item.value[listItemKey]] === true
568
569
  ? {
569
- ...(statusIndicatorStyle as object),
570
- borderRadius: 10,
571
- height: 20,
572
- width: 20,
573
- }
574
- : statusIndicatorStyle as ViewProps
570
+ ...(statusIndicatorStyle as object),
571
+ borderRadius: 10,
572
+ height: 20,
573
+ width: 20,
574
+ }
575
+ : (statusIndicatorStyle as ViewProps)
575
576
  }
576
577
  avatarStyle={avatarStyle}
577
- options={() => options ? options(item.value) : []}
578
+ options={() => (options ? options(item.value) : [])}
578
579
  activeSwipeRows={activeSwipeRows.current}
579
580
  rowOpens={(id) => {
580
- Object.keys(activeSwipeRows.current).forEach(key => {
581
- if(id !== key && activeSwipeRows.current[key]) {
582
- activeSwipeRows.current[key]?.current?.closeRow?.()
583
- delete activeSwipeRows.current[key]
584
- }
585
- })
581
+ Object.keys(activeSwipeRows.current).forEach((key) => {
582
+ if (id !== key && activeSwipeRows.current[key]) {
583
+ activeSwipeRows.current[key]?.current?.closeRow?.();
584
+ delete activeSwipeRows.current[key];
585
+ }
586
+ });
586
587
  }}
587
588
  onPress={() => {
588
589
  onListItemPress(item);
@@ -608,11 +609,14 @@ export const CometChatList = React.forwardRef<
608
609
  }
609
610
 
610
611
  lastCall = setTimeout(() => {
611
- props?.fetchNext().then((listItems: any) => {
612
- resolve(listItems);
613
- }).catch((error: any) => {
614
- reject(error)
615
- });
612
+ props
613
+ ?.fetchNext()
614
+ .then((listItems: any) => {
615
+ resolve(listItems);
616
+ })
617
+ .catch((error: any) => {
618
+ reject(error);
619
+ });
616
620
  }, 500);
617
621
  lastReject = reject;
618
622
  });
@@ -623,13 +627,16 @@ export const CometChatList = React.forwardRef<
623
627
  * Returns a container of users if exists else returns the corresponding decorator message
624
628
  */
625
629
  const getMessageContainer = () => {
626
- let messageContainer: any= null;
630
+ let messageContainer: any = null;
627
631
  decoratorMessage === LOADING;
628
632
  if (list.length === 0 && decoratorMessage.toLowerCase() === LOADING) {
629
633
  if (LoadingStateView) return <LoadingStateView />;
630
634
  messageContainer = (
631
635
  <View style={styles.msgContainerStyle}>
632
- <ActivityIndicator size={"large"} color={listStyle?.loadingIconTint || theme.palette.getPrimary()} />
636
+ <ActivityIndicator
637
+ size={'large'}
638
+ color={listStyle?.loadingIconTint || theme.palette.getPrimary()}
639
+ />
633
640
  </View>
634
641
  );
635
642
  } else if (
@@ -641,14 +648,16 @@ export const CometChatList = React.forwardRef<
641
648
  ) : (
642
649
  <View style={styles.msgContainerStyle}>
643
650
  <Text
644
- style={[
645
- styles.msgTxtStyle,
646
- listStyle?.emptyTextFont ?? theme.typography.body,
647
- {
648
- color:
649
- listStyle?.emptyTextColor ?? theme.palette.getAccent400(),
650
- },
651
- ] as TextStyle}
651
+ style={
652
+ [
653
+ styles.msgTxtStyle,
654
+ listStyle?.emptyTextFont ?? theme.typography.body,
655
+ {
656
+ color:
657
+ listStyle?.emptyTextColor ?? theme.palette.getAccent400(),
658
+ },
659
+ ] as TextStyle[]
660
+ }
652
661
  >
653
662
  {emptyStateText}
654
663
  </Text>
@@ -663,14 +672,16 @@ export const CometChatList = React.forwardRef<
663
672
  ) : (
664
673
  <View style={styles.msgContainerStyle}>
665
674
  <Text
666
- style={[
667
- styles.msgTxtStyle,
668
- listStyle?.errorTextFont ?? theme.typography.body,
669
- {
670
- color:
671
- listStyle?.errorTextColor ?? theme.palette.getAccent400(),
672
- },
673
- ] as TextStyle}
675
+ style={
676
+ [
677
+ styles.msgTxtStyle,
678
+ listStyle?.errorTextFont ?? theme.typography.body,
679
+ {
680
+ color:
681
+ listStyle?.errorTextColor ?? theme.palette.getAccent400(),
682
+ },
683
+ ] as TextStyle[]
684
+ }
674
685
  >
675
686
  {errorStateText}
676
687
  </Text>
@@ -700,12 +711,12 @@ export const CometChatList = React.forwardRef<
700
711
  renderItem={
701
712
  ListItemView
702
713
  ? ({ item, index, separators }) => (
703
- <ListItemView
704
- index={index}
705
- separators={separators}
706
- item={item.value}
707
- />
708
- )
714
+ <ListItemView
715
+ index={index}
716
+ separators={separators}
717
+ item={item.value}
718
+ />
719
+ )
709
720
  : renderListItemView
710
721
  }
711
722
  keyExtractor={(item, index) =>
@@ -727,17 +738,19 @@ export const CometChatList = React.forwardRef<
727
738
 
728
739
  return (
729
740
  <View
730
- style={[
731
- styles.containerStyle,
732
- {
733
- height: listStyle?.height ?? '100%',
734
- width: listStyle?.width ?? '100%',
735
- backgroundColor:
736
- listStyle?.background ?? theme.palette.getBackgroundColor(),
737
- borderRadius: listStyle?.borderRadius ?? 0,
738
- },
739
- listStyle?.border ?? {},
740
- ] as ViewProps}
741
+ style={
742
+ [
743
+ styles.containerStyle,
744
+ {
745
+ height: listStyle?.height ?? '100%',
746
+ width: listStyle?.width ?? '100%',
747
+ backgroundColor:
748
+ listStyle?.background ?? theme.palette.getBackgroundColor(),
749
+ borderRadius: listStyle?.borderRadius ?? 0,
750
+ },
751
+ listStyle?.border ?? {},
752
+ ] as ViewProps
753
+ }
741
754
  >
742
755
  <Header
743
756
  backButtonIcon={backButtonIcon}
@@ -762,7 +775,9 @@ export const CometChatList = React.forwardRef<
762
775
  searchBorderStyle={listStyle?.searchBorder}
763
776
  searchBorderRadius={listStyle?.searchBorderRadius}
764
777
  searchTextFontStyle={listStyle?.searchTextFont ?? theme.typography.body}
765
- searchTextColor={listStyle?.searchTextColor ?? theme.palette.getAccent()}
778
+ searchTextColor={
779
+ listStyle?.searchTextColor ?? theme.palette.getAccent()
780
+ }
766
781
  searchPlaceholderTextColor={theme.palette.getAccent600()}
767
782
  searchIconTint={
768
783
  listStyle?.searchIconTint ?? theme.palette.getAccent400()
@@ -775,19 +790,3 @@ export const CometChatList = React.forwardRef<
775
790
  </View>
776
791
  );
777
792
  });
778
-
779
- CometChatList.defaultProps = {
780
- title: 'Title',
781
- hideSearch: false,
782
- requestBuilder: undefined,
783
- searchRequestBuilder: undefined,
784
- emptyStateText: localize('NO_USERS_FOUND'), // Note: Need to add "No Data found" in localize
785
- errorStateText: localize('SOMETHING_WRONG'),
786
- hideError: false,
787
- onItemPress: () => { },
788
- onItemLongPress: () => { },
789
- onSelection: () => { },
790
- selectionMode: 'none',
791
- listItemKey: 'uid',
792
- listStyle: {},
793
- };