stream-chat-react 12.14.0 → 13.0.0-rc.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 (480) hide show
  1. package/dist/components/AIStateIndicator/AIStateIndicator.d.ts +4 -5
  2. package/dist/components/AIStateIndicator/hooks/useAIState.d.ts +2 -3
  3. package/dist/components/Attachment/Attachment.d.ts +8 -9
  4. package/dist/components/Attachment/Attachment.js +6 -5
  5. package/dist/components/Attachment/AttachmentActions.d.ts +2 -3
  6. package/dist/components/Attachment/AttachmentContainer.d.ts +15 -15
  7. package/dist/components/Attachment/AttachmentContainer.js +2 -2
  8. package/dist/components/Attachment/Audio.d.ts +3 -4
  9. package/dist/components/Attachment/Card.d.ts +1 -1
  10. package/dist/components/Attachment/FileAttachment.d.ts +3 -4
  11. package/dist/components/Attachment/FileAttachment.js +1 -1
  12. package/dist/components/Attachment/UnsupportedAttachment.d.ts +3 -4
  13. package/dist/components/Attachment/UnsupportedAttachment.js +1 -1
  14. package/dist/components/Attachment/VoiceRecording.d.ts +4 -5
  15. package/dist/components/Attachment/components/FileSizeIndicator.d.ts +1 -1
  16. package/dist/components/Attachment/components/FileSizeIndicator.js +4 -2
  17. package/dist/components/Attachment/utils.d.ts +8 -22
  18. package/dist/components/Attachment/utils.js +3 -18
  19. package/dist/components/Avatar/Avatar.d.ts +3 -4
  20. package/dist/components/Avatar/ChannelAvatar.d.ts +3 -4
  21. package/dist/components/Avatar/ChannelAvatar.js +1 -1
  22. package/dist/components/Avatar/GroupAvatar.d.ts +2 -2
  23. package/dist/components/Channel/Channel.d.ts +18 -37
  24. package/dist/components/Channel/Channel.js +25 -88
  25. package/dist/components/Channel/channelState.d.ts +17 -18
  26. package/dist/components/Channel/hooks/useChannelContainerClasses.d.ts +2 -3
  27. package/dist/components/Channel/hooks/useCreateChannelStateContext.d.ts +2 -3
  28. package/dist/components/Channel/hooks/useCreateChannelStateContext.js +1 -15
  29. package/dist/components/Channel/hooks/useCreateTypingContext.d.ts +1 -2
  30. package/dist/components/Channel/hooks/useEditMessageHandler.d.ts +3 -4
  31. package/dist/components/Channel/hooks/useMentionsHandlers.d.ts +3 -4
  32. package/dist/components/Channel/utils.d.ts +8 -6
  33. package/dist/components/Channel/utils.js +1 -0
  34. package/dist/components/ChannelHeader/ChannelHeader.d.ts +2 -3
  35. package/dist/components/ChannelList/ChannelList.d.ts +31 -30
  36. package/dist/components/ChannelList/ChannelList.js +8 -10
  37. package/dist/components/ChannelList/ChannelListMessenger.d.ts +6 -6
  38. package/dist/components/ChannelList/hooks/useChannelDeletedListener.d.ts +1 -2
  39. package/dist/components/ChannelList/hooks/useChannelHiddenListener.d.ts +1 -2
  40. package/dist/components/ChannelList/hooks/useChannelListShape.d.ts +44 -44
  41. package/dist/components/ChannelList/hooks/useChannelListShape.js +0 -2
  42. package/dist/components/ChannelList/hooks/useChannelMembershipState.d.ts +3 -3
  43. package/dist/components/ChannelList/hooks/useChannelTruncatedListener.d.ts +1 -2
  44. package/dist/components/ChannelList/hooks/useChannelUpdatedListener.d.ts +1 -2
  45. package/dist/components/ChannelList/hooks/useChannelVisibleListener.d.ts +1 -2
  46. package/dist/components/ChannelList/hooks/useConnectionRecoveredListener.d.ts +1 -2
  47. package/dist/components/ChannelList/hooks/useMessageNewListener.d.ts +1 -2
  48. package/dist/components/ChannelList/hooks/useNotificationAddedToChannelListener.d.ts +1 -2
  49. package/dist/components/ChannelList/hooks/useNotificationMessageNewListener.d.ts +1 -2
  50. package/dist/components/ChannelList/hooks/useNotificationRemovedFromChannelListener.d.ts +1 -2
  51. package/dist/components/ChannelList/hooks/usePaginatedChannels.d.ts +7 -8
  52. package/dist/components/ChannelList/hooks/usePaginatedChannels.js +3 -3
  53. package/dist/components/ChannelList/hooks/useSelectedChannelState.d.ts +7 -7
  54. package/dist/components/ChannelList/hooks/useUserPresenceChangedListener.d.ts +1 -2
  55. package/dist/components/ChannelList/utils.d.ts +20 -21
  56. package/dist/components/ChannelList/utils.js +2 -2
  57. package/dist/components/ChannelPreview/ChannelPreview.d.ts +15 -16
  58. package/dist/components/ChannelPreview/ChannelPreview.js +1 -1
  59. package/dist/components/ChannelPreview/ChannelPreviewActionButtons.d.ts +4 -4
  60. package/dist/components/ChannelPreview/ChannelPreviewMessenger.d.ts +1 -2
  61. package/dist/components/ChannelPreview/hooks/useChannelPreviewInfo.d.ts +3 -4
  62. package/dist/components/ChannelPreview/hooks/useIsChannelMuted.d.ts +1 -2
  63. package/dist/components/ChannelPreview/hooks/useMessageDeliveryStatus.d.ts +5 -7
  64. package/dist/components/ChannelPreview/icons.d.ts +1 -1
  65. package/dist/components/ChannelPreview/utils.d.ts +7 -7
  66. package/dist/components/ChannelSearch/ChannelSearch.d.ts +5 -6
  67. package/dist/components/ChannelSearch/ChannelSearch.js +2 -2
  68. package/dist/components/ChannelSearch/SearchBar.d.ts +1 -1
  69. package/dist/components/ChannelSearch/SearchBar.js +1 -1
  70. package/dist/components/ChannelSearch/SearchResults.d.ts +13 -14
  71. package/dist/components/ChannelSearch/SearchResults.js +1 -1
  72. package/dist/components/ChannelSearch/hooks/useChannelSearch.d.ts +17 -18
  73. package/dist/components/ChannelSearch/hooks/useChannelSearch.js +2 -6
  74. package/dist/components/ChannelSearch/utils.d.ts +2 -3
  75. package/dist/components/Chat/Chat.d.ts +9 -9
  76. package/dist/components/Chat/hooks/useChannelsQueryState.d.ts +1 -1
  77. package/dist/components/Chat/hooks/useChat.d.ts +10 -10
  78. package/dist/components/Chat/hooks/useChat.js +3 -3
  79. package/dist/components/Chat/hooks/useCreateChatClient.d.ts +4 -4
  80. package/dist/components/Chat/hooks/useCreateChatContext.d.ts +1 -2
  81. package/dist/components/Dialog/DialogAnchor.d.ts +4 -3
  82. package/dist/components/Dialog/DialogAnchor.js +2 -2
  83. package/dist/components/Dialog/DialogMenu.d.ts +2 -1
  84. package/dist/components/Dialog/DialogPortal.d.ts +2 -1
  85. package/dist/components/Dialog/FormDialog.d.ts +2 -1
  86. package/dist/components/Dialog/FormDialog.js +1 -1
  87. package/dist/components/Dialog/PromptDialog.d.ts +2 -1
  88. package/dist/components/DragAndDrop/DragAndDropContainer.d.ts +2 -1
  89. package/dist/components/EventComponent/EventComponent.d.ts +7 -6
  90. package/dist/components/Form/FieldError.d.ts +2 -1
  91. package/dist/components/Form/SwitchField.d.ts +2 -1
  92. package/dist/components/Form/SwitchField.js +1 -1
  93. package/dist/components/Gallery/Gallery.d.ts +5 -5
  94. package/dist/components/Gallery/Image.d.ts +6 -5
  95. package/dist/components/Gallery/ModalGallery.d.ts +3 -4
  96. package/dist/components/InfiniteScrollPaginator/InfiniteScroll.d.ts +2 -1
  97. package/dist/components/InfiniteScrollPaginator/InfiniteScrollPaginator.d.ts +2 -1
  98. package/dist/components/LoadMore/LoadMoreButton.d.ts +2 -1
  99. package/dist/components/LoadMore/LoadMorePaginator.d.ts +3 -2
  100. package/dist/components/LoadMore/LoadMorePaginator.js +1 -1
  101. package/dist/components/MediaRecorder/AudioRecorder/AudioRecorder.js +3 -2
  102. package/dist/components/MediaRecorder/AudioRecorder/AudioRecordingInProgress.js +1 -1
  103. package/dist/components/MediaRecorder/RecordingPermissionDeniedNotification.d.ts +1 -1
  104. package/dist/components/MediaRecorder/classes/MediaRecorderController.d.ts +11 -23
  105. package/dist/components/MediaRecorder/hooks/useMediaRecorder.d.ts +8 -8
  106. package/dist/components/MediaRecorder/hooks/useMediaRecorder.js +6 -4
  107. package/dist/components/MediaRecorder/observable/BehaviorSubject.d.ts +2 -2
  108. package/dist/components/MediaRecorder/observable/Observable.d.ts +1 -1
  109. package/dist/components/MediaRecorder/observable/Subject.d.ts +3 -2
  110. package/dist/components/Message/FixedHeightMessage.d.ts +4 -5
  111. package/dist/components/Message/Message.d.ts +1 -2
  112. package/dist/components/Message/MessageDeleted.d.ts +4 -5
  113. package/dist/components/Message/MessageEditedTimestamp.d.ts +2 -3
  114. package/dist/components/Message/MessageErrorText.d.ts +4 -5
  115. package/dist/components/Message/MessageErrorText.js +2 -2
  116. package/dist/components/Message/MessageOptions.d.ts +3 -3
  117. package/dist/components/Message/MessageRepliesCountButton.d.ts +2 -1
  118. package/dist/components/Message/MessageSimple.d.ts +1 -2
  119. package/dist/components/Message/MessageSimple.js +8 -10
  120. package/dist/components/Message/MessageStatus.d.ts +3 -4
  121. package/dist/components/Message/MessageText.d.ts +6 -6
  122. package/dist/components/Message/MessageTimestamp.d.ts +4 -5
  123. package/dist/components/Message/QuotedMessage.d.ts +2 -3
  124. package/dist/components/Message/QuotedMessage.js +1 -1
  125. package/dist/components/Message/StreamedMessageText.d.ts +3 -4
  126. package/dist/components/Message/hooks/useActionHandler.d.ts +2 -3
  127. package/dist/components/Message/hooks/useActionHandler.js +1 -1
  128. package/dist/components/Message/hooks/useDeleteHandler.d.ts +4 -5
  129. package/dist/components/Message/hooks/useFlagHandler.d.ts +5 -6
  130. package/dist/components/Message/hooks/useMarkUnreadHandler.d.ts +5 -6
  131. package/dist/components/Message/hooks/useMentionsHandler.d.ts +6 -8
  132. package/dist/components/Message/hooks/useMessageTextStreaming.d.ts +2 -3
  133. package/dist/components/Message/hooks/useMuteHandler.d.ts +5 -7
  134. package/dist/components/Message/hooks/useMuteHandler.js +1 -1
  135. package/dist/components/Message/hooks/useOpenThreadHandler.d.ts +2 -3
  136. package/dist/components/Message/hooks/usePinHandler.d.ts +4 -5
  137. package/dist/components/Message/hooks/usePinHandler.js +1 -1
  138. package/dist/components/Message/hooks/useReactionHandler.d.ts +3 -4
  139. package/dist/components/Message/hooks/useReactionHandler.js +2 -4
  140. package/dist/components/Message/hooks/useReactionsFetcher.d.ts +5 -7
  141. package/dist/components/Message/hooks/useRetryHandler.d.ts +2 -3
  142. package/dist/components/Message/hooks/useRetryHandler.js +1 -1
  143. package/dist/components/Message/hooks/useUserHandler.d.ts +5 -6
  144. package/dist/components/Message/hooks/useUserRole.d.ts +2 -3
  145. package/dist/components/Message/hooks/useUserRole.js +1 -1
  146. package/dist/components/Message/icons.d.ts +2 -2
  147. package/dist/components/Message/icons.js +1 -1
  148. package/dist/components/Message/renderText/componentRenderers/Anchor.d.ts +2 -1
  149. package/dist/components/Message/renderText/componentRenderers/Emoji.d.ts +1 -1
  150. package/dist/components/Message/renderText/componentRenderers/Mention.d.ts +5 -5
  151. package/dist/components/Message/renderText/componentRenderers/Mention.js +1 -1
  152. package/dist/components/Message/renderText/rehypePlugins/mentionsMarkdownPlugin.d.ts +1 -2
  153. package/dist/components/Message/renderText/renderText.d.ts +6 -6
  154. package/dist/components/Message/renderText/types.d.ts +1 -1
  155. package/dist/components/Message/types.d.ts +27 -28
  156. package/dist/components/Message/utils.d.ts +21 -22
  157. package/dist/components/Message/utils.js +5 -4
  158. package/dist/components/MessageActions/CustomMessageActionsList.d.ts +6 -7
  159. package/dist/components/MessageActions/MessageActions.d.ts +6 -5
  160. package/dist/components/MessageActions/MessageActions.js +1 -1
  161. package/dist/components/MessageActions/MessageActionsBox.d.ts +5 -5
  162. package/dist/components/MessageActions/MessageActionsBox.js +4 -3
  163. package/dist/components/MessageActions/hooks/useMessageActionsBoxPopper.d.ts +1 -1
  164. package/dist/components/MessageBounce/MessageBounceModal.d.ts +4 -3
  165. package/dist/components/MessageBounce/MessageBouncePrompt.d.ts +1 -2
  166. package/dist/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.d.ts +11 -11
  167. package/dist/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.js +17 -14
  168. package/dist/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.d.ts +4 -12
  169. package/dist/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.js +8 -5
  170. package/dist/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.d.ts +4 -5
  171. package/dist/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.js +2 -2
  172. package/dist/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.d.ts +7 -5
  173. package/dist/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.js +5 -2
  174. package/dist/components/MessageInput/AttachmentPreviewList/VoiceRecordingPreview.d.ts +4 -5
  175. package/dist/components/MessageInput/AttachmentPreviewList/VoiceRecordingPreview.js +5 -2
  176. package/dist/components/MessageInput/AttachmentPreviewList/index.d.ts +1 -1
  177. package/dist/components/MessageInput/AttachmentPreviewList/types.d.ts +3 -4
  178. package/dist/components/MessageInput/AttachmentSelector.d.ts +1 -2
  179. package/dist/components/MessageInput/AttachmentSelector.js +5 -3
  180. package/dist/components/MessageInput/EditMessageForm.d.ts +3 -2
  181. package/dist/components/MessageInput/EditMessageForm.js +30 -6
  182. package/dist/components/MessageInput/LinkPreviewList.d.ts +6 -4
  183. package/dist/components/MessageInput/LinkPreviewList.js +24 -10
  184. package/dist/components/MessageInput/MessageInput.d.ts +23 -45
  185. package/dist/components/MessageInput/MessageInput.js +25 -15
  186. package/dist/components/MessageInput/MessageInputFlat.d.ts +1 -2
  187. package/dist/components/MessageInput/MessageInputFlat.js +31 -76
  188. package/dist/components/MessageInput/QuotedMessagePreview.d.ts +4 -7
  189. package/dist/components/MessageInput/QuotedMessagePreview.js +22 -16
  190. package/dist/components/MessageInput/SendButton.d.ts +4 -5
  191. package/dist/components/MessageInput/SendButton.js +6 -2
  192. package/dist/components/MessageInput/WithDragAndDropUpload.d.ts +38 -0
  193. package/dist/components/MessageInput/WithDragAndDropUpload.js +96 -0
  194. package/dist/components/MessageInput/hooks/index.d.ts +5 -1
  195. package/dist/components/MessageInput/hooks/index.js +5 -1
  196. package/dist/components/MessageInput/hooks/useAttachmentManagerState.d.ts +10 -0
  197. package/dist/components/MessageInput/hooks/useAttachmentManagerState.js +19 -0
  198. package/dist/components/MessageInput/hooks/useCanCreatePoll.d.ts +1 -0
  199. package/dist/components/MessageInput/hooks/useCanCreatePoll.js +10 -0
  200. package/dist/components/MessageInput/hooks/useCooldownTimer.d.ts +2 -3
  201. package/dist/components/MessageInput/hooks/useCreateMessageInputContext.d.ts +1 -2
  202. package/dist/components/MessageInput/hooks/useCreateMessageInputContext.js +1 -55
  203. package/dist/components/MessageInput/hooks/useMessageComposer.d.ts +2 -0
  204. package/dist/components/MessageInput/hooks/useMessageComposer.js +80 -0
  205. package/dist/components/MessageInput/hooks/useMessageComposerHasSendableData.d.ts +1 -0
  206. package/dist/components/MessageInput/hooks/useMessageComposerHasSendableData.js +8 -0
  207. package/dist/components/MessageInput/hooks/useMessageInputControls.d.ts +12 -0
  208. package/dist/components/MessageInput/hooks/useMessageInputControls.js +23 -0
  209. package/dist/components/MessageInput/hooks/useMessageInputText.d.ts +1 -5
  210. package/dist/components/MessageInput/hooks/useMessageInputText.js +19 -53
  211. package/dist/components/MessageInput/hooks/usePasteHandler.d.ts +1 -3
  212. package/dist/components/MessageInput/hooks/usePasteHandler.js +6 -8
  213. package/dist/components/MessageInput/hooks/useSubmitHandler.d.ts +2 -6
  214. package/dist/components/MessageInput/hooks/useSubmitHandler.js +30 -98
  215. package/dist/components/MessageInput/hooks/utils.d.ts +0 -27
  216. package/dist/components/MessageInput/hooks/utils.js +0 -124
  217. package/dist/components/MessageInput/index.d.ts +1 -2
  218. package/dist/components/MessageInput/index.js +1 -2
  219. package/dist/components/MessageList/ConnectionStatus.d.ts +1 -2
  220. package/dist/components/MessageList/ConnectionStatus.js +1 -1
  221. package/dist/components/MessageList/CustomNotification.d.ts +2 -1
  222. package/dist/components/MessageList/GiphyPreviewMessage.d.ts +4 -5
  223. package/dist/components/MessageList/MessageList.d.ts +11 -12
  224. package/dist/components/MessageList/MessageList.js +4 -4
  225. package/dist/components/MessageList/MessageNotification.d.ts +2 -1
  226. package/dist/components/MessageList/VirtualizedMessageList.d.ts +22 -21
  227. package/dist/components/MessageList/VirtualizedMessageList.js +6 -6
  228. package/dist/components/MessageList/VirtualizedMessageListComponents.d.ts +10 -10
  229. package/dist/components/MessageList/VirtualizedMessageListComponents.js +7 -7
  230. package/dist/components/MessageList/hooks/MessageList/useEnrichedMessages.d.ts +8 -10
  231. package/dist/components/MessageList/hooks/MessageList/useEnrichedMessages.js +1 -1
  232. package/dist/components/MessageList/hooks/MessageList/useMessageListElements.d.ts +11 -12
  233. package/dist/components/MessageList/hooks/MessageList/useMessageListScrollManager.d.ts +4 -5
  234. package/dist/components/MessageList/hooks/MessageList/useScrollLocationLogic.d.ts +5 -6
  235. package/dist/components/MessageList/hooks/VirtualizedMessageList/useGiphyPreview.d.ts +4 -5
  236. package/dist/components/MessageList/hooks/VirtualizedMessageList/useGiphyPreview.js +3 -2
  237. package/dist/components/MessageList/hooks/VirtualizedMessageList/useMessageSetKey.d.ts +4 -5
  238. package/dist/components/MessageList/hooks/VirtualizedMessageList/useMessageSetKey.js +1 -1
  239. package/dist/components/MessageList/hooks/VirtualizedMessageList/useNewMessageNotification.d.ts +2 -3
  240. package/dist/components/MessageList/hooks/VirtualizedMessageList/usePrependMessagesCount.d.ts +2 -3
  241. package/dist/components/MessageList/hooks/VirtualizedMessageList/usePrependMessagesCount.js +6 -2
  242. package/dist/components/MessageList/hooks/VirtualizedMessageList/useScrollToBottomOnNewMessage.d.ts +4 -5
  243. package/dist/components/MessageList/hooks/VirtualizedMessageList/useShouldForceScrollToBottom.d.ts +2 -3
  244. package/dist/components/MessageList/hooks/VirtualizedMessageList/useUnreadMessagesNotificationVirtualized.d.ts +3 -4
  245. package/dist/components/MessageList/hooks/VirtualizedMessageList/useUnreadMessagesNotificationVirtualized.js +5 -6
  246. package/dist/components/MessageList/hooks/useLastReadData.d.ts +5 -6
  247. package/dist/components/MessageList/hooks/useLastReadData.js +5 -1
  248. package/dist/components/MessageList/hooks/useMarkRead.d.ts +1 -2
  249. package/dist/components/MessageList/renderMessages.d.ts +14 -14
  250. package/dist/components/MessageList/renderMessages.js +8 -7
  251. package/dist/components/MessageList/utils.d.ts +34 -28
  252. package/dist/components/MessageList/utils.js +26 -21
  253. package/dist/components/Modal/Modal.d.ts +2 -1
  254. package/dist/components/Poll/Poll.d.ts +2 -3
  255. package/dist/components/Poll/Poll.js +1 -1
  256. package/dist/components/Poll/PollActions/AddCommentForm.d.ts +1 -2
  257. package/dist/components/Poll/PollActions/AddCommentForm.js +4 -2
  258. package/dist/components/Poll/PollActions/EndPollDialog.d.ts +1 -2
  259. package/dist/components/Poll/PollActions/EndPollDialog.js +1 -1
  260. package/dist/components/Poll/PollActions/PollAction.d.ts +2 -1
  261. package/dist/components/Poll/PollActions/PollActions.d.ts +7 -8
  262. package/dist/components/Poll/PollActions/PollActions.js +5 -5
  263. package/dist/components/Poll/PollActions/PollAnswerList.d.ts +1 -2
  264. package/dist/components/Poll/PollActions/PollOptionsFullList.d.ts +1 -2
  265. package/dist/components/Poll/PollActions/PollOptionsFullList.js +4 -2
  266. package/dist/components/Poll/PollActions/PollResults/PollOptionVotesList.d.ts +3 -4
  267. package/dist/components/Poll/PollActions/PollResults/PollOptionVotesList.js +1 -1
  268. package/dist/components/Poll/PollActions/PollResults/PollOptionWithLatestVotes.d.ts +3 -4
  269. package/dist/components/Poll/PollActions/PollResults/PollOptionWithVotesHeader.d.ts +4 -5
  270. package/dist/components/Poll/PollActions/PollResults/PollOptionWithVotesHeader.js +1 -1
  271. package/dist/components/Poll/PollActions/PollResults/PollResults.d.ts +1 -2
  272. package/dist/components/Poll/PollActions/PollResults/PollResults.js +1 -1
  273. package/dist/components/Poll/PollActions/SuggestPollOptionForm.d.ts +1 -2
  274. package/dist/components/Poll/PollActions/SuggestPollOptionForm.js +3 -1
  275. package/dist/components/Poll/PollContent.d.ts +1 -2
  276. package/dist/components/Poll/PollCreationDialog/MultipleAnswersField.d.ts +2 -0
  277. package/dist/components/Poll/PollCreationDialog/MultipleAnswersField.js +35 -0
  278. package/dist/components/Poll/PollCreationDialog/NameField.d.ts +2 -0
  279. package/dist/components/Poll/PollCreationDialog/NameField.js +26 -0
  280. package/dist/components/Poll/PollCreationDialog/OptionFieldSet.d.ts +1 -8
  281. package/dist/components/Poll/PollCreationDialog/OptionFieldSet.js +33 -65
  282. package/dist/components/Poll/PollCreationDialog/PollCreationDialog.js +31 -85
  283. package/dist/components/Poll/PollCreationDialog/PollCreationDialogControls.d.ts +1 -4
  284. package/dist/components/Poll/PollCreationDialog/PollCreationDialogControls.js +15 -41
  285. package/dist/components/Poll/PollCreationDialog/types.d.ts +0 -14
  286. package/dist/components/Poll/PollHeader.d.ts +1 -2
  287. package/dist/components/Poll/PollOptionList.d.ts +1 -2
  288. package/dist/components/Poll/PollOptionList.js +4 -2
  289. package/dist/components/Poll/PollOptionSelector.d.ts +3 -4
  290. package/dist/components/Poll/PollVote.d.ts +6 -7
  291. package/dist/components/Poll/PollVote.js +3 -3
  292. package/dist/components/Poll/QuotedPoll.d.ts +1 -2
  293. package/dist/components/Poll/constants.d.ts +0 -1
  294. package/dist/components/Poll/constants.js +0 -1
  295. package/dist/components/Poll/hooks/useManagePollVotesRealtime.d.ts +2 -3
  296. package/dist/components/Poll/hooks/usePollAnswerPagination.d.ts +2 -3
  297. package/dist/components/Poll/hooks/usePollAnswerPagination.js +2 -2
  298. package/dist/components/Poll/hooks/usePollOptionVotesPagination.d.ts +2 -3
  299. package/dist/components/Poll/hooks/usePollOptionVotesPagination.js +1 -1
  300. package/dist/components/Portal/Portal.d.ts +1 -1
  301. package/dist/components/ReactFileUtilities/FileIcon/FileIcon.d.ts +1 -1
  302. package/dist/components/ReactFileUtilities/FileIcon/FileIconSet.d.ts +2 -1
  303. package/dist/components/ReactFileUtilities/FileIcon/iconMap.d.ts +1 -1
  304. package/dist/components/ReactFileUtilities/UploadButton.d.ts +3 -2
  305. package/dist/components/ReactFileUtilities/UploadButton.js +16 -6
  306. package/dist/components/ReactFileUtilities/index.d.ts +0 -1
  307. package/dist/components/ReactFileUtilities/index.js +0 -1
  308. package/dist/components/ReactFileUtilities/utils.d.ts +2 -2
  309. package/dist/components/Reactions/ReactionSelector.d.ts +4 -5
  310. package/dist/components/Reactions/ReactionSelectorWithButton.d.ts +1 -2
  311. package/dist/components/Reactions/ReactionsList.d.ts +6 -7
  312. package/dist/components/Reactions/ReactionsList.js +2 -2
  313. package/dist/components/Reactions/ReactionsListModal.d.ts +9 -10
  314. package/dist/components/Reactions/SimpleReactionsList.d.ts +5 -6
  315. package/dist/components/Reactions/StreamEmoji.d.ts +1 -1
  316. package/dist/components/Reactions/hooks/useFetchReactions.d.ts +9 -10
  317. package/dist/components/Reactions/hooks/useProcessReactions.d.ts +1 -2
  318. package/dist/components/Reactions/types.d.ts +3 -4
  319. package/dist/components/Reactions/utils/utils.d.ts +1 -1
  320. package/dist/components/SafeAnchor/SafeAnchor.d.ts +2 -1
  321. package/dist/components/{CommandItem → TextareaComposer/SuggestionList}/CommandItem.d.ts +2 -1
  322. package/dist/components/{CommandItem → TextareaComposer/SuggestionList}/CommandItem.js +1 -2
  323. package/dist/components/{EmoticonItem → TextareaComposer/SuggestionList}/EmoticonItem.d.ts +7 -7
  324. package/dist/components/TextareaComposer/SuggestionList/EmoticonItem.js +12 -0
  325. package/dist/components/TextareaComposer/SuggestionList/SuggestionList.d.ts +16 -0
  326. package/dist/components/TextareaComposer/SuggestionList/SuggestionList.js +49 -0
  327. package/dist/components/TextareaComposer/SuggestionList/SuggestionListItem.d.ts +18 -0
  328. package/dist/components/TextareaComposer/SuggestionList/SuggestionListItem.js +25 -0
  329. package/dist/components/{UserItem → TextareaComposer/SuggestionList}/UserItem.d.ts +7 -4
  330. package/dist/components/TextareaComposer/SuggestionList/UserItem.js +24 -0
  331. package/dist/components/TextareaComposer/SuggestionList/index.d.ts +5 -0
  332. package/dist/components/TextareaComposer/SuggestionList/index.js +5 -0
  333. package/dist/components/TextareaComposer/TextareaComposer.d.ts +13 -0
  334. package/dist/components/TextareaComposer/TextareaComposer.js +155 -0
  335. package/dist/components/TextareaComposer/index.d.ts +2 -0
  336. package/dist/components/TextareaComposer/index.js +2 -0
  337. package/dist/components/Thread/Thread.d.ts +13 -10
  338. package/dist/components/Thread/Thread.js +23 -12
  339. package/dist/components/Thread/ThreadHead.d.ts +2 -3
  340. package/dist/components/Thread/ThreadHeader.d.ts +5 -6
  341. package/dist/components/Thread/ThreadHeader.js +1 -1
  342. package/dist/components/Threads/ThreadContext.d.ts +2 -2
  343. package/dist/components/Threads/ThreadContext.js +1 -4
  344. package/dist/components/Threads/ThreadList/ThreadList.d.ts +1 -1
  345. package/dist/components/Threads/ThreadList/ThreadListItem.d.ts +1 -1
  346. package/dist/components/Threads/hooks/useThreadManagerState.d.ts +1 -1
  347. package/dist/components/Threads/hooks/useThreadState.d.ts +1 -1
  348. package/dist/components/Threads/icons.d.ts +1 -1
  349. package/dist/components/Tooltip/Tooltip.d.ts +3 -2
  350. package/dist/components/Tooltip/hooks/useEnterLeaveHandlers.d.ts +1 -1
  351. package/dist/components/TypingIndicator/TypingIndicator.d.ts +1 -2
  352. package/dist/components/Window/Window.d.ts +6 -6
  353. package/dist/components/index.d.ts +1 -5
  354. package/dist/components/index.js +1 -5
  355. package/dist/context/AttachmentSelectorContext.d.ts +2 -1
  356. package/dist/context/ChannelActionContext.d.ts +26 -35
  357. package/dist/context/ChannelListContext.d.ts +9 -9
  358. package/dist/context/ChannelListContext.js +1 -1
  359. package/dist/context/ChannelStateContext.d.ts +24 -34
  360. package/dist/context/ChatContext.d.ts +18 -17
  361. package/dist/context/ComponentContext.d.ts +39 -37
  362. package/dist/context/DialogManagerContext.d.ts +2 -1
  363. package/dist/context/MessageBounceContext.d.ts +8 -7
  364. package/dist/context/MessageBounceContext.js +1 -1
  365. package/dist/context/MessageContext.d.ts +23 -23
  366. package/dist/context/MessageInputContext.d.ts +8 -26
  367. package/dist/context/MessageInputContext.js +3 -2
  368. package/dist/context/MessageListContext.d.ts +2 -1
  369. package/dist/context/PollContext.d.ts +8 -8
  370. package/dist/context/TranslationContext.d.ts +2 -1
  371. package/dist/context/TypingContext.d.ts +11 -10
  372. package/dist/context/VirtualizedMessageListContext.d.ts +2 -1
  373. package/dist/context/WithComponents.d.ts +3 -2
  374. package/dist/css/v2/index.css +1 -1
  375. package/dist/css/v2/index.layout.css +1 -1
  376. package/dist/experimental/MessageActions/MessageActions.d.ts +1 -1
  377. package/dist/experimental/MessageActions/MessageActions.js +1 -1
  378. package/dist/experimental/MessageActions/defaults.js +4 -3
  379. package/dist/experimental/Search/Search.d.ts +1 -2
  380. package/dist/experimental/Search/SearchContext.d.ts +8 -8
  381. package/dist/experimental/Search/SearchResults/SearchResultItem.d.ts +11 -11
  382. package/dist/experimental/Search/SearchResults/SearchResultItem.js +3 -3
  383. package/dist/experimental/Search/SearchResults/SearchResults.d.ts +1 -2
  384. package/dist/experimental/Search/SearchResults/SearchResultsHeader.d.ts +1 -2
  385. package/dist/experimental/Search/SearchResults/SearchResultsHeader.js +1 -1
  386. package/dist/experimental/Search/SearchResults/SearchSourceResultList.d.ts +2 -3
  387. package/dist/experimental/Search/SearchResults/SearchSourceResultListFooter.d.ts +1 -2
  388. package/dist/experimental/Search/SearchResults/SearchSourceResults.d.ts +1 -2
  389. package/dist/experimental/Search/SearchResults/SearchSourceResults.js +1 -1
  390. package/dist/experimental/Search/SearchSourceResultsContext.d.ts +2 -1
  391. package/dist/experimental/Search/hooks/useSearchFocusedMessage.d.ts +1 -2
  392. package/dist/experimental/Search/hooks/useSearchFocusedMessage.js +3 -1
  393. package/dist/experimental/Search/hooks/useSearchQueriesInProgress.d.ts +3 -4
  394. package/dist/experimental/index.browser.cjs +1139 -1075
  395. package/dist/experimental/index.browser.cjs.map +4 -4
  396. package/dist/experimental/index.node.cjs +1139 -1075
  397. package/dist/experimental/index.node.cjs.map +4 -4
  398. package/dist/i18n/Streami18n.d.ts +1 -1
  399. package/dist/i18n/types.d.ts +2 -2
  400. package/dist/i18n/utils.d.ts +1 -1
  401. package/dist/i18n/utils.js +3 -1
  402. package/dist/index.browser.cjs +28545 -30631
  403. package/dist/index.browser.cjs.map +4 -4
  404. package/dist/index.node.cjs +30774 -32868
  405. package/dist/index.node.cjs.map +4 -4
  406. package/dist/plugins/Emojis/index.browser.cjs +133 -5
  407. package/dist/plugins/Emojis/index.browser.cjs.map +4 -4
  408. package/dist/plugins/Emojis/index.d.ts +1 -0
  409. package/dist/plugins/Emojis/index.js +1 -0
  410. package/dist/plugins/Emojis/index.node.cjs +135 -6
  411. package/dist/plugins/Emojis/index.node.cjs.map +4 -4
  412. package/dist/plugins/Emojis/middleware/index.d.ts +1 -0
  413. package/dist/plugins/Emojis/middleware/index.js +1 -0
  414. package/dist/plugins/Emojis/middleware/textComposerEmojiMiddleware.d.ts +66 -0
  415. package/dist/plugins/Emojis/middleware/textComposerEmojiMiddleware.js +143 -0
  416. package/dist/plugins/encoders/mp3.browser.cjs.map +2 -2
  417. package/dist/plugins/encoders/mp3.node.cjs.map +2 -2
  418. package/dist/scss/v2/Autocomplete/Autocomplete-layout.scss +14 -0
  419. package/dist/scss/v2/Autocomplete/Autocomplete-theme.scss +11 -0
  420. package/dist/scss/v2/DropzoneContainer/DropzoneContainer-layout.scss +14 -0
  421. package/dist/scss/v2/DropzoneContainer/DropzoneContainer-theme.scss +17 -0
  422. package/dist/scss/v2/LinkPreview/LinkPreview-layout.scss +18 -0
  423. package/dist/scss/v2/LinkPreview/LinkPreview-theme.scss +15 -0
  424. package/dist/scss/v2/MessageInput/MessageInput-layout.scss +0 -13
  425. package/dist/scss/v2/MessageInput/MessageInput-theme.scss +8 -19
  426. package/dist/scss/v2/index.layout.scss +2 -1
  427. package/dist/scss/v2/index.scss +1 -0
  428. package/dist/types/defaultDataInterfaces.d.ts +25 -0
  429. package/dist/types/index.d.ts +2 -1
  430. package/dist/types/types.d.ts +2 -62
  431. package/dist/utils/getChannel.d.ts +5 -6
  432. package/dist/utils/mergeDeep.d.ts +2 -3
  433. package/package.json +5 -5
  434. package/dist/components/AutoCompleteTextarea/Item.d.ts +0 -2
  435. package/dist/components/AutoCompleteTextarea/Item.js +0 -10
  436. package/dist/components/AutoCompleteTextarea/List.d.ts +0 -17
  437. package/dist/components/AutoCompleteTextarea/List.js +0 -89
  438. package/dist/components/AutoCompleteTextarea/Textarea.d.ts +0 -114
  439. package/dist/components/AutoCompleteTextarea/Textarea.js +0 -593
  440. package/dist/components/AutoCompleteTextarea/index.d.ts +0 -4
  441. package/dist/components/AutoCompleteTextarea/index.js +0 -4
  442. package/dist/components/AutoCompleteTextarea/types.d.ts +0 -15
  443. package/dist/components/AutoCompleteTextarea/utils.d.ts +0 -6
  444. package/dist/components/AutoCompleteTextarea/utils.js +0 -40
  445. package/dist/components/ChatAutoComplete/ChatAutoComplete.d.ts +0 -78
  446. package/dist/components/ChatAutoComplete/ChatAutoComplete.js +0 -33
  447. package/dist/components/ChatAutoComplete/index.d.ts +0 -1
  448. package/dist/components/ChatAutoComplete/index.js +0 -1
  449. package/dist/components/CommandItem/index.d.ts +0 -1
  450. package/dist/components/CommandItem/index.js +0 -1
  451. package/dist/components/EmoticonItem/EmoticonItem.js +0 -16
  452. package/dist/components/EmoticonItem/index.d.ts +0 -1
  453. package/dist/components/EmoticonItem/index.js +0 -1
  454. package/dist/components/MessageInput/DefaultTriggerProvider.d.ts +0 -35
  455. package/dist/components/MessageInput/DefaultTriggerProvider.js +0 -24
  456. package/dist/components/MessageInput/DropzoneProvider.d.ts +0 -4
  457. package/dist/components/MessageInput/DropzoneProvider.js +0 -23
  458. package/dist/components/MessageInput/hooks/useAttachments.d.ts +0 -14
  459. package/dist/components/MessageInput/hooks/useAttachments.js +0 -209
  460. package/dist/components/MessageInput/hooks/useCommandTrigger.d.ts +0 -3
  461. package/dist/components/MessageInput/hooks/useCommandTrigger.js +0 -62
  462. package/dist/components/MessageInput/hooks/useEmojiTrigger.d.ts +0 -3
  463. package/dist/components/MessageInput/hooks/useEmojiTrigger.js +0 -29
  464. package/dist/components/MessageInput/hooks/useLinkPreviews.d.ts +0 -30
  465. package/dist/components/MessageInput/hooks/useLinkPreviews.js +0 -109
  466. package/dist/components/MessageInput/hooks/useMessageInputState.d.ts +0 -71
  467. package/dist/components/MessageInput/hooks/useMessageInputState.js +0 -200
  468. package/dist/components/MessageInput/hooks/useUserTrigger.d.ts +0 -12
  469. package/dist/components/MessageInput/hooks/useUserTrigger.js +0 -130
  470. package/dist/components/MessageInput/types.d.ts +0 -87
  471. package/dist/components/MessageInput/types.js +0 -19
  472. package/dist/components/ReactFileUtilities/ImageDropzone.d.ts +0 -16
  473. package/dist/components/ReactFileUtilities/ImageDropzone.js +0 -42
  474. package/dist/components/UserItem/UserItem.js +0 -26
  475. package/dist/components/UserItem/index.d.ts +0 -1
  476. package/dist/components/UserItem/index.js +0 -1
  477. /package/dist/components/{MessageInput → MediaRecorder/AudioRecorder}/hooks/useTimeElapsed.d.ts +0 -0
  478. /package/dist/components/{MessageInput → MediaRecorder/AudioRecorder}/hooks/useTimeElapsed.js +0 -0
  479. /package/dist/scss/v2/DragAndDropContainer/{DragAmdDropContainer-layout.scss → DragAndDropContainer-layout.scss} +0 -0
  480. /package/dist/{components/AutoCompleteTextarea/types.js → types/defaultDataInterfaces.js} +0 -0
