stream-chat-react 11.17.0 → 11.18.1

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 (120) hide show
  1. package/dist/{Window-5a6bf944.js → Window-5802024e.js} +275 -150
  2. package/dist/assets/icons/stream-chat-icons.eot +0 -0
  3. package/dist/assets/icons/stream-chat-icons.svg +46 -0
  4. package/dist/assets/icons/stream-chat-icons.ttf +0 -0
  5. package/dist/assets/icons/stream-chat-icons.woff +0 -0
  6. package/dist/assets/icons/stream-chat-icons.woff2 +0 -0
  7. package/dist/browser.full-bundle.js +278 -151
  8. package/dist/browser.full-bundle.js.map +1 -1
  9. package/dist/browser.full-bundle.min.js +4 -4
  10. package/dist/browser.full-bundle.min.js.map +1 -1
  11. package/dist/components/Attachment/AttachmentContainer.js +1 -1
  12. package/dist/components/Attachment/UnsupportedAttachment.d.ts.map +1 -1
  13. package/dist/components/Attachment/UnsupportedAttachment.js +7 -7
  14. package/dist/components/Attachment/utils.d.ts +9 -4
  15. package/dist/components/Attachment/utils.d.ts.map +1 -1
  16. package/dist/components/Attachment/utils.js +17 -2
  17. package/dist/components/Emojis/index.cjs.js +1 -1
  18. package/dist/components/MediaRecorder/AudioRecorder/AudioRecorder.js +1 -1
  19. package/dist/components/MediaRecorder/classes/MediaRecorderController.d.ts +9 -8
  20. package/dist/components/MediaRecorder/classes/MediaRecorderController.d.ts.map +1 -1
  21. package/dist/components/MediaRecorder/classes/MediaRecorderController.js +4 -4
  22. package/dist/components/MediaRecorder/hooks/useMediaRecorder.d.ts +3 -3
  23. package/dist/components/MediaRecorder/hooks/useMediaRecorder.d.ts.map +1 -1
  24. package/dist/components/Message/MessageSimple.d.ts.map +1 -1
  25. package/dist/components/Message/MessageSimple.js +2 -1
  26. package/dist/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.d.ts +16 -0
  27. package/dist/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.d.ts.map +1 -0
  28. package/dist/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.js +37 -0
  29. package/dist/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.d.ts +13 -0
  30. package/dist/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.d.ts.map +1 -0
  31. package/dist/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.js +19 -0
  32. package/dist/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.d.ts +7 -0
  33. package/dist/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.d.ts.map +1 -0
  34. package/dist/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.js +23 -0
  35. package/dist/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.d.ts +7 -0
  36. package/dist/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.d.ts.map +1 -0
  37. package/dist/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.js +22 -0
  38. package/dist/components/MessageInput/AttachmentPreviewList/UploadPreviewItem.d.ts +12 -0
  39. package/dist/components/MessageInput/AttachmentPreviewList/UploadPreviewItem.d.ts.map +1 -0
  40. package/dist/components/MessageInput/AttachmentPreviewList/UploadPreviewItem.js +61 -0
  41. package/dist/components/MessageInput/AttachmentPreviewList/VoiceRecordingPreview.d.ts +7 -0
  42. package/dist/components/MessageInput/AttachmentPreviewList/VoiceRecordingPreview.d.ts.map +1 -0
  43. package/dist/components/MessageInput/AttachmentPreviewList/VoiceRecordingPreview.js +27 -0
  44. package/dist/components/MessageInput/AttachmentPreviewList/index.d.ts +7 -0
  45. package/dist/components/MessageInput/AttachmentPreviewList/index.d.ts.map +1 -0
  46. package/dist/components/MessageInput/AttachmentPreviewList/index.js +1 -0
  47. package/dist/components/MessageInput/AttachmentPreviewList/types.d.ts +8 -0
  48. package/dist/components/MessageInput/AttachmentPreviewList/types.d.ts.map +1 -0
  49. package/dist/components/MessageInput/AttachmentPreviewList/types.js +1 -0
  50. package/dist/components/MessageInput/hooks/useAttachments.d.ts +4 -2
  51. package/dist/components/MessageInput/hooks/useAttachments.d.ts.map +1 -1
  52. package/dist/components/MessageInput/hooks/useAttachments.js +73 -33
  53. package/dist/components/MessageInput/hooks/useCreateMessageInputContext.d.ts.map +1 -1
  54. package/dist/components/MessageInput/hooks/useCreateMessageInputContext.js +5 -3
  55. package/dist/components/MessageInput/hooks/useMessageInputState.d.ts +18 -16
  56. package/dist/components/MessageInput/hooks/useMessageInputState.d.ts.map +1 -1
  57. package/dist/components/MessageInput/hooks/useMessageInputState.js +19 -15
  58. package/dist/components/MessageInput/hooks/useSubmitHandler.js +3 -3
  59. package/dist/components/MessageInput/index.d.ts +1 -0
  60. package/dist/components/MessageInput/index.d.ts.map +1 -1
  61. package/dist/components/MessageInput/types.d.ts +33 -10
  62. package/dist/components/MessageInput/types.d.ts.map +1 -1
  63. package/dist/context/ChannelStateContext.d.ts +1 -1
  64. package/dist/context/ComponentContext.d.ts +2 -1
  65. package/dist/context/ComponentContext.d.ts.map +1 -1
  66. package/dist/context/MessageInputContext.d.ts +4 -3
  67. package/dist/context/MessageInputContext.d.ts.map +1 -1
  68. package/dist/css/v2/index.css +2 -2
  69. package/dist/css/v2/index.layout.css +2 -2
  70. package/dist/i18n/Streami18n.d.ts +1 -0
  71. package/dist/i18n/Streami18n.d.ts.map +1 -1
  72. package/dist/i18n/de.json +1 -0
  73. package/dist/i18n/en.json +1 -0
  74. package/dist/i18n/es.json +1 -0
  75. package/dist/i18n/fr.json +1 -0
  76. package/dist/i18n/hi.json +1 -0
  77. package/dist/i18n/it.json +1 -0
  78. package/dist/i18n/ja.json +1 -0
  79. package/dist/i18n/ko.json +1 -0
  80. package/dist/i18n/nl.json +1 -0
  81. package/dist/i18n/pt.json +1 -0
  82. package/dist/i18n/ru.json +1 -0
  83. package/dist/i18n/tr.json +1 -0
  84. package/dist/index.cjs.js +7 -2
  85. package/dist/scss/v2/AttachmentList/AttachmentList-layout.scss +38 -1
  86. package/dist/scss/v2/AttachmentList/AttachmentList-theme.scss +8 -0
  87. package/dist/scss/v2/AttachmentPreviewList/AttachmentPreviewList-layout.scss +9 -1
  88. package/dist/scss/v2/AttachmentPreviewList/AttachmentPreviewList-theme.scss +13 -0
  89. package/dist/scss/v2/Avatar/Avatar-layout.scss +46 -0
  90. package/dist/scss/v2/Channel/Channel-layout.scss +1 -0
  91. package/dist/scss/v2/Channel/Channel-theme.scss +1 -0
  92. package/dist/scss/v2/ChannelList/ChannelList-layout.scss +2 -2
  93. package/dist/scss/v2/ChannelList/ChannelList-theme.scss +4 -2
  94. package/dist/scss/v2/ChannelPreview/ChannelPreview-layout.scss +2 -0
  95. package/dist/scss/v2/ChannelPreview/ChannelPreview-theme.scss +1 -0
  96. package/dist/scss/v2/Icon/Icon-layout.scss +87 -0
  97. package/dist/scss/v2/Icon/Icon-theme.scss +13 -0
  98. package/dist/scss/v2/ImageCarousel/ImageCarousel-layout.scss +1 -0
  99. package/dist/scss/v2/ImageCarousel/ImageCarousel-theme.scss +1 -0
  100. package/dist/scss/v2/LoadingIndicator/LoadingIndicator-layout.scss +10 -1
  101. package/dist/scss/v2/LoadingIndicator/LoadingIndicator-theme.scss +6 -4
  102. package/dist/scss/v2/Message/Message-layout.scss +6 -0
  103. package/dist/scss/v2/Message/Message-theme.scss +6 -0
  104. package/dist/scss/v2/MessageInput/MessageInput-layout.scss +4 -1
  105. package/dist/scss/v2/MessageInput/MessageInput-theme.scss +3 -0
  106. package/dist/scss/v2/MessageList/MessageList-theme.scss +2 -0
  107. package/dist/scss/v2/Modal/Modal-layout.scss +1 -0
  108. package/dist/scss/v2/Modal/Modal-theme.scss +6 -0
  109. package/dist/scss/v2/_base.scss +3 -2
  110. package/dist/scss/v2/_emoji-replacement.scss +4 -2
  111. package/dist/scss/v2/_icons.scss +24 -2
  112. package/dist/scss/v2/_variables.scss +2 -0
  113. package/dist/scss/v2/index.layout.scss +1 -0
  114. package/dist/scss/v2/index.scss +1 -0
  115. package/dist/version.d.ts +1 -1
  116. package/dist/version.js +1 -1
  117. package/package.json +2 -2
  118. package/dist/components/MessageInput/AttachmentPreviewList.d.ts +0 -9
  119. package/dist/components/MessageInput/AttachmentPreviewList.d.ts.map +0 -1
  120. package/dist/components/MessageInput/AttachmentPreviewList.js +0 -112
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { PlayButton } from '../../Attachment';
3
+ import { RecordingTimer } from '../../MediaRecorder';
4
+ import { CloseIcon, LoadingIndicatorIcon, RetryIcon } from '../icons';
5
+ import { FileIcon } from '../../ReactFileUtilities';
6
+ import { useAudioController } from '../../Attachment/hooks/useAudioController';
7
+ export var VoiceRecordingPreview = function (_a) {
8
+ var _b, _c, _d;
9
+ var attachment = _a.attachment, handleRetry = _a.handleRetry, removeAttachments = _a.removeAttachments;
10
+ var _e = useAudioController({
11
+ mimeType: attachment.mime_type,
12
+ }), audioRef = _e.audioRef, isPlaying = _e.isPlaying, secondsElapsed = _e.secondsElapsed, togglePlay = _e.togglePlay;
13
+ return (React.createElement("div", { className: 'str-chat__attachment-preview-voice-recording', "data-testid": 'attachment-preview-voice-recording' },
14
+ React.createElement("audio", { ref: audioRef },
15
+ React.createElement("source", { "data-testid": 'audio-source', src: attachment.asset_url, type: attachment.mime_type })),
16
+ React.createElement(PlayButton, { isPlaying: isPlaying, onClick: togglePlay }),
17
+ React.createElement("button", { className: 'str-chat__attachment-preview-delete', "data-testid": 'file-preview-item-delete-button', disabled: ((_b = attachment.localMetadata) === null || _b === void 0 ? void 0 : _b.uploadState) === 'uploading', onClick: function () { var _a; return ((_a = attachment.localMetadata) === null || _a === void 0 ? void 0 : _a.id) && removeAttachments([attachment.localMetadata.id]); } },
18
+ React.createElement(CloseIcon, null)),
19
+ ((_c = attachment.localMetadata) === null || _c === void 0 ? void 0 : _c.uploadState) === 'failed' && !!handleRetry && (React.createElement("button", { className: 'str-chat__attachment-preview-error str-chat__attachment-preview-error-file', "data-testid": 'file-preview-item-retry-button', onClick: function () { return handleRetry(attachment); } },
20
+ React.createElement(RetryIcon, null))),
21
+ React.createElement("div", { className: 'str-chat__attachment-preview-metadata' },
22
+ React.createElement("div", { className: 'str-chat__attachment-preview-file-name', title: attachment.title }, attachment.title),
23
+ typeof attachment.duration !== 'undefined' && (React.createElement(RecordingTimer, { durationSeconds: secondsElapsed || attachment.duration })),
24
+ ((_d = attachment.localMetadata) === null || _d === void 0 ? void 0 : _d.uploadState) === 'uploading' && (React.createElement(LoadingIndicatorIcon, { size: 17 }))),
25
+ React.createElement("div", { className: 'str-chat__attachment-preview-file-icon' },
26
+ React.createElement(FileIcon, { filename: attachment.title, mimeType: attachment.mime_type, version: '2' }))));
27
+ };
@@ -0,0 +1,7 @@
1
+ export * from './AttachmentPreviewList';
2
+ export type { FileAttachmentPreviewProps } from './FileAttachmentPreview';
3
+ export type { ImageAttachmentPreviewProps } from './ImageAttachmentPreview';
4
+ export type { AttachmentPreviewProps } from './types';
5
+ export type { UnsupportedAttachmentPreviewProps } from './UnsupportedAttachmentPreview';
6
+ export type { VoiceRecordingPreviewProps } from './VoiceRecordingPreview';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/AttachmentPreviewList/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AACxF,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './AttachmentPreviewList';
@@ -0,0 +1,8 @@
1
+ import { LocalAttachment } from '../types';
2
+ import type { DefaultStreamChatGenerics } from '../../../types';
3
+ export type AttachmentPreviewProps<A extends LocalAttachment, StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
4
+ attachment: A;
5
+ handleRetry: (attachment: LocalAttachment<StreamChatGenerics>) => void | Promise<LocalAttachment<StreamChatGenerics> | undefined>;
6
+ removeAttachments: (ids: string[]) => void;
7
+ };
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/AttachmentPreviewList/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,MAAM,MAAM,sBAAsB,CAChC,CAAC,SAAS,eAAe,EACzB,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,UAAU,EAAE,CAAC,CAAC;IACd,WAAW,EAAE,CACX,UAAU,EAAE,eAAe,CAAC,kBAAkB,CAAC,KAC5C,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC,CAAC;IACrE,iBAAiB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC5C,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { Attachment } from 'stream-chat';
1
2
  import type { MessageInputReducerAction, MessageInputState } from './useMessageInputState';
