stream-chat-react 12.0.0-rc.8 → 12.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.
- package/dist/components/Avatar/Avatar.js +5 -1
- package/dist/components/Channel/Channel.d.ts +3 -4
- package/dist/components/Channel/Channel.js +95 -56
- package/dist/components/Channel/hooks/useCreateChannelStateContext.js +2 -1
- package/dist/components/ChannelHeader/ChannelHeader.js +4 -5
- package/dist/components/ChannelPreview/hooks/useChannelPreviewInfo.js +14 -16
- package/dist/components/ChannelPreview/utils.js +9 -20
- package/dist/components/ChannelSearch/hooks/useChannelSearch.js +2 -3
- package/dist/components/Chat/Chat.d.ts +1 -1
- package/dist/components/Chat/hooks/useChat.d.ts +2 -2
- package/dist/components/Chat/hooks/useChat.js +11 -8
- package/dist/components/ChatView/ChatView.d.ts +18 -0
- package/dist/components/ChatView/ChatView.js +103 -0
- package/dist/components/ChatView/index.d.ts +1 -0
- package/dist/components/ChatView/index.js +1 -0
- package/dist/components/DateSeparator/DateSeparator.d.ts +1 -1
- package/dist/components/Dialog/DialogAnchor.d.ts +25 -0
- package/dist/components/Dialog/DialogAnchor.js +68 -0
- package/dist/components/Dialog/DialogManager.d.ts +43 -0
- package/dist/components/Dialog/DialogManager.js +98 -0
- package/dist/components/Dialog/DialogPortal.d.ts +7 -0
- package/dist/components/Dialog/DialogPortal.js +25 -0
- package/dist/components/Dialog/hooks/index.d.ts +1 -0
- package/dist/components/Dialog/hooks/index.js +1 -0
- package/dist/components/Dialog/hooks/useDialog.d.ts +4 -0
- package/dist/components/Dialog/hooks/useDialog.js +26 -0
- package/dist/components/Dialog/index.d.ts +4 -0
- package/dist/components/Dialog/index.js +4 -0
- package/dist/components/EventComponent/EventComponent.d.ts +1 -1
- package/dist/components/Message/Message.js +5 -6
- package/dist/components/Message/MessageOptions.d.ts +1 -2
- package/dist/components/Message/MessageOptions.js +14 -11
- package/dist/components/Message/MessageSimple.js +6 -14
- package/dist/components/Message/MessageTimestamp.d.ts +1 -1
- package/dist/components/Message/QuotedMessage.js +2 -1
- package/dist/components/Message/Timestamp.d.ts +1 -1
- package/dist/components/Message/Timestamp.js +2 -2
- package/dist/components/Message/hooks/useReactionHandler.d.ts +1 -7
- package/dist/components/Message/hooks/useReactionHandler.js +8 -63
- package/dist/components/Message/utils.d.ts +10 -1
- package/dist/components/Message/utils.js +19 -7
- package/dist/components/MessageActions/MessageActions.d.ts +1 -2
- package/dist/components/MessageActions/MessageActions.js +26 -55
- package/dist/components/MessageActions/MessageActionsBox.d.ts +1 -1
- package/dist/components/MessageActions/MessageActionsBox.js +6 -6
- package/dist/components/MessageInput/MessageInputFlat.js +2 -2
- package/dist/components/MessageInput/QuotedMessagePreview.js +2 -1
- package/dist/components/MessageInput/hooks/useUserTrigger.js +0 -1
- package/dist/components/MessageList/MessageList.js +7 -7
- package/dist/components/MessageList/VirtualizedMessageList.d.ts +2 -1
- package/dist/components/MessageList/VirtualizedMessageList.js +44 -39
- package/dist/components/MessageList/VirtualizedMessageListComponents.d.ts +1 -1
- package/dist/components/MessageList/VirtualizedMessageListComponents.js +6 -6
- package/dist/components/MessageList/renderMessages.d.ts +2 -2
- package/dist/components/MessageList/renderMessages.js +4 -1
- package/dist/components/MessageList/utils.js +1 -1
- package/dist/components/Reactions/ReactionSelector.d.ts +6 -3
- package/dist/components/Reactions/ReactionSelector.js +34 -24
- package/dist/components/Reactions/ReactionSelectorWithButton.d.ts +13 -0
- package/dist/components/Reactions/ReactionSelectorWithButton.js +22 -0
- package/dist/components/Reactions/ReactionsList.d.ts +4 -4
- package/dist/components/Reactions/hooks/useProcessReactions.js +2 -1
- package/dist/components/Thread/Thread.js +38 -10
- package/dist/components/Threads/ThreadContext.d.ts +9 -0
- package/dist/components/Threads/ThreadContext.js +9 -0
- package/dist/components/Threads/ThreadList/ThreadList.d.ts +9 -0
- package/dist/components/Threads/ThreadList/ThreadList.js +41 -0
- package/dist/components/Threads/ThreadList/ThreadListEmptyPlaceholder.d.ts +2 -0
- package/dist/components/Threads/ThreadList/ThreadListEmptyPlaceholder.js +5 -0
- package/dist/components/Threads/ThreadList/ThreadListItem.d.ts +9 -0
- package/dist/components/Threads/ThreadList/ThreadListItem.js +52 -0
- package/dist/components/Threads/ThreadList/ThreadListItemUI.d.ts +15 -0
- package/dist/components/Threads/ThreadList/ThreadListItemUI.js +75 -0
- package/dist/components/Threads/ThreadList/ThreadListLoadingIndicator.d.ts +2 -0
- package/dist/components/Threads/ThreadList/ThreadListLoadingIndicator.js +14 -0
- package/dist/components/Threads/ThreadList/ThreadListUnseenThreadsBanner.d.ts +2 -0
- package/dist/components/Threads/ThreadList/ThreadListUnseenThreadsBanner.js +16 -0
- package/dist/components/Threads/ThreadList/index.d.ts +3 -0
- package/dist/components/Threads/ThreadList/index.js +3 -0
- package/dist/components/Threads/UnreadCountBadge.d.ts +6 -0
- package/dist/components/Threads/UnreadCountBadge.js +5 -0
- package/dist/components/Threads/hooks/useThreadManagerState.d.ts +2 -0
- package/dist/components/Threads/hooks/useThreadManagerState.js +6 -0
- package/dist/components/Threads/hooks/useThreadState.d.ts +5 -0
- package/dist/components/Threads/hooks/useThreadState.js +11 -0
- package/dist/components/Threads/icons.d.ts +8 -0
- package/dist/components/Threads/icons.js +13 -0
- package/dist/components/Threads/index.d.ts +2 -0
- package/dist/components/Threads/index.js +2 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/context/ComponentContext.d.ts +15 -40
- package/dist/context/ComponentContext.js +7 -9
- package/dist/context/DialogManagerContext.d.ts +10 -0
- package/dist/context/DialogManagerContext.js +14 -0
- package/dist/context/MessageContext.d.ts +3 -11
- package/dist/context/MessageContext.js +3 -2
- package/dist/context/TranslationContext.d.ts +1 -11
- package/dist/context/TranslationContext.js +1 -9
- package/dist/context/WithComponents.d.ts +5 -0
- package/dist/context/WithComponents.js +7 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +2 -0
- package/dist/css/v2/index.css +2 -2
- package/dist/css/v2/index.layout.css +2 -2
- package/dist/i18n/Streami18n.d.ts +1 -3
- package/dist/i18n/Streami18n.js +1 -2
- package/dist/i18n/index.d.ts +2 -1
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/types.d.ts +26 -0
- package/dist/i18n/types.js +1 -0
- package/dist/i18n/utils.d.ts +9 -20
- package/dist/i18n/utils.js +10 -1
- package/dist/index.browser.cjs +10827 -10601
- package/dist/index.browser.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.node.cjs +10720 -10510
- package/dist/index.node.cjs.map +4 -4
- package/dist/plugins/Emojis/index.browser.cjs +7 -169
- package/dist/plugins/Emojis/index.browser.cjs.map +4 -4
- package/dist/plugins/Emojis/index.node.cjs +7 -169
- package/dist/plugins/Emojis/index.node.cjs.map +4 -4
- package/dist/plugins/encoders/mp3.browser.cjs +2 -4
- package/dist/plugins/encoders/mp3.browser.cjs.map +1 -1
- package/dist/plugins/encoders/mp3.node.cjs +2 -4
- package/dist/plugins/encoders/mp3.node.cjs.map +1 -1
- package/dist/scss/v2/Avatar/Avatar-layout.scss +10 -2
- package/dist/scss/v2/Avatar/Avatar-theme.scss +5 -0
- package/dist/scss/v2/ChatView/ChatView-layout.scss +43 -0
- package/dist/scss/v2/ChatView/ChatView-theme.scss +32 -0
- package/dist/scss/v2/Dialog/Dialog-layout.scss +8 -0
- package/dist/scss/v2/LoadingIndicator/LoadingIndicator-layout.scss +16 -0
- package/dist/scss/v2/Message/Message-layout.scss +8 -0
- package/dist/scss/v2/MessageActionsBox/MessageActionsBox-theme.scss +8 -0
- package/dist/scss/v2/MessageList/MessageList-layout.scss +0 -6
- package/dist/scss/v2/MessageList/VirtualizedMessageList-layout.scss +0 -12
- package/dist/scss/v2/MessageReactions/MessageReactionsSelector-layout.scss +16 -0
- package/dist/scss/v2/MessageReactions/MessageReactionsSelector-theme.scss +6 -0
- package/dist/scss/v2/Thread/Thread-layout.scss +15 -1
- package/dist/scss/v2/ThreadList/ThreadList-layout.scss +152 -0
- package/dist/scss/v2/ThreadList/ThreadList-theme.scss +75 -0
- package/dist/scss/v2/UnreadCountBadge/UnreadCountBadge-layout.scss +49 -0
- package/dist/scss/v2/UnreadCountBadge/UnreadCountBadge-theme.scss +11 -0
- package/dist/scss/v2/_base.scss +31 -0
- package/dist/scss/v2/index.layout.scss +4 -0
- package/dist/scss/v2/index.scss +3 -0
- package/dist/store/hooks/index.d.ts +1 -0
- package/dist/store/hooks/index.js +1 -0
- package/dist/store/hooks/useStateStore.d.ts +3 -0
- package/dist/store/hooks/useStateStore.js +15 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +1 -0
- package/package.json +7 -6
- package/dist/assets/Poweredby_100px-White_VertText.png +0 -0
- package/dist/assets/str-chat__reaction-list-sprite@1x.png +0 -0
- package/dist/assets/str-chat__reaction-list-sprite@2x.png +0 -0
- package/dist/assets/str-chat__reaction-list-sprite@3x.png +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon } from '../icons';
|
|
3
|
+
import { useChatContext } from '../../../context';
|
|
4
|
+
import { useStateStore } from '../../../store';
|
|
5
|
+
const selector = (nextValue) => [nextValue.unseenThreadIds];
|
|
6
|
+
export const ThreadListUnseenThreadsBanner = () => {
|
|
7
|
+
const { client } = useChatContext();
|
|
8
|
+
const [unseenThreadIds] = useStateStore(client.threads.state, selector);
|
|
9
|
+
if (!unseenThreadIds.length)
|
|
10
|
+
return null;
|
|
11
|
+
return (React.createElement("div", { className: 'str-chat__unseen-threads-banner' },
|
|
12
|
+
unseenThreadIds.length,
|
|
13
|
+
" unread threads",
|
|
14
|
+
React.createElement("button", { className: 'str-chat__unseen-threads-banner__button', onClick: () => client.threads.reload() },
|
|
15
|
+
React.createElement(Icon.Reload, null))));
|
|
16
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PropsWithChildren } from 'react';
|
|
3
|
+
export declare const UnreadCountBadge: ({ children, count, position, }: PropsWithChildren<{
|
|
4
|
+
count: number;
|
|
5
|
+
position?: 'top-right' | 'bottom-right' | 'bottom-left' | 'top-left';
|
|
6
|
+
}>) => React.JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export const UnreadCountBadge = ({ children, count, position, }) => (React.createElement("div", { className: 'str-chat__unread-count-badge-container' },
|
|
4
|
+
children,
|
|
5
|
+
count > 0 && (React.createElement("div", { className: clsx('str-chat__unread-count-badge', position && `str-chat__unread-count-badge--${position}`) }, count))));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ThreadState } from 'stream-chat';
|
|
2
|
+
/**
|
|
3
|
+
* @description returns thread state, prioritizes `ThreadListItemContext` falls back to `ThreadContext` if not former is not present
|
|
4
|
+
*/
|
|
5
|
+
export declare const useThreadState: <T extends readonly unknown[]>(selector: (nextValue: ThreadState) => T) => T | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useThreadListItemContext } from '../ThreadList';
|
|
2
|
+
import { useThreadContext } from '../ThreadContext';
|
|
3
|
+
import { useStateStore } from '../../../store/';
|
|
4
|
+
/**
|
|
5
|
+
* @description returns thread state, prioritizes `ThreadListItemContext` falls back to `ThreadContext` if not former is not present
|
|
6
|
+
*/
|
|
7
|
+
export const useThreadState = (selector) => {
|
|
8
|
+
const listItemThread = useThreadListItemContext();
|
|
9
|
+
const thread = useThreadContext();
|
|
10
|
+
return useStateStore(listItemThread?.state ?? thread?.state, selector);
|
|
11
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentPropsWithoutRef } from 'react';
|
|
3
|
+
export declare const Icon: {
|
|
4
|
+
MessageBubble: (props: ComponentPropsWithoutRef<'svg'>) => React.JSX.Element;
|
|
5
|
+
MessageBubbleEmpty: (props: ComponentPropsWithoutRef<'svg'>) => React.JSX.Element;
|
|
6
|
+
Reload: (props: ComponentPropsWithoutRef<'svg'>) => React.JSX.Element;
|
|
7
|
+
User: (props: ComponentPropsWithoutRef<'svg'>) => React.JSX.Element;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* eslint-disable react/display-name */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
// TODO: unify icons across SDK
|
|
4
|
+
export const Icon = {
|
|
5
|
+
MessageBubble: (props) => (React.createElement("svg", { className: 'str-chat__icon str-chat__icon--message-bubble', fill: 'none', height: '14', viewBox: '0 0 14 14', width: '14', xmlns: 'http://www.w3.org/2000/svg', ...props },
|
|
6
|
+
React.createElement("path", { d: 'M1.66659 1.66665H12.3333V9.66665H2.44659L1.66659 10.4466V1.66665ZM1.66659 0.333313C0.933252 0.333313 0.339919 0.933313 0.339919 1.66665L0.333252 13.6666L2.99992 11H12.3333C13.0666 11 13.6666 10.4 13.6666 9.66665V1.66665C13.6666 0.933313 13.0666 0.333313 12.3333 0.333313H1.66659ZM2.99992 6.99998H10.9999V8.33331H2.99992V6.99998ZM2.99992 4.99998H10.9999V6.33331H2.99992V4.99998ZM2.99992 2.99998H10.9999V4.33331H2.99992V2.99998Z', fill: 'currentColor' }))),
|
|
7
|
+
MessageBubbleEmpty: (props) => (React.createElement("svg", { className: 'str-chat__icon str-chat__icon--message-bubble-empty', fill: 'none', height: '20', viewBox: '0 0 20 20', width: '20', xmlns: 'http://www.w3.org/2000/svg', ...props },
|
|
8
|
+
React.createElement("path", { d: 'M18 0H2C0.9 0 0 0.9 0 2V20L4 16H18C19.1 16 20 15.1 20 14V2C20 0.9 19.1 0 18 0ZM18 14H4L2 16V2H18V14Z', fill: 'currentColor' }))),
|
|
9
|
+
Reload: (props) => (React.createElement("svg", { className: 'str-chat__icon str-chat__icon--reload', fill: 'none', height: '22', viewBox: '0 0 16 22', width: '16', xmlns: 'http://www.w3.org/2000/svg', ...props },
|
|
10
|
+
React.createElement("path", { d: 'M8 3V0L4 4L8 8V5C11.31 5 14 7.69 14 11C14 12.01 13.75 12.97 13.3 13.8L14.76 15.26C15.54 14.03 16 12.57 16 11C16 6.58 12.42 3 8 3ZM8 17C4.69 17 2 14.31 2 11C2 9.99 2.25 9.03 2.7 8.2L1.24 6.74C0.46 7.97 0 9.43 0 11C0 15.42 3.58 19 8 19V22L12 18L8 14V17Z', fill: 'currentColor' }))),
|
|
11
|
+
User: (props) => (React.createElement("svg", { className: 'str-chat__icon str-chat__icon--user', fill: 'none', height: '16', viewBox: '0 0 16 16', width: '16', xmlns: 'http://www.w3.org/2000/svg', ...props },
|
|
12
|
+
React.createElement("path", { d: 'M8 2C9.1 2 10 2.9 10 4C10 5.1 9.1 6 8 6C6.9 6 6 5.1 6 4C6 2.9 6.9 2 8 2ZM8 12C10.7 12 13.8 13.29 14 14H2C2.23 13.28 5.31 12 8 12ZM8 0C5.79 0 4 1.79 4 4C4 6.21 5.79 8 8 8C10.21 8 12 6.21 12 4C12 1.79 10.21 0 8 0ZM8 10C5.33 10 0 11.34 0 14V16H16V14C16 11.34 10.67 10 8 10Z', fill: 'currentColor' }))),
|
|
13
|
+
};
|
|
@@ -10,6 +10,7 @@ export * from './Chat';
|
|
|
10
10
|
export * from './ChatAutoComplete';
|
|
11
11
|
export * from './CommandItem';
|
|
12
12
|
export * from './DateSeparator';
|
|
13
|
+
export * from './Dialog';
|
|
13
14
|
export * from './EmoticonItem';
|
|
14
15
|
export * from './EmptyStateIndicator';
|
|
15
16
|
export * from './EventComponent';
|
|
@@ -31,5 +32,7 @@ export * from './Tooltip';
|
|
|
31
32
|
export * from './TypingIndicator';
|
|
32
33
|
export * from './UserItem';
|
|
33
34
|
export * from './Window';
|
|
35
|
+
export * from './Threads';
|
|
36
|
+
export * from './ChatView';
|
|
34
37
|
export { UploadButton } from './ReactFileUtilities';
|
|
35
38
|
export type { UploadButtonProps } from './ReactFileUtilities';
|
package/dist/components/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export * from './Chat';
|
|
|
10
10
|
export * from './ChatAutoComplete';
|
|
11
11
|
export * from './CommandItem';
|
|
12
12
|
export * from './DateSeparator';
|
|
13
|
+
export * from './Dialog';
|
|
13
14
|
export * from './EmoticonItem';
|
|
14
15
|
export * from './EmptyStateIndicator';
|
|
15
16
|
export * from './EventComponent';
|
|
@@ -31,4 +32,6 @@ export * from './Tooltip';
|
|
|
31
32
|
export * from './TypingIndicator';
|
|
32
33
|
export * from './UserItem';
|
|
33
34
|
export * from './Window';
|
|
35
|
+
export * from './Threads';
|
|
36
|
+
export * from './ChatView';
|
|
34
37
|
export { UploadButton } from './ReactFileUtilities';
|
|
@@ -1,46 +1,11 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
-
import type { AttachmentProps } from '../components/Attachment/Attachment';
|
|
3
|
-
import type { AvatarProps } from '../components/Avatar/Avatar';
|
|
4
|
-
import type { DateSeparatorProps } from '../components/DateSeparator/DateSeparator';
|
|
5
|
-
import type { EmptyStateIndicatorProps } from '../components/EmptyStateIndicator/EmptyStateIndicator';
|
|
6
|
-
import type { EventComponentProps } from '../components/EventComponent/EventComponent';
|
|
7
|
-
import type { LoadingIndicatorProps } from '../components/Loading/LoadingIndicator';
|
|
8
|
-
import type { FixedHeightMessageProps } from '../components/Message/FixedHeightMessage';
|
|
9
|
-
import type { MessageProps, MessageUIComponentProps, PinIndicatorProps } from '../components/Message/types';
|
|
10
|
-
import type { MessageDeletedProps } from '../components/Message/MessageDeleted';
|
|
11
|
-
import type { GiphyPreviewMessageProps } from '../components/MessageList/GiphyPreviewMessage';
|
|
12
|
-
import type { MessageListNotificationsProps } from '../components/MessageList/MessageListNotifications';
|
|
13
|
-
import type { MessageNotificationProps } from '../components/MessageList/MessageNotification';
|
|
14
|
-
import type { MessageOptionsProps } from '../components/Message/MessageOptions';
|
|
15
|
-
import type { EmojiSearchIndex, MessageInputProps } from '../components/MessageInput/MessageInput';
|
|
16
|
-
import type { QuotedMessagePreviewProps } from '../components/MessageInput/QuotedMessagePreview';
|
|
17
|
-
import type { MessageRepliesCountButtonProps } from '../components/Message/MessageRepliesCountButton';
|
|
18
|
-
import type { MessageStatusProps } from '../components/Message/MessageStatus';
|
|
19
|
-
import type { MessageTimestampProps } from '../components/Message/MessageTimestamp';
|
|
20
|
-
import type { ModalGalleryProps } from '../components/Gallery/ModalGallery';
|
|
21
|
-
import type { ReactionSelectorProps } from '../components/Reactions/ReactionSelector';
|
|
22
|
-
import type { ReactionsListProps } from '../components/Reactions/ReactionsList';
|
|
23
|
-
import type { SuggestionItemProps, SuggestionListProps } from '../components/ChatAutoComplete/ChatAutoComplete';
|
|
24
|
-
import { UnreadMessagesSeparatorProps } from '../components/MessageList/UnreadMessagesSeparator';
|
|
25
|
-
import type { ThreadHeaderProps } from '../components/Thread/ThreadHeader';
|
|
26
|
-
import type { TypingIndicatorProps } from '../components/TypingIndicator/TypingIndicator';
|
|
27
|
-
import type { CustomTrigger, DefaultStreamChatGenerics, UnknownType } from '../types/types';
|
|
28
|
-
import type { RecordingPermissionDeniedNotificationProps } from '../components';
|
|
29
2
|
import { BaseImageProps, CooldownTimerProps, CustomMessageActionsListProps, StartRecordingAudioButtonProps } from '../components';
|
|
30
|
-
import type { AttachmentPreviewListProps } from '../components
|
|
31
|
-
import type { LinkPreviewListProps } from '../components/MessageInput/LinkPreviewList';
|
|
32
|
-
import type { ReactionOptions } from '../components/Reactions/reactionOptions';
|
|
3
|
+
import type { AttachmentPreviewListProps, AttachmentProps, AvatarProps, DateSeparatorProps, EmojiSearchIndex, EmptyStateIndicatorProps, EventComponentProps, FixedHeightMessageProps, GiphyPreviewMessageProps, LinkPreviewListProps, LoadingIndicatorProps, MessageDeletedProps, MessageInputProps, MessageListNotificationsProps, MessageNotificationProps, MessageOptionsProps, MessageProps, MessageRepliesCountButtonProps, MessageStatusProps, MessageTimestampProps, MessageUIComponentProps, ModalGalleryProps, PinIndicatorProps, QuotedMessagePreviewProps, ReactionOptions, ReactionSelectorProps, ReactionsListProps, RecordingPermissionDeniedNotificationProps, SendButtonProps, SuggestionItemProps, SuggestionListProps, ThreadHeaderProps, ThreadListItemProps, ThreadListItemUIProps, TypingIndicatorProps, UnreadMessagesNotificationProps, UnreadMessagesSeparatorProps } from '../components';
|
|
33
4
|
import type { MessageBouncePromptProps } from '../components/MessageBounce';
|
|
34
|
-
import type { UnreadMessagesNotificationProps } from '../components/MessageList/UnreadMessagesNotification';
|
|
35
|
-
import type { SendButtonProps } from '../components/MessageInput/SendButton';
|
|
36
5
|
import type { TimestampProps } from '../components/Message/Timestamp';
|
|
6
|
+
import type { CustomTrigger, DefaultStreamChatGenerics, UnknownType } from '../types/types';
|
|
37
7
|
export type ComponentContextValue<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, V extends CustomTrigger = CustomTrigger> = {
|
|
38
|
-
Attachment
|
|
39
|
-
DateSeparator: React.ComponentType<DateSeparatorProps>;
|
|
40
|
-
Message: React.ComponentType<MessageUIComponentProps<StreamChatGenerics>>;
|
|
41
|
-
MessageSystem: React.ComponentType<EventComponentProps<StreamChatGenerics>>;
|
|
42
|
-
reactionOptions: ReactionOptions;
|
|
43
|
-
UnreadMessagesSeparator: React.ComponentType<UnreadMessagesSeparatorProps>;
|
|
8
|
+
Attachment?: React.ComponentType<AttachmentProps<StreamChatGenerics>>;
|
|
44
9
|
AttachmentPreviewList?: React.ComponentType<AttachmentPreviewListProps>;
|
|
45
10
|
AudioRecorder?: React.ComponentType;
|
|
46
11
|
AutocompleteSuggestionItem?: React.ComponentType<SuggestionItemProps<StreamChatGenerics>>;
|
|
@@ -49,6 +14,7 @@ export type ComponentContextValue<StreamChatGenerics extends DefaultStreamChatGe
|
|
|
49
14
|
BaseImage?: React.ComponentType<BaseImageProps>;
|
|
50
15
|
CooldownTimer?: React.ComponentType<CooldownTimerProps>;
|
|
51
16
|
CustomMessageActionsList?: React.ComponentType<CustomMessageActionsListProps<StreamChatGenerics>>;
|
|
17
|
+
DateSeparator?: React.ComponentType<DateSeparatorProps>;
|
|
52
18
|
EditMessageInput?: React.ComponentType<MessageInputProps<StreamChatGenerics>>;
|
|
53
19
|
EmojiPicker?: React.ComponentType;
|
|
54
20
|
emojiSearchIndex?: EmojiSearchIndex;
|
|
@@ -59,6 +25,7 @@ export type ComponentContextValue<StreamChatGenerics extends DefaultStreamChatGe
|
|
|
59
25
|
Input?: React.ComponentType<MessageInputProps<StreamChatGenerics, V>>;
|
|
60
26
|
LinkPreviewList?: React.ComponentType<LinkPreviewListProps>;
|
|
61
27
|
LoadingIndicator?: React.ComponentType<LoadingIndicatorProps>;
|
|
28
|
+
Message?: React.ComponentType<MessageUIComponentProps<StreamChatGenerics>>;
|
|
62
29
|
MessageBouncePrompt?: React.ComponentType<MessageBouncePromptProps>;
|
|
63
30
|
MessageDeleted?: React.ComponentType<MessageDeletedProps<StreamChatGenerics>>;
|
|
64
31
|
MessageListNotifications?: React.ComponentType<MessageListNotificationsProps>;
|
|
@@ -66,11 +33,13 @@ export type ComponentContextValue<StreamChatGenerics extends DefaultStreamChatGe
|
|
|
66
33
|
MessageOptions?: React.ComponentType<MessageOptionsProps<StreamChatGenerics>>;
|
|
67
34
|
MessageRepliesCountButton?: React.ComponentType<MessageRepliesCountButtonProps>;
|
|
68
35
|
MessageStatus?: React.ComponentType<MessageStatusProps>;
|
|
36
|
+
MessageSystem?: React.ComponentType<EventComponentProps<StreamChatGenerics>>;
|
|
69
37
|
MessageTimestamp?: React.ComponentType<MessageTimestampProps<StreamChatGenerics>>;
|
|
70
38
|
ModalGallery?: React.ComponentType<ModalGalleryProps>;
|
|
71
39
|
PinIndicator?: React.ComponentType<PinIndicatorProps<StreamChatGenerics>>;
|
|
72
40
|
QuotedMessage?: React.ComponentType;
|
|
73
41
|
QuotedMessagePreview?: React.ComponentType<QuotedMessagePreviewProps<StreamChatGenerics>>;
|
|
42
|
+
reactionOptions?: ReactionOptions;
|
|
74
43
|
ReactionSelector?: React.ForwardRefExoticComponent<ReactionSelectorProps<StreamChatGenerics>>;
|
|
75
44
|
ReactionsList?: React.ComponentType<ReactionsListProps<StreamChatGenerics>>;
|
|
76
45
|
RecordingPermissionDeniedNotification?: React.ComponentType<RecordingPermissionDeniedNotificationProps>;
|
|
@@ -79,18 +48,24 @@ export type ComponentContextValue<StreamChatGenerics extends DefaultStreamChatGe
|
|
|
79
48
|
ThreadHead?: React.ComponentType<MessageProps<StreamChatGenerics>>;
|
|
80
49
|
ThreadHeader?: React.ComponentType<ThreadHeaderProps<StreamChatGenerics>>;
|
|
81
50
|
ThreadInput?: React.ComponentType<MessageInputProps<StreamChatGenerics, V>>;
|
|
51
|
+
ThreadListEmptyPlaceholder?: React.ComponentType;
|
|
52
|
+
ThreadListItem?: React.ComponentType<ThreadListItemProps>;
|
|
53
|
+
ThreadListItemUI?: React.ComponentType<ThreadListItemUIProps>;
|
|
54
|
+
ThreadListLoadingIndicator?: React.ComponentType;
|
|
55
|
+
ThreadListUnseenThreadsBanner?: React.ComponentType;
|
|
82
56
|
ThreadStart?: React.ComponentType;
|
|
83
57
|
Timestamp?: React.ComponentType<TimestampProps>;
|
|
84
58
|
TriggerProvider?: React.ComponentType;
|
|
85
59
|
TypingIndicator?: React.ComponentType<TypingIndicatorProps>;
|
|
86
60
|
UnreadMessagesNotification?: React.ComponentType<UnreadMessagesNotificationProps>;
|
|
61
|
+
UnreadMessagesSeparator?: React.ComponentType<UnreadMessagesSeparatorProps>;
|
|
87
62
|
VirtualMessage?: React.ComponentType<FixedHeightMessageProps<StreamChatGenerics>>;
|
|
88
63
|
};
|
|
89
|
-
export declare const ComponentContext: React.Context<ComponentContextValue<DefaultStreamChatGenerics, CustomTrigger
|
|
64
|
+
export declare const ComponentContext: React.Context<ComponentContextValue<DefaultStreamChatGenerics, CustomTrigger>>;
|
|
90
65
|
export declare const ComponentProvider: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, V extends CustomTrigger = CustomTrigger>({ children, value, }: PropsWithChildren<{
|
|
91
66
|
value: Partial<ComponentContextValue<StreamChatGenerics, V>>;
|
|
92
67
|
}>) => React.JSX.Element;
|
|
93
|
-
export declare const useComponentContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, V extends CustomTrigger = CustomTrigger>(
|
|
68
|
+
export declare const useComponentContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, V extends CustomTrigger = CustomTrigger>(_componentName?: string) => ComponentContextValue<StreamChatGenerics, V>;
|
|
94
69
|
/**
|
|
95
70
|
* Typescript currently does not support partial inference, so if ComponentContext
|
|
96
71
|
* typing is desired while using the HOC withComponentContext, the Props for the
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
export const ComponentContext = React.createContext(
|
|
2
|
+
export const ComponentContext = React.createContext({});
|
|
3
3
|
export const ComponentProvider = ({ children, value, }) => (React.createElement(ComponentContext.Provider, { value: value }, children));
|
|
4
|
-
export const useComponentContext = (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return contextValue;
|
|
11
|
-
};
|
|
4
|
+
export const useComponentContext = (
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
9
|
+
_componentName) => useContext(ComponentContext);
|
|
12
10
|
/**
|
|
13
11
|
* Typescript currently does not support partial inference, so if ComponentContext
|
|
14
12
|
* typing is desired while using the HOC withComponentContext, the Props for the
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { DialogManager } from '../components/Dialog/DialogManager';
|
|
3
|
+
type DialogManagerProviderContextValue = {
|
|
4
|
+
dialogManager: DialogManager;
|
|
5
|
+
};
|
|
6
|
+
export declare const DialogManagerProvider: ({ children, id }: PropsWithChildren<{
|
|
7
|
+
id?: string;
|
|
8
|
+
}>) => React.JSX.Element;
|
|
9
|
+
export declare const useDialogManager: () => DialogManagerProviderContextValue;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { useContext, useState } from 'react';
|
|
2
|
+
import { DialogManager } from '../components/Dialog/DialogManager';
|
|
3
|
+
import { DialogPortalDestination } from '../components/Dialog/DialogPortal';
|
|
4
|
+
const DialogManagerProviderContext = React.createContext(undefined);
|
|
5
|
+
export const DialogManagerProvider = ({ children, id }) => {
|
|
6
|
+
const [dialogManager] = useState(() => new DialogManager({ id }));
|
|
7
|
+
return (React.createElement(DialogManagerProviderContext.Provider, { value: { dialogManager } },
|
|
8
|
+
children,
|
|
9
|
+
React.createElement(DialogPortalDestination, null)));
|
|
10
|
+
};
|
|
11
|
+
export const useDialogManager = () => {
|
|
12
|
+
const value = useContext(DialogManagerProviderContext);
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
@@ -50,10 +50,6 @@ export type MessageContextValue<StreamChatGenerics extends DefaultStreamChatGene
|
|
|
50
50
|
handleRetry: ChannelActionContextValue<StreamChatGenerics>['retrySendMessage'];
|
|
51
51
|
/** Function that returns whether the Message belongs to the current user */
|
|
52
52
|
isMyMessage: () => boolean;
|
|
53
|
-
/** @deprecated will be removed in the next major release.
|
|
54
|
-
* Whether sending reactions is enabled for the active channel.
|
|
55
|
-
*/
|
|
56
|
-
isReactionEnabled: boolean;
|
|
57
53
|
/** The message object */
|
|
58
54
|
message: StreamMessage<StreamChatGenerics>;
|
|
59
55
|
/** Indicates whether a message has not been read yet or has been marked unread */
|
|
@@ -62,22 +58,18 @@ export type MessageContextValue<StreamChatGenerics extends DefaultStreamChatGene
|
|
|
62
58
|
onMentionsClickMessage: ReactEventHandler;
|
|
63
59
|
/** Handler function for a hover event on an @mention in Message */
|
|
64
60
|
onMentionsHoverMessage: ReactEventHandler;
|
|
65
|
-
/** Handler function for a click event on the reaction list */
|
|
66
|
-
onReactionListClick: ReactEventHandler;
|
|
67
61
|
/** Handler function for a click event on the user that posted the Message */
|
|
68
62
|
onUserClick: ReactEventHandler;
|
|
69
63
|
/** Handler function for a hover event on the user that posted the Message */
|
|
70
64
|
onUserHover: ReactEventHandler;
|
|
71
|
-
/** Ref to be placed on the reaction selector component */
|
|
72
|
-
reactionSelectorRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
73
65
|
/** Function to toggle the edit state on a Message */
|
|
74
66
|
setEditingState: ReactEventHandler;
|
|
75
|
-
/** Whether or not to show reaction list details */
|
|
76
|
-
showDetailedReactions: boolean;
|
|
77
67
|
/** Additional props for underlying MessageInput component, [available props](https://getstream.io/chat/docs/sdk/react/message-input-components/message_input/#props) */
|
|
78
68
|
additionalMessageInputProps?: MessageInputProps<StreamChatGenerics>;
|
|
79
69
|
/** Call this function to keep message list scrolled to the bottom when the scroll height increases, e.g. an element appears below the last message (only used in the `VirtualizedMessageList`) */
|
|
80
70
|
autoscrollToBottom?: () => void;
|
|
71
|
+
/** Message component configuration prop. If true, picking a reaction from the `ReactionSelector` component will close the selector */
|
|
72
|
+
closeReactionSelectorOnClick?: boolean;
|
|
81
73
|
/** Object containing custom message actions and function handlers */
|
|
82
74
|
customMessageActions?: CustomMessageActions<StreamChatGenerics>;
|
|
83
75
|
/** If true, the message is the last one in a group sent by a specific user (only used in the `VirtualizedMessageList`) */
|
|
@@ -123,7 +115,7 @@ export declare const MessageContext: React.Context<MessageContextValue<DefaultSt
|
|
|
123
115
|
export declare const MessageProvider: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ children, value, }: PropsWithChildren<{
|
|
124
116
|
value: MessageContextValue<StreamChatGenerics>;
|
|
125
117
|
}>) => React.JSX.Element;
|
|
126
|
-
export declare const useMessageContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
|
|
118
|
+
export declare const useMessageContext: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(_componentName?: string) => MessageContextValue<StreamChatGenerics>;
|
|
127
119
|
/**
|
|
128
120
|
* Typescript currently does not support partial inference, so if MessageContext
|
|
129
121
|
* typing is desired while using the HOC withMessageContext, the Props for the
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
export const MessageContext = React.createContext(undefined);
|
|
3
3
|
export const MessageProvider = ({ children, value, }) => (React.createElement(MessageContext.Provider, { value: value }, children));
|
|
4
|
-
export const useMessageContext = (
|
|
4
|
+
export const useMessageContext = (
|
|
5
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
6
|
+
_componentName) => {
|
|
5
7
|
const contextValue = useContext(MessageContext);
|
|
6
8
|
if (!contextValue) {
|
|
7
|
-
console.warn(`The useMessageContext hook was called outside of the MessageContext provider. Make sure this hook is called within the Message's UI component. The errored call is located in the ${componentName} component.`);
|
|
8
9
|
return {};
|
|
9
10
|
}
|
|
10
11
|
return contextValue;
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
-
import Dayjs from 'dayjs';
|
|
3
2
|
import type { TFunction } from 'i18next';
|
|
4
|
-
import type { Moment } from 'moment-timezone';
|
|
5
3
|
import type { TranslationLanguages } from 'stream-chat';
|
|
6
4
|
import type { UnknownType } from '../types/types';
|
|
7
|
-
|
|
8
|
-
export declare const isLanguageSupported: (language: string) => language is SupportedTranslations;
|
|
9
|
-
export declare const isDayOrMoment: (output: TDateTimeParserOutput) => output is Dayjs.Dayjs | Moment;
|
|
10
|
-
export declare const isDate: (output: TDateTimeParserOutput) => output is Date;
|
|
11
|
-
export declare const isNumberOrString: (output: TDateTimeParserOutput) => output is string | number;
|
|
12
|
-
export type TDateTimeParserInput = string | number | Date;
|
|
13
|
-
export type TDateTimeParserOutput = string | number | Date | Dayjs.Dayjs | Moment;
|
|
14
|
-
export type TDateTimeParser = (input?: TDateTimeParserInput) => TDateTimeParserOutput;
|
|
5
|
+
import type { TDateTimeParser } from '../i18n/types';
|
|
15
6
|
export type TranslationContextValue = {
|
|
16
7
|
t: TFunction;
|
|
17
8
|
tDateTimeParser: TDateTimeParser;
|
|
18
9
|
userLanguage: TranslationLanguages;
|
|
19
10
|
};
|
|
20
|
-
export declare const defaultDateTimeParser: (input?: TDateTimeParserInput) => Dayjs.Dayjs;
|
|
21
11
|
export declare const TranslationContext: React.Context<TranslationContextValue>;
|
|
22
12
|
export declare const TranslationProvider: ({ children, value, }: PropsWithChildren<{
|
|
23
13
|
value: TranslationContextValue;
|
|
@@ -3,17 +3,9 @@ import Dayjs from 'dayjs';
|
|
|
3
3
|
import calendar from 'dayjs/plugin/calendar';
|
|
4
4
|
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
5
5
|
import { getDisplayName } from './utils/getDisplayName';
|
|
6
|
-
import { defaultTranslatorFunction } from '../i18n';
|
|
6
|
+
import { defaultDateTimeParser, defaultTranslatorFunction } from '../i18n/utils';
|
|
7
7
|
Dayjs.extend(calendar);
|
|
8
8
|
Dayjs.extend(localizedFormat);
|
|
9
|
-
export const isLanguageSupported = (language) => {
|
|
10
|
-
const translations = ['de', 'en', 'es', 'fr', 'hi', 'it', 'ja', 'ko', 'nl', 'pt', 'ru', 'tr'];
|
|
11
|
-
return translations.some((translation) => language === translation);
|
|
12
|
-
};
|
|
13
|
-
export const isDayOrMoment = (output) => !!output?.isSame;
|
|
14
|
-
export const isDate = (output) => !!output?.getMonth;
|
|
15
|
-
export const isNumberOrString = (output) => typeof output === 'string' || typeof output === 'number';
|
|
16
|
-
export const defaultDateTimeParser = (input) => Dayjs(input);
|
|
17
9
|
export const TranslationContext = React.createContext({
|
|
18
10
|
t: defaultTranslatorFunction,
|
|
19
11
|
tDateTimeParser: defaultDateTimeParser,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { ComponentContext } from './ComponentContext';
|
|
3
|
+
export function WithComponents({ children, overrides, }) {
|
|
4
|
+
const parentOverrides = useContext(ComponentContext);
|
|
5
|
+
const actualOverrides = { ...parentOverrides, ...overrides };
|
|
6
|
+
return React.createElement(ComponentContext.Provider, { value: actualOverrides }, children);
|
|
7
|
+
}
|
package/dist/context/index.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ export * from './ChannelListContext';
|
|
|
3
3
|
export * from './ChannelStateContext';
|
|
4
4
|
export * from './ChatContext';
|
|
5
5
|
export * from './ComponentContext';
|
|
6
|
+
export * from './DialogManagerContext';
|
|
6
7
|
export * from './MessageContext';
|
|
7
8
|
export * from './MessageBounceContext';
|
|
8
9
|
export * from './MessageInputContext';
|
|
9
10
|
export * from './MessageListContext';
|
|
10
11
|
export * from './TranslationContext';
|
|
11
12
|
export * from './TypingContext';
|
|
13
|
+
export * from './WithComponents';
|
package/dist/context/index.js
CHANGED
|
@@ -3,9 +3,11 @@ export * from './ChannelListContext';
|
|
|
3
3
|
export * from './ChannelStateContext';
|
|
4
4
|
export * from './ChatContext';
|
|
5
5
|
export * from './ComponentContext';
|
|
6
|
+
export * from './DialogManagerContext';
|
|
6
7
|
export * from './MessageContext';
|
|
7
8
|
export * from './MessageBounceContext';
|
|
8
9
|
export * from './MessageInputContext';
|
|
9
10
|
export * from './MessageListContext';
|
|
10
11
|
export * from './TranslationContext';
|
|
11
12
|
export * from './TypingContext';
|
|
13
|
+
export * from './WithComponents';
|