stream-chat-react 14.0.0-beta.1 → 14.0.0-beta.2

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 (63) hide show
  1. package/dist/{WithAudioPlayback-BcKZ5Lbh.mjs → WithAudioPlayback-C1hfFIcu.mjs} +349 -256
  2. package/dist/WithAudioPlayback-C1hfFIcu.mjs.map +1 -0
  3. package/dist/{WithAudioPlayback-TERIQpZ6.js → WithAudioPlayback-myzUS2m6.js} +101 -8
  4. package/dist/WithAudioPlayback-myzUS2m6.js.map +1 -0
  5. package/dist/cjs/emojis.js +1 -1
  6. package/dist/cjs/index.js +703 -769
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/css/index.css +51 -36
  9. package/dist/css/index.css.map +1 -1
  10. package/dist/es/emojis.mjs +1 -1
  11. package/dist/es/index.mjs +827 -893
  12. package/dist/es/index.mjs.map +1 -1
  13. package/dist/types/components/Badge/Badge.d.ts +1 -0
  14. package/dist/types/components/Badge/Badge.d.ts.map +1 -1
  15. package/dist/types/components/Channel/Channel.d.ts.map +1 -1
  16. package/dist/types/components/Channel/utils.d.ts +7 -1
  17. package/dist/types/components/Channel/utils.d.ts.map +1 -1
  18. package/dist/types/components/ChatView/ChatView.d.ts.map +1 -1
  19. package/dist/types/components/Gallery/Gallery.d.ts.map +1 -1
  20. package/dist/types/components/Icons/icons.d.ts +4 -0
  21. package/dist/types/components/Icons/icons.d.ts.map +1 -1
  22. package/dist/types/components/MediaRecorder/AudioRecorder/AudioRecorderRecordingControls.d.ts.map +1 -1
  23. package/dist/types/components/Message/MessageErrorText.d.ts +0 -5
  24. package/dist/types/components/Message/MessageErrorText.d.ts.map +1 -1
  25. package/dist/types/components/Message/MessageText.d.ts.map +1 -1
  26. package/dist/types/components/Message/MessageUI.d.ts.map +1 -1
  27. package/dist/types/components/Message/hooks/useDeleteHandler.d.ts.map +1 -1
  28. package/dist/types/components/Message/index.d.ts +0 -1
  29. package/dist/types/components/Message/index.d.ts.map +1 -1
  30. package/dist/types/components/Message/utils.d.ts +1 -0
  31. package/dist/types/components/Message/utils.d.ts.map +1 -1
  32. package/dist/types/components/MessageActions/MessageActions.d.ts.map +1 -1
  33. package/dist/types/components/MessageActions/MessageActions.defaults.d.ts.map +1 -1
  34. package/dist/types/components/MessageActions/hooks/useBaseMessageActionSetFilter.d.ts.map +1 -1
  35. package/dist/types/components/MessageComposer/AttachmentPreviewList/AttachmentPreviewList.d.ts.map +1 -1
  36. package/dist/types/components/MessageComposer/AttachmentPreviewList/ImageAttachmentPreview.d.ts +3 -1
  37. package/dist/types/components/MessageComposer/AttachmentPreviewList/ImageAttachmentPreview.d.ts.map +1 -1
  38. package/dist/types/components/MessageComposer/AttachmentPreviewList/MediaAttachmentPreview.d.ts +4 -2
  39. package/dist/types/components/MessageComposer/AttachmentPreviewList/MediaAttachmentPreview.d.ts.map +1 -1
  40. package/dist/types/components/MessageComposer/AttachmentPreviewList/utils/AttachmentPreviewRoot.d.ts +6 -1
  41. package/dist/types/components/MessageComposer/AttachmentPreviewList/utils/AttachmentPreviewRoot.d.ts.map +1 -1
  42. package/dist/types/components/MessageComposer/AttachmentSelector/AttachmentSelector.d.ts +9 -2
  43. package/dist/types/components/MessageComposer/AttachmentSelector/AttachmentSelector.d.ts.map +1 -1
  44. package/dist/types/components/MessageComposer/CommandChip.d.ts +5 -1
  45. package/dist/types/components/MessageComposer/CommandChip.d.ts.map +1 -1
  46. package/dist/types/components/MessageComposer/MessageComposerUI.d.ts.map +1 -1
  47. package/dist/types/components/Notifications/Notification.d.ts.map +1 -1
  48. package/dist/types/components/Notifications/hooks/useNotificationTarget.d.ts +1 -1
  49. package/dist/types/components/Notifications/hooks/useNotificationTarget.d.ts.map +1 -1
  50. package/dist/types/components/Notifications/notificationTarget.d.ts +1 -1
  51. package/dist/types/components/Notifications/notificationTarget.d.ts.map +1 -1
  52. package/dist/types/components/Poll/PollOptionSelector.d.ts.map +1 -1
  53. package/dist/types/components/TextareaComposer/TextareaComposer.d.ts +1 -2
  54. package/dist/types/components/TextareaComposer/TextareaComposer.d.ts.map +1 -1
  55. package/dist/types/context/ComponentContext.d.ts +5 -2
  56. package/dist/types/context/ComponentContext.d.ts.map +1 -1
  57. package/dist/types/i18n/Streami18n.d.ts +11 -6
  58. package/dist/types/i18n/Streami18n.d.ts.map +1 -1
  59. package/package.json +11 -41
  60. package/dist/WithAudioPlayback-BcKZ5Lbh.mjs.map +0 -1
  61. package/dist/WithAudioPlayback-TERIQpZ6.js.map +0 -1
  62. package/dist/types/components/Message/icons.d.ts +0 -7
  63. package/dist/types/components/Message/icons.d.ts.map +0 -1