2
3
  import type { MessageInputProps } from '../MessageInput';
3
4
  import type { LocalAttachment } from '../types';
@@ -6,12 +7,13 @@ import type { CustomTrigger, DefaultStreamChatGenerics } from '../../../types/ty
6
7
  export declare const useAttachments: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, V extends CustomTrigger = CustomTrigger>(props: MessageInputProps<StreamChatGenerics, V>, state: MessageInputState<StreamChatGenerics>, dispatch: import("react").Dispatch<MessageInputReducerAction<StreamChatGenerics>>, textareaRef: React.MutableRefObject<HTMLTextAreaElement | undefined>) => {
7
8
  maxFilesLeft: number;
8
9
  numberOfUploads: number;
9
- removeAttachment: (id: string) => void;
10
+ removeAttachments: (ids: string[]) => void;
10
11
  removeFile: (id: string) => void;
11
12
  removeImage: (id: string) => void;
12
- uploadAttachment: (att: LocalAttachment<StreamChatGenerics>) => Promise<LocalAttachment<StreamChatGenerics>>;
13
+ uploadAttachment: (att: LocalAttachment<StreamChatGenerics>) => Promise<LocalAttachment<StreamChatGenerics> | undefined>;
13
14
  uploadFile: (id: string) => void;
14
15
  uploadImage: (id: string) => Promise<void>;
15
16
  uploadNewFiles: (files: FileList | File[] | FileLike[]) => void;
17
+ upsertAttachments: (attachments: (LocalAttachment<StreamChatGenerics> | Attachment<StreamChatGenerics>)[]) => void;
16
18
  };
