stream-chat-react 13.8.0 → 13.9.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 (67) hide show
  1. package/dist/components/Channel/Channel.d.ts +2 -2
  2. package/dist/components/Channel/Channel.js +3 -3
  3. package/dist/components/Channel/hooks/useCreateChannelStateContext.js +3 -1
  4. package/dist/components/ChannelPreview/hooks/useMessageDeliveryStatus.d.ts +1 -0
  5. package/dist/components/ChannelPreview/hooks/useMessageDeliveryStatus.js +26 -14
  6. package/dist/components/Chat/hooks/useChat.js +1 -1
  7. package/dist/components/Message/Message.js +1 -1
  8. package/dist/components/Message/MessageStatus.d.ts +1 -0
  9. package/dist/components/Message/MessageStatus.js +22 -12
  10. package/dist/components/Message/hooks/useDeleteHandler.js +2 -2
  11. package/dist/components/Message/icons.d.ts +1 -0
  12. package/dist/components/Message/icons.js +6 -2
  13. package/dist/components/Message/types.d.ts +2 -0
  14. package/dist/components/Message/utils.d.ts +4 -1
  15. package/dist/components/Message/utils.js +9 -0
  16. package/dist/components/MessageActions/MessageActionsBox.js +3 -1
  17. package/dist/components/MessageList/MessageList.js +2 -2
  18. package/dist/components/MessageList/VirtualizedMessageList.d.ts +2 -0
  19. package/dist/components/MessageList/VirtualizedMessageList.js +10 -4
  20. package/dist/components/MessageList/VirtualizedMessageListComponents.js +2 -2
  21. package/dist/components/MessageList/hooks/MessageList/useMessageListElements.d.ts +2 -2
  22. package/dist/components/MessageList/hooks/MessageList/useMessageListElements.js +13 -5
  23. package/dist/components/MessageList/hooks/useLastDeliveredData.d.ts +8 -0
  24. package/dist/components/MessageList/hooks/useLastDeliveredData.js +13 -0
  25. package/dist/components/MessageList/hooks/useLastReadData.d.ts +3 -8
  26. package/dist/components/MessageList/hooks/useLastReadData.js +10 -7
  27. package/dist/components/MessageList/renderMessages.d.ts +5 -4
  28. package/dist/components/MessageList/renderMessages.js +2 -2
  29. package/dist/components/MessageList/utils.d.ts +1 -5
  30. package/dist/components/MessageList/utils.js +0 -30
  31. package/dist/context/ChannelActionContext.d.ts +2 -2
  32. package/dist/context/MessageContext.d.ts +5 -3
  33. package/dist/css/v2/index.css +1 -1
  34. package/dist/css/v2/index.layout.css +1 -1
  35. package/dist/experimental/index.browser.cjs +19 -13
  36. package/dist/experimental/index.browser.cjs.map +2 -2
  37. package/dist/experimental/index.node.cjs +19 -13
  38. package/dist/experimental/index.node.cjs.map +2 -2
  39. package/dist/i18n/Streami18n.d.ts +2 -0
  40. package/dist/i18n/de.json +2 -0
  41. package/dist/i18n/en.json +2 -0
  42. package/dist/i18n/es.json +2 -0
  43. package/dist/i18n/fr.json +2 -0
  44. package/dist/i18n/hi.json +2 -0
  45. package/dist/i18n/it.json +2 -0
  46. package/dist/i18n/ja.json +2 -0
  47. package/dist/i18n/ko.json +2 -0
  48. package/dist/i18n/nl.json +2 -0
  49. package/dist/i18n/pt.json +2 -0
  50. package/dist/i18n/ru.json +2 -0
  51. package/dist/i18n/tr.json +2 -0
  52. package/dist/index.browser.cjs +984 -885
  53. package/dist/index.browser.cjs.map +4 -4
  54. package/dist/index.node.cjs +986 -886
  55. package/dist/index.node.cjs.map +4 -4
  56. package/dist/plugins/Emojis/index.browser.cjs.map +2 -2
  57. package/dist/plugins/Emojis/index.node.cjs.map +2 -2
  58. package/dist/scss/v2/Dialog/Dialog-layout.scss +12 -3
  59. package/dist/scss/v2/Icon/Icon-layout.scss +6 -0
  60. package/dist/scss/v2/Icon/Icon-theme.scss +4 -0
  61. package/dist/scss/v2/Message/Message-layout.scss +30 -3
  62. package/dist/scss/v2/Message/Message-theme.scss +9 -0
  63. package/dist/scss/v2/MessageInput/MessageInput-layout.scss +8 -0
  64. package/dist/scss/v2/MessageInput/MessageInput-theme.scss +2 -1
  65. package/dist/scss/v2/Poll/Poll-layout.scss +29 -7
  66. package/dist/types/defaultDataInterfaces.d.ts +1 -0
  67. package/package.json +4 -4