@@ -0,0 +1,143 @@
1
+ import mergeWith from 'lodash.mergewith';
2
+ import { BaseSearchSource, getTokenizedSuggestionDisplayName, getTriggerCharWithToken, insertItemWithTrigger, replaceWordWithEntity, } from 'stream-chat';
3
+ class EmojiSearchSource extends BaseSearchSource {
4
+ constructor(emojiSearchIndex, options) {
5
+ super(options);
6
+ this.type = 'emoji';
7
+ this.emojiSearchIndex = emojiSearchIndex;
8
+ }
9
+ async query(searchQuery) {
10
+ if (searchQuery.length === 0) {
11
+ return { items: [], next: null };
12
+ }
13
+ const emojis = (await this.emojiSearchIndex.search(searchQuery)) ?? [];
14
+ // emojiIndex.search sometimes returns undefined values, so filter those out first
15
+ return {
16
+ items: emojis
17
+ .filter(Boolean)
18
+ .slice(0, 7)
19
+ .map(({ emoticons = [], id, name, native, skins = [] }) => {
20
+ const [firstSkin] = skins;
21
+ return {
22
+ emoticons,
23
+ id,
24
+ name,
25
+ native: native ?? firstSkin.native,
26
+ };
27
+ }),
28
+ next: null, // todo: generate cursor
29
+ };
30
+ }
31
+ filterQueryResults(items) {
32
+ return items.map((item) => ({
33
+ ...item,
34
+ ...getTokenizedSuggestionDisplayName({
35
+ displayName: item.id,
36
+ searchToken: this.searchQuery,
37
+ }),
38
+ }));
39
+ }
40
+ }
41
+ const DEFAULT_OPTIONS = { minChars: 1, trigger: ':' };
42
+ /**
43
+ * TextComposer middleware for mentions
44
+ * Usage:
45
+ *
46
+ * const textComposer = new TextComposer(options);
47
+ *
48
+ * textComposer.use(new createTextComposerEmojiMiddleware(emojiSearchIndex, {
49
+ * minChars: 2
50
+ * }));
51
+ *
52
+ * @param emojiSearchIndex
53
+ * @param {{
54
+ * minChars: number;
55
+ * trigger: string;
56
+ * }} options
57
+ * @returns
58
+ */
59
+ export const createTextComposerEmojiMiddleware = (emojiSearchIndex, options) => {
60
+ const finalOptions = mergeWith(DEFAULT_OPTIONS, options ?? {});
61
+ const emojiSearchSource = new EmojiSearchSource(emojiSearchIndex);
62
+ emojiSearchSource.activate();
63
+ return {
64
+ id: 'stream-io/emoji-middleware',
65
+ onChange: async ({ input, nextHandler }) => {
66
+ const { state } = input;
67
+ if (!state.selection)
68
+ return nextHandler(input);
69
+ const triggerWithToken = getTriggerCharWithToken({
70
+ acceptTrailingSpaces: false,
71
+ text: state.text.slice(0, state.selection.end),
72
+ trigger: finalOptions.trigger,
73
+ });
74
+ const triggerWasRemoved = !triggerWithToken || triggerWithToken.length < finalOptions.minChars;
75
+ if (triggerWasRemoved) {
76
+ const hasSuggestionsForTrigger = input.state.suggestions?.trigger === finalOptions.trigger;
77
+ const newInput = { ...input };
78
+ if (hasSuggestionsForTrigger && newInput.state.suggestions) {
79
+ delete newInput.state.suggestions;
80
+ }
81
+ return nextHandler(newInput);
82
+ }
83
+ const newSearchTriggerred = triggerWithToken && triggerWithToken === finalOptions.trigger;
84
+ if (newSearchTriggerred) {
85
+ emojiSearchSource.resetStateAndActivate();
86
+ }
87
+ const textWithReplacedWord = await replaceWordWithEntity({
88
+ caretPosition: state.selection.end,
89
+ getEntityString: async (word) => {
90
+ const { items } = await emojiSearchSource.query(word);
91
+ const emoji = items
92
+ .filter(Boolean)
93
+ .slice(0, 10)
94
+ .find(({ emoticons }) => !!emoticons?.includes(word));
95
+ if (!emoji)
96
+ return null;
97
+ const [firstSkin] = emoji.skins ?? [];
98
+ return emoji.native ?? firstSkin.native;
99
+ },
100
+ text: state.text,
101
+ });
102
+ if (textWithReplacedWord !== state.text) {
103
+ return {
104
+ state: {
105
+ ...state,
106
+ suggestions: undefined, // to prevent the TextComposerMiddlewareExecutor to run the first page query
107
+ text: textWithReplacedWord,
108
+ },
109
+ stop: true, // Stop other middleware from processing '@' character
110
+ };
111
+ }
112
+ return {
113
+ state: {
114
+ ...state,
115
+ suggestions: {
116
+ query: triggerWithToken.slice(1),
117
+ searchSource: emojiSearchSource,
118
+ trigger: finalOptions.trigger,
119
+ },
120
+ },
121
+ stop: true, // Stop other middleware from processing '@' character
122
+ };
123
+ },
124
+ onSuggestionItemSelect: ({ input, nextHandler, selectedSuggestion, }) => {
125
+ const { state } = input;
126
+ if (!selectedSuggestion || state.suggestions?.trigger !== finalOptions.trigger)
127
+ return nextHandler(input);
128
+ emojiSearchSource.resetStateAndActivate();
129
+ return Promise.resolve({
130
+ state: {
131
+ ...state,
132
+ ...insertItemWithTrigger({
133
+ insertText: `${'native' in selectedSuggestion ? selectedSuggestion.native : ''} `,
134
+ selection: state.selection,
135
+ text: state.text,
136
+ trigger: finalOptions.trigger,
137
+ }),
138
+ suggestions: undefined, // Clear suggestions after selection
139
+ },
140
+ });
141
+ },
142
+ };
143
+ };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/encoders/mp3.ts", "../../../src/components/ReactFileUtilities/utils.ts", "../../../src/components/MediaRecorder/transcode/audioProcessing.ts"],
4
- "sourcesContent": ["import {\n renderAudio,\n toAudioBuffer,\n} from '../../components/MediaRecorder/transcode/audioProcessing';\n\nconst ENCODING_BIT_RATE = 128; // kbps;\nconst COUNT_SAMPLES_PER_ENCODED_BLOCK = 1152;\n\nconst float32ArrayToInt16Array = (float32Arr: Float32Array) => {\n const int16Arr = new Int16Array(float32Arr.length);\n for (let i = 0; i < float32Arr.length; i++) {\n const float32Value = float32Arr[i];\n // Clamp the float value between -1 and 1\n const clampedValue = Math.max(-1, Math.min(1, float32Value));\n // Convert the float value to a signed 16-bit integer\n int16Arr[i] = Math.round(clampedValue * 32767);\n }\n return int16Arr;\n};\n\nconst splitDataByChannel = (audioBuffer: AudioBuffer) =>\n Array.from({ length: audioBuffer.numberOfChannels }, (_, i) =>\n audioBuffer.getChannelData(i),\n ).map(float32ArrayToInt16Array);\n\nexport async function encodeToMp3(file: File, sampleRate: number) {\n const lameJs = await import('@breezystack/lamejs');\n const audioBuffer = await renderAudio(await toAudioBuffer(file), sampleRate);\n const channelCount = audioBuffer.numberOfChannels;\n const dataByChannel = splitDataByChannel(audioBuffer);\n const mp3Encoder = new lameJs.Mp3Encoder(channelCount, sampleRate, ENCODING_BIT_RATE);\n\n const dataBuffer: Int8Array[] = [];\n let remaining = dataByChannel[0].length;\n for (\n let i = 0;\n remaining >= COUNT_SAMPLES_PER_ENCODED_BLOCK;\n i += COUNT_SAMPLES_PER_ENCODED_BLOCK\n ) {\n const [leftChannelBlock, rightChannelBlock] = dataByChannel.map((channel) =>\n channel.subarray(i, i + COUNT_SAMPLES_PER_ENCODED_BLOCK),\n );\n dataBuffer.push(\n new Int8Array(mp3Encoder.encodeBuffer(leftChannelBlock, rightChannelBlock)),\n );\n remaining -= COUNT_SAMPLES_PER_ENCODED_BLOCK;\n }\n\n const lastBlock = mp3Encoder.flush();\n if (lastBlock.length) dataBuffer.push(new Int8Array(lastBlock));\n return new Blob(dataBuffer, { type: 'audio/mp3;sbu_type=voice' });\n}\n", "import { FileLike, RecordedMediaType } from './types';\nimport { ChangeEvent, useCallback } from 'react';\n\nexport const useHandleFileChangeWrapper = (\n resetOnChange = false,\n handler?: (files: Array<File>) => void,\n) =>\n useCallback(\n ({ currentTarget }: ChangeEvent<HTMLInputElement>) => {\n const { files } = currentTarget;\n\n if (!files) return;\n\n try {\n handler?.(Array.from(files));\n } catch (error) {\n console.error(error);\n }\n\n if (resetOnChange) currentTarget.value = '';\n },\n [handler, resetOnChange],\n );\n\nexport function dataTransferItemsHaveFiles(items?: DataTransferItem[]): boolean {\n if (!items || !items.length) {\n return false;\n }\n for (const item of items) {\n if (item.kind === 'file' || item.type === 'text/html') {\n return true;\n }\n }\n return false;\n}\n\nexport async function dataTransferItemsToFiles(\n items?: DataTransferItem[],\n): Promise<FileLike[]> {\n if (!items || !items.length) {\n return [];\n }\n\n // If there are files inside the DataTransferItem prefer those\n const fileLikes = getFileLikes(items);\n if (fileLikes.length) {\n return fileLikes;\n }\n\n // Otherwise extract images from html\n const blobPromises = [];\n for (const item of items) {\n if (item.type === 'text/html') {\n blobPromises.push(\n new Promise<void>((accept) => {\n item.getAsString(async (s) => {\n const imagePromises = extractImageSources(s).map((src) =>\n getImageSource(fileLikes, src),\n );\n\n await Promise.all(imagePromises);\n accept();\n });\n }),\n );\n }\n }\n await Promise.all(blobPromises);\n return fileLikes;\n}\n\nfunction getFileLikes(items: DataTransferItem[]) {\n const fileLikes = [];\n for (const item of items) {\n if (item.kind === 'file') {\n const file = item.getAsFile();\n if (file) {\n fileLikes.push(file);\n }\n }\n }\n return fileLikes;\n}\n\nasync function getImageSource(fileLikes: FileLike[], src: string) {\n let res;\n try {\n res = await fetch(src);\n } catch (e) {\n return;\n }\n const contentType = res.headers.get('Content-type') || 'application/octet-stream';\n const buf = await res.arrayBuffer();\n const blob = new Blob([buf], { type: contentType });\n fileLikes.push(blob);\n}\n\nconst extractImageSources = (s: string) => {\n const imageTags = new DOMParser()\n .parseFromString(s, 'text/html')\n .getElementsByTagName('img');\n return Array.from(imageTags, (tag) => tag.src).filter((tag) => tag);\n};\n\nexport const isBlobButNotFile = (obj: unknown): obj is Blob =>\n obj instanceof Blob && !(obj instanceof File);\n\nexport const createFileFromBlobs = ({\n blobsArray,\n fileName,\n mimeType,\n}: {\n blobsArray: Blob[];\n fileName: string;\n mimeType: string;\n}) => {\n const concatenatedBlob = new Blob(blobsArray, { type: mimeType });\n return new File([concatenatedBlob], fileName, { type: concatenatedBlob.type });\n};\n\nexport const getExtensionFromMimeType = (mimeType: string) => {\n const match = mimeType.match(/\\/([^/;]+)/);\n return match && match[1];\n};\n\nexport const getRecordedMediaTypeFromMimeType = (\n mimeType: string,\n): RecordedMediaType | null => {\n const match = mimeType.match(/^(audio|video)\\/.*$/);\n return match && (match[1] as RecordedMediaType);\n};\n\nexport const readFileAsArrayBuffer = (file: File): Promise<ArrayBuffer> =>\n new Promise((resolve, reject) => {\n const fileReader = new FileReader();\n fileReader.onload = () => {\n resolve(fileReader.result as ArrayBuffer);\n };\n\n fileReader.onerror = () => {\n reject(fileReader.error);\n };\n\n fileReader.readAsArrayBuffer(file);\n });\n\nexport const generateFileName = (mimeType: string) =>\n `file_${new Date().toISOString()}.${getExtensionFromMimeType(mimeType)}`;\n", "import { readFileAsArrayBuffer } from '../../ReactFileUtilities';\n\n/**\n * In the context of resampling audio data, AudioContext is used to decode the input audio file into an AudioBuffer,\n * which is a fundamental data structure representing audio data.\n * @param file\n */\nexport const toAudioBuffer = async (file: File) => {\n const audioCtx = new AudioContext();\n\n const arrayBuffer = await readFileAsArrayBuffer(file);\n const decodedData = await audioCtx.decodeAudioData(arrayBuffer);\n if (audioCtx.state !== 'closed') await audioCtx.close();\n return decodedData;\n};\n\n/**\n * OfflineAudioContext is a specialized type of AudioContext that does not render audio in real-time and is used for offline audio processing tasks.\n * It allows performing audio processing and rendering without actually playing the audio through speakers or outputting it to a destination.\n * In the context of resampling audio data, OfflineAudioContext is used to resample the decoded AudioBuffer from a file to the desired sample rate.\n * It provides more flexibility and control over audio processing, as it can operate at different sample rates and durations compared to real-time audio contexts.\n * @param audioBuffer\n * @param sampleRate\n */\nexport const renderAudio = async (audioBuffer: AudioBuffer, sampleRate: number) => {\n const offlineAudioCtx = new OfflineAudioContext(\n audioBuffer.numberOfChannels,\n audioBuffer.duration * sampleRate,\n sampleRate,\n );\n const source = offlineAudioCtx.createBufferSource();\n source.buffer = audioBuffer;\n source.connect(offlineAudioCtx.destination);\n source.start();\n\n return await offlineAudioCtx.startRendering();\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAAyC;AAmIlC,IAAM,wBAAwB,CAAC,SACpC,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,QAAM,aAAa,IAAI,WAAW;AAClC,aAAW,SAAS,MAAM;AACxB,YAAQ,WAAW,MAAqB;AAAA,EAC1C;AAEA,aAAW,UAAU,MAAM;AACzB,WAAO,WAAW,KAAK;AAAA,EACzB;AAEA,aAAW,kBAAkB,IAAI;AACnC,CAAC;;;ACzII,IAAM,gBAAgB,OAAO,SAAe;AACjD,QAAM,WAAW,IAAI,aAAa;AAElC,QAAM,cAAc,MAAM,sBAAsB,IAAI;AACpD,QAAM,cAAc,MAAM,SAAS,gBAAgB,WAAW;AAC9D,MAAI,SAAS,UAAU,SAAU,OAAM,SAAS,MAAM;AACtD,SAAO;AACT;AAUO,IAAM,cAAc,OAAO,aAA0B,eAAuB;AACjF,QAAM,kBAAkB,IAAI;AAAA,IAC1B,YAAY;AAAA,IACZ,YAAY,WAAW;AAAA,IACvB;AAAA,EACF;AACA,QAAM,SAAS,gBAAgB,mBAAmB;AAClD,SAAO,SAAS;AAChB,SAAO,QAAQ,gBAAgB,WAAW;AAC1C,SAAO,MAAM;AAEb,SAAO,MAAM,gBAAgB,eAAe;AAC9C;;;AF/BA,IAAM,oBAAoB;AAC1B,IAAM,kCAAkC;AAExC,IAAM,2BAA2B,CAAC,eAA6B;AAC7D,QAAM,WAAW,IAAI,WAAW,WAAW,MAAM;AACjD,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,eAAe,WAAW,CAAC;AAEjC,UAAM,eAAe,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,YAAY,CAAC;AAE3D,aAAS,CAAC,IAAI,KAAK,MAAM,eAAe,KAAK;AAAA,EAC/C;AACA,SAAO;AACT;AAEA,IAAM,qBAAqB,CAAC,gBAC1B,MAAM;AAAA,EAAK,EAAE,QAAQ,YAAY,iBAAiB;AAAA,EAAG,CAAC,GAAG,MACvD,YAAY,eAAe,CAAC;AAC9B,EAAE,IAAI,wBAAwB;AAEhC,eAAsB,YAAY,MAAY,YAAoB;AAChE,QAAM,SAAS,MAAM,OAAO,qBAAqB;AACjD,QAAM,cAAc,MAAM,YAAY,MAAM,cAAc,IAAI,GAAG,UAAU;AAC3E,QAAM,eAAe,YAAY;AACjC,QAAM,gBAAgB,mBAAmB,WAAW;AACpD,QAAM,aAAa,IAAI,OAAO,WAAW,cAAc,YAAY,iBAAiB;AAEpF,QAAM,aAA0B,CAAC;AACjC,MAAI,YAAY,cAAc,CAAC,EAAE;AACjC,WACM,IAAI,GACR,aAAa,iCACb,KAAK,iCACL;AACA,UAAM,CAAC,kBAAkB,iBAAiB,IAAI,cAAc;AAAA,MAAI,CAAC,YAC/D,QAAQ,SAAS,GAAG,IAAI,+BAA+B;AAAA,IACzD;AACA,eAAW;AAAA,MACT,IAAI,UAAU,WAAW,aAAa,kBAAkB,iBAAiB,CAAC;AAAA,IAC5E;AACA,iBAAa;AAAA,EACf;AAEA,QAAM,YAAY,WAAW,MAAM;AACnC,MAAI,UAAU,OAAQ,YAAW,KAAK,IAAI,UAAU,SAAS,CAAC;AAC9D,SAAO,IAAI,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAClE;",
4
+ "sourcesContent": ["import {\n renderAudio,\n toAudioBuffer,\n} from '../../components/MediaRecorder/transcode/audioProcessing';\n\nconst ENCODING_BIT_RATE = 128; // kbps;\nconst COUNT_SAMPLES_PER_ENCODED_BLOCK = 1152;\n\nconst float32ArrayToInt16Array = (float32Arr: Float32Array) => {\n const int16Arr = new Int16Array(float32Arr.length);\n for (let i = 0; i < float32Arr.length; i++) {\n const float32Value = float32Arr[i];\n // Clamp the float value between -1 and 1\n const clampedValue = Math.max(-1, Math.min(1, float32Value));\n // Convert the float value to a signed 16-bit integer\n int16Arr[i] = Math.round(clampedValue * 32767);\n }\n return int16Arr;\n};\n\nconst splitDataByChannel = (audioBuffer: AudioBuffer) =>\n Array.from({ length: audioBuffer.numberOfChannels }, (_, i) =>\n audioBuffer.getChannelData(i),\n ).map(float32ArrayToInt16Array);\n\nexport async function encodeToMp3(file: File, sampleRate: number) {\n const lameJs = await import('@breezystack/lamejs');\n const audioBuffer = await renderAudio(await toAudioBuffer(file), sampleRate);\n const channelCount = audioBuffer.numberOfChannels;\n const dataByChannel = splitDataByChannel(audioBuffer);\n const mp3Encoder = new lameJs.Mp3Encoder(channelCount, sampleRate, ENCODING_BIT_RATE);\n\n const dataBuffer: Int8Array[] = [];\n let remaining = dataByChannel[0].length;\n for (\n let i = 0;\n remaining >= COUNT_SAMPLES_PER_ENCODED_BLOCK;\n i += COUNT_SAMPLES_PER_ENCODED_BLOCK\n ) {\n const [leftChannelBlock, rightChannelBlock] = dataByChannel.map((channel) =>\n channel.subarray(i, i + COUNT_SAMPLES_PER_ENCODED_BLOCK),\n );\n dataBuffer.push(\n new Int8Array(mp3Encoder.encodeBuffer(leftChannelBlock, rightChannelBlock)),\n );\n remaining -= COUNT_SAMPLES_PER_ENCODED_BLOCK;\n }\n\n const lastBlock = mp3Encoder.flush();\n if (lastBlock.length) dataBuffer.push(new Int8Array(lastBlock));\n return new Blob(dataBuffer, { type: 'audio/mp3;sbu_type=voice' });\n}\n", "import type { FileLike, RecordedMediaType } from './types';\nimport type { ChangeEvent } from 'react';\nimport { useCallback } from 'react';\n\nexport const useHandleFileChangeWrapper = (\n resetOnChange = false,\n handler?: (files: Array<File>) => void,\n) =>\n useCallback(\n ({ currentTarget }: ChangeEvent<HTMLInputElement>) => {\n const { files } = currentTarget;\n\n if (!files) return;\n\n try {\n handler?.(Array.from(files));\n } catch (error) {\n console.error(error);\n }\n\n if (resetOnChange) currentTarget.value = '';\n },\n [handler, resetOnChange],\n );\n\nexport function dataTransferItemsHaveFiles(items?: DataTransferItem[]): boolean {\n if (!items || !items.length) {\n return false;\n }\n for (const item of items) {\n if (item.kind === 'file' || item.type === 'text/html') {\n return true;\n }\n }\n return false;\n}\n\nexport async function dataTransferItemsToFiles(\n items?: DataTransferItem[],\n): Promise<FileLike[]> {\n if (!items || !items.length) {\n return [];\n }\n\n // If there are files inside the DataTransferItem prefer those\n const fileLikes = getFileLikes(items);\n if (fileLikes.length) {\n return fileLikes;\n }\n\n // Otherwise extract images from html\n const blobPromises = [];\n for (const item of items) {\n if (item.type === 'text/html') {\n blobPromises.push(\n new Promise<void>((accept) => {\n item.getAsString(async (s) => {\n const imagePromises = extractImageSources(s).map((src) =>\n getImageSource(fileLikes, src),\n );\n\n await Promise.all(imagePromises);\n accept();\n });\n }),\n );\n }\n }\n await Promise.all(blobPromises);\n return fileLikes;\n}\n\nfunction getFileLikes(items: DataTransferItem[]) {\n const fileLikes = [];\n for (const item of items) {\n if (item.kind === 'file') {\n const file = item.getAsFile();\n if (file) {\n fileLikes.push(file);\n }\n }\n }\n return fileLikes;\n}\n\nasync function getImageSource(fileLikes: FileLike[], src: string) {\n let res;\n try {\n res = await fetch(src);\n } catch (e) {\n return;\n }\n const contentType = res.headers.get('Content-type') || 'application/octet-stream';\n const buf = await res.arrayBuffer();\n const blob = new Blob([buf], { type: contentType });\n fileLikes.push(blob);\n}\n\nconst extractImageSources = (s: string) => {\n const imageTags = new DOMParser()\n .parseFromString(s, 'text/html')\n .getElementsByTagName('img');\n return Array.from(imageTags, (tag) => tag.src).filter((tag) => tag);\n};\n\nexport const isBlobButNotFile = (obj: unknown): obj is Blob =>\n obj instanceof Blob && !(obj instanceof File);\n\nexport const createFileFromBlobs = ({\n blobsArray,\n fileName,\n mimeType,\n}: {\n blobsArray: Blob[];\n fileName: string;\n mimeType: string;\n}) => {\n const concatenatedBlob = new Blob(blobsArray, { type: mimeType });\n return new File([concatenatedBlob], fileName, { type: concatenatedBlob.type });\n};\n\nexport const getExtensionFromMimeType = (mimeType: string) => {\n const match = mimeType.match(/\\/([^/;]+)/);\n return match && match[1];\n};\n\nexport const getRecordedMediaTypeFromMimeType = (\n mimeType: string,\n): RecordedMediaType | null => {\n const match = mimeType.match(/^(audio|video)\\/.*$/);\n return match && (match[1] as RecordedMediaType);\n};\n\nexport const readFileAsArrayBuffer = (file: File): Promise<ArrayBuffer> =>\n new Promise((resolve, reject) => {\n const fileReader = new FileReader();\n fileReader.onload = () => {\n resolve(fileReader.result as ArrayBuffer);\n };\n\n fileReader.onerror = () => {\n reject(fileReader.error);\n };\n\n fileReader.readAsArrayBuffer(file);\n });\n\nexport const generateFileName = (mimeType: string) =>\n `file_${new Date().toISOString()}.${getExtensionFromMimeType(mimeType)}`;\n", "import { readFileAsArrayBuffer } from '../../ReactFileUtilities';\n\n/**\n * In the context of resampling audio data, AudioContext is used to decode the input audio file into an AudioBuffer,\n * which is a fundamental data structure representing audio data.\n * @param file\n */\nexport const toAudioBuffer = async (file: File) => {\n const audioCtx = new AudioContext();\n\n const arrayBuffer = await readFileAsArrayBuffer(file);\n const decodedData = await audioCtx.decodeAudioData(arrayBuffer);\n if (audioCtx.state !== 'closed') await audioCtx.close();\n return decodedData;\n};\n\n/**\n * OfflineAudioContext is a specialized type of AudioContext that does not render audio in real-time and is used for offline audio processing tasks.\n * It allows performing audio processing and rendering without actually playing the audio through speakers or outputting it to a destination.\n * In the context of resampling audio data, OfflineAudioContext is used to resample the decoded AudioBuffer from a file to the desired sample rate.\n * It provides more flexibility and control over audio processing, as it can operate at different sample rates and durations compared to real-time audio contexts.\n * @param audioBuffer\n * @param sampleRate\n */\nexport const renderAudio = async (audioBuffer: AudioBuffer, sampleRate: number) => {\n const offlineAudioCtx = new OfflineAudioContext(\n audioBuffer.numberOfChannels,\n audioBuffer.duration * sampleRate,\n sampleRate,\n );\n const source = offlineAudioCtx.createBufferSource();\n source.buffer = audioBuffer;\n source.connect(offlineAudioCtx.destination);\n source.start();\n\n return await offlineAudioCtx.startRendering();\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAA4B;AAmIrB,IAAM,wBAAwB,CAAC,SACpC,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,QAAM,aAAa,IAAI,WAAW;AAClC,aAAW,SAAS,MAAM;AACxB,YAAQ,WAAW,MAAqB;AAAA,EAC1C;AAEA,aAAW,UAAU,MAAM;AACzB,WAAO,WAAW,KAAK;AAAA,EACzB;AAEA,aAAW,kBAAkB,IAAI;AACnC,CAAC;;;AC1II,IAAM,gBAAgB,OAAO,SAAe;AACjD,QAAM,WAAW,IAAI,aAAa;AAElC,QAAM,cAAc,MAAM,sBAAsB,IAAI;AACpD,QAAM,cAAc,MAAM,SAAS,gBAAgB,WAAW;AAC9D,MAAI,SAAS,UAAU,SAAU,OAAM,SAAS,MAAM;AACtD,SAAO;AACT;AAUO,IAAM,cAAc,OAAO,aAA0B,eAAuB;AACjF,QAAM,kBAAkB,IAAI;AAAA,IAC1B,YAAY;AAAA,IACZ,YAAY,WAAW;AAAA,IACvB;AAAA,EACF;AACA,QAAM,SAAS,gBAAgB,mBAAmB;AAClD,SAAO,SAAS;AAChB,SAAO,QAAQ,gBAAgB,WAAW;AAC1C,SAAO,MAAM;AAEb,SAAO,MAAM,gBAAgB,eAAe;AAC9C;;;AF/BA,IAAM,oBAAoB;AAC1B,IAAM,kCAAkC;AAExC,IAAM,2BAA2B,CAAC,eAA6B;AAC7D,QAAM,WAAW,IAAI,WAAW,WAAW,MAAM;AACjD,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,eAAe,WAAW,CAAC;AAEjC,UAAM,eAAe,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,YAAY,CAAC;AAE3D,aAAS,CAAC,IAAI,KAAK,MAAM,eAAe,KAAK;AAAA,EAC/C;AACA,SAAO;AACT;AAEA,IAAM,qBAAqB,CAAC,gBAC1B,MAAM;AAAA,EAAK,EAAE,QAAQ,YAAY,iBAAiB;AAAA,EAAG,CAAC,GAAG,MACvD,YAAY,eAAe,CAAC;AAC9B,EAAE,IAAI,wBAAwB;AAEhC,eAAsB,YAAY,MAAY,YAAoB;AAChE,QAAM,SAAS,MAAM,OAAO,qBAAqB;AACjD,QAAM,cAAc,MAAM,YAAY,MAAM,cAAc,IAAI,GAAG,UAAU;AAC3E,QAAM,eAAe,YAAY;AACjC,QAAM,gBAAgB,mBAAmB,WAAW;AACpD,QAAM,aAAa,IAAI,OAAO,WAAW,cAAc,YAAY,iBAAiB;AAEpF,QAAM,aAA0B,CAAC;AACjC,MAAI,YAAY,cAAc,CAAC,EAAE;AACjC,WACM,IAAI,GACR,aAAa,iCACb,KAAK,iCACL;AACA,UAAM,CAAC,kBAAkB,iBAAiB,IAAI,cAAc;AAAA,MAAI,CAAC,YAC/D,QAAQ,SAAS,GAAG,IAAI,+BAA+B;AAAA,IACzD;AACA,eAAW;AAAA,MACT,IAAI,UAAU,WAAW,aAAa,kBAAkB,iBAAiB,CAAC;AAAA,IAC5E;AACA,iBAAa;AAAA,EACf;AAEA,QAAM,YAAY,WAAW,MAAM;AACnC,MAAI,UAAU,OAAQ,YAAW,KAAK,IAAI,UAAU,SAAS,CAAC;AAC9D,SAAO,IAAI,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAClE;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/encoders/mp3.ts", "../../../src/components/ReactFileUtilities/utils.ts", "../../../src/components/MediaRecorder/transcode/audioProcessing.ts"],
4
- "sourcesContent": ["import {\n renderAudio,\n toAudioBuffer,\n} from '../../components/MediaRecorder/transcode/audioProcessing';\n\nconst ENCODING_BIT_RATE = 128; // kbps;\nconst COUNT_SAMPLES_PER_ENCODED_BLOCK = 1152;\n\nconst float32ArrayToInt16Array = (float32Arr: Float32Array) => {\n const int16Arr = new Int16Array(float32Arr.length);\n for (let i = 0; i < float32Arr.length; i++) {\n const float32Value = float32Arr[i];\n // Clamp the float value between -1 and 1\n const clampedValue = Math.max(-1, Math.min(1, float32Value));\n // Convert the float value to a signed 16-bit integer\n int16Arr[i] = Math.round(clampedValue * 32767);\n }\n return int16Arr;\n};\n\nconst splitDataByChannel = (audioBuffer: AudioBuffer) =>\n Array.from({ length: audioBuffer.numberOfChannels }, (_, i) =>\n audioBuffer.getChannelData(i),\n ).map(float32ArrayToInt16Array);\n\nexport async function encodeToMp3(file: File, sampleRate: number) {\n const lameJs = await import('@breezystack/lamejs');\n const audioBuffer = await renderAudio(await toAudioBuffer(file), sampleRate);\n const channelCount = audioBuffer.numberOfChannels;\n const dataByChannel = splitDataByChannel(audioBuffer);\n const mp3Encoder = new lameJs.Mp3Encoder(channelCount, sampleRate, ENCODING_BIT_RATE);\n\n const dataBuffer: Int8Array[] = [];\n let remaining = dataByChannel[0].length;\n for (\n let i = 0;\n remaining >= COUNT_SAMPLES_PER_ENCODED_BLOCK;\n i += COUNT_SAMPLES_PER_ENCODED_BLOCK\n ) {\n const [leftChannelBlock, rightChannelBlock] = dataByChannel.map((channel) =>\n channel.subarray(i, i + COUNT_SAMPLES_PER_ENCODED_BLOCK),\n );\n dataBuffer.push(\n new Int8Array(mp3Encoder.encodeBuffer(leftChannelBlock, rightChannelBlock)),\n );\n remaining -= COUNT_SAMPLES_PER_ENCODED_BLOCK;\n }\n\n const lastBlock = mp3Encoder.flush();\n if (lastBlock.length) dataBuffer.push(new Int8Array(lastBlock));\n return new Blob(dataBuffer, { type: 'audio/mp3;sbu_type=voice' });\n}\n", "import { FileLike, RecordedMediaType } from './types';\nimport { ChangeEvent, useCallback } from 'react';\n\nexport const useHandleFileChangeWrapper = (\n resetOnChange = false,\n handler?: (files: Array<File>) => void,\n) =>\n useCallback(\n ({ currentTarget }: ChangeEvent<HTMLInputElement>) => {\n const { files } = currentTarget;\n\n if (!files) return;\n\n try {\n handler?.(Array.from(files));\n } catch (error) {\n console.error(error);\n }\n\n if (resetOnChange) currentTarget.value = '';\n },\n [handler, resetOnChange],\n );\n\nexport function dataTransferItemsHaveFiles(items?: DataTransferItem[]): boolean {\n if (!items || !items.length) {\n return false;\n }\n for (const item of items) {\n if (item.kind === 'file' || item.type === 'text/html') {\n return true;\n }\n }\n return false;\n}\n\nexport async function dataTransferItemsToFiles(\n items?: DataTransferItem[],\n): Promise<FileLike[]> {\n if (!items || !items.length) {\n return [];\n }\n\n // If there are files inside the DataTransferItem prefer those\n const fileLikes = getFileLikes(items);\n if (fileLikes.length) {\n return fileLikes;\n }\n\n // Otherwise extract images from html\n const blobPromises = [];\n for (const item of items) {\n if (item.type === 'text/html') {\n blobPromises.push(\n new Promise<void>((accept) => {\n item.getAsString(async (s) => {\n const imagePromises = extractImageSources(s).map((src) =>\n getImageSource(fileLikes, src),\n );\n\n await Promise.all(imagePromises);\n accept();\n });\n }),\n );\n }\n }\n await Promise.all(blobPromises);\n return fileLikes;\n}\n\nfunction getFileLikes(items: DataTransferItem[]) {\n const fileLikes = [];\n for (const item of items) {\n if (item.kind === 'file') {\n const file = item.getAsFile();\n if (file) {\n fileLikes.push(file);\n }\n }\n }\n return fileLikes;\n}\n\nasync function getImageSource(fileLikes: FileLike[], src: string) {\n let res;\n try {\n res = await fetch(src);\n } catch (e) {\n return;\n }\n const contentType = res.headers.get('Content-type') || 'application/octet-stream';\n const buf = await res.arrayBuffer();\n const blob = new Blob([buf], { type: contentType });\n fileLikes.push(blob);\n}\n\nconst extractImageSources = (s: string) => {\n const imageTags = new DOMParser()\n .parseFromString(s, 'text/html')\n .getElementsByTagName('img');\n return Array.from(imageTags, (tag) => tag.src).filter((tag) => tag);\n};\n\nexport const isBlobButNotFile = (obj: unknown): obj is Blob =>\n obj instanceof Blob && !(obj instanceof File);\n\nexport const createFileFromBlobs = ({\n blobsArray,\n fileName,\n mimeType,\n}: {\n blobsArray: Blob[];\n fileName: string;\n mimeType: string;\n}) => {\n const concatenatedBlob = new Blob(blobsArray, { type: mimeType });\n return new File([concatenatedBlob], fileName, { type: concatenatedBlob.type });\n};\n\nexport const getExtensionFromMimeType = (mimeType: string) => {\n const match = mimeType.match(/\\/([^/;]+)/);\n return match && match[1];\n};\n\nexport const getRecordedMediaTypeFromMimeType = (\n mimeType: string,\n): RecordedMediaType | null => {\n const match = mimeType.match(/^(audio|video)\\/.*$/);\n return match && (match[1] as RecordedMediaType);\n};\n\nexport const readFileAsArrayBuffer = (file: File): Promise<ArrayBuffer> =>\n new Promise((resolve, reject) => {\n const fileReader = new FileReader();\n fileReader.onload = () => {\n resolve(fileReader.result as ArrayBuffer);\n };\n\n fileReader.onerror = () => {\n reject(fileReader.error);\n };\n\n fileReader.readAsArrayBuffer(file);\n });\n\nexport const generateFileName = (mimeType: string) =>\n `file_${new Date().toISOString()}.${getExtensionFromMimeType(mimeType)}`;\n", "import { readFileAsArrayBuffer } from '../../ReactFileUtilities';\n\n/**\n * In the context of resampling audio data, AudioContext is used to decode the input audio file into an AudioBuffer,\n * which is a fundamental data structure representing audio data.\n * @param file\n */\nexport const toAudioBuffer = async (file: File) => {\n const audioCtx = new AudioContext();\n\n const arrayBuffer = await readFileAsArrayBuffer(file);\n const decodedData = await audioCtx.decodeAudioData(arrayBuffer);\n if (audioCtx.state !== 'closed') await audioCtx.close();\n return decodedData;\n};\n\n/**\n * OfflineAudioContext is a specialized type of AudioContext that does not render audio in real-time and is used for offline audio processing tasks.\n * It allows performing audio processing and rendering without actually playing the audio through speakers or outputting it to a destination.\n * In the context of resampling audio data, OfflineAudioContext is used to resample the decoded AudioBuffer from a file to the desired sample rate.\n * It provides more flexibility and control over audio processing, as it can operate at different sample rates and durations compared to real-time audio contexts.\n * @param audioBuffer\n * @param sampleRate\n */\nexport const renderAudio = async (audioBuffer: AudioBuffer, sampleRate: number) => {\n const offlineAudioCtx = new OfflineAudioContext(\n audioBuffer.numberOfChannels,\n audioBuffer.duration * sampleRate,\n sampleRate,\n );\n const source = offlineAudioCtx.createBufferSource();\n source.buffer = audioBuffer;\n source.connect(offlineAudioCtx.destination);\n source.start();\n\n return await offlineAudioCtx.startRendering();\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAAyC;AAmIlC,IAAM,wBAAwB,CAAC,SACpC,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,QAAM,aAAa,IAAI,WAAW;AAClC,aAAW,SAAS,MAAM;AACxB,YAAQ,WAAW,MAAqB;AAAA,EAC1C;AAEA,aAAW,UAAU,MAAM;AACzB,WAAO,WAAW,KAAK;AAAA,EACzB;AAEA,aAAW,kBAAkB,IAAI;AACnC,CAAC;;;ACzII,IAAM,gBAAgB,OAAO,SAAe;AACjD,QAAM,WAAW,IAAI,aAAa;AAElC,QAAM,cAAc,MAAM,sBAAsB,IAAI;AACpD,QAAM,cAAc,MAAM,SAAS,gBAAgB,WAAW;AAC9D,MAAI,SAAS,UAAU,SAAU,OAAM,SAAS,MAAM;AACtD,SAAO;AACT;AAUO,IAAM,cAAc,OAAO,aAA0B,eAAuB;AACjF,QAAM,kBAAkB,IAAI;AAAA,IAC1B,YAAY;AAAA,IACZ,YAAY,WAAW;AAAA,IACvB;AAAA,EACF;AACA,QAAM,SAAS,gBAAgB,mBAAmB;AAClD,SAAO,SAAS;AAChB,SAAO,QAAQ,gBAAgB,WAAW;AAC1C,SAAO,MAAM;AAEb,SAAO,MAAM,gBAAgB,eAAe;AAC9C;;;AF/BA,IAAM,oBAAoB;AAC1B,IAAM,kCAAkC;AAExC,IAAM,2BAA2B,CAAC,eAA6B;AAC7D,QAAM,WAAW,IAAI,WAAW,WAAW,MAAM;AACjD,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,eAAe,WAAW,CAAC;AAEjC,UAAM,eAAe,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,YAAY,CAAC;AAE3D,aAAS,CAAC,IAAI,KAAK,MAAM,eAAe,KAAK;AAAA,EAC/C;AACA,SAAO;AACT;AAEA,IAAM,qBAAqB,CAAC,gBAC1B,MAAM;AAAA,EAAK,EAAE,QAAQ,YAAY,iBAAiB;AAAA,EAAG,CAAC,GAAG,MACvD,YAAY,eAAe,CAAC;AAC9B,EAAE,IAAI,wBAAwB;AAEhC,eAAsB,YAAY,MAAY,YAAoB;AAChE,QAAM,SAAS,MAAM,OAAO,qBAAqB;AACjD,QAAM,cAAc,MAAM,YAAY,MAAM,cAAc,IAAI,GAAG,UAAU;AAC3E,QAAM,eAAe,YAAY;AACjC,QAAM,gBAAgB,mBAAmB,WAAW;AACpD,QAAM,aAAa,IAAI,OAAO,WAAW,cAAc,YAAY,iBAAiB;AAEpF,QAAM,aAA0B,CAAC;AACjC,MAAI,YAAY,cAAc,CAAC,EAAE;AACjC,WACM,IAAI,GACR,aAAa,iCACb,KAAK,iCACL;AACA,UAAM,CAAC,kBAAkB,iBAAiB,IAAI,cAAc;AAAA,MAAI,CAAC,YAC/D,QAAQ,SAAS,GAAG,IAAI,+BAA+B;AAAA,IACzD;AACA,eAAW;AAAA,MACT,IAAI,UAAU,WAAW,aAAa,kBAAkB,iBAAiB,CAAC;AAAA,IAC5E;AACA,iBAAa;AAAA,EACf;AAEA,QAAM,YAAY,WAAW,MAAM;AACnC,MAAI,UAAU,OAAQ,YAAW,KAAK,IAAI,UAAU,SAAS,CAAC;AAC9D,SAAO,IAAI,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAClE;",
4
+ "sourcesContent": ["import {\n renderAudio,\n toAudioBuffer,\n} from '../../components/MediaRecorder/transcode/audioProcessing';\n\nconst ENCODING_BIT_RATE = 128; // kbps;\nconst COUNT_SAMPLES_PER_ENCODED_BLOCK = 1152;\n\nconst float32ArrayToInt16Array = (float32Arr: Float32Array) => {\n const int16Arr = new Int16Array(float32Arr.length);\n for (let i = 0; i < float32Arr.length; i++) {\n const float32Value = float32Arr[i];\n // Clamp the float value between -1 and 1\n const clampedValue = Math.max(-1, Math.min(1, float32Value));\n // Convert the float value to a signed 16-bit integer\n int16Arr[i] = Math.round(clampedValue * 32767);\n }\n return int16Arr;\n};\n\nconst splitDataByChannel = (audioBuffer: AudioBuffer) =>\n Array.from({ length: audioBuffer.numberOfChannels }, (_, i) =>\n audioBuffer.getChannelData(i),\n ).map(float32ArrayToInt16Array);\n\nexport async function encodeToMp3(file: File, sampleRate: number) {\n const lameJs = await import('@breezystack/lamejs');\n const audioBuffer = await renderAudio(await toAudioBuffer(file), sampleRate);\n const channelCount = audioBuffer.numberOfChannels;\n const dataByChannel = splitDataByChannel(audioBuffer);\n const mp3Encoder = new lameJs.Mp3Encoder(channelCount, sampleRate, ENCODING_BIT_RATE);\n\n const dataBuffer: Int8Array[] = [];\n let remaining = dataByChannel[0].length;\n for (\n let i = 0;\n remaining >= COUNT_SAMPLES_PER_ENCODED_BLOCK;\n i += COUNT_SAMPLES_PER_ENCODED_BLOCK\n ) {\n const [leftChannelBlock, rightChannelBlock] = dataByChannel.map((channel) =>\n channel.subarray(i, i + COUNT_SAMPLES_PER_ENCODED_BLOCK),\n );\n dataBuffer.push(\n new Int8Array(mp3Encoder.encodeBuffer(leftChannelBlock, rightChannelBlock)),\n );\n remaining -= COUNT_SAMPLES_PER_ENCODED_BLOCK;\n }\n\n const lastBlock = mp3Encoder.flush();\n if (lastBlock.length) dataBuffer.push(new Int8Array(lastBlock));\n return new Blob(dataBuffer, { type: 'audio/mp3;sbu_type=voice' });\n}\n", "import type { FileLike, RecordedMediaType } from './types';\nimport type { ChangeEvent } from 'react';\nimport { useCallback } from 'react';\n\nexport const useHandleFileChangeWrapper = (\n resetOnChange = false,\n handler?: (files: Array<File>) => void,\n) =>\n useCallback(\n ({ currentTarget }: ChangeEvent<HTMLInputElement>) => {\n const { files } = currentTarget;\n\n if (!files) return;\n\n try {\n handler?.(Array.from(files));\n } catch (error) {\n console.error(error);\n }\n\n if (resetOnChange) currentTarget.value = '';\n },\n [handler, resetOnChange],\n );\n\nexport function dataTransferItemsHaveFiles(items?: DataTransferItem[]): boolean {\n if (!items || !items.length) {\n return false;\n }\n for (const item of items) {\n if (item.kind === 'file' || item.type === 'text/html') {\n return true;\n }\n }\n return false;\n}\n\nexport async function dataTransferItemsToFiles(\n items?: DataTransferItem[],\n): Promise<FileLike[]> {\n if (!items || !items.length) {\n return [];\n }\n\n // If there are files inside the DataTransferItem prefer those\n const fileLikes = getFileLikes(items);\n if (fileLikes.length) {\n return fileLikes;\n }\n\n // Otherwise extract images from html\n const blobPromises = [];\n for (const item of items) {\n if (item.type === 'text/html') {\n blobPromises.push(\n new Promise<void>((accept) => {\n item.getAsString(async (s) => {\n const imagePromises = extractImageSources(s).map((src) =>\n getImageSource(fileLikes, src),\n );\n\n await Promise.all(imagePromises);\n accept();\n });\n }),\n );\n }\n }\n await Promise.all(blobPromises);\n return fileLikes;\n}\n\nfunction getFileLikes(items: DataTransferItem[]) {\n const fileLikes = [];\n for (const item of items) {\n if (item.kind === 'file') {\n const file = item.getAsFile();\n if (file) {\n fileLikes.push(file);\n }\n }\n }\n return fileLikes;\n}\n\nasync function getImageSource(fileLikes: FileLike[], src: string) {\n let res;\n try {\n res = await fetch(src);\n } catch (e) {\n return;\n }\n const contentType = res.headers.get('Content-type') || 'application/octet-stream';\n const buf = await res.arrayBuffer();\n const blob = new Blob([buf], { type: contentType });\n fileLikes.push(blob);\n}\n\nconst extractImageSources = (s: string) => {\n const imageTags = new DOMParser()\n .parseFromString(s, 'text/html')\n .getElementsByTagName('img');\n return Array.from(imageTags, (tag) => tag.src).filter((tag) => tag);\n};\n\nexport const isBlobButNotFile = (obj: unknown): obj is Blob =>\n obj instanceof Blob && !(obj instanceof File);\n\nexport const createFileFromBlobs = ({\n blobsArray,\n fileName,\n mimeType,\n}: {\n blobsArray: Blob[];\n fileName: string;\n mimeType: string;\n}) => {\n const concatenatedBlob = new Blob(blobsArray, { type: mimeType });\n return new File([concatenatedBlob], fileName, { type: concatenatedBlob.type });\n};\n\nexport const getExtensionFromMimeType = (mimeType: string) => {\n const match = mimeType.match(/\\/([^/;]+)/);\n return match && match[1];\n};\n\nexport const getRecordedMediaTypeFromMimeType = (\n mimeType: string,\n): RecordedMediaType | null => {\n const match = mimeType.match(/^(audio|video)\\/.*$/);\n return match && (match[1] as RecordedMediaType);\n};\n\nexport const readFileAsArrayBuffer = (file: File): Promise<ArrayBuffer> =>\n new Promise((resolve, reject) => {\n const fileReader = new FileReader();\n fileReader.onload = () => {\n resolve(fileReader.result as ArrayBuffer);\n };\n\n fileReader.onerror = () => {\n reject(fileReader.error);\n };\n\n fileReader.readAsArrayBuffer(file);\n });\n\nexport const generateFileName = (mimeType: string) =>\n `file_${new Date().toISOString()}.${getExtensionFromMimeType(mimeType)}`;\n", "import { readFileAsArrayBuffer } from '../../ReactFileUtilities';\n\n/**\n * In the context of resampling audio data, AudioContext is used to decode the input audio file into an AudioBuffer,\n * which is a fundamental data structure representing audio data.\n * @param file\n */\nexport const toAudioBuffer = async (file: File) => {\n const audioCtx = new AudioContext();\n\n const arrayBuffer = await readFileAsArrayBuffer(file);\n const decodedData = await audioCtx.decodeAudioData(arrayBuffer);\n if (audioCtx.state !== 'closed') await audioCtx.close();\n return decodedData;\n};\n\n/**\n * OfflineAudioContext is a specialized type of AudioContext that does not render audio in real-time and is used for offline audio processing tasks.\n * It allows performing audio processing and rendering without actually playing the audio through speakers or outputting it to a destination.\n * In the context of resampling audio data, OfflineAudioContext is used to resample the decoded AudioBuffer from a file to the desired sample rate.\n * It provides more flexibility and control over audio processing, as it can operate at different sample rates and durations compared to real-time audio contexts.\n * @param audioBuffer\n * @param sampleRate\n */\nexport const renderAudio = async (audioBuffer: AudioBuffer, sampleRate: number) => {\n const offlineAudioCtx = new OfflineAudioContext(\n audioBuffer.numberOfChannels,\n audioBuffer.duration * sampleRate,\n sampleRate,\n );\n const source = offlineAudioCtx.createBufferSource();\n source.buffer = audioBuffer;\n source.connect(offlineAudioCtx.destination);\n source.start();\n\n return await offlineAudioCtx.startRendering();\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,mBAA4B;AAmIrB,IAAM,wBAAwB,CAAC,SACpC,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,QAAM,aAAa,IAAI,WAAW;AAClC,aAAW,SAAS,MAAM;AACxB,YAAQ,WAAW,MAAqB;AAAA,EAC1C;AAEA,aAAW,UAAU,MAAM;AACzB,WAAO,WAAW,KAAK;AAAA,EACzB;AAEA,aAAW,kBAAkB,IAAI;AACnC,CAAC;;;AC1II,IAAM,gBAAgB,OAAO,SAAe;AACjD,QAAM,WAAW,IAAI,aAAa;AAElC,QAAM,cAAc,MAAM,sBAAsB,IAAI;AACpD,QAAM,cAAc,MAAM,SAAS,gBAAgB,WAAW;AAC9D,MAAI,SAAS,UAAU,SAAU,OAAM,SAAS,MAAM;AACtD,SAAO;AACT;AAUO,IAAM,cAAc,OAAO,aAA0B,eAAuB;AACjF,QAAM,kBAAkB,IAAI;AAAA,IAC1B,YAAY;AAAA,IACZ,YAAY,WAAW;AAAA,IACvB;AAAA,EACF;AACA,QAAM,SAAS,gBAAgB,mBAAmB;AAClD,SAAO,SAAS;AAChB,SAAO,QAAQ,gBAAgB,WAAW;AAC1C,SAAO,MAAM;AAEb,SAAO,MAAM,gBAAgB,eAAe;AAC9C;;;AF/BA,IAAM,oBAAoB;AAC1B,IAAM,kCAAkC;AAExC,IAAM,2BAA2B,CAAC,eAA6B;AAC7D,QAAM,WAAW,IAAI,WAAW,WAAW,MAAM;AACjD,WAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK;AAC1C,UAAM,eAAe,WAAW,CAAC;AAEjC,UAAM,eAAe,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,YAAY,CAAC;AAE3D,aAAS,CAAC,IAAI,KAAK,MAAM,eAAe,KAAK;AAAA,EAC/C;AACA,SAAO;AACT;AAEA,IAAM,qBAAqB,CAAC,gBAC1B,MAAM;AAAA,EAAK,EAAE,QAAQ,YAAY,iBAAiB;AAAA,EAAG,CAAC,GAAG,MACvD,YAAY,eAAe,CAAC;AAC9B,EAAE,IAAI,wBAAwB;AAEhC,eAAsB,YAAY,MAAY,YAAoB;AAChE,QAAM,SAAS,MAAM,OAAO,qBAAqB;AACjD,QAAM,cAAc,MAAM,YAAY,MAAM,cAAc,IAAI,GAAG,UAAU;AAC3E,QAAM,eAAe,YAAY;AACjC,QAAM,gBAAgB,mBAAmB,WAAW;AACpD,QAAM,aAAa,IAAI,OAAO,WAAW,cAAc,YAAY,iBAAiB;AAEpF,QAAM,aAA0B,CAAC;AACjC,MAAI,YAAY,cAAc,CAAC,EAAE;AACjC,WACM,IAAI,GACR,aAAa,iCACb,KAAK,iCACL;AACA,UAAM,CAAC,kBAAkB,iBAAiB,IAAI,cAAc;AAAA,MAAI,CAAC,YAC/D,QAAQ,SAAS,GAAG,IAAI,+BAA+B;AAAA,IACzD;AACA,eAAW;AAAA,MACT,IAAI,UAAU,WAAW,aAAa,kBAAkB,iBAAiB,CAAC;AAAA,IAC5E;AACA,iBAAa;AAAA,EACf;AAEA,QAAM,YAAY,WAAW,MAAM;AACnC,MAAI,UAAU,OAAQ,YAAW,KAAK,IAAI,UAAU,SAAS,CAAC;AAC9D,SAAO,IAAI,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAClE;",
6
6
  "names": []
7
7
  }
@@ -38,6 +38,16 @@
38
38
  padding: unset;
39
39
  margin: unset;
40
40
  }
41
+
42
+ .str-chat__suggestion-list--react {
43
+ overflow-y: unset;
44
+
45
+ .str-chat__suggestion-list-item {
46
+ > button {
47
+ width: 100%;
48
+ }
49
+ }
50
+ }
41
51
  }