17
19
  //# sourceMappingURL=useAttachments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAttachments.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useAttachments.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAIrF,eAAO,MAAM,cAAc,6TAOZ,MAAM,gBAAgB,CAAC,mBAAmB,GAAG,SAAS,CAAC;;;2BA6DtC,MAAM;;;;;;4BA5B1B,QAAQ,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE;CAuIzC,CAAC"}
1
+ {"version":3,"file":"useAttachments.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useAttachments.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAsBrF,eAAO,MAAM,cAAc,6TAOZ,MAAM,gBAAgB,CAAC,mBAAmB,GAAG,SAAS,CAAC;;;6BA8D5D,MAAM,EAAE;;;;;;4BA7BN,QAAQ,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE;;CAgLzC,CAAC"}
@@ -4,10 +4,18 @@ import { nanoid } from 'nanoid';
4
4
  import { useImageUploads } from './useImageUploads';
5
5
  import { useFileUploads } from './useFileUploads';
6
6
  import { checkUploadPermissions } from './utils';
7
+ import { isLocalAttachment, isLocalImageAttachment, isUploadedImage } from '../../Attachment';
7
8
  import { useChannelActionContext, useChannelStateContext, useChatContext, useTranslationContext, } from '../../../context';
8
9
  var apiMaxNumberOfFiles = 10;
10
+ var ensureIsLocalAttachment = function (attachment) {
11
+ if (isLocalAttachment(attachment)) {
12
+ return attachment;
13
+ }
14
+ var localMetadata = attachment.localMetadata, rest = __rest(attachment, ["localMetadata"]);
15
+ return __assign({ localMetadata: __assign(__assign({}, (localMetadata !== null && localMetadata !== void 0 ? localMetadata : {})), { id: (localMetadata === null || localMetadata === void 0 ? void 0 : localMetadata.id) || nanoid() }) }, rest);
16
+ };
9
17
  export var useAttachments = function (props, state, dispatch, textareaRef) {
10
- var doFileUploadRequest = props.doFileUploadRequest, errorHandler = props.errorHandler, noFiles = props.noFiles;
18
+ var doFileUploadRequest = props.doFileUploadRequest, doImageUploadRequest = props.doImageUploadRequest, errorHandler = props.errorHandler, noFiles = props.noFiles;
11
19
  var fileUploads = state.fileUploads, imageUploads = state.imageUploads;
12
20
  var getAppSettings = useChatContext('useAttachments').getAppSettings;
13
21
  var t = useTranslationContext('useAttachments').t;
@@ -55,26 +63,37 @@ export var useAttachments = function (props, state, dispatch, textareaRef) {
55
63
  },
56
64
  // eslint-disable-next-line react-hooks/exhaustive-deps
57
65
  [maxFilesLeft, noFiles]);