@@ -1,8 +1,8 @@
1
- import React from 'react';
2
1
  import type { ReactNode } from 'react';
3
- import type { UserResponse } from 'stream-chat';
2
+ import React from 'react';
4
3
  import type { GroupStyle, RenderedMessage } from './utils';
5
4
  import type { MessageProps } from '../Message';
5
+ import type { UserResponse } from 'stream-chat';
6
6
  import type { ComponentContextValue, CustomClasses } from '../../context';
7
7
  import type { ChannelUnreadUiState } from '../../types';
8
8
  export interface RenderMessagesOptions {
@@ -10,6 +10,7 @@ export interface RenderMessagesOptions {
10
10
  lastReceivedMessageId: string | null;
11
11
  messageGroupStyles: Record<string, GroupStyle>;
12
12
  messages: Array<RenderedMessage>;
13
+ ownMessagesDeliveredToOthers: Record<string, UserResponse[]>;
13
14
  /**
14
15
  * Object mapping message IDs of own messages to the users who read those messages.
15
16
  */
@@ -28,6 +29,6 @@ export interface RenderMessagesOptions {
28
29
  }
29
30
  export type SharedMessageProps = Omit<MessageProps, MessagePropsToOmit>;
30
31
  export type MessageRenderer = (options: RenderMessagesOptions) => Array<ReactNode>;
31
- type MessagePropsToOmit = 'channel' | 'groupStyles' | 'initialMessage' | 'lastReceivedId' | 'message' | 'readBy';
32
- export declare function defaultRenderMessages({ channelUnreadUiState, components, customClasses, lastReceivedMessageId: lastReceivedId, messageGroupStyles, messages, readData, sharedMessageProps: messageProps, }: RenderMessagesOptions): React.JSX.Element[];
32
+ type MessagePropsToOmit = 'channel' | 'deliveredTo' | 'groupStyles' | 'initialMessage' | 'lastReceivedId' | 'message' | 'readBy';
33
+ export declare function defaultRenderMessages({ channelUnreadUiState, components, customClasses, lastReceivedMessageId: lastReceivedId, messageGroupStyles, messages, ownMessagesDeliveredToOthers, readData, sharedMessageProps: messageProps, }: RenderMessagesOptions): React.JSX.Element[];
33
34
  export {};
@@ -4,7 +4,7 @@ import { Message } from '../Message';
4
4
  import { DateSeparator as DefaultDateSeparator } from '../DateSeparator';
5
5
  import { EventComponent as DefaultMessageSystem } from '../EventComponent';
6
6
  import { UnreadMessagesSeparator as DefaultUnreadMessagesSeparator } from './UnreadMessagesSeparator';
7
- export function defaultRenderMessages({ channelUnreadUiState, components, customClasses, lastReceivedMessageId: lastReceivedId, messageGroupStyles, messages, readData, sharedMessageProps: messageProps, }) {
7
+ export function defaultRenderMessages({ channelUnreadUiState, components, customClasses, lastReceivedMessageId: lastReceivedId, messageGroupStyles, messages, ownMessagesDeliveredToOthers, readData, sharedMessageProps: messageProps, }) {
8
8
  const { DateSeparator = DefaultDateSeparator, HeaderComponent, MessageSystem = DefaultMessageSystem, UnreadMessagesSeparator = DefaultUnreadMessagesSeparator, } = components;
9
9
  const renderedMessages = [];
10
10
  let firstMessage;
@@ -44,7 +44,7 @@ export function defaultRenderMessages({ channelUnreadUiState, components, custom
44
44
  isFirstUnreadMessage && UnreadMessagesSeparator && (React.createElement("li", { className: 'str-chat__li str-chat__unread-messages-separator-wrapper' },
45
45
  React.createElement(UnreadMessagesSeparator, { unreadCount: channelUnreadUiState?.unread_messages }))),
46
46
  React.createElement("li", { className: messageClass, "data-message-id": message.id, "data-testid": messageClass },
47
- React.createElement(Message, { groupStyles: [groupStyles], lastReceivedId: lastReceivedId, message: message, readBy: readData[message.id] || [], ...messageProps }))));
47
+ React.createElement(Message, { deliveredTo: ownMessagesDeliveredToOthers[message.id] || [], groupStyles: [groupStyles], lastReceivedId: lastReceivedId, message: message, readBy: readData[message.id] || [], ...messageProps }))));
48
48
  previousMessage = message;
49
49
  }