42
52
 
43
53
  .str-chat__slash-command {
@@ -58,6 +68,8 @@
58
68
  .str-chat__user-item--name {
59
69
  @include utils.ellipsis-text;
60
70
  @include utils.prevent-glitch-text-overflow;
71
+ display: flex;
72
+ align-items: center;
61
73
  width: 100%;
62
74
  }
63
75
  }
@@ -69,6 +81,8 @@
69
81
 
70
82
  .str-chat__emoji-item--name {
71
83
  @include utils.ellipsis-text;
84
+ display: flex;
85
+ align-items: center;
72
86
  width: 100%;
73
87
  }
74
88
  }
@@ -156,6 +156,8 @@
156
156
 
157
157
  .str-chat__slash-command {
158
158
  @include utils.component-layer-overrides('slash-command');
159
+ text-align: left;
160
+ font: var(--str-chat__subtitle-text);
159
161
 
160
162
  .str-chat__slash-command-header {
161
163
  .str-chat__slash-command-name {
@@ -206,4 +208,13 @@
206
208
  background-color: var(--str-chat__suggestion-list-item--selected-background-color);
207
209
  }
208
210
  }
211
+
212
+ .str-chat__suggestion-list--react {
213
+ .str-chat__suggestion-list-item {
214
+ > button {
215
+ @include utils.button-reset;
216
+ text-decoration: none;
217
+ }
218
+ }
219
+ }
209
220
  }