@@ -44,6 +44,23 @@ const useChannelActionContext = (componentName) => {
44
44
  }
45
45
  return contextValue;
46
46
  };
47
+ const ChannelListContext = React.createContext(
48
+ void 0
49
+ );
50
+ const ChannelListContextProvider = ({
51
+ children,
52
+ value
53
+ }) => /* @__PURE__ */ jsxRuntime.jsx(ChannelListContext.Provider, { value, children });
54
+ const useChannelListContext = (componentName) => {
55
+ const contextValue = React.useContext(ChannelListContext);
56
+ if (!contextValue) {
57
+ console.warn(
58
+ `The useChannelListContext hook was called outside of the ChannelListContext provider. Make sure this hook is called within the ChannelList component. The errored call is located in the ${componentName} component.`
59
+ );
60
+ return {};
61
+ }
62
+ return contextValue;
63
+ };
47
64
  const ChannelStateContext = React.createContext(void 0);
48
65
  const ChannelStateProvider = ({
49
66
  children,
@@ -1002,7 +1019,10 @@ const getNotificationTargetPanel = (notification) => {
1002
1019
  return isNotificationTargetPanel(panel) ? panel : void 0;
1003
1020
  };
1004
1021
  const getNotificationTargetTag = (panel) => `target:${panel}`;
1005
- const addNotificationTargetTag = (panel, tags) => Array.from(/* @__PURE__ */ new Set([getNotificationTargetTag(panel), ...tags ?? []]));
1022
+ const addNotificationTargetTag = (panel, tags) => {
1023
+ if (!panel) return tags ?? [];
1024
+ return Array.from(/* @__PURE__ */ new Set([getNotificationTargetTag(panel), ...tags ?? []]));
1025
+ };
1006
1026
  const isNotificationForPanel = (notification, panel, options) => {
1007
1027
  const fallbackPanel = options?.fallbackPanel ?? "channel";
1008
1028
  const resolvedPanel = getNotificationTargetPanel(notification) ?? fallbackPanel;
@@ -1580,6 +1600,13 @@ const IconEmojiSmile = createIcon(
1580
1600
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10.8333 6.59998C10.8333 7.33638 10.3856 7.83331 9.83334 7.83331C9.28108 7.83331 8.83334 7.33638 8.83334 6.59998C8.83334 5.8636 9.28108 5.33331 9.83334 5.33331C10.3856 5.33331 10.8333 5.8636 10.8333 6.59998Z" })
1581
1601
  ] })
1582
1602
  );