50
50
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { CUSTOM_MESSAGE_TYPE } from '../../constants/messageTypes';
3
- import type { LocalMessage, MessageLabel, UserResponse } from 'stream-chat';
3
+ import type { LocalMessage, MessageLabel } from 'stream-chat';
4
4
  type IntroMessage = {
5
5
  customType: typeof CUSTOM_MESSAGE_TYPE.intro;
6
6
  id: string;
@@ -62,10 +62,6 @@ export declare const processMessages: (params: ProcessMessagesParams) => Rendere
62
62
  export declare const makeIntroMessage: () => IntroMessage;
63
63
  export declare const makeDateMessageId: (date?: string | Date) => string;
64
64
  export declare const getLastReceived: (messages: RenderedMessage[]) => string | null;
65
- export declare const getReadStates: (messages: LocalMessage[], read: Record<string, {
66
- last_read: Date;
67
- user: UserResponse;
68
- }> | undefined, returnAllReadData: boolean) => Record<string, UserResponse[]>;
69
65
  export declare const insertIntro: (messages: RenderedMessage[], headerPosition?: number) => RenderedMessage[];
70
66
  export type GroupStyle = '' | 'middle' | 'top' | 'bottom' | 'single';
71
67
  export declare const getGroupStyles: (message: RenderedMessage, previousMessage: RenderedMessage, nextMessage: RenderedMessage, noGroupByUser: boolean, maxTimeBetweenGroupedMessages?: number) => GroupStyle;
@@ -119,36 +119,6 @@ export const getLastReceived = (messages) => {
119
119
  }
120
120
  return null;
121
121
  };