@@ -0,0 +1,14 @@
1
+ @use '../utils';
2
+
3
+ .str-chat__dropzone-container {
4
+ @include utils.flex-row-center;
5
+
6
+ position: absolute;
7
+ height: 100%;
8
+ width: 100%;
9
+ z-index: 5;
10
+
11
+ p {
12
+ margin: unset;
13
+ }
14
+ }
@@ -0,0 +1,17 @@
1
+ .str-chat {
2
+ /* The text/icon color of the dropzone container */
3
+ --str-chat__dropzone-container-color: var(--str-chat__on-primary-color);
4
+
5
+ /* The background color of the dropzone container */
6
+ --str-chat__dropzone-container-background-color: var(--str-chat__primary-overlay-color);
7
+
8
+ /* The backdrop filter applied to the dropzone container */
9
+ --str-chat__dropzone-container-backdrop-filter: blur(3px);
10
+ }
11
+
12
+ .str-chat__dropzone-container {
13
+ background-color: var(--str-chat__dropzone-container-background-color);
14
+ color: var(--str-chat__dropzone-container-color);
15
+ backdrop-filter: var(--str-chat__dropzone-container-backdrop-filter);
16
+ font: var(--str-chat__subtitle-text);
17
+ }
@@ -46,4 +46,22 @@
46
46
  @include utils.button-reset;
