stream-chat-react 13.14.1 → 13.14.3

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.
@@ -24,7 +24,7 @@ export const useChat = ({ client, defaultLanguage = 'en', i18nInstance, initialN
24
24
  useEffect(() => {
25
25
  if (!client)
26
26
  return;
27
- const version = "13.14.1";
27
+ const version = "13.14.3";
28
28
  const userAgent = client.getUserAgent();
29
29
  if (!userAgent.includes('stream-chat-react')) {
30
30
  // result looks like: 'stream-chat-react-2.3.2-stream-chat-javascript-client-browser-2.2.2'
@@ -7,6 +7,7 @@ export type EventComponentProps = TimestampFormatterOptions & {
7
7
  message: LocalMessage & {
8
8
  event?: Event;
9
9
  };
10
+ unsafeHTML?: boolean;
10
11
  /** Custom UI component to display user avatar, defaults to and accepts same props as: [Avatar](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Avatar/Avatar.tsx) */
11
12
  Avatar?: React.ComponentType<AvatarProps>;
12
13
  };
@@ -6,15 +6,15 @@ import { getDateString } from '../../i18n/utils';
6
6
  * Component to display system and channel event messages
7
7
  */
8
8
  const UnMemoizedEventComponent = (props) => {
9
- const { Avatar = DefaultAvatar, calendar, calendarFormats, format, message } = props;
9
+ const { Avatar = DefaultAvatar, calendar, calendarFormats, format, message, unsafeHTML = false, } = props;
10
10
  const { t, tDateTimeParser } = useTranslationContext('EventComponent');
11
- const { created_at = '', event, text, type } = message;
11
+ const { created_at = '', event, type } = message;
12
12
  const getDateOptions = { messageCreatedAt: created_at.toString(), tDateTimeParser };
13
13
  if (type === 'system')
14
14
  return (React.createElement("div", { className: 'str-chat__message--system', "data-testid": 'message-system' },
15
15
  React.createElement("div", { className: 'str-chat__message--system__text' },
16
16
  React.createElement("div", { className: 'str-chat__message--system__line' }),
17
- React.createElement("p", null, text),
17
+ unsafeHTML ? (React.createElement("div", { dangerouslySetInnerHTML: { __html: message.html || '' }, "data-unsafe-inner-html": true })) : (React.createElement("p", null, message.text)),
18
18
  React.createElement("div", { className: 'str-chat__message--system__line' })),
19
19
  React.createElement("div", { className: 'str-chat__message--system__date' },
20
20
  React.createElement("strong", null, getDateString({
@@ -1,7 +1,8 @@
1
1
  import type { PropsWithChildren } from 'react';
2
2
  import React from 'react';
3
+ import type { NotificationSeverity } from 'stream-chat';
3
4
  export type CustomNotificationProps = {
4
- type: string;
5
+ type?: NotificationSeverity | string;
5
6
  active?: boolean;
6
7
  className?: string;
7
8
  };
@@ -4,6 +4,6 @@ const UnMemoizedCustomNotification = (props) => {
4
4
  const { active, children, className, type } = props;
5
5
  if (!active)
6
6
  return null;
7
- return (React.createElement("div", { "aria-live": 'polite', className: clsx(`str-chat__custom-notification notification-${type}`, `str-chat__notification`, `str-chat-react__notification`, className), "data-testid": 'custom-notification' }, children));
7
+ return (React.createElement("div", { "aria-live": 'polite', className: clsx(`str-chat__custom-notification`, `str-chat__notification`, `str-chat-react__notification`, { [`notification-${type}`]: type }, className), "data-testid": 'custom-notification' }, children));
8
8
  };
9
9
  export const CustomNotification = React.memo(UnMemoizedCustomNotification);
@@ -23,7 +23,7 @@ export function defaultRenderMessages({ channelUnreadUiState, components, custom
23
23
  }
24
24
  else if (message.type === 'system') {
25
25
  renderedMessages.push(React.createElement(MessageListItem, { "data-index": index, "data-message-id": message.id, key: message.id || message.created_at.toISOString() },
26
- React.createElement(MessageSystem, { message: message })));
26
+ React.createElement(MessageSystem, { message: message, unsafeHTML: messageProps.unsafeHTML })));
27
27
  }
28
28
  else {
29
29
  if (!firstMessage) {
@@ -24122,9 +24122,10 @@ var UnMemoizedCustomNotification = (props) => {
24122
24122
  {
24123
24123
  "aria-live": "polite",
24124
24124
  className: (0, import_clsx44.default)(
24125
- `str-chat__custom-notification notification-${type}`,
24125
+ `str-chat__custom-notification`,
24126
24126
  `str-chat__notification`,
24127
24127
  `str-chat-react__notification`,
24128
+ { [`notification-${type}`]: type },
24128
24129
  className
24129
24130
  ),
24130
24131
  "data-testid": "custom-notification"
@@ -28995,12 +28996,25 @@ var DateSeparator = import_react180.default.memo(
28995
28996
  // src/components/EventComponent/EventComponent.tsx
28996
28997
  var import_react181 = __toESM(require("react"));
28997
28998
  var UnMemoizedEventComponent = (props) => {
28998
- const { Avatar: Avatar2 = Avatar, calendar: calendar3, calendarFormats, format, message } = props;
28999
+ const {
29000
+ Avatar: Avatar2 = Avatar,
29001
+ calendar: calendar3,
29002
+ calendarFormats,
29003
+ format,
29004
+ message,
29005
+ unsafeHTML = false
29006
+ } = props;
28999
29007
  const { t, tDateTimeParser } = useTranslationContext("EventComponent");
29000
- const { created_at = "", event, text: text8, type } = message;
29008
+ const { created_at = "", event, type } = message;
29001
29009
  const getDateOptions = { messageCreatedAt: created_at.toString(), tDateTimeParser };
29002
29010
  if (type === "system")
29003
- return /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system", "data-testid": "message-system" }, /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system__text" }, /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system__line" }), /* @__PURE__ */ import_react181.default.createElement("p", null, text8), /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system__line" })), /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system__date" }, /* @__PURE__ */ import_react181.default.createElement("strong", null, getDateString({
29011
+ return /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system", "data-testid": "message-system" }, /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system__text" }, /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system__line" }), unsafeHTML ? /* @__PURE__ */ import_react181.default.createElement(
29012
+ "div",
29013
+ {
29014
+ dangerouslySetInnerHTML: { __html: message.html || "" },
29015
+ "data-unsafe-inner-html": true
29016
+ }
29017
+ ) : /* @__PURE__ */ import_react181.default.createElement("p", null, message.text), /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system__line" })), /* @__PURE__ */ import_react181.default.createElement("div", { className: "str-chat__message--system__date" }, /* @__PURE__ */ import_react181.default.createElement("strong", null, getDateString({
29004
29018
  ...getDateOptions,
29005
29019
  calendar: calendar3,
29006
29020
  calendarFormats,
@@ -29070,7 +29084,7 @@ function defaultRenderMessages({
29070
29084
  "data-message-id": message.id,
29071
29085
  key: message.id || message.created_at.toISOString()
29072
29086
  },
29073
- /* @__PURE__ */ import_react182.default.createElement(MessageSystem, { message })
29087
+ /* @__PURE__ */ import_react182.default.createElement(MessageSystem, { message, unsafeHTML: messageProps.unsafeHTML })
29074
29088
  )
29075
29089
  );
29076
29090
  } else {
@@ -29135,7 +29149,7 @@ var import_react184 = require("react");
29135
29149
 
29136
29150
  // src/utils/findReverse.ts
29137
29151
  var findReverse = (items, matches) => {
29138
- for (let i = items.length - 1; i > 0; i -= 1) {
29152
+ for (let i = items.length - 1; i >= 0; i -= 1) {
29139
29153
  if (matches(items[i])) {
29140
29154
  return items[i];
29141
29155
  }
@@ -37408,7 +37422,7 @@ var useChat = ({
37408
37422
  };
37409
37423
  (0, import_react289.useEffect)(() => {
37410
37424
  if (!client) return;
37411
- const version = "13.14.1";
37425
+ const version = "13.14.3";
37412
37426
  const userAgent = client.getUserAgent();
37413
37427
  if (!userAgent.includes("stream-chat-react")) {
37414
37428
  client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);