58
- var removeAttachment = function (id) {
59
- dispatch({ id: id, type: 'removeAttachment' });
60
- };
66
+ var removeAttachments = useCallback(function (ids) {
67
+ if (!ids.length)
68
+ return;
69
+ dispatch({ ids: ids, type: 'removeAttachments' });
70
+ }, [dispatch]);
71
+ var upsertAttachments = useCallback(function (attachments) {
72
+ if (!attachments.length)
73
+ return;
74
+ dispatch({
75
+ attachments: attachments.map(ensureIsLocalAttachment),
76
+ type: 'upsertAttachments',
77
+ });
78
+ }, [dispatch]);
61
79
  var uploadAttachment = useCallback(function (att) { return __awaiter(void 0, void 0, void 0, function () {
62
- var $internal, attachment, id, file, canUpload, notificationText, response, uploadedAttachment, error_1, finalError, failedAttachment;
80
+ var localMetadata, attachment, isImage, id, file, canUpload, notificationText, response, doUploadRequest, error_1, finalError, failedAttachment, uploadedAttachment;
63
81
  var _a;
64
82
  return __generator(this, function (_b) {
65
83
  switch (_b.label) {
66
84
  case 0:
67
- $internal = att.$internal, attachment = __rest(att, ["$internal"]);
68
- if (!($internal === null || $internal === void 0 ? void 0 : $internal.file))
85
+ localMetadata = att.localMetadata, attachment = __rest(att, ["localMetadata"]);
86
+ if (!(localMetadata === null || localMetadata === void 0 ? void 0 : localMetadata.file))
69
87
  return [2 /*return*/, att];
70
- id = (_a = $internal === null || $internal === void 0 ? void 0 : $internal.id) !== null && _a !== void 0 ? _a : nanoid();
71
- file = $internal.file;
88
+ isImage = isUploadedImage(attachment);
89
+ id = (_a = localMetadata === null || localMetadata === void 0 ? void 0 : localMetadata.id) !== null && _a !== void 0 ? _a : nanoid();
90
+ file = localMetadata.file;
72
91
  return [4 /*yield*/, checkUploadPermissions({
73
92
  addNotification: addNotification,
74
93
  file: file,
75
94
  getAppSettings: getAppSettings,
76
95
  t: t,
77
- uploadType: 'file',
96
+ uploadType: isImage ? 'image' : 'file',
78
97
  })];
79
98
  case 1:
80
99
  canUpload = _b.sent();
@@ -84,30 +103,23 @@ export var useAttachments = function (props, state, dispatch, textareaRef) {
84
103
  addNotification(notificationText, 'error');
85
104
  return [2 /*return*/, att];
86
105
  }
87
- dispatch({
88
- attachment: __assign(__assign({}, attachment), { $internal: __assign(__assign({}, $internal), { id: id, uploadState: 'uploading' }) }),
89
- type: 'upsertAttachment',
90
- });
106
+ upsertAttachments([
107
+ __assign(__assign({}, attachment), { localMetadata: __assign(__assign({}, localMetadata), { id: id, uploadState: 'uploading' }) }),
108
+ ]);
91
109
  _b.label = 2;
92
110
  case 2:
93
111
  _b.trys.push([2, 7, , 8]);
94
- response = void 0;
95
- if (!doFileUploadRequest) return [3 /*break*/, 4];
96
- return [4 /*yield*/, doFileUploadRequest(file, channel)];
112
+ doUploadRequest = isImage ? doImageUploadRequest : doFileUploadRequest;
113
+ if (!doUploadRequest) return [3 /*break*/, 4];
114
+ return [4 /*yield*/, doUploadRequest(file, channel)];
97
115
  case 3:
98
116
  response = _b.sent();
99
117
  return [3 /*break*/, 6];
100
- case 4: return [4 /*yield*/, channel.sendFile(file)];
118
+ case 4: return [4 /*yield*/, channel[isImage ? 'sendImage' : 'sendFile'](file)];
101
119
  case 5:
102
120
  response = _b.sent();
103
121
  _b.label = 6;
104
- case 6:
105
- uploadedAttachment = __assign(__assign({}, attachment), { $internal: __assign(__assign({}, $internal), { uploadState: 'finished' }), asset_url: response.file });
106
- dispatch({
107
- attachment: uploadedAttachment,
108
- type: 'upsertAttachment',
109
- });
110
- return [2 /*return*/, uploadedAttachment];
122
+ case 6: return [3 /*break*/, 8];
111
123
  case 7:
112
124
  error_1 = _b.sent();
113
125
  finalError = { message: t('Error uploading attachment'), name: 'Error' };
@@ -119,28 +131,56 @@ export var useAttachments = function (props, state, dispatch, textareaRef) {
119
131
  }
120
132
  console.error(finalError);
121
133
  addNotification(finalError.message, 'error');
122
- failedAttachment = __assign(__assign({}, attachment), { $internal: __assign(__assign({}, $internal), { uploadState: 'failed' }) });
123
- dispatch({
124
- attachment: failedAttachment,
125
- type: 'upsertAttachment',
126
- });
134
+ failedAttachment = __assign(__assign({}, attachment), { localMetadata: __assign(__assign({}, localMetadata), { uploadState: 'failed' }) });
135
+ upsertAttachments([failedAttachment]);
127
136
  if (errorHandler) {
128
137
  errorHandler(finalError, 'upload-attachment', file);
129
138
  }
130
139
  return [2 /*return*/, failedAttachment];
131
- case 8: return [2 /*return*/];
140
+ case 8:
141
+ if (!response) {
142
+ // Copied this from useImageUpload / useFileUpload. Not sure how failure could be handled on app level.
143
+ // If doUploadRequest returns any falsy value, then don't create the upload preview.
144
+ // This is for the case if someone wants to handle failure on app level.
145
+ removeAttachments([id]);
146
+ return [2 /*return*/];
147
+ }
148
+ uploadedAttachment = __assign(__assign({}, attachment), { localMetadata: __assign(__assign({}, localMetadata), { uploadState: 'finished' }) });
149
+ if (isLocalImageAttachment(uploadedAttachment)) {
150
+ if (uploadedAttachment.localMetadata.previewUri) {
151
+ URL.revokeObjectURL(uploadedAttachment.localMetadata.previewUri);
152
+ delete uploadedAttachment.localMetadata.previewUri;
153
+ }
154
+ uploadedAttachment.image_url = response.file;
155
+ }
156
+ else {
157
+ uploadedAttachment.asset_url = response.file;
158
+ }
159
+ upsertAttachments([uploadedAttachment]);
160
+ return [2 /*return*/, uploadedAttachment];
132
161
  }
133
162
  });
134
- }); }, [addNotification, channel, doFileUploadRequest, dispatch, errorHandler, getAppSettings, t]);
163
+ }); }, [
164
+ addNotification,
165
+ channel,
166
+ doFileUploadRequest,
167
+ doImageUploadRequest,
168
+ errorHandler,
169
+ getAppSettings,
170
+ removeAttachments,
171
+ t,
172
+ upsertAttachments,
173
+ ]);
135
174
  return {
136
175
  maxFilesLeft: maxFilesLeft,
137
176
  numberOfUploads: numberOfUploads,
138
- removeAttachment: removeAttachment,
177
+ removeAttachments: removeAttachments,
139
178
  removeFile: removeFile,
140
179
  removeImage: removeImage,
141
180
  uploadAttachment: uploadAttachment,
142
181
  uploadFile: uploadFile,
143
182
  uploadImage: uploadImage,
144
183
  uploadNewFiles: uploadNewFiles,
184
+ upsertAttachments: upsertAttachments,
145
185
  };
