@openpeepshq/react 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/configuration/ConfigurationCategory.js +3 -2
- package/dist/components/configuration/ConfigurationList.js +1 -1
- package/dist/components/form/LocationInput.js +1 -1
- package/dist/components/jams/JamCapacityGate.js +1 -1
- package/dist/components/jams/JamConference.js +2 -0
- package/dist/components/jams/JamParticipantConference.js +2 -0
- package/dist/components/jams/JamRoom.js +2 -3
- package/dist/components/jams/LiveJamsSection.js +8 -2
- package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
- package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
- package/dist/components/jams/dropLateAudio.d.ts +22 -0
- package/dist/components/jams/dropLateAudio.js +115 -0
- package/dist/components/jams/index.d.ts +1 -0
- package/dist/components/jams/index.js +1 -0
- package/dist/components/notifications/TypedNotification.js +46 -4
- package/dist/components/post/Markdown.d.ts +2 -2
- package/dist/components/post/Markdown.js +1 -1
- package/dist/components/post/attachmentPreview.js +1 -1
- package/dist/components/post/pieces/Attachments.js +23 -17
- package/dist/components/post/pieces/EventRsvpButton.js +37 -7
- package/dist/components/post/pieces/EventRsvpList.js +23 -3
- package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
- package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
- package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
- package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
- package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
- package/dist/components/post/pieces/ParticipantsCard.js +1 -1
- package/dist/components/post/pieces/PostActions.d.ts +1 -1
- package/dist/components/post/pieces/PostActions.js +20 -12
- package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
- package/dist/components/post/pieces/ShareMenu.js +40 -7
- package/dist/components/post/post-form/EventForm.js +10 -2
- package/dist/components/post/types/Article.js +1 -1
- package/dist/components/post/types/article/FullArticle.js +1 -1
- package/dist/components/post/types/event/CardEvent.js +2 -1
- package/dist/components/post/types/event/FullEvent.js +22 -13
- package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
- package/dist/components/preview-link/LocalPreviewLink.js +4 -2
- package/dist/components/preview-link/PreviewLink.js +1 -1
- package/dist/components/preview-link/helpers.d.ts +5 -0
- package/dist/components/preview-link/helpers.js +27 -1
- package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
- package/dist/components/preview-link/local/WelcomePreview.js +6 -0
- package/dist/components/profile/Avatar.js +2 -2
- package/dist/components/profile/ProfileFromId.js +1 -1
- package/dist/components/server-data/context.d.ts +1 -0
- package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
- package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
- package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
- package/dist/contexts/openpeeps/hooks/admin.js +11 -3
- package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
- package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
- package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
- package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
- package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
- package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
- package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
- package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
- package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
- package/dist/hooks/events/useEventComposer.d.ts +94 -41
- package/dist/hooks/events/useEventForm.d.ts +1 -0
- package/dist/hooks/events/useEventRsvp.d.ts +11 -2
- package/dist/hooks/events/useEventRsvp.js +46 -5
- package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
- package/dist/hooks/groups/useNewGroup.js +22 -2
- package/dist/hooks/index.d.ts +5 -1
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
- package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
- package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
- package/dist/hooks/jams/useJamDetails.d.ts +87 -38
- package/dist/hooks/jams/useJamLobby.d.ts +1 -0
- package/dist/hooks/jams/useJamRoom.d.ts +175 -76
- package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
- package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
- package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
- package/dist/hooks/posts/useResourceComposer.d.ts +93 -41
- package/dist/hooks/posts/useResourceComposer.js +4 -2
- package/dist/hooks/posts/useShareMenu.d.ts +2 -0
- package/dist/hooks/posts/useShareMenu.js +7 -0
- package/dist/hooks/resources/useResourceLibrary.d.ts +176 -78
- package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
- package/dist/hooks/useWelcomePreview.d.ts +13 -0
- package/dist/hooks/useWelcomePreview.js +39 -0
- package/dist/lib/groupFormErrors.d.ts +1 -0
- package/dist/lib/groupFormErrors.js +5 -2
- package/dist/lib/threadHelpers.js +1 -5
- package/dist/pages/admin/ConfigurationCommunity.js +1 -1
- package/dist/pages/admin/Diagnostics.js +1 -1
- package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
- package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
- package/dist/pages/admin/Invites.js +5 -3
- package/dist/pages/admin/Media.d.ts +1 -0
- package/dist/pages/admin/Media.js +135 -0
- package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
- package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
- package/dist/pages/admin/community/CommunityRoles.js +1 -1
- package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
- package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
- package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
- package/dist/pages/auth/Register.js +30 -8
- package/dist/pages/conversations/Show.js +11 -0
- package/dist/pages/index.d.ts +3 -0
- package/dist/pages/index.js +3 -0
- package/dist/pages/jams/Index.js +2 -4
- package/dist/pages/settings/PublicProfile.js +15 -3
- package/dist/pwa/sw.d.ts +0 -1
- package/dist/react-native.d.ts +1 -0
- package/dist/react-native.js +1 -0
- package/dist/stores/newPosts.d.ts +4 -2
- package/dist/stores/newPosts.js +6 -1
- package/package.json +12 -7
- package/src/components/configuration/ConfigurationCategory.tsx +23 -10
- package/src/components/configuration/ConfigurationList.tsx +6 -1
- package/src/components/form/LocationInput.tsx +7 -1
- package/src/components/jams/JamCapacityGate.tsx +1 -1
- package/src/components/jams/JamConference.tsx +2 -0
- package/src/components/jams/JamParticipantConference.tsx +2 -0
- package/src/components/jams/JamRoom.tsx +2 -6
- package/src/components/jams/LiveJamsSection.tsx +16 -2
- package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
- package/src/components/jams/dropLateAudio.ts +153 -0
- package/src/components/jams/index.ts +1 -0
- package/src/components/notifications/TypedNotification.tsx +81 -9
- package/src/components/post/Markdown.tsx +8 -2
- package/src/components/post/attachmentPreview.ts +1 -3
- package/src/components/post/pieces/Attachments.tsx +93 -78
- package/src/components/post/pieces/EventRsvpButton.tsx +107 -7
- package/src/components/post/pieces/EventRsvpList.tsx +64 -0
- package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
- package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
- package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
- package/src/components/post/pieces/PostActions.tsx +73 -42
- package/src/components/post/pieces/ShareMenu.tsx +67 -9
- package/src/components/post/post-form/EventForm.tsx +26 -0
- package/src/components/post/post-form/VisibilitySelector.tsx +1 -2
- package/src/components/post/types/Article.tsx +1 -1
- package/src/components/post/types/article/FullArticle.tsx +2 -2
- package/src/components/post/types/event/CardEvent.tsx +26 -14
- package/src/components/post/types/event/FullEvent.tsx +48 -35
- package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
- package/src/components/post/types/note/FullNote.tsx +1 -4
- package/src/components/post/types/poll/FullPoll.tsx +1 -4
- package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
- package/src/components/preview-link/PreviewLink.tsx +2 -7
- package/src/components/preview-link/helpers.ts +32 -1
- package/src/components/preview-link/local/GroupPreview.tsx +1 -1
- package/src/components/preview-link/local/JamPreview.tsx +1 -1
- package/src/components/preview-link/local/WelcomePreview.tsx +36 -0
- package/src/components/profile/Avatar.tsx +6 -2
- package/src/components/profile/ProfileFromId.tsx +1 -5
- package/src/components/resources/ResourceCard.tsx +0 -1
- package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
- package/src/contexts/openpeeps/hooks/admin.ts +11 -3
- package/src/contexts/openpeeps/hooks/other.ts +9 -12
- package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
- package/src/css.d.ts +4 -0
- package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
- package/src/hooks/events/useEventRsvp.ts +51 -7
- package/src/hooks/groups/useNewGroup.ts +28 -3
- package/src/hooks/index.ts +8 -1
- package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
- package/src/hooks/posts/useResourceComposer.ts +8 -6
- package/src/hooks/posts/useShareMenu.ts +9 -0
- package/src/hooks/useWelcomePreview.ts +57 -0
- package/src/i18n/I18nProvider.tsx +1 -4
- package/src/lib/groupFormErrors.ts +9 -2
- package/src/lib/threadHelpers.ts +1 -5
- package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
- package/src/pages/admin/Diagnostics.tsx +4 -0
- package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
- package/src/pages/admin/Invites.tsx +23 -1
- package/src/pages/admin/Media.tsx +290 -0
- package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
- package/src/pages/admin/community/CommunityRoles.tsx +2 -2
- package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
- package/src/pages/auth/Register.tsx +33 -4
- package/src/pages/conversations/Show.tsx +11 -0
- package/src/pages/index.ts +3 -0
- package/src/pages/jams/Index.tsx +2 -6
- package/src/pages/settings/PublicProfile.tsx +20 -2
- package/src/pwa/sw.ts +6 -3
- package/src/pwa/useNotificationBadgeSync.ts +3 -1
- package/src/react-native.ts +1 -0
- package/src/stores/newPosts.ts +6 -1
- package/src/streaming.ts +3 -3
- package/dist/setupTests.d.ts +0 -1
- package/dist/setupTests.js +0 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { canClaimYesRsvp, canJoinWaitlist, seriesClaimBlocked, } from '@openpeepshq/common/lib';
|
|
4
4
|
import { Checkbox, Dialog, DialogActions, DialogContent, DialogHeader, DialogTitle, RadioGroup, RadioGroupItem, ScrollArea, } from '@openpeepshq/react-ui';
|
|
5
5
|
import { useT } from '../../../i18n/index.js';
|
|
6
6
|
import { useCurrentProfile } from '../../layout/IdentityContext.js';
|
|
@@ -14,17 +14,17 @@ const formatOccurrenceStart = (start) => new Date(start).toLocaleString(undefine
|
|
|
14
14
|
export const EventRsvpScopeDialog = ({ open, post, response, defaultRecurrenceId, occurrences, error, submitting, onClose, onConfirm, }) => {
|
|
15
15
|
const t = useT();
|
|
16
16
|
const profile = useCurrentProfile();
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
const joiningWaitlist = response === 'waitlist';
|
|
18
|
+
const seriesFull = response === 'yes' && !!profile && seriesClaimBlocked(post, profile.id);
|
|
19
|
+
const occurrenceIsFull = (recurrenceId) => {
|
|
20
|
+
if (!profile)
|
|
21
|
+
return false;
|
|
22
|
+
if (joiningWaitlist)
|
|
23
|
+
return !canJoinWaitlist(post, profile.id, recurrenceId);
|
|
24
|
+
if (response !== 'yes')
|
|
25
|
+
return false;
|
|
26
|
+
return !canClaimYesRsvp(post, profile.id, recurrenceId);
|
|
27
|
+
};
|
|
28
28
|
const currentFull = !!defaultRecurrenceId && occurrenceIsFull(defaultRecurrenceId);
|
|
29
29
|
const initialScope = currentFull
|
|
30
30
|
? 'selected'
|
|
@@ -62,14 +62,18 @@ export const EventRsvpScopeDialog = ({ open, post, response, defaultRecurrenceId
|
|
|
62
62
|
}
|
|
63
63
|
return onConfirm({ kind: 'series' });
|
|
64
64
|
};
|
|
65
|
-
return (_jsx(Dialog, { open: open, onOpenChange: (next) => !next && onClose(), children: _jsxs(DialogContent, { className: "max-h-[85vh] max-w-md overflow-y-auto", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children:
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
return (_jsx(Dialog, { open: open, onOpenChange: (next) => !next && onClose(), children: _jsxs(DialogContent, { className: "max-h-[85vh] max-w-md overflow-y-auto", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: joiningWaitlist
|
|
66
|
+
? t('events.rsvp.scope.waitlistTitle', {
|
|
67
|
+
defaultValue: 'Join the waitlist for which dates?',
|
|
68
|
+
})
|
|
69
|
+
: t('events.rsvp.scope.title', {
|
|
70
|
+
defaultValue: 'Which dates?',
|
|
71
|
+
}) }) }), _jsxs(RadioGroup, { value: scope, onValueChange: (value) => setScope(value), className: "gap-3", children: [defaultRecurrenceId && !currentFull ? (_jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(RadioGroupItem, { value: "this" }), t('events.rsvp.scope.thisDateWith', {
|
|
68
72
|
defaultValue: 'This date ({{date}})',
|
|
69
73
|
date: defaultLabel,
|
|
70
74
|
})] })) : null, occurrences.length > 0 ? (_jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(RadioGroupItem, { value: "selected" }), t('events.rsvp.scope.selectedDates', {
|
|
71
75
|
defaultValue: 'Selected dates',
|
|
72
|
-
})] })) : null, currentFull ? null : (_jsxs("label", { className: "flex items-start gap-2 text-sm", children: [_jsx(RadioGroupItem, { value: "series", disabled: seriesFull }), _jsxs("span", { children: [t('events.rsvp.scope.wholeSeries', {
|
|
76
|
+
})] })) : null, currentFull || joiningWaitlist ? null : (_jsxs("label", { className: "flex items-start gap-2 text-sm", children: [_jsx(RadioGroupItem, { value: "series", disabled: seriesFull }), _jsxs("span", { children: [t('events.rsvp.scope.wholeSeries', {
|
|
73
77
|
defaultValue: 'All dates in the series',
|
|
74
78
|
}), seriesFull ? (_jsx("span", { className: "text-muted-foreground mt-1 block text-xs", children: t('events.rsvp.scope.seriesFull', {
|
|
75
79
|
defaultValue: 'Some dates in this series are full.',
|
|
@@ -78,15 +82,23 @@ export const EventRsvpScopeDialog = ({ open, post, response, defaultRecurrenceId
|
|
|
78
82
|
const lockedOn = full && occurrence.recurrenceId === defaultRecurrenceId;
|
|
79
83
|
const checked = lockedOn || selected.includes(occurrence.recurrenceId);
|
|
80
84
|
return (_jsx("li", { children: _jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { checked: checked, disabled: full, onCheckedChange: (value) => toggleSelected(occurrence.recurrenceId, value === true) }), _jsxs("span", { className: full ? 'text-muted-foreground' : '', children: [formatOccurrenceStart(occurrence.start), full
|
|
81
|
-
? ` — ${
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
? ` — ${joiningWaitlist
|
|
86
|
+
? t('events.rsvp.spotsOpen', {
|
|
87
|
+
defaultValue: 'Spots still open',
|
|
88
|
+
})
|
|
89
|
+
: t('events.rsvp.full', {
|
|
90
|
+
defaultValue: 'Event is full',
|
|
91
|
+
})}`
|
|
84
92
|
: ''] })] }) }, occurrence.recurrenceId));
|
|
85
93
|
}) }) })) : null, scope === 'selected' && openSelected.length === 0 ? (_jsx("p", { className: "text-muted-foreground text-sm", children: t('events.rsvp.scope.selectAtLeastOne', {
|
|
86
94
|
defaultValue: 'Select at least one date.',
|
|
87
95
|
}) })) : null, error ? _jsx("p", { className: "text-error text-sm", children: error }) : null, _jsx(DialogActions, { cancelLabel: t('events.rsvp.scope.cancel', {
|
|
88
96
|
defaultValue: 'Cancel',
|
|
89
|
-
}), onCancel: onClose, actionLabel:
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
}), onCancel: onClose, actionLabel: joiningWaitlist
|
|
98
|
+
? t('events.rsvp.joinWaitlist', {
|
|
99
|
+
defaultValue: 'Join waitlist',
|
|
100
|
+
})
|
|
101
|
+
: t('events.rsvp.scope.confirm', {
|
|
102
|
+
defaultValue: 'Confirm',
|
|
103
|
+
}), onAction: confirm, disabled: confirmDisabled })] }) }));
|
|
92
104
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PublicPost } from '@openpeepshq/common/types';
|
|
2
|
+
export type EventWaitlistJoinDialogProps = {
|
|
3
|
+
open: boolean;
|
|
4
|
+
post: PublicPost;
|
|
5
|
+
error?: string | null;
|
|
6
|
+
submitting?: boolean;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onConfirm: () => void | Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
export declare const EventWaitlistJoinDialog: ({ open, post, error, submitting, onClose, onConfirm, }: EventWaitlistJoinDialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { waitlistOfferWindowMs } from '@openpeepshq/common/lib';
|
|
3
|
+
import { Dialog, DialogActions, DialogContent, DialogHeader, DialogTitle, } from '@openpeepshq/react-ui';
|
|
4
|
+
import { useT } from '../../../i18n/index.js';
|
|
5
|
+
export const EventWaitlistJoinDialog = ({ open, post, error, submitting, onClose, onConfirm, }) => {
|
|
6
|
+
const t = useT();
|
|
7
|
+
const event = post.data?.type === 'event' ? post.data : undefined;
|
|
8
|
+
const minutes = event
|
|
9
|
+
? Math.round(waitlistOfferWindowMs(event) / 60_000)
|
|
10
|
+
: 60;
|
|
11
|
+
return (_jsx(Dialog, { open: open, onOpenChange: (next) => {
|
|
12
|
+
if (!next && !submitting)
|
|
13
|
+
onClose();
|
|
14
|
+
}, children: _jsxs(DialogContent, { className: "max-w-md", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: t('events.rsvp.waitlistConfirmTitle', {
|
|
15
|
+
defaultValue: 'Join the waitlist?',
|
|
16
|
+
}) }) }), _jsx("p", { className: "text-sm", children: t('events.rsvp.atCapacity', {
|
|
17
|
+
defaultValue: 'This event is at capacity.',
|
|
18
|
+
}) }), _jsx("p", { className: "text-muted-foreground text-sm", children: t('events.rsvp.waitlistConfirmBody', {
|
|
19
|
+
defaultValue: 'If a spot opens, you will have {{minutes}} minutes to claim it.',
|
|
20
|
+
minutes,
|
|
21
|
+
}) }), error ? _jsx("p", { className: "text-error text-sm", children: error }) : null, _jsx(DialogActions, { cancelLabel: t('events.rsvp.scope.cancel', {
|
|
22
|
+
defaultValue: 'Cancel',
|
|
23
|
+
}), onCancel: onClose, actionLabel: t('events.rsvp.joinWaitlist', {
|
|
24
|
+
defaultValue: 'Join waitlist',
|
|
25
|
+
}), onAction: onConfirm, disabled: submitting })] }) }));
|
|
26
|
+
};
|
|
@@ -5,4 +5,4 @@ export interface ParticipantsCardProps {
|
|
|
5
5
|
}
|
|
6
6
|
/** Overlapping avatar stack of the first jam participants. Mirrors the Svelte
|
|
7
7
|
* `ParticipantsCard`. */
|
|
8
|
-
export declare function ParticipantsCard({ jamState, size }: ParticipantsCardProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function ParticipantsCard({ jamState, size, }: ParticipantsCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,6 +8,6 @@ function ParticipantAvatar({ id, size }) {
|
|
|
8
8
|
}
|
|
9
9
|
/** Overlapping avatar stack of the first jam participants. Mirrors the Svelte
|
|
10
10
|
* `ParticipantsCard`. */
|
|
11
|
-
export function ParticipantsCard({ jamState, size = 1.5 }) {
|
|
11
|
+
export function ParticipantsCard({ jamState, size = 1.5, }) {
|
|
12
12
|
return (_jsx("div", { className: "flex w-full items-center justify-between gap-4", children: _jsx("div", { className: "flex items-center", children: jamState.participants.slice(0, 2).map((id) => (_jsx(ParticipantAvatar, { id: id, size: size }, id))) }) }));
|
|
13
13
|
}
|
|
@@ -5,4 +5,4 @@ export interface PostActionsProps {
|
|
|
5
5
|
/** When true, disables interactive actions (used in previews). */
|
|
6
6
|
previewMode?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare function PostActions({ post, compact, previewMode, }: PostActionsProps): import("react/jsx-runtime").JSX.Element
|
|
8
|
+
export declare function PostActions({ post, compact, previewMode, }: PostActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Reply, Repeat2, ThumbsUp } from 'lucide-react';
|
|
3
|
-
import { Button } from '@openpeepshq/react-ui';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Reply, Repeat2, Share, ThumbsUp } from 'lucide-react';
|
|
3
|
+
import { Button, cn } from '@openpeepshq/react-ui';
|
|
4
4
|
import { useT } from '../../../i18n/index.js';
|
|
5
5
|
import { useFeedPostActions } from '../../../hooks/posts/useFeedPostActions.js';
|
|
6
6
|
import { postReactionStats } from '../helpers.js';
|
|
7
|
+
import { ShareMenu } from './ShareMenu.js';
|
|
7
8
|
export function PostActions({ post, compact = false, previewMode = false, }) {
|
|
8
9
|
const t = useT();
|
|
9
10
|
const { me, myRepost, iReacted, canReply, canRepost, canReact, reply, toggleRepost, toggleReaction, } = useFeedPostActions(post);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
11
|
+
const replyActive = !previewMode && canReply;
|
|
12
|
+
const repostActive = !previewMode && canRepost;
|
|
13
|
+
const reactActive = !previewMode && canReact;
|
|
14
|
+
const shareActive = !previewMode;
|
|
15
|
+
// Unstyled buttons skip the shared disabled treatment. Mute them, and let
|
|
16
|
+
// presses fall through to this row so a feed link does not open the post.
|
|
17
|
+
const actionClass = (active) => cn('rounded-button flex gap-2 p-2 text-sm', active
|
|
18
|
+
? 'cursor-pointer hover:bg-surface'
|
|
19
|
+
: 'pointer-events-none cursor-default text-muted-foreground disabled:text-muted-foreground');
|
|
13
20
|
const replyLabel = t('posts.footer.reply', { defaultValue: 'Reply' });
|
|
14
21
|
const repostLabel = t('posts.footer.repost', { defaultValue: 'Repost' });
|
|
15
22
|
const likeLabel = t('posts.footer.like', { defaultValue: 'Like' });
|
|
16
|
-
|
|
23
|
+
const shareLabel = t('posts.footer.share', { defaultValue: 'Share' });
|
|
24
|
+
return (_jsxs("div", { className: `mx-auto flex w-full cursor-default items-center p-2 ${me ? 'justify-between' : 'justify-end'}`, onClick: (e) => {
|
|
17
25
|
e.preventDefault();
|
|
18
26
|
e.stopPropagation();
|
|
19
|
-
}, onKeyDown: (e) => e.stopPropagation(), role: "presentation", children: [_jsxs(Button, { variant: "unstyled", className:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
}, onKeyDown: (e) => e.stopPropagation(), role: "presentation", children: [me ? (_jsxs(_Fragment, { children: [_jsxs(Button, { variant: "unstyled", className: actionClass(replyActive), title: t('posts.actions.reply', { defaultValue: 'Reply' }), action: reply, disabled: !replyActive, children: [_jsx(Reply, { className: "h-4 w-4" }), compact ? post.replyCount || null : replyLabel] }), _jsxs(Button, { variant: "unstyled", className: cn(actionClass(repostActive), myRepost && repostActive && 'text-primary'), title: t('posts.actions.repost', { defaultValue: 'Repost' }), action: toggleRepost, disabled: !repostActive, spinnerOnlyOnLoading: true, "data-testid": "posts-repost-button", children: [_jsx(Repeat2, { className: "h-4 w-4" }), compact ? post.repostCount || null : repostLabel] }), _jsxs(Button, { variant: "unstyled", className: cn(actionClass(reactActive), iReacted && reactActive && 'text-primary'), title: t('posts.actions.react', { defaultValue: 'React' }), action: toggleReaction, disabled: !reactActive, spinnerOnlyOnLoading: true, children: [_jsx(ThumbsUp, { className: "h-4 w-4" }), compact
|
|
28
|
+
? post.reactions?.length
|
|
29
|
+
? ` · ${postReactionStats(post)}`
|
|
30
|
+
: null
|
|
31
|
+
: likeLabel] })] })) : null, _jsx(ShareMenu, { post: post, variant: "unstyled", className: actionClass(shareActive), text: compact ? undefined : shareLabel, menuButton: _jsx(Share, { className: "h-4 w-4" }) })] }));
|
|
24
32
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { PublicPost } from '@openpeepshq/common/types';
|
|
2
|
+
import { type PopupMenuProps } from '@openpeepshq/react-ui';
|
|
2
3
|
export interface ShareMenuProps {
|
|
3
4
|
post: PublicPost;
|
|
4
5
|
menuButton?: React.ReactNode;
|
|
6
|
+
/** `unstyled` matches neighboring text actions, such as the post footer. */
|
|
7
|
+
variant?: PopupMenuProps['variant'] | 'unstyled';
|
|
8
|
+
className?: string;
|
|
9
|
+
text?: string;
|
|
5
10
|
}
|
|
6
|
-
export declare function ShareMenu({ post, menuButton }: ShareMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function ShareMenu({ post, menuButton, variant, className, text, }: ShareMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,15 +2,24 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Calendar, Copy, Repeat2, Send, Share } from 'lucide-react';
|
|
3
3
|
import { PopupMenu, PopupMenuButton, PopupSection, PopupSeparator, } from '@openpeepshq/react-ui';
|
|
4
4
|
import { useT } from '../../../i18n/index.js';
|
|
5
|
-
import { useShareMenu } from '../../../hooks/posts/useShareMenu.js';
|
|
5
|
+
import { postPublicPath, useShareMenu, } from '../../../hooks/posts/useShareMenu.js';
|
|
6
6
|
import { useCreateNewConversation } from '../../conversations/CreateNewConversationContext.js';
|
|
7
|
-
|
|
7
|
+
import { useToast } from '../../layout/ToastProvider.js';
|
|
8
|
+
const absolutePostUrl = (post) => {
|
|
9
|
+
const path = postPublicPath(post);
|
|
10
|
+
return typeof window !== 'undefined'
|
|
11
|
+
? `${window.location.origin}${path}`
|
|
12
|
+
: path;
|
|
13
|
+
};
|
|
14
|
+
export function ShareMenu({ post, menuButton, variant = 'outline', className, text, }) {
|
|
8
15
|
const t = useT();
|
|
16
|
+
const { success, error: toastError } = useToast();
|
|
9
17
|
const { openCreateConversation } = useCreateNewConversation();
|
|
10
|
-
const postUrl =
|
|
11
|
-
? `${window.location.origin}/posts/${post.id}`
|
|
12
|
-
: `/posts/${post.id}`;
|
|
18
|
+
const postUrl = absolutePostUrl(post);
|
|
13
19
|
const { signedIn, isEvent, repost, eventIcsFile } = useShareMenu(post, postUrl);
|
|
20
|
+
// Feature-detect. Desktop browsers often have no Web Share API; copy stays
|
|
21
|
+
// in the menu either way.
|
|
22
|
+
const canSystemShare = typeof navigator !== 'undefined' && typeof navigator.share === 'function';
|
|
14
23
|
const downloadEventIcs = () => {
|
|
15
24
|
const file = eventIcsFile();
|
|
16
25
|
if (!file)
|
|
@@ -25,7 +34,27 @@ export function ShareMenu({ post, menuButton }) {
|
|
|
25
34
|
a.click();
|
|
26
35
|
URL.revokeObjectURL(href);
|
|
27
36
|
};
|
|
28
|
-
|
|
37
|
+
const copyLink = async () => {
|
|
38
|
+
try {
|
|
39
|
+
await navigator.clipboard.writeText(postUrl);
|
|
40
|
+
success(t('posts.shareMenu.linkCopied', { defaultValue: 'Link copied' }));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
toastError(t('posts.shareMenu.copyFailed', {
|
|
44
|
+
defaultValue: "Couldn't copy the link",
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const systemShare = async () => {
|
|
49
|
+
try {
|
|
50
|
+
await navigator.share({ url: postUrl });
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
if (err instanceof DOMException && err.name === 'AbortError')
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return (_jsxs(PopupMenu, { menuButton: menuButton ?? _jsx(Share, { className: "size-4" }), title: t('posts.shareMenu.title', { defaultValue: 'Share' }), variant: variant === 'unstyled' ? undefined : variant, className: className, text: text, children: [signedIn ? (_jsxs(_Fragment, { children: [_jsx(PopupSection, { title: t('posts.shareMenu.shareOnCommunity', {
|
|
29
58
|
defaultValue: 'Share on community',
|
|
30
59
|
}) }), _jsx(PopupMenuButton, { title: t('posts.shareMenu.repostToFeed', {
|
|
31
60
|
defaultValue: 'Repost',
|
|
@@ -39,5 +68,9 @@ export function ShareMenu({ post, menuButton }) {
|
|
|
39
68
|
defaultValue: 'Download calendar file',
|
|
40
69
|
}), text: t('posts.shareMenu.downloadCalendarIcs', {
|
|
41
70
|
defaultValue: 'Add to calendar (.ics)',
|
|
42
|
-
}), icon: Calendar, action: downloadEventIcs })) : null, _jsx(PopupMenuButton, { title: t('posts.shareMenu.
|
|
71
|
+
}), icon: Calendar, action: downloadEventIcs })) : null, canSystemShare ? (_jsx(PopupMenuButton, { title: t('posts.shareMenu.systemShare', {
|
|
72
|
+
defaultValue: 'Share via…',
|
|
73
|
+
}), text: t('posts.shareMenu.systemShare', {
|
|
74
|
+
defaultValue: 'Share via…',
|
|
75
|
+
}), icon: Share, action: () => void systemShare() })) : null, _jsx(PopupMenuButton, { title: t('posts.shareMenu.copyLink', { defaultValue: 'Copy link' }), text: t('posts.shareMenu.copyLink', { defaultValue: 'Copy link' }), icon: Copy, action: () => void copyLink() })] }));
|
|
43
76
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { X } from 'lucide-react';
|
|
4
|
-
import { EVENT_HEADER_ASPECT_RATIO, parseEventMaxAttendeesInput, utcIsoToZonedDateTime, zonedDateTimeToUtcIso, } from '@openpeepshq/common/lib';
|
|
4
|
+
import { EVENT_HEADER_ASPECT_RATIO, parseEventMaxAttendeesInput, parseEventWaitlistOfferMinutesInput, utcIsoToZonedDateTime, zonedDateTimeToUtcIso, } from '@openpeepshq/common/lib';
|
|
5
5
|
import { Input, Label } from '@openpeepshq/react-ui';
|
|
6
6
|
import { useT } from '../../../i18n/index.js';
|
|
7
7
|
import { EVENT_WEEKDAYS, useEventForm, } from '../../../hooks/events/useEventForm.js';
|
|
@@ -80,5 +80,13 @@ export const EventForm = ({ postData, onChange, isEdit = false, occurrenceEdit =
|
|
|
80
80
|
});
|
|
81
81
|
} }), event.maxAttendees != null ? (_jsx("button", { type: "button", className: "op-input-group-shim hover:bg-surface/80", title: t('events.form.clearMaxAttendees', {
|
|
82
82
|
defaultValue: 'Remove capacity limit',
|
|
83
|
-
}), onClick: () => patchEvent({ maxAttendees: undefined }), children: _jsx(X, { className: "size-4" }) })) : null] }) })
|
|
83
|
+
}), onClick: () => patchEvent({ maxAttendees: undefined }), children: _jsx(X, { className: "size-4" }) })) : null] }) }), event.maxAttendees != null ? (_jsx(Label, { title: t('events.form.waitlistOfferMinutes', {
|
|
84
|
+
defaultValue: 'Waitlist response window (minutes)',
|
|
85
|
+
}), description: t('events.form.waitlistOfferMinutesDescription', {
|
|
86
|
+
defaultValue: 'How long the next person on the waitlist has to claim a freed spot. Leave empty for 60 minutes.',
|
|
87
|
+
}), children: _jsx(Input, { type: "number", min: 1, max: 10080, value: event.waitlistOfferMinutes ?? '', onChange: (e) => {
|
|
88
|
+
patchEvent({
|
|
89
|
+
waitlistOfferMinutes: parseEventWaitlistOfferMinutesInput(e.target.value),
|
|
90
|
+
});
|
|
91
|
+
} }) })) : null] }), !isEdit ? (_jsx(PostAudienceSelector, { open: audienceOpen, onClose: () => setAudienceOpen(false), type: "event", visibility: postData.visibility, groupId: postData.groupId ?? undefined, audience: postData.audience ?? [], showDirect: true, onConfirm: setAudience })) : null] }));
|
|
84
92
|
};
|
|
@@ -13,5 +13,5 @@ export function FeedArticle({ post }) {
|
|
|
13
13
|
const previewContent = firstNWords(article.content, 50);
|
|
14
14
|
const minutes = minutesToRead(article.content);
|
|
15
15
|
const showReadMore = !!article.content && previewContent.length < article.content.length;
|
|
16
|
-
return (_jsxs("div", { className: "flex w-full min-w-0 flex-col gap-2", children: [article.image && (_jsx("img", { src: article.image, className: "w-full object-cover", alt: `image for ${article.title ?? 'article'}` })), _jsxs("div", { className: "prose-sm", children: [_jsx("h3", { children: article.title }), minutes > 0 && (_jsx("p", { className: "text-muted-foreground text-xs", children: t('posts.article.minutesToRead', { count: minutes }) }))] }), _jsx(PostMarkdown, { source: `${previewContent}${showReadMore ? '...' : ''}`, className: OPENPEEPS_POST_CAPTION_CLASS }), showReadMore && (_jsx("div", { className: "flex justify-end", children: _jsxs("a", { href: resolveStaticUrl(`/posts/${post.id}`, staticRender ? baseUrl : undefined), className: "text-primary inline-flex items-center gap-1 text-sm hover:underline", children: [t('posts.article.readMore', { defaultValue: 'Read more' }), _jsx(ArrowRight, { className: "inline-block size-4" })] }) }))] }));
|
|
16
|
+
return (_jsxs("div", { className: "flex w-full min-w-0 flex-col gap-2", children: [article.image && (_jsx("img", { src: article.image, className: "w-full object-cover", alt: `image for ${article.title ?? 'article'}` })), _jsxs("div", { className: "prose-sm", children: [_jsx("h3", { className: "text-foreground", children: article.title }), minutes > 0 && (_jsx("p", { className: "text-muted-foreground text-xs", children: t('posts.article.minutesToRead', { count: minutes }) }))] }), _jsx(PostMarkdown, { source: `${previewContent}${showReadMore ? '...' : ''}`, className: OPENPEEPS_POST_CAPTION_CLASS }), showReadMore && (_jsx("div", { className: "flex justify-end", children: _jsxs("a", { href: resolveStaticUrl(`/posts/${post.id}`, staticRender ? baseUrl : undefined), className: "text-primary inline-flex items-center gap-1 text-sm hover:underline", children: [t('posts.article.readMore', { defaultValue: 'Read more' }), _jsx(ArrowRight, { className: "inline-block size-4" })] }) }))] }));
|
|
17
17
|
}
|
|
@@ -8,5 +8,5 @@ export function FullArticle({ post }) {
|
|
|
8
8
|
const t = useT();
|
|
9
9
|
const article = post.data;
|
|
10
10
|
const minutes = minutesToRead(article.content);
|
|
11
|
-
return (_jsx(FullPostLayout, { post: post, deleteCallback: () => window.history.back(), children: _jsx(FeedPost, { post: post, noReactionHeader: true, deleteCallback: () => window.history.back(), content: _jsxs("div", { className: "flex w-full min-w-0 flex-col gap-2", children: [article.image ? (_jsx("img", { src: article.image, className: "w-full object-cover", alt: article.title ? `image for ${article.title}` : 'Article' })) : null, _jsxs("div", { className: "prose mb-6", children: [_jsx("h1", { children: article.title }), minutes > 0 && (_jsx("p", { className: "text-muted-foreground text-sm", children: t('posts.article.minutesToRead', { count: minutes }) }))] }), _jsx(PostMarkdown, { source: article.content ?? '' })] }) }) }));
|
|
11
|
+
return (_jsx(FullPostLayout, { post: post, deleteCallback: () => window.history.back(), children: _jsx(FeedPost, { post: post, noReactionHeader: true, deleteCallback: () => window.history.back(), content: _jsxs("div", { className: "flex w-full min-w-0 flex-col gap-2", children: [article.image ? (_jsx("img", { src: article.image, className: "w-full object-cover", alt: article.title ? `image for ${article.title}` : 'Article' })) : null, _jsxs("div", { className: "prose dark:prose-invert mb-6", children: [_jsx("h1", { className: "text-foreground", children: article.title }), minutes > 0 && (_jsx("p", { className: "text-muted-foreground text-sm", children: t('posts.article.minutesToRead', { count: minutes }) }))] }), _jsx(PostMarkdown, { source: article.content ?? '' })] }) }) }));
|
|
12
12
|
}
|
|
@@ -8,6 +8,7 @@ import { useServerInfo } from '../../../server-data/index.js';
|
|
|
8
8
|
import { usePostViewRef } from '../../../../lib/postViewCounter.js';
|
|
9
9
|
import { EventLocation } from '../../pieces/EventLocation.js';
|
|
10
10
|
import { ParticipantsCard } from '../../pieces/ParticipantsCard.js';
|
|
11
|
+
import { ShareMenu } from '../../pieces/ShareMenu.js';
|
|
11
12
|
import { ProfileEventRelationship } from './ProfileEventRelationship.js';
|
|
12
13
|
function formatEventTimespan(event, startIso, endIso) {
|
|
13
14
|
const startValue = startIso ?? event.start;
|
|
@@ -45,7 +46,7 @@ export function CardEvent({ post, showEventDate = true }) {
|
|
|
45
46
|
const postLink = occurrenceId
|
|
46
47
|
? `/posts/${post.id}?occurrence=${encodeURIComponent(occurrenceId)}`
|
|
47
48
|
: `/posts/${post.id}`;
|
|
48
|
-
return (_jsxs("article", { ref: postViewRef, className: "hover:bg-surface mb-6 w-full overflow-hidden rounded-lg border", children: [_jsx("a", { href: postLink, className: "block", children: _jsx("div", { className: "aspect-video w-full overflow-hidden", children: _jsx("img", { src: event.image || '/img/event-default.png', alt: event.name ? `image for ${event.name}` : 'Event', className: "h-full w-full object-cover" }) }) }), _jsxs("div", { className: "grid gap-y-4 p-4", children: [_jsxs("a", { href: postLink, className: "block text-inherit no-underline", children: [showEventDate ? (_jsx("p", { className: "text-muted-foreground text-sm", children: formatEventTimespan(event, post.occurrenceStart, post.occurrenceEnd) })) : null, _jsx("h3", { className: "text-xl font-semibold", children: truncateText(event.name, 100) || '-' })] }), event.recurrence ? (_jsx("p", { className: "text-muted-foreground text-sm", children: formatEventRecurrence(event.recurrence, t, event.start) })) : null, _jsxs("div", { className: "flex flex-wrap gap-x-2 gap-y-1", children: [_jsx(EventLocation, { post: post, truncate: true, occurrence: occurrenceId }), _jsx(ProfileEventRelationship, { post: post })] }), jam && me && livekitEnabled ? (jamState?.active ? (_jsxs("div", { className: "text-muted-foreground flex items-center justify-start gap-2 text-xs", children: [_jsx("span", { className: "w-12", children: _jsx(ParticipantsCard, { jamState: jamState }) }), _jsxs("span", { children: [attendeesLength, ' ', attendeesLength === 1
|
|
49
|
+
return (_jsxs("article", { ref: postViewRef, className: "hover:bg-surface mb-6 w-full overflow-hidden rounded-lg border", children: [_jsx("a", { href: postLink, className: "block", children: _jsx("div", { className: "aspect-video w-full overflow-hidden", children: _jsx("img", { src: event.image || '/img/event-default.png', alt: event.name ? `image for ${event.name}` : 'Event', className: "h-full w-full object-cover" }) }) }), _jsxs("div", { className: "grid gap-y-4 p-4", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsxs("a", { href: postLink, className: "block min-w-0 flex-1 text-inherit no-underline", children: [showEventDate ? (_jsx("p", { className: "text-muted-foreground text-sm", children: formatEventTimespan(event, post.occurrenceStart, post.occurrenceEnd) })) : null, _jsx("h3", { className: "text-xl font-semibold", children: truncateText(event.name, 100) || '-' })] }), _jsx(ShareMenu, { post: post, variant: "ghost", className: "shrink-0", text: t('posts.footer.share', { defaultValue: 'Share' }) })] }), event.recurrence ? (_jsx("p", { className: "text-muted-foreground text-sm", children: formatEventRecurrence(event.recurrence, t, event.start) })) : null, _jsxs("div", { className: "flex flex-wrap gap-x-2 gap-y-1", children: [_jsx(EventLocation, { post: post, truncate: true, occurrence: occurrenceId }), _jsx(ProfileEventRelationship, { post: post })] }), jam && me && livekitEnabled ? (jamState?.active ? (_jsxs("div", { className: "text-muted-foreground flex items-center justify-start gap-2 text-xs", children: [_jsx("span", { className: "w-12", children: _jsx(ParticipantsCard, { jamState: jamState }) }), _jsxs("span", { children: [attendeesLength, ' ', attendeesLength === 1
|
|
49
50
|
? t('events.jam.attendee', { defaultValue: 'attendee' })
|
|
50
51
|
: t('events.jam.attendees', { defaultValue: 'attendees' })] }), _jsx(Button, { action: jamLink, variant: "default", compact: true, children: t('jam.join.submit', { defaultValue: 'Join Jam' }) })] })) : jam.moderators.includes(me.id) ? (_jsx("div", { children: _jsx(Button, { action: jamLink, variant: "default", children: t('jam.start.submit', { defaultValue: 'Start Jam' }) }) })) : null) : null] })] }));
|
|
51
52
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Download, EyeOff, MoreHorizontal, Share, Trash2 } from 'lucide-react';
|
|
3
3
|
import { useCallback, useMemo, useState } from 'react';
|
|
4
|
-
import { buildThreads, canAccessJamRecordings, canManageEventRsvps, canModerateJam, canViewJamAttendees,
|
|
4
|
+
import { buildThreads, canAccessJamRecordings, canManageEventRsvps, canModerateJam, canViewJamAttendees, availableSpots, effectiveEventTimes, eventTimeZoneOptions, formatEventClockTime, formatEventRecurrence, getJamUrl, groupName, parseOccurrenceQuery, listRsvpOccurrences, profileName, rsvpExportFilename, } from '@openpeepshq/common/lib';
|
|
5
5
|
import { Button, Dialog, DialogActions, DialogContent, DialogHeader, DialogTitle, LoadingSpinner, UpdatingDate, } from '@openpeepshq/react-ui';
|
|
6
6
|
import { useOpenpeeps } from '../../../../contexts/openpeeps/index.js';
|
|
7
7
|
import { useT } from '../../../../i18n/index.js';
|
|
@@ -47,13 +47,8 @@ export function FullEvent({ post, occurrence }) {
|
|
|
47
47
|
const myEvent = post.profile?.id === profile?.id;
|
|
48
48
|
const iAmModerator = canModerateJam(profile, post);
|
|
49
49
|
const canManageRsvps = canManageEventRsvps(profile, post);
|
|
50
|
-
const slotsLeft =
|
|
51
|
-
|
|
52
|
-
(!event.recurrence || occurrenceId)
|
|
53
|
-
? event.maxAttendees - countYesRsvps(post, occurrenceId)
|
|
54
|
-
: null;
|
|
55
|
-
const times = effectiveEventTimes(event, occurrenceId ??
|
|
56
|
-
(event.recurrence ? defaultRsvpRecurrenceId(event) : undefined));
|
|
50
|
+
const slotsLeft = availableSpots(post, occurrenceId) ?? null;
|
|
51
|
+
const times = effectiveEventTimes(event, occurrenceId);
|
|
57
52
|
const recurrenceLabel = event.recurrence
|
|
58
53
|
? formatEventRecurrence(event.recurrence, t, event.start)
|
|
59
54
|
: '';
|
|
@@ -74,6 +69,20 @@ export function FullEvent({ post, occurrence }) {
|
|
|
74
69
|
}));
|
|
75
70
|
}
|
|
76
71
|
}, [client, post.id, t, toastError]);
|
|
72
|
+
const exportRsvps = useCallback(async () => {
|
|
73
|
+
try {
|
|
74
|
+
const csv = await client.posts.exportRsvps({
|
|
75
|
+
id: post.id,
|
|
76
|
+
occurrence: occurrenceId,
|
|
77
|
+
});
|
|
78
|
+
downloadCsv(csv, rsvpExportFilename(event.name, new Date()));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
toastError(t('events.exportRsvpsError', {
|
|
82
|
+
defaultValue: 'Failed to export RSVPs',
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
}, [client, event.name, occurrenceId, post.id, t, toastError]);
|
|
77
86
|
const descendentThreads = useMemo(() => (contextQuery.data && buildThreads(contextQuery.data.descendants)) || [], [contextQuery.data]);
|
|
78
87
|
const eventScope = useMemo(() => {
|
|
79
88
|
if (post.visibility === 'public')
|
|
@@ -92,15 +101,15 @@ export function FullEvent({ post, occurrence }) {
|
|
|
92
101
|
: t('events.slotsLeft', {
|
|
93
102
|
defaultValue: '{{count}} slots left',
|
|
94
103
|
count: slotsLeft,
|
|
95
|
-
}) })) : null] }), post.groupId && group ? (_jsx("a", { href: `/groups/@${group.handle}`, className: "text-muted-foreground block text-sm hover:underline", children: groupName(group) })) : null] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(ShareMenu, { post: post,
|
|
104
|
+
}) })) : null] }), post.groupId && group ? (_jsx("a", { href: `/groups/@${group.handle}`, className: "text-muted-foreground block text-sm hover:underline", children: groupName(group) })) : null] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(ShareMenu, { post: post, text: t('posts.footer.share', { defaultValue: 'Share' }), menuButton: _jsx(Share, { className: "size-4" }) }), myEvent ? (_jsx(EventMenu, { post: post, occurrence: occurrenceId, menuButton: _jsx("span", { className: "border-input flex size-10 items-center justify-center rounded-md border", children: _jsx(MoreHorizontal, { className: "size-4" }) }) })) : null] })] }), _jsx("h1", { className: "text-2xl font-bold", children: event.name }), _jsxs("div", { className: "mt-2 flex items-center gap-x-2", children: [_jsx(Avatar, { profile: post.profile, size: 2 }), _jsx("a", { href: `/@${post.profile.handle}`, className: "hover:text-primary text-sm hover:underline", children: t('events.hostedBy', {
|
|
96
105
|
defaultValue: 'Hosted by {{profileName}}',
|
|
97
106
|
profileName: `${profileName(post.profile)}${myEvent ? ' · You' : ''}`,
|
|
98
107
|
}) })] }), times.start ? (_jsx(EventWhenBlock, { iso: times.start, label: t('events.startDate', { defaultValue: 'Starts' }), timeZone: event.timeZone })) : null, times.end ? (_jsx(EventWhenBlock, { iso: times.end, label: t('events.endDate', { defaultValue: 'Ends' }), timeZone: event.timeZone })) : null, _jsx(EventLocation, { post: post, preview: false, occurrence: occurrenceId }), event.recurrence ? (_jsx(EventOccurrenceList, { post: post, postId: post.id, occurrences: upcomingOccurrences, currentOccurrenceId: occurrenceId, recurrenceLabel: recurrenceLabel })) : null, _jsx(EventRsvpButton, { post: post, recurrenceId: occurrenceId }), event.jam && (myEvent || iAmModerator) ? (livekitEnabled ? (jamState?.active ? (_jsx(Button, { variant: "default", className: "mt-2 w-full", action: jamLink, children: t('jam.join.submit', { defaultValue: 'Join Jam' }) })) : (_jsx(Button, { variant: "default", className: "mt-2 w-full", action: jamLink, children: t('events.jam.start', { defaultValue: 'Start jam' }) }))) : (_jsx("p", { role: "status", className: "text-destructive mt-2 text-sm", children: t('jams.unavailable.message', {
|
|
99
108
|
defaultValue: 'Jams are unavailable because LiveKit is not connected.',
|
|
100
|
-
}) }))) : null, _jsxs("nav", { "aria-label": t('events.tabs.label', { defaultValue: 'Event sections' }), className: "mt-4 flex flex-wrap gap-2 border-b", children: [event.content ? (_jsx(TabButton, { active: tab === 'description', onClick: () => setTab('description'), children: t('events.tabs.description', { defaultValue: 'Description' }) })) : null, _jsx(TabButton, { active: tab === 'replies', onClick: () => setTab('replies'), children: t('events.tabs.discussion', { defaultValue: 'Discussion' }) }), _jsx(TabButton, { active: tab === 'rsvps', onClick: () => setTab('rsvps'), children: t('events.tabs.rsvps', { defaultValue: 'RSVPs' }) }), showJamAttendeesTab ? (_jsx(TabButton, { active: tab === 'attendees', onClick: () => setTab('attendees'), children: t('events.tabs.jamAttendees', { defaultValue: 'Jam attendees' }) })) : null, event.jam ? (_jsx(TabButton, { active: tab === 'recordings', onClick: () => setTab('recordings'), children: t('events.tabs.recordings', { defaultValue: 'Recordings' }) })) : null] }), tab === 'description' && event.content ? (_jsx(OpenpeepsMarkdown, { source: event.content, mentions: post.mentions })) : null, tab === 'replies' ? (_jsxs(_Fragment, { children: [_jsx(ReplyBox, { post: post }), contextQuery.isLoading ? (_jsx("div", { className: "text-muted-foreground py-4 text-sm", children: _jsx(LoadingSpinner, {}) })) : (descendentThreads.map((thread) => (_jsx(ThreadedFeed, { thread: thread }, thread.id))))] })) : null, tab === 'rsvps' ? (_jsx(EventRsvpList, { post: post, occurrenceId: occurrenceId, occurrences: upcomingOccurrences, currentProfile: profile, canManageRsvps: canManageRsvps, onMessage: (target) => openCreateConversation({
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
}) }))) : null, _jsxs("nav", { "aria-label": t('events.tabs.label', { defaultValue: 'Event sections' }), className: "mt-4 flex flex-wrap gap-2 border-b", children: [event.content ? (_jsx(TabButton, { active: tab === 'description', onClick: () => setTab('description'), children: t('events.tabs.description', { defaultValue: 'Description' }) })) : null, _jsx(TabButton, { active: tab === 'replies', onClick: () => setTab('replies'), children: t('events.tabs.discussion', { defaultValue: 'Discussion' }) }), _jsx(TabButton, { active: tab === 'rsvps', onClick: () => setTab('rsvps'), children: t('events.tabs.rsvps', { defaultValue: 'RSVPs' }) }), showJamAttendeesTab ? (_jsx(TabButton, { active: tab === 'attendees', onClick: () => setTab('attendees'), children: t('events.tabs.jamAttendees', { defaultValue: 'Jam attendees' }) })) : null, event.jam ? (_jsx(TabButton, { active: tab === 'recordings', onClick: () => setTab('recordings'), children: t('events.tabs.recordings', { defaultValue: 'Recordings' }) })) : null] }), tab === 'description' && event.content ? (_jsx(OpenpeepsMarkdown, { source: event.content, mentions: post.mentions })) : null, tab === 'replies' ? (_jsxs(_Fragment, { children: [_jsx(ReplyBox, { post: post }), contextQuery.isLoading ? (_jsx("div", { className: "text-muted-foreground py-4 text-sm", children: _jsx(LoadingSpinner, {}) })) : (descendentThreads.map((thread) => (_jsx(ThreadedFeed, { thread: thread }, thread.id))))] })) : null, tab === 'rsvps' ? (_jsxs(_Fragment, { children: [canManageRsvps ? (_jsx("div", { className: "flex justify-end py-2", children: _jsxs(Button, { variant: "outline", compact: true, action: exportRsvps, children: [_jsx(Download, { className: "mr-1 h-4 w-4" }), t('events.exportRsvps', { defaultValue: 'Export RSVPs' })] }) })) : null, _jsx(EventRsvpList, { post: post, occurrenceId: occurrenceId, occurrences: upcomingOccurrences, currentProfile: profile, canManageRsvps: canManageRsvps, onMessage: (target) => openCreateConversation({
|
|
110
|
+
profiles: [target],
|
|
111
|
+
skipProfileSelection: true,
|
|
112
|
+
}), onManage: (response, profileId, recurrenceId) => rsvpManage({ response, recurrenceId }, { id: post.id, profileId }) })] })) : null, tab === 'attendees' && showJamAttendeesTab ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "flex justify-end py-2", children: _jsxs(Button, { variant: "outline", compact: true, action: exportAttendees, children: [_jsx(Download, { className: "mr-1 h-4 w-4" }), t('events.exportAttendees', {
|
|
104
113
|
defaultValue: 'Export attendees',
|
|
105
114
|
})] }) }), jamAttendeesQuery.data?.length ? (jamAttendeesQuery.data.map((attendee) => (_jsx(ProfileFromId, { profileId: attendee.profileId, action: _jsx(UpdatingDate, { date: attendee.createdAt }) }, attendee.id)))) : (_jsx("p", { className: "text-muted-foreground py-4 text-sm", children: t('events.noAttendees', { defaultValue: 'No attendees yet.' }) }))] })) : null, tab === 'recordings' && event.jam ? (!canViewRecordings ? (_jsxs("div", { role: "status", className: "flex flex-col items-center justify-center gap-2 py-6", children: [_jsx(EyeOff, { className: "size-12" }), _jsx("p", { className: "text-center text-sm", children: recordingsForbiddenMessage })] })) : recordingsQuery.isLoading ? (_jsx("div", { className: "text-muted-foreground py-4 text-sm", children: _jsx(LoadingSpinner, {}) })) : recordingsQuery.isError ? (_jsx(AccessDenied, { queries: [recordingsQuery], message: recordingsForbiddenMessage })) : recordingsQuery.data?.length ? (recordingsQuery.data.map((recording) => (_jsx(JamRecordingItem, { post: post, recording: recording, canManage: canViewRecordings }, recording.id)))) : (_jsx("p", { className: "text-muted-foreground py-4 text-sm", children: t('events.noRecordings', { defaultValue: 'No recordings yet.' }) }))) : null, _jsx("div", { className: "h-[40vh]" })] }));
|
|
106
115
|
}
|
|
@@ -43,6 +43,14 @@ export const ProfileEventRelationship = ({ post, }) => {
|
|
|
43
43
|
variant: 'outline',
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
+
if (myRsvp?.response === 'waitlist') {
|
|
47
|
+
return {
|
|
48
|
+
status: t('events.profileRelationship.waitlisted', {
|
|
49
|
+
defaultValue: 'Waitlisted',
|
|
50
|
+
}),
|
|
51
|
+
variant: 'outline',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
46
54
|
return null;
|
|
47
55
|
})();
|
|
48
56
|
if (!badge)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { isGroupPath, isJamPath, isPostPath } from './helpers.js';
|
|
2
|
+
import { isGroupPath, isJamPath, isPostPath, isWelcomePath } from './helpers.js';
|
|
3
3
|
import { GroupPreview } from './local/GroupPreview.js';
|
|
4
4
|
import { PostPreview } from './local/PostPreview.js';
|
|
5
5
|
import { JamPreview } from './local/JamPreview.js';
|
|
6
|
+
import { WelcomePreview } from './local/WelcomePreview.js';
|
|
6
7
|
export function LocalPreviewLink({ url }) {
|
|
7
8
|
const path = new URL(url).pathname;
|
|
8
9
|
const isPost = isPostPath(path);
|
|
9
10
|
const isJam = isJamPath(path);
|
|
10
11
|
const isGroup = isGroupPath(path);
|
|
11
|
-
|
|
12
|
+
const isWelcome = isWelcomePath(path);
|
|
13
|
+
return (_jsxs("a", { href: url, className: "hover:bg-surface mb-2 block w-full min-w-0 max-w-full overflow-hidden rounded-md border p-3 no-underline", onClick: (e) => e.stopPropagation(), children: [isPost ? _jsx(PostPreview, { path: path }) : null, isGroup ? _jsx(GroupPreview, { path: path }) : null, isJam ? _jsx(JamPreview, { path: path }) : null, isWelcome ? _jsx(WelcomePreview, {}) : null] }));
|
|
12
14
|
}
|
|
@@ -7,5 +7,5 @@ export function PreviewLink({ url = '' }) {
|
|
|
7
7
|
return null;
|
|
8
8
|
const origin = typeof window !== 'undefined' ? window.location.origin : '';
|
|
9
9
|
const local = isLocalLink(url, origin);
|
|
10
|
-
return (_jsx("div", { className: "min-w-0 max-w-full overflow-hidden", children: local ?
|
|
10
|
+
return (_jsx("div", { className: "min-w-0 max-w-full overflow-hidden", children: local ? _jsx(LocalPreviewLink, { url: url }) : _jsx(RemotePreviewLink, { url: url }) }));
|
|
11
11
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export declare const isPostPath: (path: string) => boolean;
|
|
2
2
|
export declare const isJamPath: (path: string) => boolean;
|
|
3
3
|
export declare const isGroupPath: (path: string) => boolean;
|
|
4
|
+
export declare const isWelcomePath: (path: string) => path is "/welcome" | "/welcome/";
|
|
4
5
|
export declare const isLocalLink: (url: string, origin: string) => boolean;
|
|
6
|
+
/** Plain-text clip of the welcome page, without image markup. */
|
|
7
|
+
export declare const welcomePreviewExcerpt: (markdown?: string) => string;
|
|
8
|
+
/** First content image on the welcome page, ignoring inline data URLs. */
|
|
9
|
+
export declare const firstMarkdownImage: (markdown?: string) => string | undefined;
|
|
5
10
|
export declare const isValidUrl: (url?: string) => boolean;
|
|
6
11
|
export declare const isEmail: (url: string) => boolean;
|
|
7
12
|
export declare const extractUrlsFromText: (text?: string) => [] | RegExpMatchArray;
|
|
@@ -1,21 +1,47 @@
|
|
|
1
|
+
import { markdownPlainText } from '@openpeepshq/common';
|
|
1
2
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
3
|
+
const EXCERPT_MAX = 180;
|
|
2
4
|
export const isPostPath = (path) => path.startsWith('/posts/') && UUID_RE.test(path.substring(7));
|
|
3
5
|
export const isJamPath = (path) => path.startsWith('/events/') &&
|
|
4
6
|
UUID_RE.test(path.substring(8, 44)) &&
|
|
5
7
|
path.endsWith('/jam');
|
|
6
8
|
export const isGroupPath = (path) => path.startsWith('/groups/@');
|
|
9
|
+
export const isWelcomePath = (path) => path === '/welcome' || path === '/welcome/';
|
|
7
10
|
export const isLocalLink = (url, origin) => {
|
|
8
11
|
try {
|
|
9
12
|
const urlObj = new URL(url);
|
|
10
13
|
return (urlObj.origin === origin &&
|
|
11
14
|
(isPostPath(urlObj.pathname) ||
|
|
12
15
|
isJamPath(urlObj.pathname) ||
|
|
13
|
-
isGroupPath(urlObj.pathname)
|
|
16
|
+
isGroupPath(urlObj.pathname) ||
|
|
17
|
+
isWelcomePath(urlObj.pathname)));
|
|
14
18
|
}
|
|
15
19
|
catch {
|
|
16
20
|
return false;
|
|
17
21
|
}
|
|
18
22
|
};
|
|
23
|
+
/** Plain-text clip of the welcome page, without image markup. */
|
|
24
|
+
export const welcomePreviewExcerpt = (markdown) => {
|
|
25
|
+
const plain = markdownPlainText((markdown ?? '').replace(/!\[[^\]]*]\([^)]*\)/g, ' '));
|
|
26
|
+
if (plain.length <= EXCERPT_MAX)
|
|
27
|
+
return plain;
|
|
28
|
+
const cut = plain.slice(0, EXCERPT_MAX);
|
|
29
|
+
const lastSpace = cut.lastIndexOf(' ');
|
|
30
|
+
const clipped = lastSpace > 80 ? cut.slice(0, lastSpace) : cut;
|
|
31
|
+
return `${clipped.trimEnd()}…`;
|
|
32
|
+
};
|
|
33
|
+
/** First content image on the welcome page, ignoring inline data URLs. */
|
|
34
|
+
export const firstMarkdownImage = (markdown) => {
|
|
35
|
+
if (!markdown)
|
|
36
|
+
return undefined;
|
|
37
|
+
const pattern = /!\[[^\]]*]\(\s*(<([^>]+)>|([^\s)]+))/g;
|
|
38
|
+
for (const match of markdown.matchAll(pattern)) {
|
|
39
|
+
const src = (match[2] ?? match[3])?.trim();
|
|
40
|
+
if (src && !src.startsWith('data:'))
|
|
41
|
+
return src;
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
};
|
|
19
45
|
export const isValidUrl = (url) => {
|
|
20
46
|
if (!url)
|
|
21
47
|
return false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const WelcomePreview: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useWelcomePreview } from '../../../hooks/useWelcomePreview.js';
|
|
3
|
+
export const WelcomePreview = () => {
|
|
4
|
+
const { eyebrow, title, description, imageUrl, imageFit } = useWelcomePreview();
|
|
5
|
+
return (_jsxs("div", { "data-testid": "welcome-preview-card", className: "flex w-full min-w-0 flex-row items-center gap-4", children: [imageUrl ? (_jsx("div", { className: "flex h-24 w-24 shrink-0 items-center justify-center overflow-hidden rounded-md", children: _jsx("img", { src: imageUrl, alt: "", className: `h-full w-full ${imageFit === 'cover' ? 'object-cover' : 'object-contain'}` }) })) : null, _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [eyebrow ? (_jsx("p", { className: "text-muted-foreground truncate text-xs", children: eyebrow })) : null, _jsx("p", { className: "line-clamp-2 font-semibold", children: title }), description ? (_jsx("p", { className: "text-muted-foreground line-clamp-3 break-words text-sm", children: description })) : null] })] }));
|
|
6
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getTheme, isDeletedProfile } from '@openpeepshq/common';
|
|
2
|
+
import { DELETED_AUTHOR_DISPLAY_NAME, getTheme, isDeletedProfile, } from '@openpeepshq/common';
|
|
3
3
|
import { UserX } from 'lucide-react';
|
|
4
4
|
import { useServerInfo } from '../server-data/index.js';
|
|
5
5
|
import { useCurrentProfileSettings } from '../layout/IdentityContext.js';
|
|
@@ -28,7 +28,7 @@ export function Avatar({ profile, size = 3.5, borderless = false, containerClass
|
|
|
28
28
|
width: `${size}rem`,
|
|
29
29
|
height: `${size}rem`,
|
|
30
30
|
backgroundColor,
|
|
31
|
-
}, children: deleted ? (_jsx(UserX, { "aria-label": profile?.displayName ||
|
|
31
|
+
}, children: deleted ? (_jsx(UserX, { "aria-label": profile?.displayName || DELETED_AUTHOR_DISPLAY_NAME, className: "text-muted-foreground", size: iconSize })) : src ? (_jsx("img", { src: svgCoverSrc(src), alt: profile?.displayName || profile?.handle || 'avatar', className: "h-full w-full rounded-full object-cover" })) : (_jsx("span", { className: "text-primary font-medium", style: { fontSize: `${size / 4}rem` }, children: getInitials(profile?.displayName, profile?.handle) })) }));
|
|
32
32
|
return (_jsx("div", { className: containerClassName, style: {
|
|
33
33
|
width: `${size}rem`,
|
|
34
34
|
height: `${size}rem`,
|
|
@@ -7,7 +7,7 @@ export function ProfileFromId({ profileId, avatarSize = 2, action, }) {
|
|
|
7
7
|
const profileQuery = openpeepsApi.useProfile(profileId);
|
|
8
8
|
const profile = profileQuery.data;
|
|
9
9
|
if (profileQuery.isLoading) {
|
|
10
|
-
return
|
|
10
|
+
return _jsx("div", { className: "text-muted-foreground py-2 text-sm", children: "Loading\u2026" });
|
|
11
11
|
}
|
|
12
12
|
if (!profile)
|
|
13
13
|
return null;
|