@cometchat/chat-uikit-react-native 5.2.3 → 5.2.5
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.
- package/package.json +1 -1
- package/src/CometChatConversations/CometChatConversations.tsx +167 -86
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +312 -116
- package/src/CometChatMessageComposer/styles.tsx +2 -1
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +83 -17
- package/src/CometChatMessageList/CometChatMessageList.tsx +675 -122
- package/src/CometChatMessageList/style.ts +4 -2
- package/src/CometChatSearch/CometChatSearch.tsx +2165 -0
- package/src/CometChatSearch/SearchConstants.ts +46 -0
- package/src/CometChatSearch/Skeleton.tsx +192 -0
- package/src/CometChatSearch/index.ts +1 -0
- package/src/CometChatSearch/style.ts +414 -0
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +43 -7
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +45 -7
- package/src/extensions/Polls/Polls.tsx +36 -2
- package/src/extensions/Polls/PollsBubble.tsx +13 -9
- package/src/extensions/Polls/PollsDecorator.tsx +13 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +50 -11
- package/src/extensions/Stickers/style.ts +0 -1
- package/src/index.ts +5 -0
- package/src/shared/base/Types.ts +8 -0
- package/src/shared/constants/UIKitConstants.ts +2 -0
- package/src/shared/events/CometChatMessageEvents/index.ts +8 -7
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +158 -27
- package/src/shared/framework/DataSource.ts +7 -0
- package/src/shared/framework/DataSourceDecorator.tsx +12 -0
- package/src/shared/framework/MessageDataSource.tsx +182 -1
- package/src/shared/helper/functions.js +0 -67
- package/src/shared/helper/helperFunctions.ts +72 -0
- package/src/shared/icons/components/documents.tsx +23 -0
- package/src/shared/icons/components/empty-search.tsx +52 -0
- package/src/shared/icons/components/message-blocked.tsx +1 -1
- package/src/shared/icons/components/unread.tsx +29 -0
- package/src/shared/icons/icon-mapping.tsx +7 -0
- package/src/shared/index.ts +2 -1
- package/src/shared/modals/CometChatMessageTemplate.ts +23 -0
- package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +4 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +17 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +70 -34
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +60 -24
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +60 -24
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +40 -4
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +38 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +37 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +40 -4
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +274 -23
- package/src/shared/utils/MessageUtils.tsx +0 -1
- package/src/shared/views/CometChatAudioBubble/style.ts +0 -2
- package/src/shared/views/CometChatFileBubble/style.ts +0 -4
- package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +1 -0
- package/src/shared/views/CometChatList/CometChatList.tsx +12 -0
- package/src/shared/views/CometChatList/Header.tsx +79 -49
- package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
- package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +390 -0
- package/src/shared/views/CometChatReportDialog/index.ts +3 -0
- package/src/shared/views/CometChatReportDialog/style.ts +164 -0
- package/src/shared/views/CometChatStatusIndicator/private.png +0 -0
- package/src/shared/views/CometChatStatusIndicator/protected.png +0 -0
- package/src/shared/views/CometChatStatusIndicator/styles.ts +2 -2
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +18 -2
- package/src/shared/views/index.ts +6 -0
- package/src/theme/default/default.ts +3 -0
- package/src/theme/provider.tsx +23 -12
- package/src/theme/type.ts +2 -0
package/package.json
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
CometChatUiKitConstants,
|
|
27
27
|
CometChatUrlsFormatter,
|
|
28
28
|
} from "../shared";
|
|
29
|
+
import { CometChatSearch } from "../CometChatSearch";
|
|
29
30
|
import { SelectionMode } from "../shared/base/Types";
|
|
30
31
|
import {
|
|
31
32
|
ConversationTypeConstants,
|
|
@@ -57,6 +58,7 @@ import { CometChatTheme } from "../theme/type";
|
|
|
57
58
|
import { MenuItemInterface } from "../shared/views/CometChatTooltipMenu/CometChatTooltipMenu";
|
|
58
59
|
import { JSX } from "react";
|
|
59
60
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
61
|
+
import { SuggestionItem } from "../shared/views/CometChatSuggestionList/SuggestionItem";
|
|
60
62
|
|
|
61
63
|
// Unique listener IDs for conversation, user, group, message and call events.
|
|
62
64
|
const conversationListenerId = "chatlist_" + new Date().getTime();
|
|
@@ -220,6 +222,27 @@ export interface ConversationInterface {
|
|
|
220
222
|
* Toggle delete conversation option visibilty.
|
|
221
223
|
*/
|
|
222
224
|
deleteConversationOptionVisibility?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Toggle search bar visibility in the conversations header.
|
|
227
|
+
*/
|
|
228
|
+
showSearchBar?: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Callback triggered when the search bar is clicked or focused.
|
|
231
|
+
*/
|
|
232
|
+
onSearchBarClicked?: () => void;
|
|
233
|
+
/**
|
|
234
|
+
* Callback triggered when search text changes.
|
|
235
|
+
*/
|
|
236
|
+
onSearchTextChanged?: (searchText: string) => void;
|
|
237
|
+
/**
|
|
238
|
+
* Current search text value.
|
|
239
|
+
*/
|
|
240
|
+
searchText?: string;
|
|
241
|
+
/**
|
|
242
|
+
* Custom search view component to display in the conversations header.
|
|
243
|
+
*/
|
|
244
|
+
SearchView?: () => JSX.Element;
|
|
245
|
+
|
|
223
246
|
}
|
|
224
247
|
|
|
225
248
|
/**
|
|
@@ -262,6 +285,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
262
285
|
usersStatusVisibility = true,
|
|
263
286
|
groupTypeVisibility = true,
|
|
264
287
|
deleteConversationOptionVisibility = true,
|
|
288
|
+
showSearchBar = false,
|
|
289
|
+
onSearchBarClicked,
|
|
290
|
+
onSearchTextChanged,
|
|
291
|
+
searchText = "",
|
|
292
|
+
SearchView,
|
|
265
293
|
} = props;
|
|
266
294
|
|
|
267
295
|
// Reference for accessing CometChatList methods
|
|
@@ -294,8 +322,37 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
294
322
|
const theme = useTheme();
|
|
295
323
|
const { t } = useCometChatTranslation()
|
|
296
324
|
const mergedStyles = useMemo(() => {
|
|
297
|
-
|
|
298
|
-
|
|
325
|
+
const baseStyles = deepMerge(theme.conversationStyles, style ?? {});
|
|
326
|
+
// Add search styling for CometChatList component
|
|
327
|
+
return {
|
|
328
|
+
...baseStyles,
|
|
329
|
+
searchStyle: {
|
|
330
|
+
textStyle: {
|
|
331
|
+
color: theme.color.textPrimary,
|
|
332
|
+
...theme.typography.heading4.regular,
|
|
333
|
+
},
|
|
334
|
+
placehodlerTextStyle: {
|
|
335
|
+
color: theme.color.textTertiary,
|
|
336
|
+
},
|
|
337
|
+
containerStyle: {
|
|
338
|
+
backgroundColor: theme.color.background3,
|
|
339
|
+
borderRadius: theme.spacing.radius.max,
|
|
340
|
+
paddingHorizontal: theme.spacing.spacing.s3,
|
|
341
|
+
marginVertical: theme.spacing.spacing.s2,
|
|
342
|
+
flexDirection: 'row' as const,
|
|
343
|
+
alignItems: 'center' as const,
|
|
344
|
+
gap: theme.spacing.spacing.s1,
|
|
345
|
+
},
|
|
346
|
+
iconStyle: {
|
|
347
|
+
tintColor: theme.color.iconSecondary,
|
|
348
|
+
width: 24,
|
|
349
|
+
height: 24,
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
} as any;
|
|
353
|
+
}, [theme, style]);
|
|
354
|
+
|
|
355
|
+
|
|
299
356
|
|
|
300
357
|
/**
|
|
301
358
|
* ErrorStateView renders a view to show when an error occurs.
|
|
@@ -757,28 +814,27 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
757
814
|
|
|
758
815
|
if (lastMessage && typeof messageText === "string") {
|
|
759
816
|
messageText = getFormattedText(lastMessage, messageText?.trim());
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
)
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
}
|
|
817
|
+
}
|
|
818
|
+
if (
|
|
819
|
+
lastMessage instanceof CometChat.TextMessage &&
|
|
820
|
+
lastMessage.getCategory() === "message" &&
|
|
821
|
+
(() => {
|
|
822
|
+
// Guard against undefined text or non-string values.
|
|
823
|
+
const text = typeof lastMessage.getText === "function" ? lastMessage.getText() : undefined;
|
|
824
|
+
return typeof text === "string" && text.slice(0, 50).match(/https?:\/\//);
|
|
825
|
+
})()
|
|
826
|
+
) {
|
|
827
|
+
messageText = getMessagePreviewInternal("link-fill", t("LINK"), { theme });
|
|
828
|
+
} else if (messageText) {
|
|
829
|
+
messageText = (
|
|
830
|
+
<Text
|
|
831
|
+
style={[mergedStyles.itemStyle.subtitleStyle, { flexShrink: 2 }]}
|
|
832
|
+
numberOfLines={1}
|
|
833
|
+
ellipsizeMode='tail'
|
|
834
|
+
>
|
|
835
|
+
{messageText}
|
|
836
|
+
</Text>
|
|
837
|
+
);
|
|
782
838
|
}
|
|
783
839
|
|
|
784
840
|
let groupText = "";
|
|
@@ -817,25 +873,48 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
817
873
|
function getFormattedText(message: CometChat.BaseMessage, subtitle: string) {
|
|
818
874
|
let messageTextTmp: string | JSX.Element = subtitle;
|
|
819
875
|
let allFormatters = [...(textFormatters || [])];
|
|
876
|
+
// Detect presence of @all alias token in raw string
|
|
877
|
+
const containsAllAlias =
|
|
878
|
+
typeof messageTextTmp === "string" && /<@all:(.*?)>/.test(messageTextTmp);
|
|
820
879
|
|
|
821
|
-
if (message.getMentionedUsers().length) {
|
|
880
|
+
if (message.getMentionedUsers().length || containsAllAlias) {
|
|
822
881
|
let mentionsFormatter = ChatConfigurator.getDataSource().getMentionsFormatter();
|
|
823
882
|
mentionsFormatter.setContext("conversation");
|
|
824
883
|
mentionsFormatter.setLoggedInUser(CometChatUIKit.loggedInUser!);
|
|
825
884
|
mentionsFormatter.setMentionsStyle(mergedStyles.mentionsStyles);
|
|
826
885
|
mentionsFormatter.setTargetElement(MentionsTargetElement.conversation);
|
|
827
|
-
|
|
828
886
|
mentionsFormatter.setMessage(message);
|
|
887
|
+
|
|
888
|
+
// Inject alias suggestion item if needed so formatter can render styled @All
|
|
889
|
+
if (containsAllAlias) {
|
|
890
|
+
const match = (messageTextTmp as string).match(/<@all:(.*?)>/);
|
|
891
|
+
const aliasLabel = match && match[1] ? match[1] : "all";
|
|
892
|
+
let existing = mentionsFormatter.getSuggestionItems();
|
|
893
|
+
const underlyingText = `<@all:${aliasLabel}>`;
|
|
894
|
+
const already = existing.find((it: any) => it.underlyingText === underlyingText);
|
|
895
|
+
if (!already) {
|
|
896
|
+
const aliasItem = new SuggestionItem({
|
|
897
|
+
id: aliasLabel,
|
|
898
|
+
name: aliasLabel,
|
|
899
|
+
promptText: aliasLabel,
|
|
900
|
+
trackingCharacter: "@",
|
|
901
|
+
underlyingText,
|
|
902
|
+
hideLeadingIcon: true,
|
|
903
|
+
});
|
|
904
|
+
mentionsFormatter.setSuggestionItems([...existing, aliasItem]);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
829
908
|
allFormatters.push(mentionsFormatter);
|
|
830
909
|
}
|
|
831
910
|
|
|
832
911
|
if (
|
|
833
912
|
message instanceof CometChat.TextMessage &&
|
|
834
913
|
message.getCategory() === "message" &&
|
|
835
|
-
|
|
836
|
-
.getText()
|
|
837
|
-
.
|
|
838
|
-
|
|
914
|
+
(() => {
|
|
915
|
+
const text = typeof message.getText === "function" ? message.getText() : undefined;
|
|
916
|
+
return typeof text === "string" && text.slice(0, 50).match(/https?:\/\//);
|
|
917
|
+
})()
|
|
839
918
|
) {
|
|
840
919
|
// For link messages, simply return the text.
|
|
841
920
|
return messageTextTmp;
|
|
@@ -1567,6 +1646,64 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1567
1646
|
|
|
1568
1647
|
return (
|
|
1569
1648
|
<View style={mergedStyles.containerStyle}>
|
|
1649
|
+
<CometChatList
|
|
1650
|
+
AppBarOptions={AppBarOptions}
|
|
1651
|
+
onError={onError}
|
|
1652
|
+
ref={conversationListRef}
|
|
1653
|
+
LeadingView={LeadingView ? LeadingView : LeadingViewRaw}
|
|
1654
|
+
TitleView={TitleView ? TitleView : TitleViewRaw}
|
|
1655
|
+
SubtitleView={SubtitleView ? SubtitleView : SubtitleViewRaw}
|
|
1656
|
+
TrailingView={TrailingView ? TrailingView : TrailingViewRaw}
|
|
1657
|
+
requestBuilder={
|
|
1658
|
+
conversationsRequestBuilder || new CometChat.ConversationsRequestBuilder().setLimit(30)
|
|
1659
|
+
}
|
|
1660
|
+
hideStickyHeader={true}
|
|
1661
|
+
title={!hideHeader ? t("CHATS") : ""}
|
|
1662
|
+
listStyle={mergedStyles}
|
|
1663
|
+
hideSearch={!showSearchBar}
|
|
1664
|
+
hideHeader={hideHeader}
|
|
1665
|
+
hideSubmitButton={hideSubmitButton}
|
|
1666
|
+
SearchView={SearchView}
|
|
1667
|
+
onSearchBarClicked={onSearchBarClicked}
|
|
1668
|
+
onItemPress={(conversation) =>
|
|
1669
|
+
selectionMode === "none" ? conversationClicked(conversation) : null
|
|
1670
|
+
}
|
|
1671
|
+
onItemLongPress={(conversation: CometChat.Conversation, e?: GestureResponderEvent) => {
|
|
1672
|
+
if (selectionMode === "none") {
|
|
1673
|
+
if (onItemLongPress) {
|
|
1674
|
+
onItemLongPress(conversation);
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
if (e && "nativeEvent" in e) {
|
|
1678
|
+
longPressId.current = conversation.getConversationId();
|
|
1679
|
+
longPressedConversation.current = conversation;
|
|
1680
|
+
tooltipPositon.current = {
|
|
1681
|
+
pageX: e.nativeEvent.pageX,
|
|
1682
|
+
pageY: e.nativeEvent.pageY,
|
|
1683
|
+
};
|
|
1684
|
+
setTooltipVisible(true);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
}}
|
|
1688
|
+
listItemKey={"conversationId"}
|
|
1689
|
+
LoadingView={LoadingView ?? (() => <Skeleton style={mergedStyles.skeletonStyle} />)}
|
|
1690
|
+
ItemView={ItemView}
|
|
1691
|
+
EmptyView={EmptyView ? EmptyView : () => <EmptyStateView />}
|
|
1692
|
+
ErrorView={ErrorView ? ErrorView : () => <ErrorStateView />}
|
|
1693
|
+
onBack={onBack}
|
|
1694
|
+
hideBackButton={hideBackButton}
|
|
1695
|
+
onSelection={onSelection}
|
|
1696
|
+
onSubmit={onSubmit}
|
|
1697
|
+
selectionMode={selectionMode}
|
|
1698
|
+
hideError={hideError}
|
|
1699
|
+
onListFetched={(conversations: CometChat.Conversation[]) => {
|
|
1700
|
+
if (conversations.length === 0) {
|
|
1701
|
+
onEmpty?.();
|
|
1702
|
+
} else {
|
|
1703
|
+
onLoad?.(conversations);
|
|
1704
|
+
}
|
|
1705
|
+
}}
|
|
1706
|
+
/>
|
|
1570
1707
|
<CometChatTooltipMenu
|
|
1571
1708
|
visible={tooltipVisible}
|
|
1572
1709
|
onClose={() => {
|
|
@@ -1618,62 +1755,6 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1618
1755
|
}}
|
|
1619
1756
|
{...mergedStyles.confirmDialogStyle}
|
|
1620
1757
|
/>
|
|
1621
|
-
<CometChatList
|
|
1622
|
-
AppBarOptions={AppBarOptions}
|
|
1623
|
-
onError={onError}
|
|
1624
|
-
ref={conversationListRef}
|
|
1625
|
-
LeadingView={LeadingView ? LeadingView : LeadingViewRaw}
|
|
1626
|
-
TitleView={TitleView ? TitleView : TitleViewRaw}
|
|
1627
|
-
SubtitleView={SubtitleView ? SubtitleView : SubtitleViewRaw}
|
|
1628
|
-
TrailingView={TrailingView ? TrailingView : TrailingViewRaw}
|
|
1629
|
-
requestBuilder={
|
|
1630
|
-
conversationsRequestBuilder || new CometChat.ConversationsRequestBuilder().setLimit(30)
|
|
1631
|
-
}
|
|
1632
|
-
hideStickyHeader={true}
|
|
1633
|
-
title={t("CHATS")}
|
|
1634
|
-
listStyle={mergedStyles}
|
|
1635
|
-
hideSearch={true}
|
|
1636
|
-
hideSubmitButton={hideSubmitButton}
|
|
1637
|
-
onItemPress={(conversation) =>
|
|
1638
|
-
selectionMode === "none" ? conversationClicked(conversation) : null
|
|
1639
|
-
}
|
|
1640
|
-
onItemLongPress={(conversation: CometChat.Conversation, e?: GestureResponderEvent) => {
|
|
1641
|
-
if (selectionMode === "none") {
|
|
1642
|
-
if (onItemLongPress) {
|
|
1643
|
-
onItemLongPress(conversation);
|
|
1644
|
-
return;
|
|
1645
|
-
}
|
|
1646
|
-
if (e && "nativeEvent" in e) {
|
|
1647
|
-
longPressId.current = conversation.getConversationId();
|
|
1648
|
-
longPressedConversation.current = conversation;
|
|
1649
|
-
tooltipPositon.current = {
|
|
1650
|
-
pageX: e.nativeEvent.pageX,
|
|
1651
|
-
pageY: e.nativeEvent.pageY,
|
|
1652
|
-
};
|
|
1653
|
-
setTooltipVisible(true);
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
}}
|
|
1657
|
-
listItemKey={"conversationId"}
|
|
1658
|
-
LoadingView={LoadingView ?? (() => <Skeleton style={mergedStyles.skeletonStyle} />)}
|
|
1659
|
-
ItemView={ItemView}
|
|
1660
|
-
EmptyView={EmptyView ? EmptyView : () => <EmptyStateView />}
|
|
1661
|
-
ErrorView={ErrorView ? ErrorView : () => <ErrorStateView />}
|
|
1662
|
-
onBack={onBack}
|
|
1663
|
-
hideBackButton={hideBackButton}
|
|
1664
|
-
onSelection={onSelection}
|
|
1665
|
-
onSubmit={onSubmit}
|
|
1666
|
-
selectionMode={selectionMode}
|
|
1667
|
-
hideError={hideError}
|
|
1668
|
-
hideHeader={hideHeader}
|
|
1669
|
-
onListFetched={(conversations: CometChat.Conversation[]) => {
|
|
1670
|
-
if (conversations.length === 0) {
|
|
1671
|
-
onEmpty?.();
|
|
1672
|
-
} else {
|
|
1673
|
-
onLoad?.(conversations);
|
|
1674
|
-
}
|
|
1675
|
-
}}
|
|
1676
|
-
/>
|
|
1677
1758
|
</View>
|
|
1678
1759
|
);
|
|
1679
1760
|
};
|