47
47
  cursor: pointer;
48
48
  }
49
+ }
50
+
51
+ .str-chat__link-preview-card--loading {
52
+ .str-chat__link-preview-card__content {
53
+ display: flex;
54
+ flex-direction: column;
55
+ gap: 0.25rem;
56
+
57
+ .str-chat__link-preview-card__content-title {
58
+ height: calc(var(--str-chat__spacing-px) * 16);
59
+ width: 100%
60
+ }
61
+
62
+ .str-chat__link-preview-card__content-description {
63
+ height: calc(var(--str-chat__spacing-px) * 12);
64
+ width: 100%;
65
+ }
66
+ }
49
67
  }
@@ -1,3 +1,9 @@
1
+ @use '../utils';
2
+
3
+ .str-chat {
4
+ --str-chat__link-preview-loading-state-color: var(--str-chat__disabled-color);
5
+ }
6
+
1
7
  .str-chat__link-preview-card {
2
8
  .str-chat__link-preview-card__content {
3
9
  border-left: 2px solid var(--str-chat__primary-color);
@@ -14,4 +20,13 @@
14
20
  .str-chat__link-preview-card__dismiss-button svg path {
15
21
  fill: var(--str-chat__text-low-emphasis-color);
16
22
  }
23
+ }
24
+
25
+ .str-chat__link-preview-card--loading {
26
+ .str-chat__link-preview-card__content-title,
27
+ .str-chat__link-preview-card__content-description {
28
+ @include utils.loading-item-background('link-preview');
29
+ @include utils.loading-animation;
30
+ border-radius: calc(var(--str-chat__spacing-px) * 3);
31
+ }
17
32
  }
@@ -26,19 +26,6 @@
26
26
  }