122
- export const getReadStates = (messages, read = {}, returnAllReadData) => {
123
- // create object with empty array for each message id
124
- const readData = {};
125
- Object.values(read).forEach((readState) => {
126
- if (!readState.last_read)
127
- return;
128
- let userLastReadMsgId;
129
- // loop messages sent by current user and add read data for other users in channel
130
- messages.forEach((msg) => {
131
- if (msg.created_at && msg.created_at < readState.last_read) {
132
- userLastReadMsgId = msg.id;
133
- // if true, save other user's read data for all messages they've read
134
- if (returnAllReadData) {
135
- if (!readData[userLastReadMsgId]) {
136
- readData[userLastReadMsgId] = [];
137
- }
138
- readData[userLastReadMsgId].push(readState.user);
139
- }
140
- }
141
- });
142
- // if true, only save read data for other user's last read message
143
- if (userLastReadMsgId && !returnAllReadData) {
144
- if (!readData[userLastReadMsgId]) {
145
- readData[userLastReadMsgId] = [];
146
- }
147
- readData[userLastReadMsgId].push(readState.user);
148
- }
149
- });
150
- return readData;
151
- };
152
122
  export const insertIntro = (messages, headerPosition) => {
153
123
  const newMessages = messages;
154
124
  const intro = makeIntroMessage();
@@ -1,6 +1,6 @@
1
1
  import type { PropsWithChildren } from 'react';
2
2
  import React from 'react';
3
- import type { LocalMessage, Message, MessageResponse, SendMessageOptions, UpdateMessageAPIResponse, UpdateMessageOptions } from 'stream-chat';
3
+ import type { DeleteMessageOptions, LocalMessage, Message, MessageResponse, SendMessageOptions, UpdateMessageAPIResponse, UpdateMessageOptions } from 'stream-chat';
4
4
  import type { ChannelStateReducerAction } from '../components/Channel/channelState';
5
5
  import type { CustomMentionHandler } from '../components/Message/hooks/useMentionsHandler';
6
6
  import type { ChannelUnreadUiState, UnknownType } from '../types/types';
@@ -16,7 +16,7 @@ export type RetrySendMessage = (message: LocalMessage) => Promise<void>;
16
16
  export type ChannelActionContextValue = {
17
17
  addNotification: (text: string, type: 'success' | 'error') => void;
18
18
  closeThread: (event?: React.BaseSyntheticEvent) => void;
19
- deleteMessage: (message: LocalMessage) => Promise<MessageResponse>;
19
+ deleteMessage: (message: LocalMessage, options?: DeleteMessageOptions) => Promise<MessageResponse>;
20
20
  dispatch: React.Dispatch<ChannelStateReducerAction>;
21
21
  editMessage: (message: LocalMessage | MessageResponse, options?: UpdateMessageOptions) => Promise<UpdateMessageAPIResponse | void>;
22
22
  jumpToFirstUnreadMessage: (queryMessageLimit?: number, highlightDuration?: number) => Promise<void>;
@@ -1,6 +1,6 @@
1
- import type { PropsWithChildren, ReactNode } from 'react';
1
+ import type { BaseSyntheticEvent, PropsWithChildren, ReactNode } from 'react';
2
2
  import React from 'react';
3
- import type { LocalMessage, Mute, ReactionResponse, ReactionSort, UserResponse } from 'stream-chat';
3
+ import type { DeleteMessageOptions, LocalMessage, Mute, ReactionResponse, ReactionSort, UserResponse } from 'stream-chat';
4
4
  import type { ChannelActionContextValue } from './ChannelActionContext';
5
5
  import type { ActionHandlerReturnType } from '../components/Message/hooks/useActionHandler';
6
6
  import type { PinPermissions } from '../components/Message/hooks/usePinHandler';
@@ -29,7 +29,7 @@ export type MessageContextValue = {
29
29
  /** Function to send an action in a Channel */
30
30
  handleAction: ActionHandlerReturnType;
31
31
  /** Function to delete a message in a Channel */
32
- handleDelete: ReactEventHandler;
32
+ handleDelete: (event: BaseSyntheticEvent, options?: DeleteMessageOptions) => Promise<void> | void;
33
33
  /** Function to edit a message in a Channel */
34
34
  handleEdit: ReactEventHandler;
35
35
  /** Function to fetch the message reactions */
@@ -72,6 +72,8 @@ export type MessageContextValue = {
72
72
  closeReactionSelectorOnClick?: boolean;
73
73
  /** Object containing custom message actions and function handlers */
74
74
  customMessageActions?: CustomMessageActions;
75
+ /** An array of user IDs that have confirmed the message delivery to their device */
76
+ deliveredTo?: UserResponse[];
75
77
  /** If true, the message is the last one in a group sent by a specific user (only used in the `VirtualizedMessageList`) */
76
78
  endOfGroup?: boolean;
77
79
  /** If true, the message is the first one in a group sent by a specific user (only used in the `VirtualizedMessageList`) */