146
186
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateMessageInputContext.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useCreateMessageInputContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAErF,eAAO,MAAM,4BAA4B,wOAmLxC,CAAC"}
1
+ {"version":3,"file":"useCreateMessageInputContext.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useCreateMessageInputContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAErF,eAAO,MAAM,4BAA4B,wOAsLxC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { useMemo } from 'react';
2
2
  export var useCreateMessageInputContext = function (value) {
3
- var additionalTextareaProps = value.additionalTextareaProps, asyncMessagesMultiSendEnabled = value.asyncMessagesMultiSendEnabled, attachments = value.attachments, audioRecordingEnabled = value.audioRecordingEnabled, autocompleteTriggers = value.autocompleteTriggers, cancelURLEnrichment = value.cancelURLEnrichment, clearEditingState = value.clearEditingState, closeCommandsList = value.closeCommandsList, closeMentionsList = value.closeMentionsList, cooldownInterval = value.cooldownInterval, cooldownRemaining = value.cooldownRemaining, disabled = value.disabled, disableMentions = value.disableMentions, dismissLinkPreview = value.dismissLinkPreview, doFileUploadRequest = value.doFileUploadRequest, doImageUploadRequest = value.doImageUploadRequest, emojiSearchIndex = value.emojiSearchIndex, errorHandler = value.errorHandler, fileOrder = value.fileOrder, fileUploads = value.fileUploads, findAndEnqueueURLsToEnrich = value.findAndEnqueueURLsToEnrich, focus = value.focus, grow = value.grow, handleChange = value.handleChange, handleSubmit = value.handleSubmit, hideSendButton = value.hideSendButton, imageOrder = value.imageOrder, imageUploads = value.imageUploads, insertText = value.insertText, isUploadEnabled = value.isUploadEnabled, linkPreviews = value.linkPreviews, maxFilesLeft = value.maxFilesLeft, maxRows = value.maxRows, mentionAllAppUsers = value.mentionAllAppUsers, mentioned_users = value.mentioned_users, mentionQueryParams = value.mentionQueryParams, message = value.message, noFiles = value.noFiles, numberOfUploads = value.numberOfUploads, onPaste = value.onPaste, onSelectUser = value.onSelectUser, openCommandsList = value.openCommandsList, openMentionsList = value.openMentionsList, overrideSubmitHandler = value.overrideSubmitHandler, parent = value.parent, publishTypingEvent = value.publishTypingEvent, recordingController = value.recordingController, removeAttachment = value.removeAttachment, removeFile = value.removeFile, removeImage = value.removeImage, setCooldownRemaining = value.setCooldownRemaining, setText = value.setText, shouldSubmit = value.shouldSubmit, showCommandsList = value.showCommandsList, showMentionsList = value.showMentionsList, text = value.text, textareaRef = value.textareaRef, uploadAttachment = value.uploadAttachment, uploadFile = value.uploadFile, uploadImage = value.uploadImage, uploadNewFiles = value.uploadNewFiles, useMentionsTransliteration = value.useMentionsTransliteration;
3
+ var additionalTextareaProps = value.additionalTextareaProps, asyncMessagesMultiSendEnabled = value.asyncMessagesMultiSendEnabled, attachments = value.attachments, audioRecordingEnabled = value.audioRecordingEnabled, autocompleteTriggers = value.autocompleteTriggers, cancelURLEnrichment = value.cancelURLEnrichment, clearEditingState = value.clearEditingState, closeCommandsList = value.closeCommandsList, closeMentionsList = value.closeMentionsList, cooldownInterval = value.cooldownInterval, cooldownRemaining = value.cooldownRemaining, disabled = value.disabled, disableMentions = value.disableMentions, dismissLinkPreview = value.dismissLinkPreview, doFileUploadRequest = value.doFileUploadRequest, doImageUploadRequest = value.doImageUploadRequest, emojiSearchIndex = value.emojiSearchIndex, errorHandler = value.errorHandler, fileOrder = value.fileOrder, fileUploads = value.fileUploads, findAndEnqueueURLsToEnrich = value.findAndEnqueueURLsToEnrich, focus = value.focus, grow = value.grow, handleChange = value.handleChange, handleSubmit = value.handleSubmit, hideSendButton = value.hideSendButton, imageOrder = value.imageOrder, imageUploads = value.imageUploads, insertText = value.insertText, isUploadEnabled = value.isUploadEnabled, linkPreviews = value.linkPreviews, maxFilesLeft = value.maxFilesLeft, maxRows = value.maxRows, mentionAllAppUsers = value.mentionAllAppUsers, mentioned_users = value.mentioned_users, mentionQueryParams = value.mentionQueryParams, message = value.message, noFiles = value.noFiles, numberOfUploads = value.numberOfUploads, onPaste = value.onPaste, onSelectUser = value.onSelectUser, openCommandsList = value.openCommandsList, openMentionsList = value.openMentionsList, overrideSubmitHandler = value.overrideSubmitHandler, parent = value.parent, publishTypingEvent = value.publishTypingEvent, recordingController = value.recordingController, removeAttachments = value.removeAttachments, removeFile = value.removeFile, removeImage = value.removeImage, setCooldownRemaining = value.setCooldownRemaining, setText = value.setText, shouldSubmit = value.shouldSubmit, showCommandsList = value.showCommandsList, showMentionsList = value.showMentionsList, text = value.text, textareaRef = value.textareaRef, uploadAttachment = value.uploadAttachment, uploadFile = value.uploadFile, uploadImage = value.uploadImage, uploadNewFiles = value.uploadNewFiles, upsertAttachments = value.upsertAttachments, useMentionsTransliteration = value.useMentionsTransliteration;
4
4
  var editing = message === null || message === void 0 ? void 0 : message.editing;
5
5
  var fileUploadsValue = Object.entries(fileUploads)
6
6
  // eslint-disable-next-line
@@ -67,7 +67,7 @@ export var useCreateMessageInputContext = function (value) {
67
67
  parent: parent,
68
68
  publishTypingEvent: publishTypingEvent,
69
69
  recordingController: recordingController,
70
- removeAttachment: removeAttachment,
70
+ removeAttachments: removeAttachments,
71
71
  removeFile: removeFile,
72
72
  removeImage: removeImage,
73
73
  setCooldownRemaining: setCooldownRemaining,
@@ -81,6 +81,7 @@ export var useCreateMessageInputContext = function (value) {
81
81
  uploadFile: uploadFile,
82
82
  uploadImage: uploadImage,
83
83
  uploadNewFiles: uploadNewFiles,
84
+ upsertAttachments: upsertAttachments,
84
85
  useMentionsTransliteration: useMentionsTransliteration,
85
86
  }); },
86
87
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -104,11 +105,12 @@ export var useCreateMessageInputContext = function (value) {
104
105
  parentId,
105
106
  publishTypingEvent,
106
107
  recordingController,
107
- removeAttachment,
108
+ removeAttachments,
108
109
  showCommandsList,
109
110
  showMentionsList,
110
111
  text,
111
112
  uploadAttachment,
113
+ upsertAttachments,
112
114
  ]);
113
115
  return messageInputContext;
114
116
  };
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { EnrichURLsController } from './useLinkPreviews';
3
3
  import { RecordingController } from '../../MediaRecorder/hooks/useMediaRecorder';
4
- import { LocalAttachment, SetLinkPreviewMode } from '../types';
4
+ import { SetLinkPreviewMode } from '../types';
5
+ import type { FileUpload, ImageUpload, LinkPreviewMap, LocalAttachment } from '../types';
5
6
  import type { FileLike } from '../../ReactFileUtilities';
6
- import type { Message, UserResponse } from 'stream-chat';
7
+ import type { Attachment, Message, UserResponse } from 'stream-chat';
7
8
  import type { MessageInputProps } from '../MessageInput';
8
9
  import type { CustomTrigger, DefaultStreamChatGenerics, SendMessageOptions } from '../../../types/types';
9
- import type { FileUpload, ImageUpload, LinkPreviewMap } from '../types';
10
10
  export type MessageInputState<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
11
11
  attachments: LocalAttachment<StreamChatGenerics>[];
12
12
  fileOrder: string[];
@@ -18,13 +18,13 @@ export type MessageInputState<StreamChatGenerics extends DefaultStreamChatGeneri
18
18
  setText: (text: string) => void;
19
19
  text: string;
20
20
  };
21
- type UpsertAttachmentAction = {
22
- attachment: LocalAttachment;
23
- type: 'upsertAttachment';
21
+ type UpsertAttachmentsAction<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
22
+ attachments: LocalAttachment<StreamChatGenerics>[];
23
+ type: 'upsertAttachments';
24
24
  };