27
27
  }
28
28
 
29
- .str-chat__dropzone-container {
30
- @include utils.flex-row-center;
31
-
32
- position: absolute;
33
- height: 100%;
34
- width: 100%;
35
- z-index: 5;
36
-
37
- p {
38
- margin: unset;
39
- }
40
- }
41
-
42
29
  .str-chat__message-input-inner {
43
30
  flex-grow: 1;
44
31
  width: 100%;
@@ -25,15 +25,6 @@
25
25
  /* Box shadow applied to the component */
26
26
  --str-chat__message-input-box-shadow: none;
27
27
 
28
- /* The text/icon color of the dropzone container */
29
- --str-chat__dropzone-container-color: var(--str-chat__on-primary-color);
30
-
31
- /* The background color of the dropzone container */
32
- --str-chat__dropzone-container-background-color: var(--str-chat__primary-overlay-color);
33
-
34
- /* The backdrop filter applied to the dropzone container */
35
- --str-chat__dropzone-container-backdrop-filter: blur(3px);
36
-
37
28
  /* The border radius used for the borders of the textarea */
38
29
  --str-chat__message-textarea-border-radius: var(--str-chat__border-radius-md);
39
30
 
@@ -179,19 +170,14 @@
179
170
  --str-chat__attachment-selector-actions-menu-button-icon-color: var(--str-chat__primary-color);
180
171
 
181
172
  /* Color applied to an attachment selector menu item icon when hovered over or focused */
182
- --str-chat__attachment-selector-actions-menu-button-icon-color-active: var(--str-chat__primary-color);
173
+ --str-chat__attachment-selector-actions-menu-button-icon-color-active: var(
174
+ --str-chat__primary-color
175
+ );
183
176
  }