1603
+ const IconExclamation = createIcon(
1604
+ "IconExclamation",
1605
+ /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: "translate(6.2222 0) scale(1.7778)", children: [
1606
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0 7.5C0 6.9477 0.4477 6.5 1 6.5C1.5523 6.5 2 6.9477 2 7.5C1.99989 8.05211 1.55223 8.5 1 8.5C0.447768 8.5 0.000110293 8.05211 0 7.5Z" }),
1607
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M0.25 0.75C0.25 0.33578 0.5858 0 1 0C1.4142 0 1.75 0.33578 1.75 0.75V4.75C1.74989 5.16411 1.41413 5.5 1 5.5C0.585868 5.5 0.25011 5.16411 0.25 4.75V0.75Z" })
1608
+ ] }) })
1609
+ );
1583
1610
  const IconExclamationCircle1 = createIcon(
1584
1611
  "IconExclamationCircle1",
1585
1612
  /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -2835,6 +2862,7 @@ const messageTextHasEmojisOnly = (message) => {
2835
2862
  return !noSpace;
2836
2863
  };
2837
2864
  const isMessageErrorRetryable = (message) => message.status === "failed" && message.error?.status !== 403;
2865
+ const isNetworkSendFailure = (message) => message.status === "failed" && message.error?.status === 0;
2838
2866
  const isMessageBounced = (message) => message.type === "error" && (message.moderation_details?.action === "MESSAGE_RESPONSE_ACTION_BOUNCE" || message.moderation?.action === "bounce");
2839
2867
  const isMessageBlocked = (message) => message.type === "error" && (message.moderation_details?.action === "MESSAGE_RESPONSE_ACTION_REMOVE" || message.moderation?.action === "remove");
2840
2868
  const isMessageEdited = (message) => !!message.message_text_updated_at;
@@ -3167,6 +3195,64 @@ const findInMsgSetByDate = (targetDate, msgSet, exact = false) => {
3167
3195
  }
3168
3196
  return { index: -1 };
3169
3197
  };
3198
+ const adaptMessageSendErrorToErrorFromResponse = (error) => {
3199
+ if (error instanceof streamChat.ErrorFromResponse) {
3200
+ return error;
3201
+ }
3202
+ const fallbackMessage = error instanceof Error ? error.message : "Message send failed";
3203
+ let message = fallbackMessage;
3204
+ let status = 0;
3205
+ let code = null;
3206
+ if (typeof error === "object" && error !== null) {
3207
+ const maybeAxiosError = error;
3208
+ if (maybeAxiosError.name === "AxiosError" && maybeAxiosError.code === "ERR_NETWORK") {
3209
+ message = typeof maybeAxiosError.message === "string" ? maybeAxiosError.message : "Network Error";
3210
+ status = maybeAxiosError.response?.status ?? 0;
3211
+ return new streamChat.ErrorFromResponse(message, {
3212
+ code: null,
3213
+ response: maybeAxiosError.response ?? {
3214
+ // Compatibility shim: this is an intentionally incomplete AxiosResponse-like object.
3215
+ data: {
3216
+ duration: "",
3217
+ message,
3218
+ more_info: "",
3219
+ StatusCode: status
3220
+ },
3221
+ status
3222
+ },
3223
+ status
3224
+ });
3225
+ }
3226
+ try {
3227
+ const stringError = JSON.stringify(error);
3228
+ const parsedError = stringError ? JSON.parse(stringError) : {};
3229
+ if (typeof parsedError.message === "string") {
3230
+ message = parsedError.message;
3231
+ }
3232
+ if (typeof parsedError.status === "number") {
3233
+ status = parsedError.status;
3234
+ }
3235
+ if (typeof parsedError.code === "number") {
3236
+ code = parsedError.code;
3237
+ }
3238
+ } catch {
3239
+ }
3240
+ }
3241
+ return new streamChat.ErrorFromResponse(message, {
3242
+ code,
3243
+ response: {
3244
+ // Compatibility shim: this is an intentionally incomplete AxiosResponse-like object.
3245
+ data: {
3246
+ duration: "",
3247
+ message,
3248
+ more_info: "",
3249
+ StatusCode: status
3250
+ },
3251
+ status
3252
+ },
3253
+ status
3254
+ });
3255
+ };
3170
3256
  const WATCH_QUERY_IN_PROGRESS_FOR_CHANNEL = {};
3171
3257
  const getChannel = async ({
3172
3258
  channel,
@@ -3896,8 +3982,7 @@ const ChannelInner = (props) => {
3896
3982
  });
3897
3983
  }