25
- type RemoveAttachmentAction = {
26
- id: string;
27
- type: 'removeAttachment';
25
+ type RemoveAttachmentsAction = {
26
+ ids: string[];
27
+ type: 'removeAttachments';
28
28
  };
29
29
  type SetTextAction = {
30
30
  getNewText: (currentStateText: string) => string;
@@ -66,7 +66,7 @@ type AddMentionedUserAction<StreamChatGenerics extends DefaultStreamChatGenerics
66
66
  type: 'addMentionedUser';
67
67
  user: UserResponse<StreamChatGenerics>;
68
68
  };
69
- export type MessageInputReducerAction<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = SetTextAction | ClearAction | SetImageUploadAction | SetFileUploadAction | SetLinkPreviewsAction | RemoveImageUploadAction | RemoveFileUploadAction | AddMentionedUserAction<StreamChatGenerics> | UpsertAttachmentAction | RemoveAttachmentAction;
69
+ export type MessageInputReducerAction<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = SetTextAction | ClearAction | SetImageUploadAction | SetFileUploadAction | SetLinkPreviewsAction | RemoveImageUploadAction | RemoveFileUploadAction | AddMentionedUserAction<StreamChatGenerics> | UpsertAttachmentsAction | RemoveAttachmentsAction;
70
70
  export type MessageInputHookProps<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = EnrichURLsController & {
71
71
  handleChange: React.ChangeEventHandler<HTMLTextAreaElement>;
72
72
  handleSubmit: (event?: React.BaseSyntheticEvent, customMessageData?: Partial<Message<StreamChatGenerics>>, options?: SendMessageOptions) => void;
@@ -76,15 +76,16 @@ export type MessageInputHookProps<StreamChatGenerics extends DefaultStreamChatGe
76
76
  numberOfUploads: number;
77
77
  onPaste: (event: React.ClipboardEvent<HTMLTextAreaElement>) => void;
78
78
  onSelectUser: (item: UserResponse<StreamChatGenerics>) => void;
79
- recordingController: RecordingController;
80
- removeAttachment: (id: string) => void;
79
+ recordingController: RecordingController<StreamChatGenerics>;
80
+ removeAttachments: (ids: string[]) => void;
81
81
  removeFile: (id: string) => void;
82
82
  removeImage: (id: string) => void;
83
83
  textareaRef: React.MutableRefObject<HTMLTextAreaElement | null | undefined>;
84
- uploadAttachment: (attachment: LocalAttachment<StreamChatGenerics>) => Promise<LocalAttachment<StreamChatGenerics>>;
84
+ uploadAttachment: (attachment: LocalAttachment<StreamChatGenerics>) => Promise<LocalAttachment<StreamChatGenerics> | undefined>;
85
85
  uploadFile: (id: string) => void;
86
86
  uploadImage: (id: string) => void;
87
87
  uploadNewFiles: (files: FileList | File[]) => void;
88
+ upsertAttachments: (attachments: (Attachment<StreamChatGenerics> | LocalAttachment<StreamChatGenerics>)[]) => void;
88
89
  };
89
90
  export type CommandsListState = {
90
91
  closeCommandsList: () => void;
@@ -108,15 +109,16 @@ export declare const useMessageInputState: <StreamChatGenerics extends DefaultSt
108
109
  numberOfUploads: number;
109
110
  onPaste: (event: React.ClipboardEvent<HTMLTextAreaElement>) => void;
110
111
  onSelectUser: (item: UserResponse<StreamChatGenerics>) => void;
111
- recordingController: RecordingController;
112
- removeAttachment: (id: string) => void;
112
+ recordingController: RecordingController<StreamChatGenerics>;
113
+ removeAttachments: (ids: string[]) => void;
113
114
  removeFile: (id: string) => void;
114
115
  removeImage: (id: string) => void;
115
116
  textareaRef: React.MutableRefObject<HTMLTextAreaElement | null | undefined>;
116
- uploadAttachment: (attachment: LocalAttachment<StreamChatGenerics>) => Promise<LocalAttachment<StreamChatGenerics>>;
117
+ uploadAttachment: (attachment: LocalAttachment<StreamChatGenerics>) => Promise<LocalAttachment<StreamChatGenerics> | undefined>;
117
118
  uploadFile: (id: string) => void;
118
119
  uploadImage: (id: string) => void;
119
120
  uploadNewFiles: (files: FileList | File[]) => void;
121
+ upsertAttachments: (attachments: (Attachment<StreamChatGenerics> | LocalAttachment<StreamChatGenerics>)[]) => void;
120
122
  } & CommandsListState & MentionsListState;
121
123
  export {};
122
124
  //# sourceMappingURL=useMessageInputState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMessageInputState.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useMessageInputState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAM1E,OAAO,EAAE,oBAAoB,EAAmB,MAAM,mBAAmB,CAAC;AAI1E,OAAO,EAAE,mBAAmB,EAAoB,MAAM,4CAA4C,CAAC;AACnG,OAAO,EAAoB,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EACV,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGxE,MAAM,MAAM,iBAAiB,CAC3B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,WAAW,EAAE,eAAe,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACnD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC1C,YAAY,EAAE,cAAc,CAAC;IAC7B,eAAe,EAAE,YAAY,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACpD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd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,MAAM,KAAK,IAAI;sBACd,MAAM,KAAK,IAAI;4BACT,QAAQ,GAAG,IAAI,EAAE,KAAK,IAAI;yCA2anD,CAAC"}
1
+ {"version":3,"file":"useMessageInputState.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useMessageInputState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAqD,MAAM,OAAO,CAAC;AAM1E,OAAO,EAAE,oBAAoB,EAAmB,MAAM,mBAAmB,CAAC;AAI1E,OAAO,EAAE,mBAAmB,EAAoB,MAAM,4CAA4C,CAAC;AACnG,OAAO,EAAoB,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAC;AAEnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EACV,aAAa,EACb,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,MAAM,iBAAiB,CAC3B,kBAAkB,SAAS,yBAAyB,GAAG,yBAAyB,IAC9E;IACF,WAAW,EAAE,eAAe,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACnD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC1C,YAAY,EAAE,cAAc,CAAC;IAC7B,eAAe,EAAE,YAAY,CAAC,kBAAkB,CAAC,EAAE,CAAC;IACpD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,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B,KACzB,IAAI;+BACkB,MAAM,KAAK,IAAI;qBACzB,OAAO;kBACV,MAAM;qBACH,MAAM;qBACN,oBAAoB,CAAC,mBAAmB,CAAC,KAAK,IAAI;8DACT,IAAI;;6BAErC,MAAM,EAAE,KAAK,IAAI;qBACzB,MAAM,KAAK,IAAI;sBACd,MAAM,KAAK,IAAI;iBACpB,MAAM,gBAAgB,CAAC,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC;;qBAI1D,MAAM,KAAK,IAAI;sBACd,MAAM,KAAK,IAAI;4BACT,QAAQ,GAAG,IAAI,EAAE,KAAK,IAAI;kHAG7C,IAAI;yCAibV,CAAC"}
@@ -82,7 +82,7 @@ var initState = function (message) {
82
82
  var type = _a.type;
83
83
  return type !== 'file' && type !== 'image';
84
84
  }).map(function (att) {
85
- return (__assign(__assign({}, att), { $internal: { id: nanoid(), uploadState: 'finished' } }));
85
+ return (__assign(__assign({}, att), { localMetadata: { id: nanoid() } }));
86
86
  })) || [];
87
87
  var mentioned_users = message.mentioned_users || [];