184
177
 
185
178
  .str-chat__message-input {
186
179
  @include utils.component-layer-overrides('message-input');
187
180
 
188
- .str-chat__dropzone-container {
189
- background-color: var(--str-chat__dropzone-container-background-color);
190
- color: var(--str-chat__dropzone-container-color);
191
- backdrop-filter: var(--str-chat__dropzone-container-backdrop-filter);
192
- font: var(--str-chat__subtitle-text);
193
- }
194
-
195
181
  .str-chat__file-input-container {
196
182
  --str-chat-icon-color: var(--str-chat__message-input-tools-color);
197
183
  @include utils.component-layer-overrides('message-input-tools');
@@ -326,11 +312,14 @@
326
312
  background-color: var(--str-chat__attachment-selector-actions-menu-button-icon-color);
327
313
  }
328
314
 
329
- &:hover, &:focus {
315
+ &:hover,
316
+ &:focus {
330
317
  color: var(--str-chat__text-color);
331
318
 
332
319
  .str-chat__dialog-menu__button-icon {
333
- background-color: var(--str-chat__attachment-selector-actions-menu-button-icon-color-active);
320
+ background-color: var(
321
+ --str-chat__attachment-selector-actions-menu-button-icon-color-active
322
+ );
334
323
  }
335
324
  }
336
325
  }
@@ -16,7 +16,8 @@
16
16
  @use 'common/CTAButton/CTAButton-layout';
17
17
  @use 'common/CircleFAButton/CircleFAButton-layout';
18
18
  @use 'Dialog/Dialog-layout';
19
- @use 'DragAndDropContainer/DragAmdDropContainer-layout';
19
+ @use 'DragAndDropContainer/DragAndDropContainer-layout';
20
+ @use 'DropzoneContainer/DropzoneContainer-layout';
20
21
  @use 'EditMessageForm/EditMessageForm-layout';
21
22
  @use 'Form/Form-layout';
22
23
  @use 'ImageCarousel/ImageCarousel-layout';
@@ -19,6 +19,7 @@
19
19
  @use 'ChannelSearch/ChannelSearch-theme';
20
20
  @use 'Dialog/Dialog-theme';
21
21
  @use 'DragAndDropContainer/DragAndDropContainer-theme';
22
+ @use 'DropzoneContainer/DropzoneContainer-theme';
22
23
  @use 'EditMessageForm/EditMessageForm-theme';
23
24
  @use 'Form/Form-theme';
24
25
  @use 'Icon/Icon-theme';
@@ -0,0 +1,25 @@
1
+ export interface DefaultChannelData {
2
+ image?: string;
3
+ name?: string;
4
+ subtitle?: string;
5
+ }
6
+ export interface DefaultAttachmentData {
7
+ }
8
+ export interface DefaultCommandData {
9
+ }
10
+ export interface DefaultEventData {
11
+ }
12
+ export interface DefaultMemberData {
13
+ }
14
+ export interface DefaultMessageData {
15
+ }
16
+ export interface DefaultPollOptionData {
17
+ }
18
+ export interface DefaultPollData {
19
+ }
20
+ export interface DefaultReactionData {
21
+ }
22
+ export interface DefaultUserData {
23
+ }
24
+ export interface DefaultThreadData {
25
+ }
@@ -1 +1,2 @@
1
- export type { DefaultStreamChatGenerics, ChannelUnreadUiState } from './types';
1
+ export type { ChannelUnreadUiState } from './types';
2
+ export type * from './defaultDataInterfaces';
@@ -1,57 +1,9 @@
1
1
  import type { PropsWithChildren } from 'react';
2
2
  import type { LoadingIndicatorProps } from '../components/Loading/LoadingIndicator';
3
- import type { APIErrorResponse, Attachment, ErrorFromResponse, Event, ExtendableGenerics, LiteralStringForUnion, Mute, ChannelState as StreamChannelState } from 'stream-chat';
3
+ import type { Attachment, ChannelState as StreamChannelState } from 'stream-chat';
4
4
  export type UnknownType = Record<string, unknown>;
5
5
  export type PropsWithChildrenOnly = PropsWithChildren<Record<never, never>>;
6
- export type CustomTrigger = {
7
- [key: string]: {
8
- componentProps: UnknownType;
9
- data: UnknownType;
10
- };
11
- };
12
6
  export type CustomMessageType = 'channel.intro' | 'message.date';
13
- export type DefaultAttachmentType = UnknownType & {
14
- asset_url?: string;
15
- file_size?: number;
16
- id?: string;
17
- images?: Array<{
18
- image_url?: string;
19
- thumb_url?: string;
20
- }>;
21
- };
22
- export type DefaultChannelType = UnknownType & {
23
- frozen?: boolean;
24
- image?: string;
25
- member_count?: number;
26
- subtitle?: string;
27
- };
28
- export type DefaultMessageType<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = UnknownType & {
29
- customType?: CustomMessageType;
30
- date?: string | Date;
31
- error?: ErrorFromResponse<APIErrorResponse>;
32
- errorStatusCode?: number;
33
- event?: Event<StreamChatGenerics>;
34
- unread?: boolean;
35
- };
36
- export type DefaultUserTypeInternal = {
37
- image?: string;
38
- status?: string;
39
- };
40
- export type DefaultUserType<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = UnknownType & DefaultUserTypeInternal & {
41
- mutes?: Array<Mute<StreamChatGenerics>>;
42
- };
43
- export type DefaultStreamChatGenerics = ExtendableGenerics & {
44
- attachmentType: DefaultAttachmentType;
45
- channelType: DefaultChannelType;
46
- commandType: LiteralStringForUnion;
47
- eventType: UnknownType;
48
- memberType: UnknownType;
49
- messageType: DefaultMessageType;
50
- pollOptionType: UnknownType;
51
- pollType: UnknownType;
52
- reactionType: UnknownType;
53
- userType: DefaultUserType;
54
- };
55
7
  export type GiphyVersions = 'original' | 'fixed_height' | 'fixed_height_still' | 'fixed_height_downsampled' | 'fixed_width' | 'fixed_width_still' | 'fixed_width_downsampled';
56
8
  export type PaginatorProps = {
57
9
  /** callback to load the next page */
@@ -91,19 +43,7 @@ export type VideoAttachmentConfiguration = ImageAttachmentConfiguration & {
91
43
  };
92
44
  export type ImageAttachmentSizeHandler = (attachment: Attachment, element: HTMLElement) => ImageAttachmentConfiguration;
93
45
  export type VideoAttachmentSizeHandler = (attachment: Attachment, element: HTMLElement, shouldGenerateVideoThumbnail: boolean) => VideoAttachmentConfiguration;
94
- export type ChannelUnreadUiState<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = Omit<ValuesType<StreamChannelState<StreamChatGenerics>['read']>, 'user'>;
95
- export type SendMessageOptions = {
96
- force_moderation?: boolean;
97
- is_pending_message?: boolean;
98
- keep_channel_hidden?: boolean;
99
- pending?: boolean;
100
- pending_message_metadata?: Record<string, string>;
101
- skip_enrich_url?: boolean;
102
- skip_push?: boolean;
103
- };
104
- export type UpdateMessageOptions = {
105
- skip_enrich_url?: boolean;
106
- };
46
+ export type ChannelUnreadUiState = Omit<ValuesType<StreamChannelState['read']>, 'user'>;
107
47
  export type Readable<T> = {
108
48
  [key in keyof T]: T[key];
109
49
  } & {};
@@ -1,11 +1,10 @@
1
1
  import type { Channel, ChannelQueryOptions, StreamChat } from 'stream-chat';
2
- import type { DefaultStreamChatGenerics } from '../types/types';
3
- type GetChannelParams<StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics> = {
4
- client: StreamChat<StreamChatGenerics>;
5
- channel?: Channel<StreamChatGenerics>;
2
+ type GetChannelParams = {
3
+ client: StreamChat;
4
+ channel?: Channel;
6
5
  id?: string;
7
6
  members?: string[];
8
- options?: ChannelQueryOptions<StreamChatGenerics>;
7
+ options?: ChannelQueryOptions;
9
8
  type?: string;
10
9
  };
11
10
  /**
@@ -17,5 +16,5 @@ type GetChannelParams<StreamChatGenerics extends DefaultStreamChatGenerics = Def
17
16
  * @param id
18
17
  * @param channel
19
18
  */
20
- export declare const getChannel: <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>({ channel, client, id, members, options, type, }: GetChannelParams<StreamChatGenerics>) => Promise<Channel<StreamChatGenerics>>;
19
+ export declare const getChannel: ({ channel, client, id, members, options, type, }: GetChannelParams) => Promise<Channel>;
21
20
  export {};
@@ -1,3 +1,2 @@
1
- import { UR } from 'stream-chat';
2
- export declare const mergeDeep: <TObject extends UR, TSource extends UR>(target: TObject, source: TSource) => TObject & TSource;
3
- export declare const mergeDeepUndefined: <TObject extends UR, TSource extends UR>(target: TObject, source: TSource) => TObject & TSource;
1
+ export declare const mergeDeep: <TObject, TSource>(target: TObject, source: TSource) => TObject & TSource;
2
+ export declare const mergeDeepUndefined: <TObject, TSource>(target: TObject, source: TSource) => TObject & TSource;