3898
3984
  } catch (error) {
3899
- const stringError = JSON.stringify(error);
3900
- const parsedError = stringError ? JSON.parse(stringError) : {};
3985
+ const parsedError = adaptMessageSendErrorToErrorFromResponse(error);
3901
3986
  if (parsedError.code === 4 && error instanceof Error && error.message.includes("already exists")) {
3902
3987
  updateMessage({
3903
3988
  ...localMessage,
@@ -4093,9 +4178,10 @@ const ChatViewContext = React.createContext(void 0);
4093
4178
  const useChatViewContext = () => {
4094
4179
  const value = React.useContext(ChatViewContext);
4095
4180
  if (!value) {
4096
- throw new Error(
4181
+ console.warn(
4097
4182
  "The useChatViewContext hook was called outside of the ChatView provider."
4098
4183
  );
4184
+ return {};
4099
4185
  }
4100
4186
  return value;
4101
4187
  };
@@ -4296,14 +4382,16 @@ ChatView.Threads = ThreadsView;
4296
4382
  ChatView.ThreadAdapter = ThreadAdapter;
4297
4383
  ChatView.Selector = ChatViewSelector;
4298
4384
  const useNotificationTarget = () => {
4299
- const { activeChatView } = useChatViewContext();
4385
+ const chatViewContext = React.useContext(ChatViewContext);
4386
+ const { channels } = useChannelListContext();
4300
4387
  const { channel } = useChannelStateContext();
4301
4388
  const threadInstance = useThreadContext();
4302
4389
  const { legacyThread } = useLegacyThreadContext();
4303
4390
  if (threadInstance || legacyThread) return "thread";
4304
4391
  if (channel) return "channel";
4305
- if (activeChatView === "threads") return "thread-list";
4306
- return "channel-list";
4392
+ if (chatViewContext?.activeChatView === "threads") return "thread-list";
4393
+ if (channels) return "channel-list";
4394
+ return void 0;
4307
4395
  };
4308
4396
  const AudioPlayerContext = React.createContext({
4309
4397
  audioPlayers: null
@@ -4378,6 +4466,8 @@ exports.CHANNEL_CONTAINER_ID = CHANNEL_CONTAINER_ID;
4378
4466
  exports.Channel = Channel;
4379
4467
  exports.ChannelActionContext = ChannelActionContext;
4380
4468
  exports.ChannelActionProvider = ChannelActionProvider;
4469
+ exports.ChannelListContext = ChannelListContext;
4470
+ exports.ChannelListContextProvider = ChannelListContextProvider;
4381
4471
  exports.ChannelStateContext = ChannelStateContext;
4382
4472
  exports.ChannelStateProvider = ChannelStateProvider;
4383
4473
  exports.ChatContext = ChatContext;
@@ -4466,6 +4556,7 @@ exports.IconEditBigSolid = IconEditBigSolid;
4466
4556
  exports.IconEmojiAddReaction = IconEmojiAddReaction;
4467
4557
  exports.IconEmojiSad = IconEmojiSad;
4468
4558
  exports.IconEmojiSmile = IconEmojiSmile;
4559
+ exports.IconExclamation = IconExclamation;
4469
4560
  exports.IconExclamationCircle = IconExclamationCircle;
4470
4561
  exports.IconExclamationCircle1 = IconExclamationCircle1;
4471
4562
  exports.IconExclamationTriangle = IconExclamationTriangle;
@@ -4600,6 +4691,7 @@ exports.isMessageBlocked = isMessageBlocked;
4600
4691
  exports.isMessageBounced = isMessageBounced;
4601
4692
  exports.isMessageEdited = isMessageEdited;
4602
4693
  exports.isMessageErrorRetryable = isMessageErrorRetryable;
4694
+ exports.isNetworkSendFailure = isNetworkSendFailure;
4603
4695
  exports.isNotificationForPanel = isNotificationForPanel;
4604
4696
  exports.isNotificationTargetPanel = isNotificationTargetPanel;
4605
4697
  exports.isNumberOrString = isNumberOrString;
@@ -4618,6 +4710,7 @@ exports.useActiveAudioPlayer = useActiveAudioPlayer;
4618
4710
  exports.useActiveThread = useActiveThread;
4619
4711
  exports.useAudioPlayer = useAudioPlayer;
4620
4712
  exports.useChannelActionContext = useChannelActionContext;
4713
+ exports.useChannelListContext = useChannelListContext;
4621
4714
  exports.useChannelStateContext = useChannelStateContext;
4622
4715
  exports.useChatContext = useChatContext;
4623
4716
  exports.useChatViewContext = useChatViewContext;
@@ -4636,4 +4729,4 @@ exports.useThreadsViewContext = useThreadsViewContext;
4636
4729
  exports.useTranslationContext = useTranslationContext;
4637
4730
  exports.useTypingContext = useTypingContext;
4638
4731
  exports.validateAndGetMessage = validateAndGetMessage;
4639
- //# sourceMappingURL=WithAudioPlayback-TERIQpZ6.js.map
4732
+ //# sourceMappingURL=WithAudioPlayback-myzUS2m6.js.map