88
88
  return {
@@ -102,24 +102,28 @@ var initState = function (message) {
102
102
  */
103
103
  var messageInputReducer = function (state, action) {
104
104
  var _a, _b;
105
- var _c;
106
105
  switch (action.type) {
107
106
  case 'setText':
108
107
  return __assign(__assign({}, state), { text: action.getNewText(state.text) });
109
108
  case 'clear':
110
109
  return makeEmptyMessageInputState();
111
- case 'upsertAttachment': {
112
- var attachmentIndex = state.attachments.findIndex(function (att) { var _a, _b, _c; return ((_a = att.$internal) === null || _a === void 0 ? void 0 : _a.id) && ((_b = att.$internal) === null || _b === void 0 ? void 0 : _b.id) === ((_c = action.attachment.$internal) === null || _c === void 0 ? void 0 : _c.id); });
113
- var upsertedAttachment = mergeDeep((_c = state.attachments[attachmentIndex]) !== null && _c !== void 0 ? _c : {}, action.attachment);
114
- var attachments = __spreadArray([], state.attachments, true);
115
- attachments.splice(attachmentIndex, 1, upsertedAttachment);
116
- return __assign(__assign({}, state), { attachments: attachments });
110
+ case 'upsertAttachments': {
111
+ var attachments_1 = __spreadArray([], state.attachments, true);
112
+ action.attachments.forEach(function (actionAttachment) {
113
+ var _a;
114
+ var attachmentIndex = state.attachments.findIndex(function (att) { var _a, _b, _c; return ((_a = att.localMetadata) === null || _a === void 0 ? void 0 : _a.id) && ((_b = att.localMetadata) === null || _b === void 0 ? void 0 : _b.id) === ((_c = actionAttachment.localMetadata) === null || _c === void 0 ? void 0 : _c.id); });
115
+ if (attachmentIndex === -1) {
116
+ attachments_1.push(actionAttachment);
117
+ }
118
+ else {
119
+ var upsertedAttachment = mergeDeep((_a = state.attachments[attachmentIndex]) !== null && _a !== void 0 ? _a : {}, actionAttachment);
120
+ attachments_1.splice(attachmentIndex, 1, upsertedAttachment);
121
+ }
122
+ });
123
+ return __assign(__assign({}, state), { attachments: attachments_1 });
117
124
  }
118
- case 'removeAttachment': {
119
- var attachmentIndex = state.attachments.findIndex(function (att) { var _a, _b; return ((_a = att.$internal) === null || _a === void 0 ? void 0 : _a.id) && ((_b = att.$internal) === null || _b === void 0 ? void 0 : _b.id) === action.id; });
120
- if (attachmentIndex === -1)
121
- return state;
122
- return __assign(__assign({}, state), { attachments: __spreadArray([], state.attachments.splice(attachmentIndex, 1), true) });
125
+ case 'removeAttachments': {
126
+ return __assign(__assign({}, state), { attachments: state.attachments.filter(function (att) { var _a; return !action.ids.includes((_a = att.localMetadata) === null || _a === void 0 ? void 0 : _a.id); }) });
123
127
  }
124
128
  case 'setImageUpload': {
125
129
  var imageAlreadyExists = state.imageUploads[action.id];
@@ -218,7 +222,7 @@ export var useMessageInputState = function (props) {
218
222
  setShowMentionsList(true);
219
223
  };
220
224
  var closeMentionsList = function () { return setShowMentionsList(false); };
221
- var _h = useAttachments(props, state, dispatch, textareaRef), maxFilesLeft = _h.maxFilesLeft, numberOfUploads = _h.numberOfUploads, removeAttachment = _h.removeAttachment, removeFile = _h.removeFile, removeImage = _h.removeImage, uploadAttachment = _h.uploadAttachment, uploadFile = _h.uploadFile, uploadImage = _h.uploadImage, uploadNewFiles = _h.uploadNewFiles;
225
+ var _h = useAttachments(props, state, dispatch, textareaRef), maxFilesLeft = _h.maxFilesLeft, numberOfUploads = _h.numberOfUploads, removeAttachments = _h.removeAttachments, removeFile = _h.removeFile, removeImage = _h.removeImage, uploadAttachment = _h.uploadAttachment, uploadFile = _h.uploadFile, uploadImage = _h.uploadImage, uploadNewFiles = _h.uploadNewFiles, upsertAttachments = _h.upsertAttachments;
222
226
  var handleSubmit = useSubmitHandler(props, state, dispatch, numberOfUploads, enrichURLsController).handleSubmit;
223
227
  var recordingController = useMediaRecorder({
224
228
  asyncMessagesMultiSendEnabled: asyncMessagesMultiSendEnabled,
@@ -236,5 +240,5 @@ export var useMessageInputState = function (props) {
236
240
  var setText = useCallback(function (text) {
237
241
  dispatch({ getNewText: function () { return text; }, type: 'setText' });
238
242
  }, []);
239
- return __assign(__assign(__assign({}, state), enrichURLsController), { closeCommandsList: closeCommandsList, closeMentionsList: closeMentionsList, handleChange: handleChange, handleSubmit: handleSubmit, insertText: insertText, isUploadEnabled: isUploadEnabled, maxFilesLeft: maxFilesLeft, numberOfUploads: numberOfUploads, onPaste: onPaste, onSelectUser: onSelectUser, openCommandsList: openCommandsList, openMentionsList: openMentionsList, recordingController: recordingController, removeAttachment: removeAttachment, removeFile: removeFile, removeImage: removeImage, setText: setText, showCommandsList: showCommandsList, showMentionsList: showMentionsList, textareaRef: textareaRef, uploadAttachment: uploadAttachment, uploadFile: uploadFile, uploadImage: uploadImage, uploadNewFiles: uploadNewFiles });
243
+ return __assign(__assign(__assign({}, state), enrichURLsController), { closeCommandsList: closeCommandsList, closeMentionsList: closeMentionsList, handleChange: handleChange, handleSubmit: handleSubmit, insertText: insertText, isUploadEnabled: isUploadEnabled, maxFilesLeft: maxFilesLeft, numberOfUploads: numberOfUploads, onPaste: onPaste, onSelectUser: onSelectUser, openCommandsList: openCommandsList, openMentionsList: openMentionsList, recordingController: recordingController, removeAttachments: removeAttachments, removeFile: removeFile, removeImage: removeImage, setText: setText, showCommandsList: showCommandsList, showMentionsList: showMentionsList, textareaRef: textareaRef, uploadAttachment: uploadAttachment, uploadFile: uploadFile, uploadImage: uploadImage, uploadNewFiles: uploadNewFiles, upsertAttachments: upsertAttachments });
240
244
  };
@@ -66,9 +66,9 @@ export var useSubmitHandler = function (props, state, dispatch, numberOfUploads,
66
66
  type: getAttachmentTypeFromMime(upload.file.type || ''),
67
67
  }); });
68
68
  var otherAttachments = attachments
69
- .filter(function (att) { var _a; return ((_a = att.$internal) === null || _a === void 0 ? void 0 : _a.uploadState) !== 'failed'; })
69
+ .filter(function (att) { var _a; return ((_a = att.localMetadata) === null || _a === void 0 ? void 0 : _a.uploadState) !== 'failed'; })
70
70
  .map(function (localAttachment) {
71
- var _ = localAttachment.$internal, attachment = __rest(localAttachment, ["$internal"]);
71
+ var _ = localAttachment.localMetadata, attachment = __rest(localAttachment, ["localMetadata"]);
72
72
  return attachment;
73
73
  });
74
74
  return __spreadArray(__spreadArray(__spreadArray([], otherAttachments, true), imageAttachments, true), fileAttachments, true);
@@ -92,7 +92,7 @@ export var useSubmitHandler = function (props, state, dispatch, numberOfUploads,
92
92
  return [2 /*return*/];
93
93
  someAttachmentsUploading = Object.values(imageUploads).some(function (upload) { return upload.state === 'uploading'; }) ||
94
94
  Object.values(fileUploads).some(function (upload) { return upload.state === 'uploading'; }) ||
95
- attachments.some(function (att) { var _a; return ((_a = att.$internal) === null || _a === void 0 ? void 0 : _a.uploadState) === 'uploading'; });
95
+ attachments.some(function (att) { var _a; return ((_a = att.localMetadata) === null || _a === void 0 ? void 0 : _a.uploadState) === 'uploading'; });
96
96
  if (someAttachmentsUploading) {
97
97
  return [2 /*return*/, addNotification(t('Wait until all attachments have uploaded'), 'error')];
98
98
  }
@@ -1,4 +1,5 @@
1
1
  export { AttachmentPreviewList } from './AttachmentPreviewList';
2
+ export type { AttachmentPreviewListProps, FileAttachmentPreviewProps, ImageAttachmentPreviewProps, AttachmentPreviewProps, UnsupportedAttachmentPreviewProps, VoiceRecordingPreviewProps, } from './AttachmentPreviewList';
2
3
  export * from './CooldownTimer';
3
4
  export * from './DefaultTriggerProvider';
4
5
  export * from './EditMessageForm';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MessageInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MessageInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,sBAAsB,EACtB,iCAAiC,EACjC,0BAA0B,GAC3B,MAAM,yBAAyB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { Attachment, DefaultGenerics, ExtendableGenerics, OGAttachment } from 'stream-chat';
2
2
  import type { DefaultStreamChatGenerics } from '../../types/types';
3
- type AttachmentLoadingState = 'uploading' | 'finished' | 'failed';
3
+ export type AttachmentLoadingState = 'uploading' | 'finished' | 'failed';
4
4
  export type FileUpload = {
5
5
  file: {
6
6
  name: string;
@@ -62,31 +62,54 @@ export type VoiceRecordingAttachment<StreamChatGenerics extends ExtendableGeneri
62
62
  title?: string;
63
63
  waveform_data?: Array<number>;
64
64
  };
65
+ type FileAttachment<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Attachment<StreamChatGenerics> & {
66
+ type: 'file';
67
+ asset_url?: string;
68
+ file_size?: number;
69
+ mime_type?: string;
70
+ title?: string;
71
+ };
65
72
  export type AudioAttachment<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Attachment<StreamChatGenerics> & {
66
- asset_url: string;
67
73
  type: 'audio';
74
+ asset_url?: string;
68
75
  file_size?: number;
69
76
  mime_type?: string;
70
77
  title?: string;
71
78
  };
72
79
  export type VideoAttachment<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Attachment<StreamChatGenerics> & {
73
- asset_url: string;
74
80
  type: 'video';
81
+ asset_url?: string;
75
82
  mime_type?: string;
76
83
  thumb_url?: string;
77
84
  title?: string;
78
85
  };
79
- export type AttachmentInternalMetadata = {
86
+ type ImageAttachment<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Attachment<StreamChatGenerics> & {
87
+ type: 'image';
88
+ fallback?: string;
89
+ image_url?: string;
90
+ original_height?: number;
91
+ original_width?: number;
92
+ };
93
+ export type BaseLocalAttachmentMetadata = {
80
94
  id: string;
95
+ };
96
+ export type LocalAttachmentUploadMetadata = {
81
97
  file?: File;
82
98
  uploadState?: AttachmentLoadingState;
83
99
  };
84
- type LocalAttachmentCast<T> = T & {
85
- $internal: AttachmentInternalMetadata;
100
+ export type LocalImageAttachmentUploadMetadata = LocalAttachmentUploadMetadata & {
101
+ previewUri?: string;
102
+ };
103
+ export type LocalAttachmentCast<A, L = Record<string, unknown>> = A & {
104
+ localMetadata: L & BaseLocalAttachmentMetadata;
86
105
  };
87
- export type LocalVoiceRecordingAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = LocalAttachmentCast<VoiceRecordingAttachment<StreamChatGenerics>>;
88
- export type LocalAudioAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = LocalAttachmentCast<AudioAttachment<StreamChatGenerics>>;
89
- export type LocalVideoAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = LocalAttachmentCast<VideoAttachment<StreamChatGenerics>>;
90
- export type LocalAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = LocalAttachmentCast<Attachment<StreamChatGenerics>> | LocalAudioAttachment<StreamChatGenerics> | LocalVideoAttachment<StreamChatGenerics> | LocalVoiceRecordingAttachment<StreamChatGenerics>;
106
+ export type LocalAttachmentMetadata<CustomLocalMetadata = Record<string, unknown>> = CustomLocalMetadata & BaseLocalAttachmentMetadata & LocalImageAttachmentUploadMetadata;
107
+ export type LocalVoiceRecordingAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, CustomLocalMetadata = Record<string, unknown>> = LocalAttachmentCast<VoiceRecordingAttachment<StreamChatGenerics>, LocalAttachmentUploadMetadata & CustomLocalMetadata>;
108
+ export type LocalAudioAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, CustomLocalMetadata = Record<string, unknown>> = LocalAttachmentCast<AudioAttachment<StreamChatGenerics>, LocalAttachmentUploadMetadata & CustomLocalMetadata>;
109
+ export type LocalVideoAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, CustomLocalMetadata = Record<string, unknown>> = LocalAttachmentCast<VideoAttachment<StreamChatGenerics>, LocalAttachmentUploadMetadata & CustomLocalMetadata>;
110
+ export type LocalImageAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, CustomLocalMetadata = Record<string, unknown>> = LocalAttachmentCast<ImageAttachment<StreamChatGenerics>, LocalImageAttachmentUploadMetadata & CustomLocalMetadata>;
111
+ export type LocalFileAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, CustomLocalMetadata = Record<string, unknown>> = LocalAttachmentCast<FileAttachment<StreamChatGenerics>, LocalAttachmentUploadMetadata & CustomLocalMetadata>;
112
+ export type AnyLocalAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, CustomLocalMetadata = Record<string, unknown>> = LocalAttachmentCast<Attachment<StreamChatGenerics>, LocalAttachmentMetadata<CustomLocalMetadata>>;
113
+ export type LocalAttachment<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = AnyLocalAttachment<StreamChatGenerics> | LocalFileAttachment<StreamChatGenerics> | LocalImageAttachment<StreamChatGenerics> | LocalAudioAttachment<StreamChatGenerics> | LocalVideoAttachment<StreamChatGenerics> | LocalVoiceRecordingAttachment<StreamChatGenerics>;
91
114
  export {};
92
115
  //# sourceMappingURL=types.d.ts.map