@weavy/uikit-react 14.0.3 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +2 -0
- package/changelog.md +10 -0
- package/dist/cjs/client/WeavyClient.d.ts +1 -0
- package/dist/cjs/components/Attachment.d.ts +5 -5
- package/dist/cjs/components/Blob.d.ts +9 -0
- package/dist/cjs/components/Comment.d.ts +18 -0
- package/dist/cjs/components/CommentCount.d.ts +7 -0
- package/dist/cjs/components/CommentEdit.d.ts +16 -0
- package/dist/cjs/components/CommentPlaceholder.d.ts +8 -0
- package/dist/cjs/components/CommentTrashed.d.ts +15 -0
- package/dist/cjs/components/CommentView.d.ts +18 -0
- package/dist/cjs/components/Comments.d.ts +8 -0
- package/dist/cjs/components/ConversationListItem.d.ts +1 -1
- package/dist/cjs/components/Dropzone.d.ts +10 -0
- package/dist/cjs/components/Editor.d.ts +25 -0
- package/dist/cjs/components/Embed.d.ts +8 -0
- package/dist/cjs/components/FileItem.d.ts +41 -0
- package/dist/cjs/components/FileList.d.ts +11 -0
- package/dist/cjs/components/FileVersions.d.ts +9 -0
- package/dist/cjs/components/Files.d.ts +4 -0
- package/dist/cjs/components/Image.d.ts +3 -3
- package/dist/cjs/components/MeetingCard.d.ts +1 -1
- package/dist/cjs/components/Meetings.d.ts +2 -1
- package/dist/cjs/components/Poll.d.ts +8 -0
- package/dist/cjs/components/PollOption.d.ts +10 -0
- package/dist/cjs/components/Post.d.ts +21 -0
- package/dist/cjs/components/PostEdit.d.ts +17 -0
- package/dist/cjs/components/PostList.d.ts +6 -0
- package/dist/cjs/components/PostPlaceholder.d.ts +8 -0
- package/dist/cjs/components/PostTrashed.d.ts +14 -0
- package/dist/cjs/components/PostView.d.ts +21 -0
- package/dist/cjs/components/Posts.d.ts +4 -0
- package/dist/cjs/components/Preview.d.ts +1 -3
- package/dist/cjs/components/PreviewFiles.d.ts +10 -0
- package/dist/cjs/components/Reactions.d.ts +6 -2
- package/dist/cjs/components/SearchUsers.d.ts +2 -1
- package/dist/cjs/contexts/CloudFilesContext.d.ts +9 -0
- package/dist/cjs/hooks/useApps.d.ts +1 -0
- package/dist/cjs/hooks/useCloudFiles.d.ts +3 -0
- package/dist/cjs/hooks/useCommentList.d.ts +1 -0
- package/dist/cjs/hooks/useEmbeds.d.ts +5 -0
- package/dist/cjs/hooks/useFileList.d.ts +1 -0
- package/dist/cjs/hooks/useFileUploader.d.ts +8 -0
- package/dist/cjs/hooks/useFileVersions.d.ts +2 -0
- package/dist/cjs/hooks/useInfiniteScroll.d.ts +4 -0
- package/dist/cjs/hooks/useIsFirstRender.d.ts +2 -0
- package/dist/cjs/hooks/useMutateApps.d.ts +5 -0
- package/dist/cjs/hooks/useMutateComment.d.ts +10 -0
- package/dist/cjs/hooks/useMutateConversationName.d.ts +1 -1
- package/dist/cjs/hooks/useMutateDeleteReaction.d.ts +3 -1
- package/dist/cjs/hooks/useMutateEditComment.d.ts +10 -0
- package/dist/cjs/hooks/useMutateEditPost.d.ts +10 -0
- package/dist/cjs/hooks/useMutateExternalBlobs.d.ts +2 -2
- package/dist/cjs/hooks/useMutateFile.d.ts +26 -0
- package/dist/cjs/hooks/useMutateFileRename.d.ts +5 -0
- package/dist/cjs/hooks/useMutateFileSubscribe.d.ts +7 -0
- package/dist/cjs/hooks/useMutateFileTrash.d.ts +10 -0
- package/dist/cjs/hooks/useMutateFileVersion.d.ts +7 -0
- package/dist/cjs/hooks/useMutateFiles.d.ts +2 -0
- package/dist/cjs/hooks/useMutateLeaveConversation.d.ts +4 -0
- package/dist/cjs/hooks/useMutateMessage.d.ts +2 -2
- package/dist/cjs/hooks/useMutatePost.d.ts +10 -0
- package/dist/cjs/hooks/useMutateReaction.d.ts +3 -1
- package/dist/cjs/hooks/useMutateRead.d.ts +1 -1
- package/dist/cjs/hooks/useMutateReplaceReaction.d.ts +6 -0
- package/dist/cjs/hooks/useMutateRestoreComment.d.ts +5 -0
- package/dist/cjs/hooks/useMutateRestorePost.d.ts +4 -0
- package/dist/cjs/hooks/useMutateStarred.d.ts +4 -0
- package/dist/cjs/hooks/useMutateSubscribe.d.ts +4 -0
- package/dist/cjs/hooks/useMutateTrashComment.d.ts +5 -0
- package/dist/cjs/hooks/useMutateTrashPost.d.ts +4 -0
- package/dist/cjs/hooks/useMutateTyping.d.ts +2 -0
- package/dist/cjs/hooks/useMutateUnsubscribe.d.ts +4 -0
- package/dist/cjs/hooks/useMutateVote.d.ts +5 -0
- package/dist/cjs/hooks/usePost.d.ts +1 -0
- package/dist/cjs/hooks/usePosts.d.ts +1 -0
- package/dist/cjs/hooks/usePostsList.d.ts +1 -0
- package/dist/cjs/hooks/useReactionList.d.ts +1 -0
- package/dist/cjs/hooks/useSessionState.d.ts +2 -0
- package/dist/cjs/hooks/useUnload.d.ts +2 -0
- package/dist/cjs/hooks/useUpdateEffect.d.ts +3 -0
- package/dist/cjs/hooks/useVotes.d.ts +1 -0
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +28 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/ConversationListItem.d.ts +1 -0
- package/dist/cjs/types/Files.d.ts +7 -0
- package/dist/cjs/types/Message.d.ts +2 -2
- package/dist/cjs/types/Posts.d.ts +4 -0
- package/dist/cjs/types/interfaces.d.ts +9 -0
- package/dist/cjs/types/types.d.ts +138 -22
- package/dist/cjs/ui/Dropdown.d.ts +18 -2
- package/dist/cjs/ui/Icon.d.ts +10 -2
- package/dist/cjs/ui/Overlay.d.ts +3 -1
- package/dist/cjs/ui/Sheet.d.ts +14 -0
- package/dist/cjs/ui/Spinner.d.ts +2 -1
- package/dist/cjs/utils/cacheUtils.d.ts +14 -0
- package/dist/cjs/utils/fileUtilities.d.ts +10 -1
- package/dist/cjs/utils/mentions.d.ts +6 -0
- package/dist/cjs/utils/openUrl.d.ts +1 -0
- package/dist/css/weavy-chat.css +637 -218
- package/dist/css/weavy-files.css +3046 -0
- package/dist/css/weavy-messenger.css +643 -213
- package/dist/css/weavy-posts.css +2773 -0
- package/dist/css/weavy.css +1749 -308
- package/dist/esm/client/WeavyClient.d.ts +1 -0
- package/dist/esm/components/Attachment.d.ts +5 -5
- package/dist/esm/components/Blob.d.ts +9 -0
- package/dist/esm/components/Comment.d.ts +18 -0
- package/dist/esm/components/CommentCount.d.ts +7 -0
- package/dist/esm/components/CommentEdit.d.ts +16 -0
- package/dist/esm/components/CommentPlaceholder.d.ts +8 -0
- package/dist/esm/components/CommentTrashed.d.ts +15 -0
- package/dist/esm/components/CommentView.d.ts +18 -0
- package/dist/esm/components/Comments.d.ts +8 -0
- package/dist/esm/components/ConversationListItem.d.ts +1 -1
- package/dist/esm/components/Dropzone.d.ts +10 -0
- package/dist/esm/components/Editor.d.ts +25 -0
- package/dist/esm/components/Embed.d.ts +8 -0
- package/dist/esm/components/FileItem.d.ts +41 -0
- package/dist/esm/components/FileList.d.ts +11 -0
- package/dist/esm/components/FileVersions.d.ts +9 -0
- package/dist/esm/components/Files.d.ts +4 -0
- package/dist/esm/components/Image.d.ts +3 -3
- package/dist/esm/components/MeetingCard.d.ts +1 -1
- package/dist/esm/components/Meetings.d.ts +2 -1
- package/dist/esm/components/Poll.d.ts +8 -0
- package/dist/esm/components/PollOption.d.ts +10 -0
- package/dist/esm/components/Post.d.ts +21 -0
- package/dist/esm/components/PostEdit.d.ts +17 -0
- package/dist/esm/components/PostList.d.ts +6 -0
- package/dist/esm/components/PostPlaceholder.d.ts +8 -0
- package/dist/esm/components/PostTrashed.d.ts +14 -0
- package/dist/esm/components/PostView.d.ts +21 -0
- package/dist/esm/components/Posts.d.ts +4 -0
- package/dist/esm/components/Preview.d.ts +1 -3
- package/dist/esm/components/PreviewFiles.d.ts +10 -0
- package/dist/esm/components/Reactions.d.ts +6 -2
- package/dist/esm/components/SearchUsers.d.ts +2 -1
- package/dist/esm/contexts/CloudFilesContext.d.ts +9 -0
- package/dist/esm/hooks/useApps.d.ts +1 -0
- package/dist/esm/hooks/useCloudFiles.d.ts +3 -0
- package/dist/esm/hooks/useCommentList.d.ts +1 -0
- package/dist/esm/hooks/useEmbeds.d.ts +5 -0
- package/dist/esm/hooks/useFileList.d.ts +1 -0
- package/dist/esm/hooks/useFileUploader.d.ts +8 -0
- package/dist/esm/hooks/useFileVersions.d.ts +2 -0
- package/dist/esm/hooks/useInfiniteScroll.d.ts +4 -0
- package/dist/esm/hooks/useIsFirstRender.d.ts +2 -0
- package/dist/esm/hooks/useMutateApps.d.ts +5 -0
- package/dist/esm/hooks/useMutateComment.d.ts +10 -0
- package/dist/esm/hooks/useMutateConversationName.d.ts +1 -1
- package/dist/esm/hooks/useMutateDeleteReaction.d.ts +3 -1
- package/dist/esm/hooks/useMutateEditComment.d.ts +10 -0
- package/dist/esm/hooks/useMutateEditPost.d.ts +10 -0
- package/dist/esm/hooks/useMutateExternalBlobs.d.ts +2 -2
- package/dist/esm/hooks/useMutateFile.d.ts +26 -0
- package/dist/esm/hooks/useMutateFileRename.d.ts +5 -0
- package/dist/esm/hooks/useMutateFileSubscribe.d.ts +7 -0
- package/dist/esm/hooks/useMutateFileTrash.d.ts +10 -0
- package/dist/esm/hooks/useMutateFileVersion.d.ts +7 -0
- package/dist/esm/hooks/useMutateFiles.d.ts +2 -0
- package/dist/esm/hooks/useMutateLeaveConversation.d.ts +4 -0
- package/dist/esm/hooks/useMutateMessage.d.ts +2 -2
- package/dist/esm/hooks/useMutatePost.d.ts +10 -0
- package/dist/esm/hooks/useMutateReaction.d.ts +3 -1
- package/dist/esm/hooks/useMutateRead.d.ts +1 -1
- package/dist/esm/hooks/useMutateReplaceReaction.d.ts +6 -0
- package/dist/esm/hooks/useMutateRestoreComment.d.ts +5 -0
- package/dist/esm/hooks/useMutateRestorePost.d.ts +4 -0
- package/dist/esm/hooks/useMutateStarred.d.ts +4 -0
- package/dist/esm/hooks/useMutateSubscribe.d.ts +4 -0
- package/dist/esm/hooks/useMutateTrashComment.d.ts +5 -0
- package/dist/esm/hooks/useMutateTrashPost.d.ts +4 -0
- package/dist/esm/hooks/useMutateTyping.d.ts +2 -0
- package/dist/esm/hooks/useMutateUnsubscribe.d.ts +4 -0
- package/dist/esm/hooks/useMutateVote.d.ts +5 -0
- package/dist/esm/hooks/usePost.d.ts +1 -0
- package/dist/esm/hooks/usePosts.d.ts +1 -0
- package/dist/esm/hooks/usePostsList.d.ts +1 -0
- package/dist/esm/hooks/useReactionList.d.ts +1 -0
- package/dist/esm/hooks/useSessionState.d.ts +2 -0
- package/dist/esm/hooks/useUnload.d.ts +2 -0
- package/dist/esm/hooks/useUpdateEffect.d.ts +3 -0
- package/dist/esm/hooks/useVotes.d.ts +1 -0
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.js +28 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/ConversationListItem.d.ts +1 -0
- package/dist/esm/types/Files.d.ts +7 -0
- package/dist/esm/types/Message.d.ts +2 -2
- package/dist/esm/types/Posts.d.ts +4 -0
- package/dist/esm/types/interfaces.d.ts +9 -0
- package/dist/esm/types/types.d.ts +138 -22
- package/dist/esm/ui/Dropdown.d.ts +18 -2
- package/dist/esm/ui/Icon.d.ts +10 -2
- package/dist/esm/ui/Overlay.d.ts +3 -1
- package/dist/esm/ui/Sheet.d.ts +14 -0
- package/dist/esm/ui/Spinner.d.ts +2 -1
- package/dist/esm/utils/cacheUtils.d.ts +14 -0
- package/dist/esm/utils/fileUtilities.d.ts +10 -1
- package/dist/esm/utils/mentions.d.ts +6 -0
- package/dist/esm/utils/openUrl.d.ts +1 -0
- package/dist/index.d.ts +50 -6
- package/package.json +8 -2
- package/src/client/WeavyClient.ts +35 -1
- package/src/components/Attachment.tsx +20 -13
- package/src/components/Blob.tsx +28 -0
- package/src/components/Comment.tsx +43 -0
- package/src/components/CommentCount.tsx +15 -0
- package/src/components/CommentEdit.tsx +48 -0
- package/src/components/CommentPlaceholder.tsx +34 -0
- package/src/components/CommentTrashed.tsx +45 -0
- package/src/components/CommentView.tsx +142 -0
- package/src/components/Comments.tsx +78 -0
- package/src/components/Conversation.tsx +85 -31
- package/src/components/ConversationList.tsx +12 -41
- package/src/components/ConversationListItem.tsx +125 -74
- package/src/components/Dropzone.tsx +26 -0
- package/src/components/Editor.tsx +700 -0
- package/src/components/Embed.tsx +80 -0
- package/src/components/FileItem.tsx +391 -0
- package/src/components/FileList.tsx +166 -0
- package/src/components/FileVersions.tsx +100 -0
- package/src/components/Files.tsx +294 -0
- package/src/components/Image.tsx +11 -10
- package/src/components/Meeting.tsx +1 -2
- package/src/components/MeetingCard.tsx +1 -1
- package/src/components/Meetings.tsx +13 -5
- package/src/components/Message.tsx +14 -19
- package/src/components/Messages.tsx +38 -64
- package/src/components/NewConversation.tsx +8 -6
- package/src/components/PdfViewer.tsx +2 -2
- package/src/components/Poll.tsx +45 -0
- package/src/components/PollOption.tsx +65 -0
- package/src/components/Post.tsx +45 -0
- package/src/components/PostEdit.tsx +49 -0
- package/src/components/PostList.tsx +95 -0
- package/src/components/PostPlaceholder.tsx +32 -0
- package/src/components/PostTrashed.tsx +35 -0
- package/src/components/PostView.tsx +194 -0
- package/src/components/Posts.tsx +59 -0
- package/src/components/Preview.tsx +16 -23
- package/src/components/PreviewFiles.tsx +336 -0
- package/src/components/Reactions.tsx +142 -38
- package/src/components/SearchUsers.tsx +77 -37
- package/src/components/Typing.tsx +1 -1
- package/src/{components/FileBrowser.tsx → contexts/CloudFilesContext.tsx} +46 -30
- package/src/contexts/PreviewContext.tsx +102 -85
- package/src/contexts/WeavyContext.tsx +10 -6
- package/src/hooks/useApps.ts +23 -0
- package/src/hooks/useCloudFiles.ts +12 -0
- package/src/hooks/useCommentList.ts +30 -0
- package/src/hooks/useEmbeds.ts +126 -0
- package/src/hooks/useEvents.ts +3 -1
- package/src/hooks/useFileList.ts +84 -0
- package/src/hooks/useFileUploader.ts +38 -1
- package/src/hooks/useFileVersions.ts +20 -0
- package/src/hooks/useInfiniteScroll.ts +45 -0
- package/src/hooks/useIsFirstRender.ts +15 -0
- package/src/hooks/useMembers.ts +3 -3
- package/src/hooks/useMutateApps.ts +48 -0
- package/src/hooks/useMutateComment.ts +60 -0
- package/src/hooks/useMutateConversationName.ts +1 -1
- package/src/hooks/useMutateDeleteReaction.ts +17 -4
- package/src/hooks/useMutateEditComment.ts +63 -0
- package/src/hooks/useMutateEditPost.ts +64 -0
- package/src/hooks/useMutateExternalBlobs.ts +5 -9
- package/src/hooks/useMutateFile.ts +311 -0
- package/src/hooks/useMutateFileRename.ts +51 -0
- package/src/hooks/useMutateFileSubscribe.ts +80 -0
- package/src/hooks/useMutateFileTrash.ts +115 -0
- package/src/hooks/useMutateFileVersion.ts +85 -0
- package/src/hooks/useMutateFiles.ts +23 -0
- package/src/hooks/useMutateLeaveConversation.ts +38 -0
- package/src/hooks/useMutateMessage.ts +23 -62
- package/src/hooks/useMutatePost.ts +60 -0
- package/src/hooks/useMutateReaction.ts +21 -6
- package/src/hooks/useMutateRead.ts +8 -2
- package/src/hooks/useMutateRemoveMembers.ts +2 -9
- package/src/hooks/useMutateReplaceReaction.ts +59 -0
- package/src/hooks/useMutateRestoreComment.ts +37 -0
- package/src/hooks/useMutateRestorePost.ts +36 -0
- package/src/hooks/useMutateStarred.ts +35 -0
- package/src/hooks/useMutateSubscribe.ts +36 -0
- package/src/hooks/useMutateTrashComment.ts +37 -0
- package/src/hooks/useMutateTrashPost.ts +36 -0
- package/src/hooks/useMutateTyping.ts +5 -3
- package/src/hooks/useMutateUnsubscribe.ts +36 -0
- package/src/hooks/useMutateVote.ts +59 -0
- package/src/hooks/usePost.ts +20 -0
- package/src/hooks/usePosts.ts +21 -0
- package/src/hooks/usePostsList.ts +31 -0
- package/src/hooks/useReactionList.ts +21 -0
- package/src/hooks/useSearchUsers.ts +2 -2
- package/src/hooks/useSessionState.ts +23 -0
- package/src/hooks/useUnload.ts +19 -0
- package/src/hooks/useUpdateEffect.ts +16 -0
- package/src/hooks/useVotes.ts +21 -0
- package/src/index.ts +5 -1
- package/src/scss/theme/_appbar.scss +8 -4
- package/src/scss/theme/_card.scss +2 -0
- package/src/scss/theme/_comment-editor-cm.scss +5 -1
- package/src/scss/theme/_comments.scss +9 -8
- package/src/scss/theme/_conversations.scss +4 -0
- package/src/scss/theme/_files.scss +2 -81
- package/src/scss/theme/_icons.scss +21 -3
- package/src/scss/theme/_input.scss +13 -7
- package/src/scss/theme/_item.scss +23 -1
- package/src/scss/theme/_message-editor-cm.scss +5 -1
- package/src/scss/theme/_pager.scss +1 -1
- package/src/scss/theme/_post-editor-cm.scss +2 -2
- package/src/scss/theme/_post.scss +3 -10
- package/src/scss/theme/_preview-pdf-viewer.scss +996 -0
- package/src/scss/theme/_preview-pdf.scss +57 -783
- package/src/scss/theme/_sheet.scss +4 -1
- package/src/scss/theme/_spinner.scss +10 -1
- package/src/scss/theme/_tables.scss +2 -0
- package/src/scss/theme/base/_scroll.scss +3 -0
- package/src/scss/weavy-chat.scss +3 -1
- package/src/scss/weavy-files.scss +31 -0
- package/src/scss/weavy-messenger.scss +3 -1
- package/src/scss/weavy-posts.scss +35 -0
- package/src/scss/weavy.scss +2 -0
- package/src/types/ConversationListItem.ts +1 -0
- package/src/types/Files.ts +7 -0
- package/src/types/Message.ts +2 -2
- package/src/types/Posts.ts +4 -0
- package/src/types/interfaces.ts +13 -0
- package/src/types/types.ts +157 -28
- package/src/ui/Button.tsx +6 -5
- package/src/ui/Dropdown.tsx +67 -16
- package/src/ui/Icon.tsx +112 -15
- package/src/ui/Overlay.tsx +6 -2
- package/src/ui/Sheet.tsx +87 -0
- package/src/ui/Spinner.tsx +7 -4
- package/src/utils/cacheUtils.ts +246 -0
- package/src/utils/fileUtilities.ts +208 -24
- package/src/utils/infinite-scroll.js +103 -0
- package/src/utils/mentions.ts +50 -0
- package/src/utils/openUrl.ts +41 -0
- package/src/utils/{scrollToBottom.js → scroll-position.js} +50 -9
- package/src/utils/{scrollbarDetection.js → scrollbar-detection.js} +0 -0
- package/src/utils/utils.js +15 -1
- package/tsconfig.json +1 -1
- package/dist/cjs/components/ConversationForm.d.ts +0 -7
- package/dist/cjs/components/File.d.ts +0 -9
- package/dist/cjs/components/FileBrowser.d.ts +0 -6
- package/dist/cjs/hooks/usePreview.d.ts +0 -4
- package/dist/cjs/hooks/useReactions.d.ts +0 -3
- package/dist/esm/components/ConversationForm.d.ts +0 -7
- package/dist/esm/components/File.d.ts +0 -9
- package/dist/esm/components/FileBrowser.d.ts +0 -6
- package/dist/esm/hooks/usePreview.d.ts +0 -4
- package/dist/esm/hooks/useReactions.d.ts +0 -3
- package/src/components/ConversationForm.tsx +0 -210
- package/src/components/File.tsx +0 -21
- package/src/hooks/usePreview.ts +0 -21
- package/src/hooks/useReactions.ts +0 -51
- package/src/utils/infiniteScroll.js +0 -184
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { useQueryClient } from 'react-query';
|
|
3
|
-
import useFileUploader from '../hooks/useFileUploader';
|
|
4
|
-
import File from './File';
|
|
5
|
-
import Icon from '../ui/Icon';
|
|
6
|
-
import Button from '../ui/Button';
|
|
7
|
-
import useMutateTyping from '../hooks/useMutateTyping';
|
|
8
|
-
import useThrottle from '../hooks/useThrottle';
|
|
9
|
-
import { flushSync } from 'react-dom';
|
|
10
|
-
import Meetings from './Meetings';
|
|
11
|
-
import Meeting from './Meeting';
|
|
12
|
-
import FileBrowser from './FileBrowser';
|
|
13
|
-
import { getIcon } from '../utils/fileUtilities';
|
|
14
|
-
|
|
15
|
-
type Props = {
|
|
16
|
-
conversationId: number,
|
|
17
|
-
handleInsert: Function
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let uploadedFiles: any[] = [];
|
|
21
|
-
|
|
22
|
-
const ConversationForm = ({ conversationId, handleInsert }: Props) => {
|
|
23
|
-
|
|
24
|
-
const [text, setText] = useState<string>("");
|
|
25
|
-
const [files, setFiles] = useState<string>("");
|
|
26
|
-
const [fileCount, setFileCount] = useState<number>(0);
|
|
27
|
-
const [currentUploadCount, setCurrentUploadCount] = useState<number>(1);
|
|
28
|
-
const [working, setWorking] = useState<boolean>(false);
|
|
29
|
-
const queryClient = useQueryClient();
|
|
30
|
-
const [attachments, setAttachments] = useState<FileType[]>([]);
|
|
31
|
-
const [meetings, setMeetings] = useState<MeetingType[]>([]);
|
|
32
|
-
const [uploadError, setUploadError] = useState<string | boolean>(false);
|
|
33
|
-
const startTyping = useMutateTyping();
|
|
34
|
-
const textInput = useRef<HTMLTextAreaElement>(null);
|
|
35
|
-
|
|
36
|
-
let fileInput: HTMLInputElement | null;
|
|
37
|
-
|
|
38
|
-
const handleUploaded = (attachment: any) => {
|
|
39
|
-
// update attachment list
|
|
40
|
-
flushSync(() => {
|
|
41
|
-
if (attachment.status && attachment.status !== 200) {
|
|
42
|
-
setUploadError(attachment.detail);
|
|
43
|
-
} else {
|
|
44
|
-
setAttachments([...attachments, attachment[0]]);
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const { mutateAsync: uploadFile, isSuccess: uploadSuccess } = useFileUploader(handleUploaded);
|
|
50
|
-
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
// set stored text and attachments if available
|
|
53
|
-
let textValue: any = queryClient.getQueryData(["form-text", conversationId]) || "";
|
|
54
|
-
setText(textValue);
|
|
55
|
-
|
|
56
|
-
let attachmentValue: any = queryClient.getQueryData(["form-attachments", conversationId]) || [];
|
|
57
|
-
setAttachments(attachmentValue);
|
|
58
|
-
}, [conversationId]);
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
// store attachments
|
|
62
|
-
queryClient.setQueryData(["form-attachments", conversationId], attachments);
|
|
63
|
-
}, [attachments]);
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
handleAutoGrow();
|
|
67
|
-
}, [text])
|
|
68
|
-
|
|
69
|
-
const handleInsertMessage = (e: React.KeyboardEvent<EventTarget>) => {
|
|
70
|
-
|
|
71
|
-
if(e.type === 'keydown' && !(e.key === "Enter" && e.ctrlKey )) return;
|
|
72
|
-
|
|
73
|
-
e.preventDefault();
|
|
74
|
-
e.stopPropagation();
|
|
75
|
-
|
|
76
|
-
if (text === "" && attachments.length === 0 && meetings.length === 0) return;
|
|
77
|
-
|
|
78
|
-
handleInsert(text, attachments, meetings);
|
|
79
|
-
setText("");
|
|
80
|
-
setFiles("");
|
|
81
|
-
setAttachments([]);
|
|
82
|
-
setMeetings([]);
|
|
83
|
-
|
|
84
|
-
// clear stored text and attachments
|
|
85
|
-
queryClient.setQueryData(["form-text", conversationId], "");
|
|
86
|
-
queryClient.setQueryData(["form-attachments", conversationId], []);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const handleChange = (e: any) => {
|
|
90
|
-
|
|
91
|
-
// store text
|
|
92
|
-
queryClient.setQueryData(["form-text", conversationId], e.target.value);
|
|
93
|
-
|
|
94
|
-
// set text value
|
|
95
|
-
setText(e.target.value);
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const handleFileUpload = async (e: any) => {
|
|
100
|
-
setUploadError(false);
|
|
101
|
-
setFiles(e.target.value);
|
|
102
|
-
setFileCount(e.target.files.length);
|
|
103
|
-
setWorking(true);
|
|
104
|
-
|
|
105
|
-
for (var i = 0; i < e.target.files.length; i++) {
|
|
106
|
-
setCurrentUploadCount(i + 1);
|
|
107
|
-
const file = e.target.files[i];
|
|
108
|
-
await uploadFile({ request: { file } });
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
setWorking(false)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const handleRemoveFile = (id: number, e: any) => {
|
|
115
|
-
setFiles("");
|
|
116
|
-
setAttachments(attachments.filter((a: FileType) => {
|
|
117
|
-
return a.id !== id
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const handleKeyPress = () => {
|
|
122
|
-
startTyping.mutate({ id: conversationId });
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const openFileInput = (e: any) => {
|
|
126
|
-
fileInput?.click();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const handleAddMeeting = (data: any) => {
|
|
130
|
-
if (meetings.length > 0) return;
|
|
131
|
-
|
|
132
|
-
setMeetings([...meetings, data]);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const handleExternalFileAdded = (blobs: FileType[]) => {
|
|
136
|
-
setAttachments([...attachments, ...blobs]);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const handleRemoveMeeting = (id: number, e: any) => {
|
|
140
|
-
setMeetings(meetings.filter((a: MeetingType) => {
|
|
141
|
-
return a.id !== id
|
|
142
|
-
}));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const handleAutoGrow = () => {
|
|
146
|
-
if(textInput.current && textInput.current.parentNode){
|
|
147
|
-
const parent = textInput.current.parentNode as HTMLElement;
|
|
148
|
-
parent.dataset.replicatedValue = textInput.current.value;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<form className="wy-message-form">
|
|
156
|
-
{uploadError &&
|
|
157
|
-
<div>{uploadError}</div>
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
{(working || attachments.length > 0 || meetings.length > 0) &&
|
|
161
|
-
<div>
|
|
162
|
-
{working &&
|
|
163
|
-
<div>Now uploading ({currentUploadCount} of {fileCount}) selected files</div>
|
|
164
|
-
}
|
|
165
|
-
<div className="wy-picker-list">
|
|
166
|
-
{attachments.map((a: FileType) => {
|
|
167
|
-
let { icon } = getIcon(a.name);
|
|
168
|
-
return (
|
|
169
|
-
<div key={a.id} className="wy-picker-list-item">
|
|
170
|
-
<File id={a.id} name={a.name} className="wy-picker-list-item-title" icon={ icon } />
|
|
171
|
-
<Button.UI onClick={handleRemoveFile.bind(ConversationForm, a.id)}><Icon.UI name='close-circle' /></Button.UI>
|
|
172
|
-
</div>
|
|
173
|
-
|
|
174
|
-
)
|
|
175
|
-
})}
|
|
176
|
-
|
|
177
|
-
{meetings.map((m: MeetingType) => {
|
|
178
|
-
return (
|
|
179
|
-
<div key={m.id} className="wy-picker-list-item">
|
|
180
|
-
<Meeting id={m.id} title={m.provider} className="wy-picker-list-item-title" />
|
|
181
|
-
<Button.UI onClick={handleRemoveMeeting.bind(ConversationForm, m.id)}><Icon.UI name='close-circle' /></Button.UI>
|
|
182
|
-
</div>
|
|
183
|
-
|
|
184
|
-
)
|
|
185
|
-
})}
|
|
186
|
-
</div>
|
|
187
|
-
</div>
|
|
188
|
-
}
|
|
189
|
-
<div className="wy-message-editor-inputs">
|
|
190
|
-
|
|
191
|
-
<div className="wy-message-editor-buttons">
|
|
192
|
-
<input type="file" ref={input => fileInput = input} value={files} onChange={handleFileUpload} multiple hidden tabIndex={-1} />
|
|
193
|
-
<Button.UI title="Upload attachment" onClick={openFileInput}><Icon.UI name="attachment" /></Button.UI>
|
|
194
|
-
<Meetings onMeetingAdded={handleAddMeeting} />
|
|
195
|
-
<FileBrowser onFileAdded={handleExternalFileAdded} />
|
|
196
|
-
</div>
|
|
197
|
-
|
|
198
|
-
<div className="wy-message-editor-text wy-message-editor-grow">
|
|
199
|
-
<textarea rows={1} ref={textInput} className="wy-message-editor-textfield wy-message-editor-textcontent" value={text} onChange={handleChange} onKeyDown={handleInsertMessage} onKeyPress={useThrottle(handleKeyPress, 4000)}></textarea>
|
|
200
|
-
</div>
|
|
201
|
-
<div className="wy-message-editor-buttons">
|
|
202
|
-
<Button.UI type="button" onClick={handleInsertMessage} ><Icon.UI color="primary" name="send"/></Button.UI>
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
</form>
|
|
206
|
-
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export default ConversationForm;
|
package/src/components/File.tsx
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Icon from "../ui/Icon";
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
id: number,
|
|
6
|
-
name: string
|
|
7
|
-
className?: string,
|
|
8
|
-
icon: string
|
|
9
|
-
}
|
|
10
|
-
const File = ({ id, name, className, icon }: Props) => {
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<>
|
|
14
|
-
<Icon.UI name={icon} size={1} />
|
|
15
|
-
<div className={className}>{name}</div>
|
|
16
|
-
<input type="hidden" value={id} name="blob"/>
|
|
17
|
-
</>
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default File;
|
package/src/hooks/usePreview.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect } from "react";
|
|
2
|
-
import { PreviewContext } from "../contexts/PreviewContext";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default function usePreview(attachments: AttachmentType[]) {
|
|
6
|
-
|
|
7
|
-
const { openPreview, closePreview } = useContext(PreviewContext);
|
|
8
|
-
|
|
9
|
-
const open = (attachmentId: number) => {
|
|
10
|
-
openPreview(attachments, attachmentId);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const close = () => {
|
|
14
|
-
closePreview()
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
open,
|
|
19
|
-
close
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { useCallback, useContext, useEffect, useLayoutEffect, useState } from "react";
|
|
2
|
-
import { UserContext } from "../contexts/UserContext";
|
|
3
|
-
import useEvents from "./useEvents";
|
|
4
|
-
|
|
5
|
-
export default function useReactions(id: number, reactions: ReactableType[]) {
|
|
6
|
-
const { on, off } = useEvents();
|
|
7
|
-
const { user } = useContext(UserContext);
|
|
8
|
-
const [reactionsList, setReactionsList] = useState<ReactableType[]>([]);
|
|
9
|
-
|
|
10
|
-
const groupReactions = useCallback((data: ReactableType[]) => {
|
|
11
|
-
var group = [...new Map<string, ReactableType>(data.map((item: ReactableType) => [item.content, item])).values()];
|
|
12
|
-
|
|
13
|
-
return group.map((item: ReactableType): ReactionGroup => {
|
|
14
|
-
return {
|
|
15
|
-
content: item.content,
|
|
16
|
-
count: data.filter((r) => r.content === item.content).length,
|
|
17
|
-
has_reacted: data.filter((r) => r.content === item.content && r.created_by_id === user.id).length > 0
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}, [reactionsList]);
|
|
21
|
-
|
|
22
|
-
const handleRealtimeReactionInserted = useCallback((reaction: RealtimeReaction) => {
|
|
23
|
-
if (reaction.entity.id === id) {
|
|
24
|
-
setReactionsList((oldList) => {
|
|
25
|
-
return [...oldList || [], { content: reaction.reaction, created_by_id: reaction.actor.id }];
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}, [id, reactionsList]);
|
|
29
|
-
|
|
30
|
-
const handleRealtimeReactionDeleted = useCallback((reaction: RealtimeReaction) => {
|
|
31
|
-
if (reaction.entity.id === id) {
|
|
32
|
-
setReactionsList(oldList => oldList.filter(item => item.created_by_id !== reaction.actor.id));
|
|
33
|
-
}
|
|
34
|
-
}, [id, reactionsList]);
|
|
35
|
-
|
|
36
|
-
useLayoutEffect(() => {
|
|
37
|
-
setReactionsList(reactions || []);
|
|
38
|
-
}, [reactions]);
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
on('reaction_added_' + id, handleRealtimeReactionInserted);
|
|
42
|
-
on('reaction_deleted_' + id, handleRealtimeReactionDeleted);
|
|
43
|
-
|
|
44
|
-
return () => {
|
|
45
|
-
off('reaction_added_' + id, handleRealtimeReactionInserted);
|
|
46
|
-
off('reaction_deleted_' + id, handleRealtimeReactionDeleted);
|
|
47
|
-
}
|
|
48
|
-
}, [id]);
|
|
49
|
-
|
|
50
|
-
return { reactionsList: groupReactions(reactionsList) };
|
|
51
|
-
}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new regular scroll listener
|
|
3
|
-
*
|
|
4
|
-
* @param {Element} observeElement
|
|
5
|
-
* @param {Function} whenNext
|
|
6
|
-
* @returns IntersectionObserver
|
|
7
|
-
*/
|
|
8
|
-
export function createScroller(observeElement, whenNext) {
|
|
9
|
-
//console.log("creating regular scroller");
|
|
10
|
-
var parent = getScrollParent(observeElement);
|
|
11
|
-
|
|
12
|
-
// Disable scroll anchoring https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-anchor/Guide_to_scroll_anchoring
|
|
13
|
-
parent.style.overflowAnchor = "none";
|
|
14
|
-
|
|
15
|
-
// Bug using scrollingElement in frames. See https://github.com/w3c/IntersectionObserver/issues/372
|
|
16
|
-
var intersectionParent = (parent === document.documentElement ? document : parent);
|
|
17
|
-
|
|
18
|
-
whenNext ??= () => Promise.reject(new Error("No scroller handler function defined")); // default
|
|
19
|
-
|
|
20
|
-
const nextObserver = new IntersectionObserver((entries, observer) => {
|
|
21
|
-
entries.forEach(function (entry) {
|
|
22
|
-
if (entry.isIntersecting) {
|
|
23
|
-
whenNext();
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}, { root: intersectionParent, threshold: 0, rootMargin: "500px" });
|
|
27
|
-
|
|
28
|
-
nextObserver.observe(observeElement);
|
|
29
|
-
|
|
30
|
-
return nextObserver;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Creates a new reverse scroll listener
|
|
35
|
-
*
|
|
36
|
-
* @param {Element} observeElement
|
|
37
|
-
* @param {Function} whenNext
|
|
38
|
-
* @returns IntersectionObserver
|
|
39
|
-
*/
|
|
40
|
-
export function createReverseScroller(observeElement, whenNext) {
|
|
41
|
-
// inverted infinite scroll (e.g. for messages)
|
|
42
|
-
let prevSleep = false;
|
|
43
|
-
|
|
44
|
-
//console.log("creating reverse scroller");
|
|
45
|
-
var parent = getScrollParent(observeElement);
|
|
46
|
-
|
|
47
|
-
// Disable scroll anchoring https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-anchor/Guide_to_scroll_anchoring
|
|
48
|
-
parent.style.overflowAnchor = "none";
|
|
49
|
-
|
|
50
|
-
// Bug using scrollingElement in frames. See https://github.com/w3c/IntersectionObserver/issues/372
|
|
51
|
-
var intersectionParent = (parent === document.documentElement ? document : parent);
|
|
52
|
-
|
|
53
|
-
whenNext ??= () => Promise.reject(new Error("No reverse scroller handler function defined")); // default
|
|
54
|
-
|
|
55
|
-
const prevObserver = new IntersectionObserver((entries, observer) => {
|
|
56
|
-
entries.forEach(function (entry) {
|
|
57
|
-
if (entry.isIntersecting && !prevSleep) {
|
|
58
|
-
prevSleep = true;
|
|
59
|
-
|
|
60
|
-
// find first child (that is regularly positioned)
|
|
61
|
-
var nextPositionedChild = getNextPositionedChild(entry.target);
|
|
62
|
-
|
|
63
|
-
var prevScrollHeight = parent.scrollHeight;
|
|
64
|
-
var childOffsetBefore = nextPositionedChild.offsetTop;
|
|
65
|
-
|
|
66
|
-
//console.log("intersecting", childOffsetBefore);
|
|
67
|
-
|
|
68
|
-
let afterNext = () => {
|
|
69
|
-
queueMicrotask(() => { // Place last in microtask queue
|
|
70
|
-
// scroll parent so that first child remains in the same position as before
|
|
71
|
-
// NOTE: when this is called via observer we need to requestAnimationFrame, otherwise scrolling happens to fast (before the DOM has been updated)
|
|
72
|
-
if (prevScrollHeight !== parent.scrollHeight) {
|
|
73
|
-
// layout already rendered
|
|
74
|
-
let diff = nextPositionedChild.offsetTop - childOffsetBefore;
|
|
75
|
-
//console.log("infinite scroll updated instantly", diff);
|
|
76
|
-
parent.scrollTop += diff;
|
|
77
|
-
requestAnimationFrame(() => prevSleep = false);
|
|
78
|
-
} else {
|
|
79
|
-
queueMicrotask(() => {
|
|
80
|
-
if (prevScrollHeight !== parent.scrollHeight) {
|
|
81
|
-
// layout rendered after
|
|
82
|
-
let diff = nextPositionedChild.offsetTop - childOffsetBefore;
|
|
83
|
-
//console.log("infinite scroll updated by microtask", diff);
|
|
84
|
-
parent.scrollTop += diff;
|
|
85
|
-
requestAnimationFrame(() => prevSleep = false);
|
|
86
|
-
} else {
|
|
87
|
-
// layout not rendered yet
|
|
88
|
-
requestAnimationFrame(() => {
|
|
89
|
-
let diff = nextPositionedChild.offsetTop - childOffsetBefore;
|
|
90
|
-
//console.log("infinite scroll updated by animationframe", diff);
|
|
91
|
-
parent.scrollTop += diff;
|
|
92
|
-
requestAnimationFrame(() => prevSleep = false);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
let whenNextResult = whenNext();
|
|
101
|
-
|
|
102
|
-
if (whenNextResult) {
|
|
103
|
-
whenNextResult.then(afterNext);
|
|
104
|
-
} else {
|
|
105
|
-
afterNext();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
}, { root: intersectionParent, threshold: 0, rootMargin: "500px" });
|
|
110
|
-
|
|
111
|
-
prevObserver.observe(observeElement);
|
|
112
|
-
|
|
113
|
-
return prevObserver;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
* @param {Element} el
|
|
119
|
-
* @returns Element
|
|
120
|
-
*/
|
|
121
|
-
export function getNextPositionedChild(el) {
|
|
122
|
-
while(el = el?.nextElementSibling) {
|
|
123
|
-
if(/absolute|sticky|fixed/.test(getComputedStyle(el).position) === false) {
|
|
124
|
-
return el;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// get the closest ancestor element that is scrollable (adapted from https://stackoverflow.com/a/42543908/891843)
|
|
130
|
-
/**
|
|
131
|
-
*
|
|
132
|
-
* @param {Element} element
|
|
133
|
-
* @returns Element
|
|
134
|
-
*/
|
|
135
|
-
export function getScrollParent(element) {
|
|
136
|
-
var includeHidden = false;
|
|
137
|
-
|
|
138
|
-
if (element) {
|
|
139
|
-
var style = getComputedStyle(element);
|
|
140
|
-
var excludeStaticParent = style.position === "absolute";
|
|
141
|
-
var overflowRegex = includeHidden ? /(auto|scroll|overlay|hidden)/ : /(auto|overlay|scroll)/;
|
|
142
|
-
|
|
143
|
-
if (style.position === "fixed") {
|
|
144
|
-
return document.scrollingElement;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
for (var parent = element; (parent = parent.parentElement);) {
|
|
148
|
-
style = getComputedStyle(parent);
|
|
149
|
-
|
|
150
|
-
if (excludeStaticParent && style.position === "static") {
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) {
|
|
154
|
-
return parent;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return document.scrollingElement;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
*
|
|
164
|
-
* @param {Element} ref
|
|
165
|
-
* @param {boolean} smooth
|
|
166
|
-
*/
|
|
167
|
-
export function scrollToBottom(ref, smooth) {
|
|
168
|
-
var parent = getScrollParent(ref);
|
|
169
|
-
//console.log("scrolling #messages", origin, el.scrollHeight, el);
|
|
170
|
-
|
|
171
|
-
if (parent && parent.scrollTop + parent.clientHeight !== parent.scrollHeight) {
|
|
172
|
-
if (smooth) {
|
|
173
|
-
parent.scrollTo({
|
|
174
|
-
top: parent.scrollHeight,
|
|
175
|
-
left: 0,
|
|
176
|
-
behavior: 'smooth'
|
|
177
|
-
});
|
|
178
|
-
} else {
|
|
179
|
-
parent.scrollTop = parent.scrollHeight;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|