@openpeepshq/react 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +1 -0
- package/dist/auth/credentials/index.d.ts +11 -0
- package/dist/auth/credentials/index.js +57 -0
- package/dist/auth/credentials/types.d.ts +6 -0
- package/dist/auth/credentials/types.js +1 -0
- package/dist/components/accounts/SignUpLoginModal.d.ts +9 -0
- package/dist/components/accounts/SignUpLoginModal.js +19 -0
- package/dist/components/accounts/SignUpLoginModalContext.d.ts +10 -0
- package/dist/components/accounts/SignUpLoginModalContext.js +16 -0
- package/dist/components/accounts/index.d.ts +3 -0
- package/dist/components/accounts/index.js +2 -0
- package/dist/components/configuration/ConfigurationCategory.d.ts +12 -0
- package/dist/components/configuration/ConfigurationCategory.js +61 -0
- package/dist/components/configuration/ConfigurationList.d.ts +10 -0
- package/dist/components/configuration/ConfigurationList.js +30 -0
- package/dist/components/configuration/ConfigurationTree.d.ts +8 -0
- package/dist/components/configuration/ConfigurationTree.js +20 -0
- package/dist/components/configuration/ConfigurationValueEditor.d.ts +11 -0
- package/dist/components/configuration/ConfigurationValueEditor.js +45 -0
- package/dist/components/configuration/index.d.ts +4 -0
- package/dist/components/configuration/index.js +4 -0
- package/dist/components/conversations/ConversationMessageBubble.d.ts +4 -0
- package/dist/components/conversations/ConversationMessageBubble.js +10 -0
- package/dist/components/conversations/CreateNewConversation.d.ts +8 -0
- package/dist/components/conversations/CreateNewConversation.js +62 -0
- package/dist/components/conversations/CreateNewConversationContext.d.ts +15 -0
- package/dist/components/conversations/CreateNewConversationContext.js +18 -0
- package/dist/components/conversations/DirectMessagesHeaderActions.d.ts +1 -0
- package/dist/components/conversations/DirectMessagesHeaderActions.js +10 -0
- package/dist/components/conversations/MessageInThread.d.ts +13 -0
- package/dist/components/conversations/MessageInThread.js +41 -0
- package/dist/components/conversations/index.d.ts +8 -0
- package/dist/components/conversations/index.js +5 -0
- package/dist/components/form/HeaderAvatarInput.d.ts +13 -0
- package/dist/components/form/HeaderAvatarInput.js +16 -0
- package/dist/components/form/ImageEditModal.d.ts +23 -0
- package/dist/components/form/ImageEditModal.js +75 -0
- package/dist/components/form/ImageInput.d.ts +32 -0
- package/dist/components/form/ImageInput.js +65 -0
- package/dist/components/form/LocationInput.d.ts +20 -0
- package/dist/components/form/LocationInput.js +59 -0
- package/dist/components/form/index.d.ts +8 -0
- package/dist/components/form/index.js +4 -0
- package/dist/components/groups/AddGroupMemberModal.d.ts +6 -0
- package/dist/components/groups/AddGroupMemberModal.js +40 -0
- package/dist/components/groups/AddGroupMembersButton.d.ts +5 -0
- package/dist/components/groups/AddGroupMembersButton.js +17 -0
- package/dist/components/groups/ChangeGroupRolesModal.d.ts +7 -0
- package/dist/components/groups/ChangeGroupRolesModal.js +45 -0
- package/dist/components/groups/ConfirmGroupExitModal.d.ts +6 -0
- package/dist/components/groups/ConfirmGroupExitModal.js +35 -0
- package/dist/components/groups/ConfirmMemberRemovalModal.d.ts +7 -0
- package/dist/components/groups/ConfirmMemberRemovalModal.js +33 -0
- package/dist/components/groups/DeleteGroupModal.d.ts +6 -0
- package/dist/components/groups/DeleteGroupModal.js +34 -0
- package/dist/components/groups/GroupAvatar.d.ts +14 -0
- package/dist/components/groups/GroupAvatar.js +32 -0
- package/dist/components/groups/GroupCard.d.ts +19 -0
- package/dist/components/groups/GroupCard.js +12 -0
- package/dist/components/groups/GroupFeed.d.ts +9 -0
- package/dist/components/groups/GroupFeed.js +14 -0
- package/dist/components/groups/GroupForm.d.ts +7 -0
- package/dist/components/groups/GroupForm.js +73 -0
- package/dist/components/groups/GroupHeader.d.ts +5 -0
- package/dist/components/groups/GroupHeader.js +14 -0
- package/dist/components/groups/GroupMembersList.d.ts +5 -0
- package/dist/components/groups/GroupMembersList.js +38 -0
- package/dist/components/groups/GroupOptionsMenu.d.ts +5 -0
- package/dist/components/groups/GroupOptionsMenu.js +61 -0
- package/dist/components/groups/GroupShareMenu.d.ts +5 -0
- package/dist/components/groups/GroupShareMenu.js +29 -0
- package/dist/components/groups/JoinGroupButton.d.ts +6 -0
- package/dist/components/groups/JoinGroupButton.js +28 -0
- package/dist/components/groups/index.d.ts +30 -0
- package/dist/components/groups/index.js +15 -0
- package/dist/components/index.d.ts +15 -0
- package/dist/components/index.js +15 -0
- package/dist/components/jams/CreateNewJam.d.ts +4 -0
- package/dist/components/jams/CreateNewJam.js +138 -0
- package/dist/components/jams/CreateNewJamContext.d.ts +9 -0
- package/dist/components/jams/CreateNewJamContext.js +16 -0
- package/dist/components/jams/JamAnimatedEmoji.d.ts +4 -0
- package/dist/components/jams/JamAnimatedEmoji.js +12 -0
- package/dist/components/jams/JamCallParticipant.d.ts +15 -0
- package/dist/components/jams/JamCallParticipant.js +101 -0
- package/dist/components/jams/JamCapacityGate.d.ts +7 -0
- package/dist/components/jams/JamCapacityGate.js +30 -0
- package/dist/components/jams/JamChatDrawer.d.ts +6 -0
- package/dist/components/jams/JamChatDrawer.js +88 -0
- package/dist/components/jams/JamChatMessage.d.ts +5 -0
- package/dist/components/jams/JamChatMessage.js +35 -0
- package/dist/components/jams/JamConference.d.ts +8 -0
- package/dist/components/jams/JamConference.js +38 -0
- package/dist/components/jams/JamContext.d.ts +20 -0
- package/dist/components/jams/JamContext.js +24 -0
- package/dist/components/jams/JamDetailsDrawer.d.ts +9 -0
- package/dist/components/jams/JamDetailsDrawer.js +39 -0
- package/dist/components/jams/JamDeviceSelectors.d.ts +12 -0
- package/dist/components/jams/JamDeviceSelectors.js +71 -0
- package/dist/components/jams/JamEventsContext.d.ts +14 -0
- package/dist/components/jams/JamEventsContext.js +143 -0
- package/dist/components/jams/JamFooter.d.ts +18 -0
- package/dist/components/jams/JamFooter.js +171 -0
- package/dist/components/jams/JamGuestForm.d.ts +1 -0
- package/dist/components/jams/JamGuestForm.js +55 -0
- package/dist/components/jams/JamLobby.d.ts +17 -0
- package/dist/components/jams/JamLobby.js +159 -0
- package/dist/components/jams/JamObserverShell.d.ts +6 -0
- package/dist/components/jams/JamObserverShell.js +11 -0
- package/dist/components/jams/JamParticipantConference.d.ts +7 -0
- package/dist/components/jams/JamParticipantConference.js +80 -0
- package/dist/components/jams/JamPeopleDrawer.d.ts +10 -0
- package/dist/components/jams/JamPeopleDrawer.js +76 -0
- package/dist/components/jams/JamReactionMenu.d.ts +12 -0
- package/dist/components/jams/JamReactionMenu.js +79 -0
- package/dist/components/jams/JamRequestJoin.d.ts +9 -0
- package/dist/components/jams/JamRequestJoin.js +34 -0
- package/dist/components/jams/JamRoom.d.ts +21 -0
- package/dist/components/jams/JamRoom.js +166 -0
- package/dist/components/jams/JamRoomIndicators.d.ts +10 -0
- package/dist/components/jams/JamRoomIndicators.js +39 -0
- package/dist/components/jams/JamVideoCall.d.ts +15 -0
- package/dist/components/jams/JamVideoCall.js +18 -0
- package/dist/components/jams/JamVideoLayout.d.ts +13 -0
- package/dist/components/jams/JamVideoLayout.js +68 -0
- package/dist/components/jams/LeaveCloseButton.d.ts +6 -0
- package/dist/components/jams/LeaveCloseButton.js +58 -0
- package/dist/components/jams/LiveJamsSection.d.ts +1 -0
- package/dist/components/jams/LiveJamsSection.js +16 -0
- package/dist/components/jams/animateEmoji.d.ts +1 -0
- package/dist/components/jams/animateEmoji.js +48 -0
- package/dist/components/jams/blurProcessor.d.ts +8 -0
- package/dist/components/jams/blurProcessor.js +28 -0
- package/dist/components/jams/constants.d.ts +10 -0
- package/dist/components/jams/constants.js +44 -0
- package/dist/components/jams/index.d.ts +24 -0
- package/dist/components/jams/index.js +19 -0
- package/dist/components/jams/jamEventActions.d.ts +26 -0
- package/dist/components/jams/jamEventActions.js +76 -0
- package/dist/components/jams/jamLocalSettings.d.ts +17 -0
- package/dist/components/jams/jamLocalSettings.js +53 -0
- package/dist/components/jams/jamReactionPreferences.d.ts +15 -0
- package/dist/components/jams/jamReactionPreferences.js +53 -0
- package/dist/components/jams/jamRecordingState.d.ts +10 -0
- package/dist/components/jams/jamRecordingState.js +25 -0
- package/dist/components/jams/reactionEmojis.d.ts +30 -0
- package/dist/components/jams/reactionEmojis.js +73 -0
- package/dist/components/jams/useJamHands.d.ts +7 -0
- package/dist/components/jams/useJamHands.js +39 -0
- package/dist/components/jams/useJamLiveKitTheme.d.ts +3 -0
- package/dist/components/jams/useJamLiveKitTheme.js +10 -0
- package/dist/components/layout/AccessDenied.d.ts +14 -0
- package/dist/components/layout/AccessDenied.js +28 -0
- package/dist/components/layout/AccessDeniedLoader.d.ts +16 -0
- package/dist/components/layout/AccessDeniedLoader.js +12 -0
- package/dist/components/layout/Auth.d.ts +22 -0
- package/dist/components/layout/Auth.js +82 -0
- package/dist/components/layout/IdentityContext.d.ts +17 -0
- package/dist/components/layout/IdentityContext.js +38 -0
- package/dist/components/layout/Infos.d.ts +5 -0
- package/dist/components/layout/Infos.js +42 -0
- package/dist/components/layout/OpenpeepsContextProvider.d.ts +10 -0
- package/dist/components/layout/OpenpeepsContextProvider.js +63 -0
- package/dist/components/layout/OpenpeepsThemeProvider.d.ts +11 -0
- package/dist/components/layout/OpenpeepsThemeProvider.js +47 -0
- package/dist/components/layout/ProfileGuard.d.ts +14 -0
- package/dist/components/layout/ProfileGuard.js +38 -0
- package/dist/components/layout/ProfileProvider.d.ts +10 -0
- package/dist/components/layout/ProfileProvider.js +60 -0
- package/dist/components/layout/Root.d.ts +16 -0
- package/dist/components/layout/Root.js +36 -0
- package/dist/components/layout/ToastProvider.d.ts +22 -0
- package/dist/components/layout/ToastProvider.js +37 -0
- package/dist/components/layout/index.d.ts +21 -0
- package/dist/components/layout/index.js +11 -0
- package/dist/components/markdown/CompiledMarkdown.d.ts +5 -0
- package/dist/components/markdown/CompiledMarkdown.js +3 -0
- package/dist/components/markdown/OpenpeepsMarkdown.d.ts +16 -0
- package/dist/components/markdown/OpenpeepsMarkdown.js +66 -0
- package/dist/components/markdown/classes.d.ts +2 -0
- package/dist/components/markdown/classes.js +2 -0
- package/dist/components/markdown/compileMarkdown.d.ts +5 -0
- package/dist/components/markdown/compileMarkdown.js +36 -0
- package/dist/components/markdown/index.d.ts +11 -0
- package/dist/components/markdown/index.js +7 -0
- package/dist/components/markdown/linkTargets.d.ts +3 -0
- package/dist/components/markdown/linkTargets.js +27 -0
- package/dist/components/markdown/staticRender.d.ts +16 -0
- package/dist/components/markdown/staticRender.js +17 -0
- package/dist/components/navigation/ContentHeader.d.ts +1 -0
- package/dist/components/navigation/ContentHeader.js +18 -0
- package/dist/components/navigation/FooterMobile.d.ts +5 -0
- package/dist/components/navigation/FooterMobile.js +8 -0
- package/dist/components/navigation/HeaderMobile.d.ts +11 -0
- package/dist/components/navigation/HeaderMobile.js +26 -0
- package/dist/components/navigation/MobileMenuItem.d.ts +7 -0
- package/dist/components/navigation/MobileMenuItem.js +13 -0
- package/dist/components/navigation/PageHeaderAction.d.ts +5 -0
- package/dist/components/navigation/PageHeaderAction.js +7 -0
- package/dist/components/navigation/PlusButton.d.ts +1 -0
- package/dist/components/navigation/PlusButton.js +11 -0
- package/dist/components/navigation/SideBar.d.ts +16 -0
- package/dist/components/navigation/SideBar.js +24 -0
- package/dist/components/navigation/SidebarNavContext.d.ts +3 -0
- package/dist/components/navigation/SidebarNavContext.js +4 -0
- package/dist/components/navigation/breadcrumbs/Breadcrumbs.d.ts +1 -0
- package/dist/components/navigation/breadcrumbs/Breadcrumbs.js +10 -0
- package/dist/components/navigation/breadcrumbs/Crumb.d.ts +5 -0
- package/dist/components/navigation/breadcrumbs/Crumb.js +4 -0
- package/dist/components/navigation/index.d.ts +17 -0
- package/dist/components/navigation/index.js +11 -0
- package/dist/components/navigation/sideBarNavLinkClass.d.ts +4 -0
- package/dist/components/navigation/sideBarNavLinkClass.js +3 -0
- package/dist/components/notifications/NotificationErrorBoundary.d.ts +16 -0
- package/dist/components/notifications/NotificationErrorBoundary.js +21 -0
- package/dist/components/notifications/NotificationHeaderActions.d.ts +6 -0
- package/dist/components/notifications/NotificationHeaderActions.js +35 -0
- package/dist/components/notifications/NotificationItem.d.ts +5 -0
- package/dist/components/notifications/NotificationItem.js +6 -0
- package/dist/components/notifications/NotificationWrapper.d.ts +10 -0
- package/dist/components/notifications/NotificationWrapper.js +6 -0
- package/dist/components/notifications/NotificationsList.d.ts +12 -0
- package/dist/components/notifications/NotificationsList.js +88 -0
- package/dist/components/notifications/TypedNotification.d.ts +4 -0
- package/dist/components/notifications/TypedNotification.js +201 -0
- package/dist/components/notifications/index.d.ts +7 -0
- package/dist/components/notifications/index.js +5 -0
- package/dist/components/post/Feed.d.ts +20 -0
- package/dist/components/post/Feed.js +63 -0
- package/dist/components/post/FeedPost.d.ts +17 -0
- package/dist/components/post/FeedPost.js +31 -0
- package/dist/components/post/FeedPostContent.d.ts +5 -0
- package/dist/components/post/FeedPostContent.js +22 -0
- package/dist/components/post/FullPostLayout.d.ts +7 -0
- package/dist/components/post/FullPostLayout.js +23 -0
- package/dist/components/post/Markdown.d.ts +2 -0
- package/dist/components/post/Markdown.js +1 -0
- package/dist/components/post/NewEventButton.d.ts +14 -0
- package/dist/components/post/NewEventButton.js +39 -0
- package/dist/components/post/NewNoteButton.d.ts +14 -0
- package/dist/components/post/NewNoteButton.js +38 -0
- package/dist/components/post/PinnedPost.d.ts +5 -0
- package/dist/components/post/PinnedPost.js +15 -0
- package/dist/components/post/PostDetail.d.ts +4 -0
- package/dist/components/post/PostDetail.js +31 -0
- package/dist/components/post/ReplyBox.d.ts +5 -0
- package/dist/components/post/ReplyBox.js +30 -0
- package/dist/components/post/VideoPlayOverlay.d.ts +5 -0
- package/dist/components/post/VideoPlayOverlay.js +8 -0
- package/dist/components/post/attachmentPreview.d.ts +5 -0
- package/dist/components/post/attachmentPreview.js +14 -0
- package/dist/components/post/feed/events/EventsFeed.d.ts +7 -0
- package/dist/components/post/feed/events/EventsFeed.js +44 -0
- package/dist/components/post/feed/threaded/ThreadPost.d.ts +9 -0
- package/dist/components/post/feed/threaded/ThreadPost.js +19 -0
- package/dist/components/post/feed/threaded/ThreadedFeed.d.ts +10 -0
- package/dist/components/post/feed/threaded/ThreadedFeed.js +8 -0
- package/dist/components/post/helpers.d.ts +6 -0
- package/dist/components/post/helpers.js +24 -0
- package/dist/components/post/index.d.ts +78 -0
- package/dist/components/post/index.js +57 -0
- package/dist/components/post/pieces/Attachments.d.ts +5 -0
- package/dist/components/post/pieces/Attachments.js +44 -0
- package/dist/components/post/pieces/EventLocation.d.ts +7 -0
- package/dist/components/post/pieces/EventLocation.js +28 -0
- package/dist/components/post/pieces/EventMenu.d.ts +6 -0
- package/dist/components/post/pieces/EventMenu.js +35 -0
- package/dist/components/post/pieces/EventRsvpButton.d.ts +5 -0
- package/dist/components/post/pieces/EventRsvpButton.js +60 -0
- package/dist/components/post/pieces/FeedPostStats.d.ts +5 -0
- package/dist/components/post/pieces/FeedPostStats.js +27 -0
- package/dist/components/post/pieces/GalleryModal.d.ts +7 -0
- package/dist/components/post/pieces/GalleryModal.js +16 -0
- package/dist/components/post/pieces/ParticipantsCard.d.ts +8 -0
- package/dist/components/post/pieces/ParticipantsCard.js +13 -0
- package/dist/components/post/pieces/PollContent.d.ts +5 -0
- package/dist/components/post/pieces/PollContent.js +109 -0
- package/dist/components/post/pieces/PostActions.d.ts +6 -0
- package/dist/components/post/pieces/PostActions.js +63 -0
- package/dist/components/post/pieces/PostInfoHeader.d.ts +7 -0
- package/dist/components/post/pieces/PostInfoHeader.js +8 -0
- package/dist/components/post/pieces/PostMenu.d.ts +6 -0
- package/dist/components/post/pieces/PostMenu.js +77 -0
- package/dist/components/post/pieces/PostReactionHeader.d.ts +12 -0
- package/dist/components/post/pieces/PostReactionHeader.js +31 -0
- package/dist/components/post/pieces/ShareMenu.d.ts +6 -0
- package/dist/components/post/pieces/ShareMenu.js +46 -0
- package/dist/components/post/pieces/UnreadPostIndicator.d.ts +9 -0
- package/dist/components/post/pieces/UnreadPostIndicator.js +6 -0
- package/dist/components/post/pieces/VideoPlayer.d.ts +16 -0
- package/dist/components/post/pieces/VideoPlayer.js +127 -0
- package/dist/components/post/pieces/modals/DeletePostModal.d.ts +8 -0
- package/dist/components/post/pieces/modals/DeletePostModal.js +20 -0
- package/dist/components/post/pieces/modals/ReactionsModal.d.ts +7 -0
- package/dist/components/post/pieces/modals/ReactionsModal.js +11 -0
- package/dist/components/post/pieces/modals/RepostModal.d.ts +7 -0
- package/dist/components/post/pieces/modals/RepostModal.js +13 -0
- package/dist/components/post/post-form/ArticleForm.d.ts +7 -0
- package/dist/components/post/post-form/ArticleForm.js +45 -0
- package/dist/components/post/post-form/AttachmentCard.d.ts +29 -0
- package/dist/components/post/post-form/AttachmentCard.js +120 -0
- package/dist/components/post/post-form/ComposeAttachments.d.ts +25 -0
- package/dist/components/post/post-form/ComposeAttachments.js +137 -0
- package/dist/components/post/post-form/ComposePreviewLinks.d.ts +4 -0
- package/dist/components/post/post-form/ComposePreviewLinks.js +9 -0
- package/dist/components/post/post-form/DescriptionEditModal.d.ts +13 -0
- package/dist/components/post/post-form/DescriptionEditModal.js +22 -0
- package/dist/components/post/post-form/EditPostModal.d.ts +6 -0
- package/dist/components/post/post-form/EditPostModal.js +81 -0
- package/dist/components/post/post-form/EditPostModalContext.d.ts +10 -0
- package/dist/components/post/post-form/EditPostModalContext.js +18 -0
- package/dist/components/post/post-form/EventForm.d.ts +7 -0
- package/dist/components/post/post-form/EventForm.js +104 -0
- package/dist/components/post/post-form/EventTypeSwitcher.d.ts +8 -0
- package/dist/components/post/post-form/EventTypeSwitcher.js +165 -0
- package/dist/components/post/post-form/NewPostModal.d.ts +13 -0
- package/dist/components/post/post-form/NewPostModal.js +272 -0
- package/dist/components/post/post-form/NewPostModalContext.d.ts +15 -0
- package/dist/components/post/post-form/NewPostModalContext.js +20 -0
- package/dist/components/post/post-form/OpenpeepsMarkdownInput.d.ts +19 -0
- package/dist/components/post/post-form/OpenpeepsMarkdownInput.js +65 -0
- package/dist/components/post/post-form/PollComposerFields.d.ts +12 -0
- package/dist/components/post/post-form/PollComposerFields.js +19 -0
- package/dist/components/post/post-form/PostAudienceSelector.d.ts +12 -0
- package/dist/components/post/post-form/PostAudienceSelector.js +83 -0
- package/dist/components/post/post-form/PostTypeSwitcher.d.ts +16 -0
- package/dist/components/post/post-form/PostTypeSwitcher.js +22 -0
- package/dist/components/post/post-form/ReplyModal.d.ts +6 -0
- package/dist/components/post/post-form/ReplyModal.js +202 -0
- package/dist/components/post/post-form/ReplyModalContext.d.ts +10 -0
- package/dist/components/post/post-form/ReplyModalContext.js +18 -0
- package/dist/components/post/post-form/VisibilitySelector.d.ts +8 -0
- package/dist/components/post/post-form/VisibilitySelector.js +35 -0
- package/dist/components/post/post-form/audienceChoices.d.ts +14 -0
- package/dist/components/post/post-form/audienceChoices.js +66 -0
- package/dist/components/post/types/Article.d.ts +5 -0
- package/dist/components/post/types/Article.js +14 -0
- package/dist/components/post/types/Event.d.ts +5 -0
- package/dist/components/post/types/Event.js +19 -0
- package/dist/components/post/types/Note.d.ts +5 -0
- package/dist/components/post/types/Note.js +10 -0
- package/dist/components/post/types/Poll.d.ts +7 -0
- package/dist/components/post/types/Poll.js +11 -0
- package/dist/components/post/types/article/FullArticle.d.ts +5 -0
- package/dist/components/post/types/article/FullArticle.js +8 -0
- package/dist/components/post/types/event/CardEvent.d.ts +5 -0
- package/dist/components/post/types/event/CardEvent.js +45 -0
- package/dist/components/post/types/event/FullEvent.d.ts +5 -0
- package/dist/components/post/types/event/FullEvent.js +161 -0
- package/dist/components/post/types/event/ProfileEventRelationship.d.ts +5 -0
- package/dist/components/post/types/event/ProfileEventRelationship.js +31 -0
- package/dist/components/post/types/note/FullNote.d.ts +5 -0
- package/dist/components/post/types/note/FullNote.js +5 -0
- package/dist/components/post/types/poll/FullPoll.d.ts +5 -0
- package/dist/components/post/types/poll/FullPoll.js +7 -0
- package/dist/components/post/visibility.d.ts +7 -0
- package/dist/components/post/visibility.js +10 -0
- package/dist/components/preview-link/LocalPreviewLink.d.ts +4 -0
- package/dist/components/preview-link/LocalPreviewLink.js +12 -0
- package/dist/components/preview-link/PreviewLink.d.ts +4 -0
- package/dist/components/preview-link/PreviewLink.js +11 -0
- package/dist/components/preview-link/RemotePreviewLink.d.ts +4 -0
- package/dist/components/preview-link/RemotePreviewLink.js +21 -0
- package/dist/components/preview-link/helpers.d.ts +7 -0
- package/dist/components/preview-link/helpers.js +31 -0
- package/dist/components/preview-link/index.d.ts +3 -0
- package/dist/components/preview-link/index.js +2 -0
- package/dist/components/preview-link/local/GroupPreview.d.ts +4 -0
- package/dist/components/preview-link/local/GroupPreview.js +15 -0
- package/dist/components/preview-link/local/JamPreview.d.ts +9 -0
- package/dist/components/preview-link/local/JamPreview.js +20 -0
- package/dist/components/preview-link/local/PostPreview.d.ts +4 -0
- package/dist/components/preview-link/local/PostPreview.js +15 -0
- package/dist/components/profile/Avatar.d.ts +17 -0
- package/dist/components/profile/Avatar.js +36 -0
- package/dist/components/profile/AvatarWithName.d.ts +5 -0
- package/dist/components/profile/AvatarWithName.js +5 -0
- package/dist/components/profile/FollowUnfollowButton.d.ts +8 -0
- package/dist/components/profile/FollowUnfollowButton.js +27 -0
- package/dist/components/profile/ProfileBadge.d.ts +7 -0
- package/dist/components/profile/ProfileBadge.js +12 -0
- package/dist/components/profile/ProfileCard.d.ts +24 -0
- package/dist/components/profile/ProfileCard.js +12 -0
- package/dist/components/profile/ProfileFromId.d.ts +6 -0
- package/dist/components/profile/ProfileFromId.js +15 -0
- package/dist/components/profile/ProfileHeader.d.ts +10 -0
- package/dist/components/profile/ProfileHeader.js +16 -0
- package/dist/components/profile/ProfileLink.d.ts +9 -0
- package/dist/components/profile/ProfileLink.js +9 -0
- package/dist/components/profile/ProfilePageAction.d.ts +6 -0
- package/dist/components/profile/ProfilePageAction.js +35 -0
- package/dist/components/profile/ProfilePostsAndReplies.d.ts +9 -0
- package/dist/components/profile/ProfilePostsAndReplies.js +24 -0
- package/dist/components/profile/ProfileSelector.d.ts +14 -0
- package/dist/components/profile/ProfileSelector.js +72 -0
- package/dist/components/profile/ProfileStats.d.ts +5 -0
- package/dist/components/profile/ProfileStats.js +6 -0
- package/dist/components/profile/ProfileWithActionCard.d.ts +5 -0
- package/dist/components/profile/ProfileWithActionCard.js +6 -0
- package/dist/components/profile/ProfilesInput.d.ts +15 -0
- package/dist/components/profile/ProfilesInput.js +31 -0
- package/dist/components/profile/ReportProfileOrPostModal.d.ts +9 -0
- package/dist/components/profile/ReportProfileOrPostModal.js +75 -0
- package/dist/components/profile/index.d.ts +30 -0
- package/dist/components/profile/index.js +15 -0
- package/dist/components/registry/ErrorComponent.d.ts +6 -0
- package/dist/components/registry/ErrorComponent.js +7 -0
- package/dist/components/registry/PluginLoader.d.ts +3 -0
- package/dist/components/registry/PluginLoader.js +51 -0
- package/dist/components/registry/PluginRegistryProvider.d.ts +23 -0
- package/dist/components/registry/PluginRegistryProvider.js +57 -0
- package/dist/components/registry/PluginSlot.d.ts +7 -0
- package/dist/components/registry/PluginSlot.js +31 -0
- package/dist/components/registry/index.d.ts +10 -0
- package/dist/components/registry/index.js +16 -0
- package/dist/components/server-data/ServerDataProvider.d.ts +8 -0
- package/dist/components/server-data/ServerDataProvider.js +30 -0
- package/dist/components/server-data/context.d.ts +121 -0
- package/dist/components/server-data/context.js +10 -0
- package/dist/components/server-data/index.d.ts +4 -0
- package/dist/components/server-data/index.js +2 -0
- package/dist/components/server-data/types.d.ts +5 -0
- package/dist/components/server-data/types.js +1 -0
- package/dist/contexts/credentialsStore/index.d.ts +8 -0
- package/dist/contexts/credentialsStore/index.js +13 -0
- package/dist/contexts/credentialsStore/types.d.ts +4 -0
- package/dist/contexts/credentialsStore/types.js +1 -0
- package/dist/contexts/index.d.ts +3 -0
- package/dist/contexts/index.js +3 -0
- package/dist/contexts/openpeeps/helpers.d.ts +93 -0
- package/dist/contexts/openpeeps/helpers.js +311 -0
- package/dist/contexts/openpeeps/hooks/accounts.d.ts +302 -0
- package/dist/contexts/openpeeps/hooks/accounts.js +17 -0
- package/dist/contexts/openpeeps/hooks/admin.d.ts +17177 -0
- package/dist/contexts/openpeeps/hooks/admin.js +115 -0
- package/dist/contexts/openpeeps/hooks/auth.d.ts +55 -0
- package/dist/contexts/openpeeps/hooks/auth.js +22 -0
- package/dist/contexts/openpeeps/hooks/conversations.d.ts +9815 -0
- package/dist/contexts/openpeeps/hooks/conversations.js +6 -0
- package/dist/contexts/openpeeps/hooks/groups.d.ts +319 -0
- package/dist/contexts/openpeeps/hooks/groups.js +31 -0
- package/dist/contexts/openpeeps/hooks/index.d.ts +18 -0
- package/dist/contexts/openpeeps/hooks/index.js +26 -0
- package/dist/contexts/openpeeps/hooks/jams.d.ts +3318 -0
- package/dist/contexts/openpeeps/hooks/jams.js +32 -0
- package/dist/contexts/openpeeps/hooks/other.d.ts +239 -0
- package/dist/contexts/openpeeps/hooks/other.js +89 -0
- package/dist/contexts/openpeeps/hooks/payments.d.ts +36 -0
- package/dist/contexts/openpeeps/hooks/payments.js +10 -0
- package/dist/contexts/openpeeps/hooks/posts.d.ts +26001 -0
- package/dist/contexts/openpeeps/hooks/posts.js +139 -0
- package/dist/contexts/openpeeps/hooks/profiles.d.ts +6896 -0
- package/dist/contexts/openpeeps/hooks/profiles.js +43 -0
- package/dist/contexts/openpeeps/hooks/search.d.ts +9620 -0
- package/dist/contexts/openpeeps/hooks/search.js +24 -0
- package/dist/contexts/openpeeps/hooks/streaming.d.ts +26 -0
- package/dist/contexts/openpeeps/hooks/streaming.js +10 -0
- package/dist/contexts/openpeeps/hooks/useHasAuthToken.d.ts +2 -0
- package/dist/contexts/openpeeps/hooks/useHasAuthToken.js +35 -0
- package/dist/contexts/openpeeps/index.d.ts +21 -0
- package/dist/contexts/openpeeps/index.js +180 -0
- package/dist/contexts/openpeeps/types.d.ts +11 -0
- package/dist/contexts/openpeeps/types.js +1 -0
- package/dist/contexts/router/index.d.ts +28 -0
- package/dist/contexts/router/index.js +69 -0
- package/dist/email/index.d.ts +13 -0
- package/dist/email/index.js +10 -0
- package/dist/i18n/I18nProvider.d.ts +19 -0
- package/dist/i18n/I18nProvider.js +33 -0
- package/dist/i18n/context.d.ts +8 -0
- package/dist/i18n/context.js +10 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.js +23 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/lib/apiErrorMessage.d.ts +3 -0
- package/dist/lib/apiErrorMessage.js +14 -0
- package/dist/lib/canvasUtils.d.ts +12 -0
- package/dist/lib/canvasUtils.js +104 -0
- package/dist/lib/configuration/helpers.d.ts +7 -0
- package/dist/lib/configuration/helpers.js +83 -0
- package/dist/lib/configuration/resolveSchema.d.ts +3 -0
- package/dist/lib/configuration/resolveSchema.js +8 -0
- package/dist/lib/groupCapabilityHelpers.d.ts +24 -0
- package/dist/lib/groupCapabilityHelpers.js +119 -0
- package/dist/lib/notificationBadge.d.ts +5 -0
- package/dist/lib/notificationBadge.js +25 -0
- package/dist/lib/postUnread.d.ts +2 -0
- package/dist/lib/postUnread.js +1 -0
- package/dist/lib/postViewCounter.d.ts +17 -0
- package/dist/lib/postViewCounter.js +162 -0
- package/dist/lib/threadHelpers.d.ts +5 -0
- package/dist/lib/threadHelpers.js +23 -0
- package/dist/lib/unseenCountsOptimistic.d.ts +15 -0
- package/dist/lib/unseenCountsOptimistic.js +43 -0
- package/dist/log/index.d.ts +11 -0
- package/dist/log/index.js +14 -0
- package/dist/push/index.d.ts +16 -0
- package/dist/push/index.js +145 -0
- package/dist/push/usePushSubscription.d.ts +18 -0
- package/dist/push/usePushSubscription.js +102 -0
- package/dist/push/vapid.d.ts +6 -0
- package/dist/push/vapid.js +12 -0
- package/dist/pwa/InstallPrompt.d.ts +13 -0
- package/dist/pwa/InstallPrompt.js +17 -0
- package/dist/pwa/NotificationPermissionPrompt.d.ts +22 -0
- package/dist/pwa/NotificationPermissionPrompt.js +56 -0
- package/dist/pwa/PwaProvider.d.ts +16 -0
- package/dist/pwa/PwaProvider.js +56 -0
- package/dist/pwa/UpdatePrompt.d.ts +14 -0
- package/dist/pwa/UpdatePrompt.js +14 -0
- package/dist/pwa/index.d.ts +18 -0
- package/dist/pwa/index.js +16 -0
- package/dist/pwa/navigationUrl.d.ts +16 -0
- package/dist/pwa/navigationUrl.js +51 -0
- package/dist/pwa/pushInvalidate.d.ts +7 -0
- package/dist/pwa/pushInvalidate.js +29 -0
- package/dist/pwa/registration.d.ts +28 -0
- package/dist/pwa/registration.js +71 -0
- package/dist/pwa/sw-types.d.ts +14 -0
- package/dist/pwa/sw-types.js +1 -0
- package/dist/pwa/sw.d.ts +2 -0
- package/dist/pwa/sw.js +171 -0
- package/dist/pwa/useInstallPrompt.d.ts +10 -0
- package/dist/pwa/useInstallPrompt.js +45 -0
- package/dist/pwa/useNotificationBadgeSync.d.ts +2 -0
- package/dist/pwa/useNotificationBadgeSync.js +23 -0
- package/dist/pwa/useServiceWorker.d.ts +19 -0
- package/dist/pwa/useServiceWorker.js +49 -0
- package/dist/pwa/vite.d.ts +50 -0
- package/dist/pwa/vite.js +53 -0
- package/dist/react-native.d.ts +11 -0
- package/dist/react-native.js +11 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +5 -0
- package/dist/stores/breadcrumbs.d.ts +5 -0
- package/dist/stores/breadcrumbs.js +5 -0
- package/dist/stores/createStore.d.ts +19 -0
- package/dist/stores/createStore.js +63 -0
- package/dist/stores/index.d.ts +7 -0
- package/dist/stores/index.js +9 -0
- package/dist/stores/newPosts.d.ts +591 -0
- package/dist/stores/newPosts.js +191 -0
- package/dist/stores/pageHeader.d.ts +15 -0
- package/dist/stores/pageHeader.js +22 -0
- package/dist/stores/plusButton.d.ts +5 -0
- package/dist/stores/plusButton.js +13 -0
- package/dist/stores/types.d.ts +35 -0
- package/dist/stores/types.js +1 -0
- package/dist/streaming.d.ts +6 -0
- package/dist/streaming.js +6 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/index.js +1 -0
- package/package.json +72 -0
- package/src/pwa/navigationUrl.ts +61 -0
- package/src/pwa/sw-types.ts +9 -0
- package/src/pwa/sw.ts +228 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Button, Popover, PopoverAnchor, PopoverContent, Textarea, cn, } from '@openpeepshq/react-ui';
|
|
4
|
+
import { useT } from '../../../i18n/index.js';
|
|
5
|
+
import { useOpenpeeps } from '../../../contexts/openpeeps/index.js';
|
|
6
|
+
import { OpenpeepsMarkdown } from '../../markdown/index.js';
|
|
7
|
+
import { ProfileCard } from '../../profile/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Markdown editor mirroring the Svelte `OpenpeepsMarkdownInput`: a textarea
|
|
10
|
+
* with @-mention autocomplete, a preview toggle that renders the markdown over
|
|
11
|
+
* the field, and a character counter.
|
|
12
|
+
*/
|
|
13
|
+
export function OpenpeepsMarkdownInput({ value, onChange, maxLength = 500, placeholder, rows = 5, previewButton = true, className, testId, }) {
|
|
14
|
+
const t = useT();
|
|
15
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
16
|
+
const [query, setQuery] = useState('');
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const [showPreview, setShowPreview] = useState(false);
|
|
19
|
+
const textareaRef = useRef(null);
|
|
20
|
+
const anchorRef = useRef(null);
|
|
21
|
+
const profilesQuery = openpeepsApi.useSearchProfiles(query);
|
|
22
|
+
const profiles = useMemo(() => (profilesQuery.data?.pages ?? [])
|
|
23
|
+
.flat()
|
|
24
|
+
.map((item) => item.data)
|
|
25
|
+
.slice(0, 6), [profilesQuery.data]);
|
|
26
|
+
const showMentions = open && query.length >= 1 && profiles.length > 0;
|
|
27
|
+
const handleChange = (next) => {
|
|
28
|
+
onChange(next);
|
|
29
|
+
const el = textareaRef.current;
|
|
30
|
+
if (!el)
|
|
31
|
+
return;
|
|
32
|
+
const cursor = el.selectionStart ?? next.length;
|
|
33
|
+
const before = next.slice(0, cursor);
|
|
34
|
+
const match = before.match(/@([a-zA-Z0-9_-]*)$/);
|
|
35
|
+
if (match) {
|
|
36
|
+
setQuery(match[1] ?? '');
|
|
37
|
+
setOpen(true);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
setOpen(false);
|
|
41
|
+
setQuery('');
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const insertMention = (profile) => {
|
|
45
|
+
const el = textareaRef.current;
|
|
46
|
+
const cursor = el?.selectionStart ?? value.length;
|
|
47
|
+
const before = value.slice(0, cursor);
|
|
48
|
+
const after = value.slice(cursor);
|
|
49
|
+
const replaced = before.replace(/@([a-zA-Z0-9_-]*)$/, `@${profile.handle} `);
|
|
50
|
+
onChange(`${replaced}${after}`);
|
|
51
|
+
setOpen(false);
|
|
52
|
+
setQuery('');
|
|
53
|
+
};
|
|
54
|
+
const overLimit = value.length > maxLength;
|
|
55
|
+
return (_jsxs("div", { className: "relative w-full", children: [showPreview ? (_jsxs("div", { className: "bg-surface-50 border-surface-200 absolute inset-0 z-10 overflow-y-auto rounded-md border p-4 pt-16", children: [_jsx(Button, { compact: true, variant: "variant-ringed-surface", className: "absolute left-2 top-2", action: () => setShowPreview(false), children: t('form.edit', { defaultValue: 'Back to Editing' }) }), _jsx(OpenpeepsMarkdown, { source: value, linkPreviewMode: "none" })] })) : null, previewButton ? (_jsx("div", { className: "w-full pb-2", children: _jsx(Button, { compact: true, variant: "variant-ringed-surface", action: () => setShowPreview(true), children: t('form.preview', { defaultValue: 'Preview' }) }) })) : null, _jsxs(Popover, { open: showMentions, modal: false, children: [_jsx(PopoverAnchor, { asChild: true, children: _jsx("div", { ref: anchorRef, className: "w-full", children: _jsx(Textarea, { ref: textareaRef, rows: rows, value: value, maxLength: maxLength, placeholder: placeholder ?? t('posts.form.content'), onChange: (e) => handleChange(e.target.value), "data-testid": testId, className: cn('resize-y', className) }) }) }), _jsx(PopoverContent, { align: "start", side: "bottom", sideOffset: 4, onOpenAutoFocus: (e) => e.preventDefault(), onCloseAutoFocus: (e) => e.preventDefault(),
|
|
56
|
+
// Keep the list open while the user keeps typing in the anchored field.
|
|
57
|
+
onPointerDownOutside: (e) => {
|
|
58
|
+
if (anchorRef.current?.contains(e.target)) {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
}
|
|
61
|
+
}, className: "bg-card z-[100] max-h-48 w-[var(--radix-popover-trigger-width)] overflow-y-auto p-0 shadow-md", children: profiles.map((profile) => (_jsx("button", { type: "button", className: "hover:bg-surface-100 w-full text-left", onMouseDown: (e) => {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
insertMention(profile);
|
|
64
|
+
}, children: _jsx(ProfileCard, { profile: profile, showAction: false }) }, profile.id))) })] }), _jsxs("div", { className: "w-full px-2 text-right text-sm", children: [_jsx("span", { className: overLimit ? 'text-error' : undefined, children: value.length }), ' ', "/ ", maxLength] })] }));
|
|
65
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface PollComposerFieldsProps {
|
|
2
|
+
options: string[];
|
|
3
|
+
onOptionsChange: (options: string[]) => void;
|
|
4
|
+
expiresAt: string;
|
|
5
|
+
onExpiresAtChange: (value: string) => void;
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
onMultipleChange?: (value: boolean) => void;
|
|
8
|
+
votersVisible?: boolean;
|
|
9
|
+
onVotersVisibleChange?: (value: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
/** Shared poll option + settings fields used in compose and edit flows. */
|
|
12
|
+
export declare function PollComposerFields({ options, onOptionsChange, expiresAt, onExpiresAtChange, multiple, onMultipleChange, votersVisible, onVotersVisibleChange, }: PollComposerFieldsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Input, Label } from '@openpeepshq/react-ui';
|
|
3
|
+
import { useT } from '../../../i18n/index.js';
|
|
4
|
+
/** Shared poll option + settings fields used in compose and edit flows. */
|
|
5
|
+
export function PollComposerFields({ options, onOptionsChange, expiresAt, onExpiresAtChange, multiple = false, onMultipleChange, votersVisible = false, onVotersVisibleChange, }) {
|
|
6
|
+
const t = useT();
|
|
7
|
+
return (_jsxs("div", { className: "space-y-2", children: [options.map((opt, index) => (_jsx(Input, { value: opt, placeholder: t('posts.form.poll.optionPlaceholder', {
|
|
8
|
+
defaultValue: 'Option {{n}}',
|
|
9
|
+
n: index + 1,
|
|
10
|
+
}), "data-testid": `posts-poll-option-${index + 1}`, onChange: (e) => {
|
|
11
|
+
const next = [...options];
|
|
12
|
+
next[index] = e.target.value;
|
|
13
|
+
onOptionsChange(next);
|
|
14
|
+
} }, index))), options.length < 6 ? (_jsx(Button, { variant: "variant-ghost-primary", action: () => onOptionsChange([...options, '']), children: t('posts.form.poll.addOption', { defaultValue: 'Add option' }) })) : null, _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "poll-expires", children: t('posts.form.poll.expiresAt', { defaultValue: 'Expires at' }) }), _jsx(Input, { id: "poll-expires", type: "datetime-local", value: expiresAt, onChange: (e) => onExpiresAtChange(e.target.value) })] }), onMultipleChange ? (_jsxs("label", { className: "flex items-start gap-2 text-sm", children: [_jsx("input", { type: "checkbox", checked: multiple, onChange: (e) => onMultipleChange(e.target.checked) }), _jsx("span", { children: t('posts.form.poll.multipleAnswers', {
|
|
15
|
+
defaultValue: 'Allow multiple answers',
|
|
16
|
+
}) })] })) : null, onVotersVisibleChange ? (_jsxs("label", { className: "flex items-start gap-2 text-sm", children: [_jsx("input", { type: "checkbox", checked: votersVisible, onChange: (e) => onVotersVisibleChange(e.target.checked) }), _jsx("span", { children: t('posts.form.poll.seeWhoVotedTitle', {
|
|
17
|
+
defaultValue: 'Show who voted',
|
|
18
|
+
}) })] })) : null] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AudienceSetting, PostType, PublicProfile, VisibilityType } from '@openpeepshq/common';
|
|
2
|
+
export interface PostAudienceSelectorProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
type?: PostType;
|
|
6
|
+
visibility: VisibilityType;
|
|
7
|
+
groupId?: string;
|
|
8
|
+
audience?: PublicProfile[];
|
|
9
|
+
showDirect?: boolean;
|
|
10
|
+
onConfirm: (settings: AudienceSetting) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const PostAudienceSelector: ({ open, onClose, type, visibility, groupId, audience, showDirect, onConfirm, }: PostAudienceSelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { CheckCircle } from 'lucide-react';
|
|
4
|
+
import { checkGroupCapabilities } from '@openpeepshq/common/lib';
|
|
5
|
+
import { Button, Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from '@openpeepshq/react-ui';
|
|
6
|
+
import { useT } from '../../../i18n/index.js';
|
|
7
|
+
import { useAuthData, useCurrentProfile } from '../../layout/IdentityContext.js';
|
|
8
|
+
import { useServerInfo } from '../../server-data/index.js';
|
|
9
|
+
import { GroupCard } from '../../groups/GroupCard.js';
|
|
10
|
+
import { ProfileBadge, ProfileSelector } from '../../profile/index.js';
|
|
11
|
+
import { buildAudienceChoices } from './audienceChoices.js';
|
|
12
|
+
export const PostAudienceSelector = ({ open, onClose, type = 'note', visibility, groupId, audience = [], showDirect = true, onConfirm, }) => {
|
|
13
|
+
const t = useT();
|
|
14
|
+
const authData = useAuthData();
|
|
15
|
+
const me = useCurrentProfile();
|
|
16
|
+
const serverInfo = useServerInfo();
|
|
17
|
+
const [draftVisibility, setDraftVisibility] = useState(visibility);
|
|
18
|
+
const [draftGroupId, setDraftGroupId] = useState(groupId);
|
|
19
|
+
const [draftAudience, setDraftAudience] = useState(audience);
|
|
20
|
+
const [view, setView] = useState('main');
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!open)
|
|
23
|
+
return;
|
|
24
|
+
setDraftVisibility(visibility);
|
|
25
|
+
setDraftGroupId(groupId);
|
|
26
|
+
setDraftAudience(audience);
|
|
27
|
+
setView('main');
|
|
28
|
+
}, [open, visibility, groupId, audience]);
|
|
29
|
+
const choices = useMemo(() => buildAudienceChoices(type, authData, t, {
|
|
30
|
+
publicContent: serverInfo.publicContent,
|
|
31
|
+
showDirect,
|
|
32
|
+
}), [type, authData, t, serverInfo.publicContent, showDirect]);
|
|
33
|
+
const groups = useMemo(() => me?.memberships
|
|
34
|
+
?.map((m) => m.group)
|
|
35
|
+
.filter((grp) => checkGroupCapabilities(authData, [`core-posts-create-${type}`], grp)
|
|
36
|
+
.success) ?? [], [me, authData, type]);
|
|
37
|
+
const selectVisibility = (value) => {
|
|
38
|
+
setDraftVisibility(value);
|
|
39
|
+
if (value !== 'direct')
|
|
40
|
+
setDraftAudience([]);
|
|
41
|
+
if (value !== 'group')
|
|
42
|
+
setDraftGroupId(undefined);
|
|
43
|
+
if (value === 'group' && !draftGroupId) {
|
|
44
|
+
setView('groups');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (value === 'direct') {
|
|
48
|
+
setView('audience');
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const confirm = () => {
|
|
52
|
+
onConfirm({
|
|
53
|
+
visibility: draftVisibility,
|
|
54
|
+
groupId: draftVisibility === 'group' ? draftGroupId : undefined,
|
|
55
|
+
audience: draftVisibility === 'direct' && draftAudience.length
|
|
56
|
+
? draftAudience
|
|
57
|
+
: undefined,
|
|
58
|
+
});
|
|
59
|
+
onClose();
|
|
60
|
+
};
|
|
61
|
+
return (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: open && view !== 'audience', onOpenChange: (next) => !next && onClose(), children: _jsxs(DialogContent, { className: "max-h-[85vh] max-w-lg overflow-y-auto", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t('posts.form.audienceTitle', {
|
|
62
|
+
defaultValue: 'Who can see this?',
|
|
63
|
+
}) }) }), view === 'groups' ? (_jsxs("div", { className: "space-y-2", children: [groups.map((group) => (_jsxs("div", { className: "flex w-full items-center justify-between rounded-md border p-2", children: [_jsx(GroupCard, { group: group, noPadding: true, showAction: false, onSelect: () => {
|
|
64
|
+
setDraftGroupId(group.id);
|
|
65
|
+
setDraftVisibility('group');
|
|
66
|
+
setView('main');
|
|
67
|
+
} }), draftGroupId === group.id ? (_jsx(CheckCircle, { className: "text-primary size-5" })) : null] }, group.id))), groups.length === 0 ? (_jsx("p", { className: "text-muted-foreground py-4 text-center text-sm", children: t('posts.form.noGroups', {
|
|
68
|
+
defaultValue: 'No groups available',
|
|
69
|
+
}) })) : null] })) : (_jsx("div", { className: "space-y-2", children: choices.map((choice) => {
|
|
70
|
+
const Icon = choice.icon;
|
|
71
|
+
return (_jsxs("button", { type: "button", className: "hover:bg-surface-100 flex w-full items-start gap-3 rounded-md border p-3 text-left", onClick: () => selectVisibility(choice.value), children: [_jsx("span", { className: "bg-surface-100 flex size-10 items-center justify-center rounded-full", children: _jsx(Icon, { className: "size-5" }) }), _jsxs("span", { className: "flex-1", children: [_jsx("span", { className: "block font-medium", children: choice.title }), _jsx("span", { className: "text-muted-foreground block text-sm", children: choice.description }), choice.value === 'group' && draftGroupId ? (_jsx("span", { className: "text-primary mt-1 block text-xs", children: groups.find((g) => g.id === draftGroupId)
|
|
72
|
+
?.displayName ??
|
|
73
|
+
groups.find((g) => g.id === draftGroupId)?.handle })) : null, choice.value === 'direct' && draftAudience.length ? (_jsx("span", { className: "mt-1 flex flex-wrap gap-1", children: draftAudience.map((profile) => (_jsx(ProfileBadge, { profile: profile, onRemove: () => setDraftAudience((current) => current.filter((p) => p.id !== profile.id)) }, profile.id))) })) : null] }), _jsx("span", { className: `mt-1 size-4 rounded-full border ${draftVisibility === choice.value ? 'bg-primary border-primary' : ''}` })] }, choice.value));
|
|
74
|
+
}) })), _jsxs(DialogFooter, { children: [view !== 'main' ? (_jsx(Button, { variant: "variant-ringed-surface", action: () => setView('main'), children: t('navigation.back', { defaultValue: 'Back' }) })) : (_jsx(Button, { variant: "variant-ringed-surface", action: onClose, children: t('common.cancel', { defaultValue: 'Cancel' }) })), _jsx(Button, { variant: "variant-filled-primary", action: confirm, children: t('common.done', { defaultValue: 'Done' }) })] })] }) }), _jsx(ProfileSelector, { open: open && view === 'audience', onOpenChange: (next) => {
|
|
75
|
+
if (!next)
|
|
76
|
+
setView('main');
|
|
77
|
+
}, mode: "multiple", selectedProfiles: draftAudience, banlist: me ? [me] : [], onConfirm: (profiles) => {
|
|
78
|
+
setDraftAudience(profiles);
|
|
79
|
+
setView('main');
|
|
80
|
+
}, title: t('posts.form.audienceTitle', {
|
|
81
|
+
defaultValue: 'Who can see this?',
|
|
82
|
+
}) })] }));
|
|
83
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PostType } from '@openpeepshq/common/types';
|
|
2
|
+
export interface PostTypeSwitcherProps {
|
|
3
|
+
type: PostType;
|
|
4
|
+
/** Switch the in-modal composer between the note and poll forms. */
|
|
5
|
+
onSelect: (type: 'note' | 'question') => void;
|
|
6
|
+
/** Dismiss the modal before navigating to a full-page composer. */
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
showEventType?: boolean;
|
|
9
|
+
showArticleType?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Icon switcher mirroring the Svelte `PostTypeSwitcher`. Note and poll swap the
|
|
13
|
+
* in-modal form; event and article navigate to their dedicated pages (events
|
|
14
|
+
* are gated to community owners, matching the Svelte role check).
|
|
15
|
+
*/
|
|
16
|
+
export declare function PostTypeSwitcher({ type, onSelect, onClose, showEventType, showArticleType, }: PostTypeSwitcherProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CalendarDays, ChartColumnBig, Notebook, ScrollText, } from 'lucide-react';
|
|
3
|
+
import { Button } from '@openpeepshq/react-ui';
|
|
4
|
+
import { useT } from '../../../i18n/index.js';
|
|
5
|
+
import { useNavigate } from '../../../contexts/router/index.js';
|
|
6
|
+
import { useCurrentProfile } from '../../layout/IdentityContext.js';
|
|
7
|
+
/**
|
|
8
|
+
* Icon switcher mirroring the Svelte `PostTypeSwitcher`. Note and poll swap the
|
|
9
|
+
* in-modal form; event and article navigate to their dedicated pages (events
|
|
10
|
+
* are gated to community owners, matching the Svelte role check).
|
|
11
|
+
*/
|
|
12
|
+
export function PostTypeSwitcher({ type, onSelect, onClose, showEventType = true, showArticleType = true, }) {
|
|
13
|
+
const t = useT();
|
|
14
|
+
const navigate = useNavigate();
|
|
15
|
+
const me = useCurrentProfile();
|
|
16
|
+
const isOwner = Boolean(me?.roles?.some((role) => role.key === 'owner'));
|
|
17
|
+
const goto = (path) => {
|
|
18
|
+
onClose();
|
|
19
|
+
navigate(path);
|
|
20
|
+
};
|
|
21
|
+
return (_jsxs("div", { className: "flex items-center gap-1", children: [type !== 'note' ? (_jsx(Button, { compact: true, variant: "variant-ghost-primary", title: t('posts.switcher.note', { defaultValue: 'Write Note' }), action: () => onSelect('note'), children: _jsx(Notebook, { className: "size-5" }) })) : null, type !== 'question' ? (_jsx(Button, { compact: true, variant: "variant-ghost-primary", title: t('posts.switcher.poll', { defaultValue: 'Add Poll' }), action: () => onSelect('question'), "data-testid": "posts-composer-poll-type", children: _jsx(ChartColumnBig, { className: "size-5" }) })) : null, showEventType && isOwner ? (_jsx(Button, { compact: true, variant: "variant-ghost-primary", title: t('posts.switcher.event', { defaultValue: 'Create an Event' }), action: () => goto('/events/new'), children: _jsx(CalendarDays, { className: "size-5" }) })) : null, showArticleType ? (_jsx(Button, { compact: true, variant: "variant-ghost-primary", title: t('posts.switcher.article', { defaultValue: 'Write Article' }), action: () => goto('/articles/new'), children: _jsx(ScrollText, { className: "size-5" }) })) : null] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { Image, Paperclip } from 'lucide-react';
|
|
4
|
+
import { Button, Dialog, DialogContent, DialogHeader, DialogTitle, ModalFooter, } from '@openpeepshq/react-ui';
|
|
5
|
+
import { useOpenpeeps } from '../../../contexts/openpeeps/index.js';
|
|
6
|
+
import { useT } from '../../../i18n/index.js';
|
|
7
|
+
import { useToast } from '../../layout/ToastProvider.js';
|
|
8
|
+
import { useCurrentProfile } from '../../layout/IdentityContext.js';
|
|
9
|
+
import { defaultNewNote, defaultNewQuestion, resetReplyData, useReplyStore, } from '../../../stores/newPosts.js';
|
|
10
|
+
import { useServerInfo } from '../../server-data/index.js';
|
|
11
|
+
import { ThreadPost } from '../feed/threaded/ThreadPost.js';
|
|
12
|
+
import { Avatar } from '../../profile/index.js';
|
|
13
|
+
import { OpenpeepsMarkdownInput } from './OpenpeepsMarkdownInput.js';
|
|
14
|
+
import { ComposePreviewLinks } from './ComposePreviewLinks.js';
|
|
15
|
+
import { useComposeAttachments } from './ComposeAttachments.js';
|
|
16
|
+
import { PostTypeSwitcher } from './PostTypeSwitcher.js';
|
|
17
|
+
import { PollComposerFields } from './PollComposerFields.js';
|
|
18
|
+
export function ReplyModal({ post, onClose }) {
|
|
19
|
+
const t = useT();
|
|
20
|
+
const { success, error: toastError } = useToast();
|
|
21
|
+
const serverInfo = useServerInfo();
|
|
22
|
+
const me = useCurrentProfile();
|
|
23
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
24
|
+
const createPost = openpeepsApi.createPostAction();
|
|
25
|
+
const replyStore = useReplyStore(post.id);
|
|
26
|
+
const [submitting, setSubmitting] = useState(false);
|
|
27
|
+
const draft = replyStore.get();
|
|
28
|
+
const composerType = draft.data.type === 'question' ? 'question' : 'note';
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
replyStore.set((prev) => ({
|
|
31
|
+
...prev,
|
|
32
|
+
visibility: post.visibility,
|
|
33
|
+
groupId: post.groupId ?? undefined,
|
|
34
|
+
inReplyToId: post.id,
|
|
35
|
+
audience: post.audience,
|
|
36
|
+
}));
|
|
37
|
+
}, [post.audience, post.groupId, post.id, post.visibility, replyStore]);
|
|
38
|
+
const content = draft.data.type === 'note' || draft.data.type === 'question'
|
|
39
|
+
? (draft.data.content ?? '')
|
|
40
|
+
: '';
|
|
41
|
+
const attachments = draft.data.type === 'note' ? (draft.data.attachments ?? []) : [];
|
|
42
|
+
const pollOptions = draft.data.type === 'question'
|
|
43
|
+
? draft.data.options.map((o) => o.content)
|
|
44
|
+
: ['', ''];
|
|
45
|
+
const expiresAt = draft.data.type === 'question' && draft.data.expiresAt
|
|
46
|
+
? draft.data.expiresAt.slice(0, 16)
|
|
47
|
+
: '';
|
|
48
|
+
const composeAttachments = useComposeAttachments({
|
|
49
|
+
attachments,
|
|
50
|
+
onChange: (next) => {
|
|
51
|
+
if (draft.data.type !== 'note')
|
|
52
|
+
return;
|
|
53
|
+
replyStore.set({
|
|
54
|
+
...draft,
|
|
55
|
+
data: { ...draft.data, attachments: next },
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const setComposerType = (type) => {
|
|
60
|
+
const base = type === 'question'
|
|
61
|
+
? defaultNewQuestion(serverInfo.publicContent)
|
|
62
|
+
: defaultNewNote(serverInfo.publicContent);
|
|
63
|
+
replyStore.set({
|
|
64
|
+
...draft,
|
|
65
|
+
type,
|
|
66
|
+
data: base.data,
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const setContent = (value) => {
|
|
70
|
+
if (draft.data.type !== 'note' && draft.data.type !== 'question')
|
|
71
|
+
return;
|
|
72
|
+
replyStore.set({
|
|
73
|
+
...draft,
|
|
74
|
+
data: { ...draft.data, content: value },
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const trimmedContent = content.trim();
|
|
78
|
+
const validPollOptions = pollOptions.map((o) => o.trim()).filter(Boolean);
|
|
79
|
+
const canSubmit = useMemo(() => {
|
|
80
|
+
if (submitting || composeAttachments.pending)
|
|
81
|
+
return false;
|
|
82
|
+
if (composerType === 'question') {
|
|
83
|
+
return trimmedContent.length > 0 && validPollOptions.length >= 2;
|
|
84
|
+
}
|
|
85
|
+
return ((trimmedContent.length > 0 && trimmedContent.length <= 500) ||
|
|
86
|
+
attachments.length > 0);
|
|
87
|
+
}, [
|
|
88
|
+
submitting,
|
|
89
|
+
composeAttachments.pending,
|
|
90
|
+
composerType,
|
|
91
|
+
trimmedContent,
|
|
92
|
+
validPollOptions.length,
|
|
93
|
+
attachments.length,
|
|
94
|
+
]);
|
|
95
|
+
const publish = async () => {
|
|
96
|
+
if (!canSubmit)
|
|
97
|
+
return;
|
|
98
|
+
setSubmitting(true);
|
|
99
|
+
try {
|
|
100
|
+
let payload = { ...draft };
|
|
101
|
+
if (composerType === 'question' && payload.data.type === 'question') {
|
|
102
|
+
payload = {
|
|
103
|
+
...payload,
|
|
104
|
+
type: 'question',
|
|
105
|
+
data: {
|
|
106
|
+
...payload.data,
|
|
107
|
+
type: 'question',
|
|
108
|
+
content: trimmedContent,
|
|
109
|
+
options: validPollOptions.map((text) => ({
|
|
110
|
+
type: 'note',
|
|
111
|
+
content: text,
|
|
112
|
+
})),
|
|
113
|
+
expiresAt: expiresAt
|
|
114
|
+
? new Date(expiresAt).toISOString()
|
|
115
|
+
: payload.data.expiresAt,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
else if (composerType === 'note' && payload.data.type === 'note') {
|
|
120
|
+
payload = {
|
|
121
|
+
...payload,
|
|
122
|
+
type: 'note',
|
|
123
|
+
data: {
|
|
124
|
+
type: 'note',
|
|
125
|
+
content: trimmedContent,
|
|
126
|
+
attachments: attachments.length ? attachments : undefined,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
await createPost(payload);
|
|
131
|
+
resetReplyData(post.id);
|
|
132
|
+
success(t('posts.replyModal.successToast', {
|
|
133
|
+
defaultValue: 'Reply posted',
|
|
134
|
+
}));
|
|
135
|
+
onClose();
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
toastError(t('posts.replyModal.errorToast', {
|
|
139
|
+
defaultValue: 'Failed to post reply',
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
setSubmitting(false);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
return (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: true, onOpenChange: (open) => !open && onClose(), children: _jsxs(DialogContent, { className: "flex max-h-[90vh] max-w-xl flex-col gap-0 overflow-hidden p-0", children: [_jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-6 pb-4 pt-6", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t('posts.replyModal.title', { defaultValue: 'Reply' }) }) }), _jsx(ThreadPost, { post: post, noActions: true, noMenu: true }), _jsxs("div", { className: "m-4 flex gap-2", children: [me ? _jsx(Avatar, { profile: me, size: 3 }) : null, _jsxs("div", { className: "w-full space-y-2", children: [_jsx(OpenpeepsMarkdownInput, { rows: 4, value: content, onChange: setContent, placeholder: composerType === 'question'
|
|
147
|
+
? t('posts.form.poll.question', {
|
|
148
|
+
defaultValue: 'Poll question…',
|
|
149
|
+
})
|
|
150
|
+
: t('posts.replyPlaceholder', {
|
|
151
|
+
defaultValue: 'Write a reply…',
|
|
152
|
+
}) }), _jsx(ComposePreviewLinks, { content: content }), composerType === 'note' ? composeAttachments.previews : null, composerType === 'question' ? (_jsx(PollComposerFields, { options: pollOptions, onOptionsChange: (options) => {
|
|
153
|
+
if (draft.data.type !== 'question')
|
|
154
|
+
return;
|
|
155
|
+
replyStore.set({
|
|
156
|
+
...draft,
|
|
157
|
+
data: {
|
|
158
|
+
...draft.data,
|
|
159
|
+
options: options.map((text) => ({
|
|
160
|
+
type: 'note',
|
|
161
|
+
content: text,
|
|
162
|
+
})),
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
}, expiresAt: expiresAt, onExpiresAtChange: (value) => {
|
|
166
|
+
if (draft.data.type !== 'question')
|
|
167
|
+
return;
|
|
168
|
+
replyStore.set({
|
|
169
|
+
...draft,
|
|
170
|
+
data: {
|
|
171
|
+
...draft.data,
|
|
172
|
+
expiresAt: value
|
|
173
|
+
? new Date(value).toISOString()
|
|
174
|
+
: undefined,
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}, multiple: draft.data.type === 'question'
|
|
178
|
+
? draft.data.multiple
|
|
179
|
+
: false, onMultipleChange: (value) => {
|
|
180
|
+
if (draft.data.type !== 'question')
|
|
181
|
+
return;
|
|
182
|
+
replyStore.set({
|
|
183
|
+
...draft,
|
|
184
|
+
data: { ...draft.data, multiple: value },
|
|
185
|
+
});
|
|
186
|
+
}, votersVisible: draft.data.type === 'question'
|
|
187
|
+
? draft.data.votersVisible
|
|
188
|
+
: false, onVotersVisibleChange: (value) => {
|
|
189
|
+
if (draft.data.type !== 'question')
|
|
190
|
+
return;
|
|
191
|
+
replyStore.set({
|
|
192
|
+
...draft,
|
|
193
|
+
data: { ...draft.data, votersVisible: value },
|
|
194
|
+
});
|
|
195
|
+
} })) : null] })] })] }), _jsx(ModalFooter, { className: "border-t", children: _jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [_jsxs("div", { className: "flex items-center gap-1", children: [composerType === 'note' ? (_jsxs(_Fragment, { children: [_jsx(Button, { compact: true, variant: "variant-ghost-primary", title: t('posts.form.addImage', {
|
|
196
|
+
defaultValue: 'Add image',
|
|
197
|
+
}), action: composeAttachments.openImagePicker, children: _jsx(Image, { className: "size-5" }) }), _jsx(Button, { compact: true, variant: "variant-ghost-primary", title: t('posts.form.addAttachment', {
|
|
198
|
+
defaultValue: 'Add attachment',
|
|
199
|
+
}), action: composeAttachments.openDocumentPicker, children: _jsx(Paperclip, { className: "size-5" }) })] })) : null, _jsx(PostTypeSwitcher, { type: composerType, onSelect: setComposerType, onClose: onClose, showEventType: false, showArticleType: false })] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "variant-ghost-primary", action: onClose, children: t('common.cancel', { defaultValue: 'Cancel' }) }), _jsx(Button, { variant: "variant-filled-primary", action: publish, disabled: !canSubmit, children: submitting
|
|
200
|
+
? t('common.posting', { defaultValue: 'Posting…' })
|
|
201
|
+
: t('posts.reply', { defaultValue: 'Reply' }) })] })] }) })] }) }), composeAttachments.inputs] }));
|
|
202
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { PublicPost } from '@openpeepshq/common/types';
|
|
3
|
+
interface ReplyModalContextValue {
|
|
4
|
+
openReply: (post: PublicPost) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function ReplyModalProvider({ children }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function useReplyModal(): ReplyModalContextValue;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useState, } from 'react';
|
|
3
|
+
import { ReplyModal } from './ReplyModal.js';
|
|
4
|
+
const ReplyModalContext = createContext(null);
|
|
5
|
+
export function ReplyModalProvider({ children }) {
|
|
6
|
+
const [replyTo, setReplyTo] = useState();
|
|
7
|
+
const openReply = useCallback((post) => {
|
|
8
|
+
setReplyTo(post);
|
|
9
|
+
}, []);
|
|
10
|
+
return (_jsxs(ReplyModalContext.Provider, { value: { openReply }, children: [children, replyTo ? (_jsx(ReplyModal, { post: replyTo, onClose: () => setReplyTo(undefined) })) : null] }));
|
|
11
|
+
}
|
|
12
|
+
export function useReplyModal() {
|
|
13
|
+
const ctx = useContext(ReplyModalContext);
|
|
14
|
+
if (!ctx) {
|
|
15
|
+
throw new Error('useReplyModal must be used within ReplyModalProvider');
|
|
16
|
+
}
|
|
17
|
+
return ctx;
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PostCreationData } from '@openpeepshq/common/types';
|
|
2
|
+
export interface VisibilitySelectorProps {
|
|
3
|
+
postData: PostCreationData;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
showDirect?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const VisibilitySelector: ({ postData, onClick, disabled, showDirect, }: VisibilitySelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { ChevronDown, Eye } from 'lucide-react';
|
|
4
|
+
import { groupName } from '@openpeepshq/common/lib';
|
|
5
|
+
import { useT } from '../../../i18n/index.js';
|
|
6
|
+
import { useAuthData, useCurrentProfile } from '../../layout/IdentityContext.js';
|
|
7
|
+
import { useServerInfo } from '../../server-data/index.js';
|
|
8
|
+
import { GroupAvatar } from '../../groups/GroupAvatar.js';
|
|
9
|
+
import { ProfileBadge } from '../../profile/index.js';
|
|
10
|
+
import { buildAudienceChoices } from './audienceChoices.js';
|
|
11
|
+
export const VisibilitySelector = ({ postData, onClick, disabled = false, showDirect = false, }) => {
|
|
12
|
+
const t = useT();
|
|
13
|
+
const authData = useAuthData();
|
|
14
|
+
const me = useCurrentProfile();
|
|
15
|
+
const serverInfo = useServerInfo();
|
|
16
|
+
const audienceChoices = useMemo(() => buildAudienceChoices(postData.type, authData, t, {
|
|
17
|
+
publicContent: serverInfo.publicContent,
|
|
18
|
+
showDirect,
|
|
19
|
+
}), [postData.type, authData, t, serverInfo.publicContent, showDirect]);
|
|
20
|
+
const selectedGroup = useMemo(() => me?.memberships?.find((m) => m.group.id === postData.groupId)?.group, [me?.memberships, postData.groupId]);
|
|
21
|
+
const description = (visibility) => audienceChoices.find((c) => c.value === visibility)?.description ?? '';
|
|
22
|
+
const content = () => {
|
|
23
|
+
if (postData.visibility === 'group') {
|
|
24
|
+
return (_jsxs("span", { className: "flex min-w-0 items-center gap-1 text-sm font-normal", children: [_jsx("span", { className: "shrink-0 pr-2", children: description('group') }), selectedGroup ? (_jsxs("span", { className: "flex min-w-0 items-center gap-1 truncate", children: [_jsx(GroupAvatar, { group: selectedGroup, size: 1.5, borderless: true }), _jsx("span", { className: "truncate", children: groupName(selectedGroup) })] })) : null] }));
|
|
25
|
+
}
|
|
26
|
+
if (postData.visibility === 'direct') {
|
|
27
|
+
const audience = postData.audience ?? [];
|
|
28
|
+
return (_jsxs("span", { className: "flex min-w-0 items-center gap-1 text-sm font-light", children: [_jsx("span", { className: "shrink-0 pr-2", children: description('direct') }), audience.length ? (_jsx("span", { className: "flex min-w-0 flex-wrap items-center gap-1", children: audience.map((profile) => (_jsx(ProfileBadge, { profile: profile }, profile.id))) })) : null] }));
|
|
29
|
+
}
|
|
30
|
+
return (_jsx("span", { className: "text-sm font-light", children: description(postData.visibility) }));
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs("div", { className: "op-input-group grid grid-cols-[auto_1fr_auto]", children: [_jsx("div", { className: "op-input-group-shim", children: _jsx(Eye, { className: "size-4" }) }), _jsx("button", { type: "button", title: t('posts.form.changeAudience', {
|
|
33
|
+
defaultValue: 'Change audience',
|
|
34
|
+
}), className: "hover:bg-muted/50 flex h-10 w-full min-w-0 items-center px-3 text-left disabled:cursor-not-allowed disabled:opacity-50", onClick: onClick, disabled: disabled, children: content() }), !disabled ? (_jsx("div", { className: "op-input-group-shim", children: _jsx(ChevronDown, { className: "text-muted-foreground size-4" }) })) : null] }));
|
|
35
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TFunction } from 'i18next';
|
|
2
|
+
import { type LucideIcon } from 'lucide-react';
|
|
3
|
+
import type { AuthorizationData, PostType, VisibilityType } from '@openpeepshq/common';
|
|
4
|
+
export interface AudienceChoice {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
value: VisibilityType;
|
|
8
|
+
icon: LucideIcon;
|
|
9
|
+
}
|
|
10
|
+
export declare function buildAudienceChoices(type: PostType, authData: AuthorizationData, t: TFunction, options?: {
|
|
11
|
+
publicContent?: boolean;
|
|
12
|
+
showDirect?: boolean;
|
|
13
|
+
}): AudienceChoice[];
|
|
14
|
+
export declare function audienceSummary(visibility: VisibilityType, t: TFunction, groupName?: string, audienceCount?: number): string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Globe, UserCheck, Users, WashingMachine, } from 'lucide-react';
|
|
2
|
+
import { canCreatePostTypeInAnyGroup, canCreatePostTypeWithVisibility, } from '@openpeepshq/common/lib';
|
|
3
|
+
export function buildAudienceChoices(type, authData, t, options = {}) {
|
|
4
|
+
const { publicContent = false, showDirect = false } = options;
|
|
5
|
+
const profile = authData.profile;
|
|
6
|
+
const prefix = `visibility.${type === 'event' ? 'event' : 'post'}.`;
|
|
7
|
+
const i = (key) => t(`${prefix}${key}`, { defaultValue: key });
|
|
8
|
+
const allChoices = [
|
|
9
|
+
{
|
|
10
|
+
title: i('public.title'),
|
|
11
|
+
description: i('public.description'),
|
|
12
|
+
value: 'public',
|
|
13
|
+
icon: Globe,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title: i('local.title'),
|
|
17
|
+
description: i('local.description'),
|
|
18
|
+
value: 'local',
|
|
19
|
+
icon: WashingMachine,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: i('group.title'),
|
|
23
|
+
description: i('group.description'),
|
|
24
|
+
value: 'group',
|
|
25
|
+
icon: Users,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: i('direct.title'),
|
|
29
|
+
description: i('direct.description'),
|
|
30
|
+
value: 'direct',
|
|
31
|
+
icon: UserCheck,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
const allowPublicWithoutServerSetting = type === 'event';
|
|
35
|
+
return allChoices.filter((choice) => {
|
|
36
|
+
if (choice.value === 'public' &&
|
|
37
|
+
!publicContent &&
|
|
38
|
+
!allowPublicWithoutServerSetting) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (choice.value === 'direct' && !showDirect)
|
|
42
|
+
return false;
|
|
43
|
+
if (choice.value === 'group') {
|
|
44
|
+
return (!!profile && canCreatePostTypeInAnyGroup(authData, type));
|
|
45
|
+
}
|
|
46
|
+
return (!!profile &&
|
|
47
|
+
canCreatePostTypeWithVisibility(authData, type, choice.value));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function audienceSummary(visibility, t, groupName, audienceCount) {
|
|
51
|
+
if (visibility === 'group' && groupName) {
|
|
52
|
+
return t('posts.form.audienceGroup', {
|
|
53
|
+
defaultValue: 'Group · {{name}}',
|
|
54
|
+
name: groupName,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (visibility === 'direct' && audienceCount) {
|
|
58
|
+
return t('posts.form.audienceDirect', {
|
|
59
|
+
defaultValue: '{{count}} recipients',
|
|
60
|
+
count: audienceCount,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return t(`visibility.post.${visibility}.title`, {
|
|
64
|
+
defaultValue: visibility,
|
|
65
|
+
});
|
|
66
|
+
}
|