@openpeepshq/react 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/dist/components/configuration/ConfigurationCategory.js +3 -2
  2. package/dist/components/configuration/ConfigurationList.js +1 -1
  3. package/dist/components/form/LocationInput.js +1 -1
  4. package/dist/components/jams/JamCapacityGate.js +1 -1
  5. package/dist/components/jams/JamConference.js +2 -0
  6. package/dist/components/jams/JamParticipantConference.js +2 -0
  7. package/dist/components/jams/JamRoom.js +2 -3
  8. package/dist/components/jams/LiveJamsSection.js +8 -2
  9. package/dist/components/jams/LivekitUnavailableNotice.d.ts +9 -0
  10. package/dist/components/jams/LivekitUnavailableNotice.js +19 -0
  11. package/dist/components/jams/dropLateAudio.d.ts +22 -0
  12. package/dist/components/jams/dropLateAudio.js +115 -0
  13. package/dist/components/jams/index.d.ts +1 -0
  14. package/dist/components/jams/index.js +1 -0
  15. package/dist/components/markdown/compileMarkdown.js +1 -0
  16. package/dist/components/navigation/FooterMobile.js +4 -3
  17. package/dist/components/navigation/HeaderMobile.js +5 -2
  18. package/dist/components/navigation/MobileMenuItem.d.ts +3 -1
  19. package/dist/components/navigation/MobileMenuItem.js +7 -2
  20. package/dist/components/navigation/NavWithTooltip.d.ts +9 -0
  21. package/dist/components/navigation/NavWithTooltip.js +4 -0
  22. package/dist/components/navigation/index.d.ts +2 -0
  23. package/dist/components/navigation/index.js +1 -0
  24. package/dist/components/navigation/sideBarNavLinkClass.d.ts +6 -4
  25. package/dist/components/navigation/sideBarNavLinkClass.js +6 -2
  26. package/dist/components/notifications/TypedNotification.js +46 -4
  27. package/dist/components/post/CompactReplyParent.js +5 -6
  28. package/dist/components/post/Markdown.d.ts +2 -2
  29. package/dist/components/post/Markdown.js +1 -1
  30. package/dist/components/post/TruncatedMarkdown.d.ts +27 -0
  31. package/dist/components/post/TruncatedMarkdown.js +37 -0
  32. package/dist/components/post/attachmentPreview.js +1 -1
  33. package/dist/components/post/helpers.d.ts +2 -2
  34. package/dist/components/post/helpers.js +3 -16
  35. package/dist/components/post/index.d.ts +2 -0
  36. package/dist/components/post/index.js +1 -0
  37. package/dist/components/post/pieces/Attachments.js +23 -17
  38. package/dist/components/post/pieces/EventLocation.js +14 -0
  39. package/dist/components/post/pieces/EventRsvpButton.js +39 -7
  40. package/dist/components/post/pieces/EventRsvpList.js +23 -3
  41. package/dist/components/post/pieces/EventRsvpScopeDialog.d.ts +1 -1
  42. package/dist/components/post/pieces/EventRsvpScopeDialog.js +34 -22
  43. package/dist/components/post/pieces/EventWaitlistJoinDialog.d.ts +10 -0
  44. package/dist/components/post/pieces/EventWaitlistJoinDialog.js +26 -0
  45. package/dist/components/post/pieces/ParticipantsCard.d.ts +1 -1
  46. package/dist/components/post/pieces/ParticipantsCard.js +1 -1
  47. package/dist/components/post/pieces/PollContent.js +8 -2
  48. package/dist/components/post/pieces/PostActions.d.ts +1 -1
  49. package/dist/components/post/pieces/PostActions.js +20 -12
  50. package/dist/components/post/pieces/ShareMenu.d.ts +6 -1
  51. package/dist/components/post/pieces/ShareMenu.js +40 -7
  52. package/dist/components/post/post-form/ArticleForm.js +1 -1
  53. package/dist/components/post/post-form/EventForm.js +33 -5
  54. package/dist/components/post/post-form/ResourceForm.d.ts +3 -1
  55. package/dist/components/post/post-form/ResourceForm.js +48 -7
  56. package/dist/components/post/post-form/VisibilitySelector.js +9 -3
  57. package/dist/components/post/types/Article.js +2 -3
  58. package/dist/components/post/types/Event.js +10 -1
  59. package/dist/components/post/types/article/FullArticle.js +1 -1
  60. package/dist/components/post/types/event/CardEvent.js +2 -1
  61. package/dist/components/post/types/event/FullEvent.js +22 -13
  62. package/dist/components/post/types/event/ProfileEventRelationship.js +8 -0
  63. package/dist/components/post/types/resource/FullResource.js +3 -3
  64. package/dist/components/preview-link/LocalPreviewLink.js +4 -2
  65. package/dist/components/preview-link/PreviewLink.js +1 -1
  66. package/dist/components/preview-link/helpers.d.ts +5 -0
  67. package/dist/components/preview-link/helpers.js +27 -1
  68. package/dist/components/preview-link/local/WelcomePreview.d.ts +1 -0
  69. package/dist/components/preview-link/local/WelcomePreview.js +8 -0
  70. package/dist/components/profile/Avatar.js +2 -2
  71. package/dist/components/profile/ProfileFromId.js +1 -1
  72. package/dist/components/resources/ResourceCard.d.ts +5 -1
  73. package/dist/components/resources/ResourceCard.js +29 -5
  74. package/dist/components/resources/ResourceCard.test.d.ts +1 -0
  75. package/dist/components/resources/ResourceCard.test.js +75 -0
  76. package/dist/components/resources/ResourceLibrary.js +1 -1
  77. package/dist/components/server-data/context.d.ts +1 -0
  78. package/dist/contexts/openpeeps/hooks/accounts.d.ts +5 -5
  79. package/dist/contexts/openpeeps/hooks/accounts.js +1 -3
  80. package/dist/contexts/openpeeps/hooks/admin.d.ts +165 -66
  81. package/dist/contexts/openpeeps/hooks/admin.js +11 -3
  82. package/dist/contexts/openpeeps/hooks/auth.d.ts +2 -2
  83. package/dist/contexts/openpeeps/hooks/groups.d.ts +8 -8
  84. package/dist/contexts/openpeeps/hooks/jams.d.ts +73 -24
  85. package/dist/contexts/openpeeps/hooks/other.d.ts +7 -6
  86. package/dist/contexts/openpeeps/hooks/payments.d.ts +2 -2
  87. package/dist/contexts/openpeeps/hooks/posts.d.ts +368 -170
  88. package/dist/contexts/openpeeps/hooks/streaming.d.ts +1 -1
  89. package/dist/hooks/admin/useCanAccessAdminSection.d.ts +13 -0
  90. package/dist/hooks/admin/useCanAccessAdminSection.js +21 -0
  91. package/dist/hooks/events/useEventComposer.d.ts +94 -41
  92. package/dist/hooks/events/useEventForm.d.ts +1 -0
  93. package/dist/hooks/events/useEventRsvp.d.ts +12 -2
  94. package/dist/hooks/events/useEventRsvp.js +59 -10
  95. package/dist/hooks/events/useEventsCalendar.d.ts +174 -76
  96. package/dist/hooks/groups/useNewGroup.js +22 -2
  97. package/dist/hooks/index.d.ts +5 -1
  98. package/dist/hooks/index.js +4 -1
  99. package/dist/hooks/jams/useCanDiagnoseLivekit.d.ts +2 -0
  100. package/dist/hooks/jams/useCanDiagnoseLivekit.js +3 -0
  101. package/dist/hooks/jams/useCreateNewJamForm.d.ts +3 -1
  102. package/dist/hooks/jams/useJamDetails.d.ts +87 -38
  103. package/dist/hooks/jams/useJamLobby.d.ts +1 -0
  104. package/dist/hooks/jams/useJamRoom.d.ts +175 -76
  105. package/dist/hooks/posts/useArticleComposer.d.ts +93 -41
  106. package/dist/hooks/posts/useFeedPostPresentation.d.ts +174 -76
  107. package/dist/hooks/posts/usePostDetailTitle.d.ts +87 -38
  108. package/dist/hooks/posts/useResourceComposer.d.ts +95 -41
  109. package/dist/hooks/posts/useResourceComposer.js +135 -27
  110. package/dist/hooks/posts/useShareMenu.d.ts +2 -0
  111. package/dist/hooks/posts/useShareMenu.js +7 -0
  112. package/dist/hooks/resources/useResourceLibrary.d.ts +177 -79
  113. package/dist/hooks/resources/useResourceLibrary.js +6 -2
  114. package/dist/hooks/settings/useNotificationPreferences.d.ts +1 -1
  115. package/dist/hooks/useWelcomePreview.d.ts +16 -0
  116. package/dist/hooks/useWelcomePreview.js +40 -0
  117. package/dist/lib/groupFormErrors.d.ts +1 -0
  118. package/dist/lib/groupFormErrors.js +5 -2
  119. package/dist/lib/threadHelpers.js +1 -5
  120. package/dist/navigation/menuItems.js +15 -0
  121. package/dist/navigation/targets.d.ts +2 -0
  122. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  123. package/dist/pages/admin/Diagnostics.js +1 -1
  124. package/dist/pages/admin/DiagnosticsLivekit.d.ts +1 -0
  125. package/dist/pages/admin/DiagnosticsLivekit.js +50 -0
  126. package/dist/pages/admin/Invites.js +5 -3
  127. package/dist/pages/admin/Media.d.ts +1 -0
  128. package/dist/pages/admin/Media.js +135 -0
  129. package/dist/pages/admin/community/CommunityForbiddenUsernames.d.ts +1 -0
  130. package/dist/pages/admin/community/CommunityForbiddenUsernames.js +106 -0
  131. package/dist/pages/admin/community/CommunityMarkdownPage.js +2 -1
  132. package/dist/pages/admin/community/CommunityRoles.js +1 -1
  133. package/dist/pages/admin/community/useCommunityConfig.d.ts +2 -0
  134. package/dist/pages/admin/components/EditInviteLinkModal.d.ts +5 -0
  135. package/dist/pages/admin/components/EditInviteLinkModal.js +131 -0
  136. package/dist/pages/auth/Register.js +33 -9
  137. package/dist/pages/conversations/Show.js +11 -0
  138. package/dist/pages/index.d.ts +3 -0
  139. package/dist/pages/index.js +3 -0
  140. package/dist/pages/jams/Index.js +2 -4
  141. package/dist/pages/resources/Edit.js +3 -3
  142. package/dist/pages/resources/New.js +2 -2
  143. package/dist/pages/settings/Account.js +30 -2
  144. package/dist/pages/settings/PublicProfile.js +15 -3
  145. package/dist/pwa/sw.d.ts +0 -1
  146. package/dist/react-native.d.ts +1 -0
  147. package/dist/react-native.js +1 -0
  148. package/dist/stores/newPosts.d.ts +4 -2
  149. package/dist/stores/newPosts.js +6 -1
  150. package/package.json +12 -7
  151. package/src/components/configuration/ConfigurationCategory.tsx +23 -10
  152. package/src/components/configuration/ConfigurationList.tsx +6 -1
  153. package/src/components/form/LocationInput.tsx +7 -1
  154. package/src/components/jams/JamCapacityGate.tsx +1 -1
  155. package/src/components/jams/JamConference.tsx +2 -0
  156. package/src/components/jams/JamParticipantConference.tsx +2 -0
  157. package/src/components/jams/JamRoom.tsx +2 -6
  158. package/src/components/jams/LiveJamsSection.tsx +16 -2
  159. package/src/components/jams/LivekitUnavailableNotice.tsx +40 -0
  160. package/src/components/jams/dropLateAudio.ts +153 -0
  161. package/src/components/jams/index.ts +1 -0
  162. package/src/components/markdown/compileMarkdown.ts +1 -0
  163. package/src/components/navigation/FooterMobile.tsx +41 -33
  164. package/src/components/navigation/HeaderMobile.tsx +55 -41
  165. package/src/components/navigation/MobileMenuItem.tsx +15 -2
  166. package/src/components/navigation/NavWithTooltip.tsx +26 -0
  167. package/src/components/navigation/index.ts +2 -0
  168. package/src/components/navigation/sideBarNavLinkClass.ts +9 -6
  169. package/src/components/notifications/TypedNotification.tsx +81 -9
  170. package/src/components/post/CompactReplyParent.tsx +17 -10
  171. package/src/components/post/Markdown.tsx +8 -2
  172. package/src/components/post/TruncatedMarkdown.tsx +91 -0
  173. package/src/components/post/attachmentPreview.ts +1 -3
  174. package/src/components/post/helpers.ts +4 -18
  175. package/src/components/post/index.ts +2 -0
  176. package/src/components/post/pieces/Attachments.tsx +93 -78
  177. package/src/components/post/pieces/EventLocation.tsx +27 -0
  178. package/src/components/post/pieces/EventRsvpButton.tsx +110 -7
  179. package/src/components/post/pieces/EventRsvpList.tsx +64 -0
  180. package/src/components/post/pieces/EventRsvpScopeDialog.tsx +39 -27
  181. package/src/components/post/pieces/EventWaitlistJoinDialog.tsx +77 -0
  182. package/src/components/post/pieces/ParticipantsCard.tsx +4 -1
  183. package/src/components/post/pieces/PollContent.tsx +8 -2
  184. package/src/components/post/pieces/PostActions.tsx +73 -42
  185. package/src/components/post/pieces/ShareMenu.tsx +67 -9
  186. package/src/components/post/post-form/ArticleForm.tsx +1 -1
  187. package/src/components/post/post-form/EventForm.tsx +69 -15
  188. package/src/components/post/post-form/ResourceForm.tsx +132 -4
  189. package/src/components/post/post-form/VisibilitySelector.tsx +12 -5
  190. package/src/components/post/types/Article.tsx +6 -6
  191. package/src/components/post/types/Event.tsx +68 -7
  192. package/src/components/post/types/article/FullArticle.tsx +2 -2
  193. package/src/components/post/types/event/CardEvent.tsx +26 -14
  194. package/src/components/post/types/event/FullEvent.tsx +48 -35
  195. package/src/components/post/types/event/ProfileEventRelationship.tsx +8 -0
  196. package/src/components/post/types/note/FullNote.tsx +1 -4
  197. package/src/components/post/types/poll/FullPoll.tsx +1 -4
  198. package/src/components/post/types/resource/FullResource.tsx +9 -1
  199. package/src/components/preview-link/LocalPreviewLink.tsx +4 -1
  200. package/src/components/preview-link/PreviewLink.tsx +2 -7
  201. package/src/components/preview-link/helpers.ts +32 -1
  202. package/src/components/preview-link/local/GroupPreview.tsx +1 -1
  203. package/src/components/preview-link/local/JamPreview.tsx +1 -1
  204. package/src/components/preview-link/local/WelcomePreview.tsx +45 -0
  205. package/src/components/profile/Avatar.tsx +6 -2
  206. package/src/components/profile/ProfileFromId.tsx +1 -5
  207. package/src/components/resources/ResourceCard.tsx +68 -11
  208. package/src/components/resources/ResourceLibrary.tsx +2 -2
  209. package/src/contexts/openpeeps/hooks/accounts.ts +1 -3
  210. package/src/contexts/openpeeps/hooks/admin.ts +11 -3
  211. package/src/contexts/openpeeps/hooks/other.ts +9 -12
  212. package/src/contexts/openpeeps/hooks/streaming.ts +3 -3
  213. package/src/css.d.ts +4 -0
  214. package/src/hooks/admin/useCanAccessAdminSection.ts +27 -0
  215. package/src/hooks/events/useEventRsvp.ts +69 -13
  216. package/src/hooks/groups/useNewGroup.ts +28 -3
  217. package/src/hooks/index.ts +8 -1
  218. package/src/hooks/jams/useCanDiagnoseLivekit.ts +5 -0
  219. package/src/hooks/posts/useResourceComposer.ts +165 -39
  220. package/src/hooks/posts/useShareMenu.ts +9 -0
  221. package/src/hooks/resources/useResourceLibrary.ts +6 -2
  222. package/src/hooks/useWelcomePreview.ts +61 -0
  223. package/src/i18n/I18nProvider.tsx +1 -4
  224. package/src/lib/groupFormErrors.ts +9 -2
  225. package/src/lib/threadHelpers.ts +1 -5
  226. package/src/navigation/menuItems.ts +16 -0
  227. package/src/navigation/targets.ts +2 -0
  228. package/src/pages/admin/ConfigurationCommunity.tsx +5 -0
  229. package/src/pages/admin/Diagnostics.tsx +4 -0
  230. package/src/pages/admin/DiagnosticsLivekit.tsx +147 -0
  231. package/src/pages/admin/Invites.tsx +23 -1
  232. package/src/pages/admin/Media.tsx +290 -0
  233. package/src/pages/admin/community/CommunityForbiddenUsernames.tsx +223 -0
  234. package/src/pages/admin/community/CommunityMarkdownPage.tsx +5 -1
  235. package/src/pages/admin/community/CommunityRoles.tsx +2 -2
  236. package/src/pages/admin/components/EditInviteLinkModal.tsx +263 -0
  237. package/src/pages/auth/Register.tsx +45 -4
  238. package/src/pages/conversations/Show.tsx +11 -0
  239. package/src/pages/index.ts +3 -0
  240. package/src/pages/jams/Index.tsx +2 -6
  241. package/src/pages/resources/Edit.tsx +3 -2
  242. package/src/pages/resources/New.tsx +6 -1
  243. package/src/pages/settings/Account.tsx +51 -1
  244. package/src/pages/settings/PublicProfile.tsx +20 -2
  245. package/src/pwa/sw.ts +6 -3
  246. package/src/pwa/useNotificationBadgeSync.ts +3 -1
  247. package/src/react-native.ts +1 -0
  248. package/src/stores/newPosts.ts +6 -1
  249. package/src/streaming.ts +3 -3
  250. package/dist/setupTests.d.ts +0 -1
  251. package/dist/setupTests.js +0 -5
@@ -0,0 +1,27 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface TruncatedMarkdownProps {
3
+ /** Full markdown content; rendered in the popover when `interactive`. */
4
+ source: string;
5
+ /** Pre-truncated excerpt. When omitted, computed via `truncateMarkdown`. */
6
+ snippet?: string;
7
+ maxBlocks?: number;
8
+ maxChars?: number;
9
+ /** Lines the excerpt is clamped to (only when `interactive`). */
10
+ maxLines?: number;
11
+ /**
12
+ * When true, the excerpt is clamped and a "Show more" control reveals the
13
+ * full content in a popover (click/tap; hover on desktop via the popover).
14
+ * When false, the excerpt renders as-is — callers that own their own
15
+ * navigation keep it plain.
16
+ */
17
+ interactive?: boolean;
18
+ className?: string;
19
+ }
20
+ /**
21
+ * Single rendering surface for abbreviated markdown. The excerpt is always
22
+ * produced by the markdown-aware `truncateMarkdown` (links, images and
23
+ * emphasis are never severed), so every abbreviated preview renders as real
24
+ * markdown instead of raw text. Call sites with their own read-more navigation
25
+ * (e.g. Article) keep `interactive` off and render the link themselves.
26
+ */
27
+ export declare const TruncatedMarkdown: ({ source, snippet: snippetProp, maxBlocks, maxChars, maxLines, interactive, className, }: TruncatedMarkdownProps) => ReactNode;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import {} from 'react';
3
+ import { truncateMarkdown } from '@openpeepshq/common/lib';
4
+ import { Popover, PopoverContent, PopoverTrigger } from '@openpeepshq/react-ui';
5
+ import { useT } from '../../i18n/index.js';
6
+ import { PostMarkdown } from './Markdown.js';
7
+ import { OPENPEEPS_POST_CAPTION_CLASS } from '../markdown/classes.js';
8
+ const clampClass = (n) => `line-clamp-${n}`;
9
+ /**
10
+ * Single rendering surface for abbreviated markdown. The excerpt is always
11
+ * produced by the markdown-aware `truncateMarkdown` (links, images and
12
+ * emphasis are never severed), so every abbreviated preview renders as real
13
+ * markdown instead of raw text. Call sites with their own read-more navigation
14
+ * (e.g. Article) keep `interactive` off and render the link themselves.
15
+ */
16
+ export const TruncatedMarkdown = ({ source, snippet: snippetProp, maxBlocks = 2, maxChars = 240, maxLines = 2, interactive = true, className, }) => {
17
+ const t = useT();
18
+ const excerpt = snippetProp ?? truncateMarkdown(source, maxBlocks, maxChars);
19
+ if (!excerpt)
20
+ return null;
21
+ const excerptClass = [
22
+ OPENPEEPS_POST_CAPTION_CLASS,
23
+ interactive && maxLines > 0 ? clampClass(maxLines) : '',
24
+ className ?? '',
25
+ ]
26
+ .join(' ')
27
+ .trim();
28
+ const body = _jsx(PostMarkdown, { source: excerpt, className: excerptClass });
29
+ if (!interactive)
30
+ return body;
31
+ return (_jsxs("div", { className: "inline-block max-w-full align-baseline", children: [body, _jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: (e) => {
32
+ e.stopPropagation();
33
+ e.preventDefault();
34
+ }, "aria-label": t('posts.truncatedMarkdown.showHint', {
35
+ defaultValue: 'Show more',
36
+ }), className: "text-primary inline-flex items-center gap-1 text-xs font-medium underline decoration-transparent underline-offset-2 hover:decoration-inherit", children: t('posts.truncatedMarkdown.show', { defaultValue: 'Show more' }) }) }), _jsx(PopoverContent, { side: "top", align: "start", sideOffset: 8, className: "bg-popover text-popover-foreground z-50 max-w-xs rounded-md border p-3 shadow-md", children: _jsx(PostMarkdown, { source: source }) })] })] }));
37
+ };
@@ -10,5 +10,5 @@ export const resolveAttachmentPreviewUrl = (localPreviewUrl, attachment) => {
10
10
  attachment?.url,
11
11
  localPreviewUrl,
12
12
  ].filter((url) => !!url);
13
- return (candidates.find((url) => !isBlobUrl(url)) ?? candidates[0] ?? '');
13
+ return candidates.find((url) => !isBlobUrl(url)) ?? candidates[0] ?? '';
14
14
  };
@@ -1,6 +1,6 @@
1
1
  import type { PublicPost } from '@openpeepshq/common/types';
2
+ /** @deprecated Use `firstNWords` from `@openpeepshq/common/lib` directly. */
3
+ export declare const firstNWords: (markdown: string | undefined, n: number) => string;
2
4
  /** Splits a string into user-visible grapheme clusters (so emojis don't get chopped). */
3
5
  export declare const stringToSegments: (text: string) => string[];
4
6
  export declare const postReactionStats: (post: PublicPost) => string;
5
- /** Truncates markdown to roughly the first N words, preserving links. */
6
- export declare const firstNWords: (markdown: string | undefined, n: number) => string;
@@ -1,3 +1,6 @@
1
+ import { firstNWords as _firstNWords } from '@openpeepshq/common/lib';
2
+ /** @deprecated Use `firstNWords` from `@openpeepshq/common/lib` directly. */
3
+ export const firstNWords = _firstNWords;
1
4
  /** Splits a string into user-visible grapheme clusters (so emojis don't get chopped). */
2
5
  export const stringToSegments = (text) => typeof Intl.Segmenter === 'function'
3
6
  ? [...new Intl.Segmenter().segment(text)].map((x) => x.segment)
@@ -8,19 +11,3 @@ export const postReactionStats = (post) => {
8
11
  ].join('');
9
12
  return `${uniqueEmojis} ${post.reactions?.length ?? 0}`;
10
13
  };
11
- /** Truncates markdown to roughly the first N words, preserving links. */
12
- export const firstNWords = (markdown, n) => {
13
- if (!markdown)
14
- return '';
15
- const regex = /\[.*?\]\(.*?\)|(\w+)/g;
16
- let wordCount = 0;
17
- const out = [];
18
- let match;
19
- while ((match = regex.exec(markdown)) !== null) {
20
- if (wordCount >= n)
21
- break;
22
- out.push(match[0]);
23
- wordCount++;
24
- }
25
- return out.join(' ');
26
- };
@@ -6,6 +6,8 @@ export { FeedPostContent } from './FeedPostContent';
6
6
  export { PostDetail } from './PostDetail';
7
7
  export type { PostDetailProps } from './PostDetail';
8
8
  export { PostMarkdown, OpenpeepsMarkdown } from './Markdown';
9
+ export { TruncatedMarkdown } from './TruncatedMarkdown';
10
+ export type { TruncatedMarkdownProps } from './TruncatedMarkdown';
9
11
  export { PostMenu } from './pieces/PostMenu';
10
12
  export type { PostMenuProps } from './pieces/PostMenu';
11
13
  export { ShareMenu } from './pieces/ShareMenu';
@@ -3,6 +3,7 @@ export { FeedPost } from './FeedPost.js';
3
3
  export { FeedPostContent } from './FeedPostContent.js';
4
4
  export { PostDetail } from './PostDetail.js';
5
5
  export { PostMarkdown, OpenpeepsMarkdown } from './Markdown.js';
6
+ export { TruncatedMarkdown } from './TruncatedMarkdown.js';
6
7
  export { PostMenu } from './pieces/PostMenu.js';
7
8
  export { ShareMenu } from './pieces/ShareMenu.js';
8
9
  export { EventMenu } from './pieces/EventMenu.js';
@@ -16,13 +16,21 @@ export function Attachments({ post }) {
16
16
  const [galleryIndex, setGalleryIndex] = useState(null);
17
17
  if (attachments.length === 0)
18
18
  return null;
19
+ // A lone audio or video file plays inline. Anything else stays a gallery
20
+ // tile, including an audio or video file that shares the post with others.
21
+ const sole = attachments.length === 1 ? attachments[0] : undefined;
22
+ const inline = sole && (isAudioAttachment(sole) || isVideo(sole)) ? sole : undefined;
23
+ if (inline && isVideo(inline)) {
24
+ return (_jsx("div", { className: "bg-surface mt-2 w-full overflow-hidden rounded-md", children: _jsx("video", { src: inline.url, poster: inline.previewUrl ?? undefined, controls: true, playsInline: true, preload: "metadata", className: "max-h-[70vh] w-full" }) }));
25
+ }
26
+ if (inline) {
27
+ return (_jsx("div", { className: "mt-2", children: _jsx(AudioAttachment, { src: inline.url, label: inline.filename ?? inline.description, size: inline.meta?.size }) }));
28
+ }
19
29
  const indexed = attachments.map((att, idx) => ({ att, idx }));
20
- const visual = indexed.filter(({ att }) => !isAudioAttachment(att));
21
- const audio = indexed.filter(({ att }) => isAudioAttachment(att));
22
- const single = visual.length === 1;
30
+ const single = indexed.length === 1;
23
31
  const cols = single
24
32
  ? ''
25
- : visual.length === 2
33
+ : indexed.length === 2
26
34
  ? 'grid grid-cols-2'
27
35
  : 'grid grid-cols-2 grid-rows-2';
28
36
  // With a single attachment the grid has no fixed height, so the children
@@ -34,17 +42,15 @@ export function Attachments({ post }) {
34
42
  const mediaClass = single
35
43
  ? 'max-h-[600px] w-full object-contain'
36
44
  : 'h-full w-full object-cover';
37
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "mt-2 flex w-full flex-col gap-2", children: [visual.length > 0 ? (_jsx("div", { className: `w-full gap-1 overflow-hidden rounded-md ${cols} ${height}`, children: visual.map(({ att, idx }) => {
38
- const tile = (_jsx(_Fragment, { children: isImage(att) && (att.previewUrl || att.url) ? (_jsx("img", { src: att.previewUrl ?? att.url ?? '', alt: att.description ?? `attachment ${idx + 1}`, className: mediaClass })) : isVideo(att) && (att.previewUrl || att.url) ? (_jsxs("div", { className: "relative h-full w-full", children: [_jsx("img", { src: att.previewUrl ?? att.url ?? '', alt: att.description ?? `attachment ${idx + 1}`, className: mediaClass }), _jsx(VideoPlayOverlay, { video: true })] })) : (_jsxs("div", { className: "text-muted-foreground flex min-h-24 w-full flex-col items-center justify-center gap-1 p-4 text-center text-xs", children: [_jsx("span", { className: "text-foreground break-all font-medium", children: att.filename ??
39
- att.description ??
40
- `Attachment ${idx + 1}` }), att.meta?.mimetype ? (_jsx("span", { className: "uppercase", children: att.meta.mimetype })) : null] })) }));
41
- if (staticRender) {
42
- return (_jsx("div", { className: `${tileClass} bg-surface overflow-hidden`, children: tile }, `${att.url ?? idx}-${idx}`));
43
- }
44
- return (_jsx("button", { type: "button", className: `${tileClass} bg-surface overflow-hidden`, onClick: (e) => {
45
- e.preventDefault();
46
- e.stopPropagation();
47
- setGalleryIndex(idx);
48
- }, children: tile }, `${att.url ?? idx}-${idx}`));
49
- }) })) : null, audio.map(({ att, idx }) => (_jsx(AudioAttachment, { src: att.url, label: att.filename ?? att.description, size: att.meta?.size }, `${att.url ?? idx}-${idx}`)))] }), galleryIndex !== null ? (_jsx(GalleryModal, { attachments: attachments, initialIndex: galleryIndex, onClose: () => setGalleryIndex(null) })) : null] }));
45
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: `mt-2 w-full gap-1 overflow-hidden rounded-md ${cols} ${height}`, children: indexed.map(({ att, idx }) => {
46
+ const tile = (_jsx(_Fragment, { children: isImage(att) && (att.previewUrl || att.url) ? (_jsx("img", { src: att.previewUrl ?? att.url ?? '', alt: att.description ?? `attachment ${idx + 1}`, className: mediaClass })) : isVideo(att) && (att.previewUrl || att.url) ? (_jsxs("div", { className: "relative h-full w-full", children: [_jsx("img", { src: att.previewUrl ?? att.url ?? '', alt: att.description ?? `attachment ${idx + 1}`, className: mediaClass }), _jsx(VideoPlayOverlay, { video: true })] })) : (_jsxs("div", { className: "text-muted-foreground flex min-h-24 w-full flex-col items-center justify-center gap-1 p-4 text-center text-xs", children: [_jsx("span", { className: "text-foreground break-all font-medium", children: att.filename ?? att.description ?? `Attachment ${idx + 1}` }), att.meta?.mimetype ? (_jsx("span", { className: "uppercase", children: att.meta.mimetype })) : null] })) }));
47
+ if (staticRender) {
48
+ return (_jsx("div", { className: `${tileClass} bg-surface overflow-hidden`, children: tile }, `${att.url ?? idx}-${idx}`));
49
+ }
50
+ return (_jsx("button", { type: "button", className: `${tileClass} bg-surface overflow-hidden`, onClick: (e) => {
51
+ e.preventDefault();
52
+ e.stopPropagation();
53
+ setGalleryIndex(idx);
54
+ }, children: tile }, `${att.url ?? idx}-${idx}`));
55
+ }) }), galleryIndex !== null ? (_jsx(GalleryModal, { attachments: attachments, initialIndex: galleryIndex, onClose: () => setGalleryIndex(null) })) : null] }));
50
56
  }
@@ -19,6 +19,20 @@ export function EventLocation({ post, preview = true, truncate = false, occurren
19
19
  ? window.location.origin
20
20
  : undefined;
21
21
  const jamLink = getJamUrl(post.id, origin, occurrence);
22
+ if (preview && staticRender) {
23
+ if (physicalLocation) {
24
+ return (_jsx("span", { className: "text-sm", children: truncate
25
+ ? truncateText(physicalLocation.text)
26
+ : physicalLocation.text }));
27
+ }
28
+ if (event.jam) {
29
+ return (_jsx("a", { href: jamLink, className: "text-primary text-sm underline", children: t('events.location.jam', { defaultValue: 'Jam Event' }) }));
30
+ }
31
+ if (event.url) {
32
+ return (_jsx("a", { href: event.url, className: "text-primary text-sm underline", children: t('events.location.online', { defaultValue: 'Online' }) }));
33
+ }
34
+ return null;
35
+ }
22
36
  if (preview) {
23
37
  return (_jsx("div", { className: "flex items-center gap-1 text-sm", children: physicalLocation ? (_jsxs(_Fragment, { children: [_jsx(MapPin, { className: "h-4 w-4 shrink-0" }), _jsx("span", { children: truncate
24
38
  ? truncateText(physicalLocation.text)
@@ -3,9 +3,10 @@ import { useT } from '../../../i18n/index.js';
3
3
  import { Button } from '@openpeepshq/react-ui';
4
4
  import { useEventRsvp } from '../../../hooks/events/useEventRsvp.js';
5
5
  import { EventRsvpScopeDialog } from './EventRsvpScopeDialog.js';
6
+ import { EventWaitlistJoinDialog } from './EventWaitlistJoinDialog.js';
6
7
  export const EventRsvpButton = ({ post, recurrenceId, lockToOccurrence = false, }) => {
7
8
  const t = useT();
8
- const { profile, myEvent, myRsvp, canRsvp, rsvpClosed, recurring, defaultId, occurrences, capacityEvent, full, error, pending, setPending, submitting, requestRespond, confirmScope, } = useEventRsvp({ post, recurrenceId, lockToOccurrence });
9
+ const { profile, myEvent, myRsvp, canRsvp, rsvpClosed, hideRsvpButton, recurring, defaultId, occurrences, capacityEvent, full, onWaitlist, offerExpiresAt, error, pending, setPending, confirmingWaitlist, setConfirmingWaitlist, submitting, requestRespond, requestJoinWaitlist, confirmJoinWaitlist, claimSpot, confirmScope, } = useEventRsvp({ post, recurrenceId, lockToOccurrence });
9
10
  if (myEvent || !profile)
10
11
  return null;
11
12
  if (!canRsvp && !(myRsvp && myRsvp.response !== 'no'))
@@ -20,18 +21,47 @@ export const EventRsvpButton = ({ post, recurrenceId, lockToOccurrence = false,
20
21
  ? t('posts.rsvp.attendingMessage', {
21
22
  defaultValue: 'You are attending.',
22
23
  })
23
- : t('posts.rsvp.maybeMessage', {
24
- defaultValue: 'You responded maybe.',
25
- }) })) : null, _jsx("p", { className: "text-muted-foreground mt-2 text-center text-sm", children: t('events.rsvp.ended', {
24
+ : myRsvp.response === 'waitlist'
25
+ ? t('events.rsvp.onWaitlist', {
26
+ defaultValue: 'You are on the waitlist.',
27
+ })
28
+ : t('posts.rsvp.maybeMessage', {
29
+ defaultValue: 'You responded maybe.',
30
+ }) })) : null, _jsx("p", { className: "text-muted-foreground mt-2 text-center text-sm", children: t('events.rsvp.ended', {
26
31
  defaultValue: 'This event has ended.',
27
32
  }) })] }));
28
33
  }
34
+ if (hideRsvpButton)
35
+ return null;
29
36
  const scopeDialog = pending && recurring && !lockToOccurrence ? (_jsx(EventRsvpScopeDialog, { open: true, post: post, response: pending, defaultRecurrenceId: defaultId, occurrences: occurrences, error: error, submitting: submitting, onClose: () => {
30
37
  if (!submitting)
31
38
  setPending(null);
32
39
  }, onConfirm: async (scope) => {
33
40
  await confirmScope(scope);
34
41
  } })) : null;
42
+ const waitlistDialog = (_jsx(EventWaitlistJoinDialog, { open: confirmingWaitlist, post: post, error: error, submitting: submitting, onClose: () => {
43
+ if (!submitting)
44
+ setConfirmingWaitlist(false);
45
+ }, onConfirm: async () => {
46
+ await confirmJoinWaitlist();
47
+ } }));
48
+ if (offerExpiresAt) {
49
+ return (_jsxs("div", { className: "mt-4 w-full", children: [_jsx("p", { className: "text-center text-sm", children: t('events.rsvp.offerOpen', {
50
+ defaultValue: 'A spot is open for you until {{until}}.',
51
+ until: new Date(offerExpiresAt).toLocaleString(),
52
+ }) }), _jsx(Button, { variant: "default", className: "mt-2 w-full", disabled: submitting, action: claimSpot, children: t('events.rsvp.claimSpot', { defaultValue: 'Claim spot' }) }), _jsx(Button, { variant: "outline", className: "text-error mt-2 w-full", disabled: submitting, action: () => requestRespond('no'), children: t('events.rsvp.leaveWaitlist', {
53
+ defaultValue: 'Leave waitlist',
54
+ }) }), error ? (_jsx("p", { className: "text-error mt-2 text-center text-sm", children: error })) : null] }));
55
+ }
56
+ if (onWaitlist) {
57
+ return (_jsxs("div", { className: "mt-4 w-full", children: [_jsx("p", { className: "text-center text-sm", children: t('events.rsvp.onWaitlist', {
58
+ defaultValue: 'You are on the waitlist.',
59
+ }) }), _jsx("p", { className: "text-muted-foreground mt-1 text-center text-sm", children: t('events.rsvp.atCapacity', {
60
+ defaultValue: 'This event is at capacity.',
61
+ }) }), _jsx(Button, { variant: "outline", className: "text-error mt-2 w-full", disabled: submitting, action: () => requestRespond('no'), children: t('events.rsvp.leaveWaitlist', {
62
+ defaultValue: 'Leave waitlist',
63
+ }) }), error && !pending ? (_jsx("p", { className: "text-error mt-2 text-center text-sm", children: error })) : null, scopeDialog] }));
64
+ }
35
65
  if (myRsvp && myRsvp.response !== 'no') {
36
66
  return (_jsxs("div", { className: "w-full", children: [_jsx(Button, { variant: "outline", className: "text-error w-full", disabled: submitting, action: () => requestRespond('no'), children: t('posts.rsvp.cancelRegistration', {
37
67
  defaultValue: 'Cancel registration',
@@ -43,7 +73,9 @@ export const EventRsvpButton = ({ post, recurrenceId, lockToOccurrence = false,
43
73
  defaultValue: 'You responded maybe.',
44
74
  }) }), error && !pending ? (_jsx("p", { className: "text-error mt-2 text-center text-sm", children: error })) : null, scopeDialog] }));
45
75
  }
46
- return (_jsxs("div", { className: "mt-4 w-full", children: [_jsxs("div", { className: "flex w-full gap-x-2", children: [_jsx(Button, { variant: "default", className: "w-[70%]", disabled: full || submitting, action: () => requestRespond('yes'), children: full
47
- ? t('events.rsvp.full', { defaultValue: 'Event is full' })
48
- : t('posts.rsvp.register', { defaultValue: 'Register' }) }), !capacityEvent ? (_jsx(Button, { variant: "ghost", disabled: submitting, action: () => requestRespond('tentative'), children: t('posts.rsvp.maybe', { defaultValue: 'Maybe' }) })) : null, _jsx(Button, { variant: "outline", disabled: submitting, action: () => requestRespond('no'), children: t('posts.rsvp.no', { defaultValue: 'No' }) })] }), error && !pending ? (_jsx("p", { className: "text-error mt-2 text-center text-sm", children: error })) : null, scopeDialog] }));
76
+ return (_jsxs("div", { className: "mt-4 w-full", children: [full ? (_jsx("p", { className: "text-muted-foreground mb-2 text-center text-sm", children: t('events.rsvp.atCapacity', {
77
+ defaultValue: 'This event is at capacity.',
78
+ }) })) : null, _jsxs("div", { className: "flex w-full gap-x-2", children: [_jsx(Button, { variant: "default", className: "w-[70%]", disabled: submitting, action: () => (full ? requestJoinWaitlist() : requestRespond('yes')), children: full
79
+ ? t('events.rsvp.joinWaitlist', { defaultValue: 'Join waitlist' })
80
+ : t('posts.rsvp.register', { defaultValue: 'Register' }) }), !capacityEvent ? (_jsx(Button, { variant: "ghost", disabled: submitting, action: () => requestRespond('tentative'), children: t('posts.rsvp.maybe', { defaultValue: 'Maybe' }) })) : null, _jsx(Button, { variant: "outline", disabled: submitting, action: () => requestRespond('no'), children: t('posts.rsvp.no', { defaultValue: 'No' }) })] }), error && !pending && !confirmingWaitlist ? (_jsx("p", { className: "text-error mt-2 text-center text-sm", children: error })) : null, scopeDialog, waitlistDialog] }));
49
81
  };
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { ChevronDown, ChevronRight } from 'lucide-react';
4
- import { calculateEffectiveRsvps, countYesRsvps, isCapacityEvent, isRecurringEvent, listedRsvps, listRsvpCancellations, profileName, rsvpCancelWhenLabels, sameRecurrenceId, } from '@openpeepshq/common/lib';
4
+ import { calculateEffectiveRsvps, countYesRsvps, isCapacityEvent, isRecurringEvent, listedRsvps, listRsvpCancellations, offerStillOpen, orderedWaitlist, profileName, rsvpCancelWhenLabels, sameRecurrenceId, } from '@openpeepshq/common/lib';
5
5
  import { Button, PopupMenu, PopupMenuButton, UpdatingDate, } from '@openpeepshq/react-ui';
6
6
  import { useT } from '../../../i18n/index.js';
7
7
  import { FollowUnfollowButton, ProfileCard } from '../../profile/index.js';
@@ -56,15 +56,35 @@ export const EventRsvpList = ({ post, occurrenceId, occurrences, currentProfile,
56
56
  };
57
57
  const history = canManageRsvps ? (_jsx(RsvpCancellationHistory, { post: post })) : null;
58
58
  if (!recurring) {
59
- return (_jsxs(_Fragment, { children: [_jsx(RsvpGroup, { rsvps: listedRsvps(calculateEffectiveRsvps(post, occurrenceId)), post: post, currentProfile: currentProfile, canManageRsvps: canManageRsvps, recurrenceId: occurrenceId, onMessage: onMessage, onManage: onManage }), history] }));
59
+ return (_jsxs(_Fragment, { children: [_jsx(RsvpGroup, { rsvps: listedRsvps(calculateEffectiveRsvps(post, occurrenceId)), post: post, currentProfile: currentProfile, canManageRsvps: canManageRsvps, recurrenceId: occurrenceId, onMessage: onMessage, onManage: onManage }), canManageRsvps ? (_jsx(WaitlistSection, { post: post, recurrenceId: occurrenceId })) : null, history] }));
60
60
  }
61
61
  return (_jsxs("div", { className: "flex flex-col gap-1 py-2", children: [_jsx(RsvpPanel, { title: `${t('events.occurrence.viewSeries', {
62
62
  defaultValue: 'All dates',
63
63
  })} ${panelCountLabel(post, undefined, t)}`, open: openKeys.has(seriesKey), onToggle: () => toggle(seriesKey), children: _jsx(RsvpGroup, { rsvps: listedRsvps(calculateEffectiveRsvps(post)), post: post, currentProfile: currentProfile, canManageRsvps: canManageRsvps, onMessage: onMessage, onManage: onManage }) }), occurrences.map((occurrence) => {
64
64
  const key = occurrence.recurrenceId;
65
- return (_jsx(RsvpPanel, { title: `${formatOccurrenceStart(occurrence.start)} ${panelCountLabel(post, key, t)}`, open: openKeys.has(key), onToggle: () => toggle(key), current: sameRecurrenceId(key, occurrenceId), children: _jsx(RsvpGroup, { rsvps: listedRsvps(calculateEffectiveRsvps(post, key)), post: post, currentProfile: currentProfile, canManageRsvps: canManageRsvps, recurrenceId: key, onMessage: onMessage, onManage: onManage }) }, key));
65
+ return (_jsxs(RsvpPanel, { title: `${formatOccurrenceStart(occurrence.start)} ${panelCountLabel(post, key, t)}`, open: openKeys.has(key), onToggle: () => toggle(key), current: sameRecurrenceId(key, occurrenceId), children: [_jsx(RsvpGroup, { rsvps: listedRsvps(calculateEffectiveRsvps(post, key)), post: post, currentProfile: currentProfile, canManageRsvps: canManageRsvps, recurrenceId: key, onMessage: onMessage, onManage: onManage }), canManageRsvps ? (_jsx(WaitlistSection, { post: post, recurrenceId: key })) : null] }, key));
66
66
  }), history] }));
67
67
  };
68
+ const WaitlistSection = ({ post, recurrenceId, }) => {
69
+ const t = useT();
70
+ const waiting = orderedWaitlist(post, recurrenceId);
71
+ if (!waiting.length)
72
+ return null;
73
+ const profiles = new Map((post.rsvps ?? []).map((rsvp) => [rsvp.profile.id, rsvp.profile]));
74
+ return (_jsxs("div", { className: "mt-4 border-t pt-3", children: [_jsx("h3", { className: "mb-2 text-sm font-semibold", children: t('events.rsvp.waitlistTitle', { defaultValue: 'Waitlist' }) }), _jsx("ol", { className: "flex flex-col gap-2", children: waiting.map((member, index) => {
75
+ const profile = profiles.get(member.profileId);
76
+ if (!profile)
77
+ return null;
78
+ const until = member.offerExpiresAt;
79
+ const offered = !!until && offerStillOpen({ offerExpiresAt: until });
80
+ return (_jsxs("li", { className: "text-sm", children: [_jsxs("span", { className: "text-muted-foreground", children: [index + 1, ". "] }), _jsx("span", { className: "font-medium", children: profileName(profile) }), offered ? (_jsxs("span", { className: "text-muted-foreground", children: [' ', "\u2014", ' ', t('events.rsvp.waitlistOffered', {
81
+ defaultValue: 'offered until {{until}}',
82
+ until: new Date(until ?? '').toLocaleString(),
83
+ })] })) : null, profile.type === 'federated' ? (_jsxs("span", { className: "text-muted-foreground", children: [' ', "\u2014", ' ', t('events.rsvp.waitlistRemote', {
84
+ defaultValue: 'Remote member, not offered a spot automatically',
85
+ })] })) : null] }, member.profileId));
86
+ }) })] }));
87
+ };
68
88
  const RsvpCancellationHistory = ({ post }) => {
69
89
  const t = useT();
70
90
  const cancellations = listRsvpCancellations(post);
@@ -5,7 +5,7 @@ export type { RsvpScopeChoice };
5
5
  export type EventRsvpScopeDialogProps = {
6
6
  open: boolean;
7
7
  post: PublicPost;
8
- response: 'yes' | 'tentative' | 'no';
8
+ response: 'yes' | 'tentative' | 'no' | 'waitlist';
9
9
  defaultRecurrenceId?: string;
10
10
  occurrences: ExpandedOccurrence[];
11
11
  error?: string | null;
@@ -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 { countYesRsvps, getEffectiveRsvp, isCapacityEvent, seriesYesBlockedByCapacity, } from '@openpeepshq/common/lib';
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 event = post.data?.type === 'event' ? post.data : undefined;
18
- const capacityEvent = event ? isCapacityEvent(event) : false;
19
- const seriesFull = response === 'yes' &&
20
- !!profile &&
21
- seriesYesBlockedByCapacity(post, profile.id);
22
- const occurrenceIsFull = (recurrenceId) => response === 'yes' &&
23
- capacityEvent &&
24
- event?.maxAttendees !== undefined &&
25
- getEffectiveRsvp(post, profile?.id ?? '', recurrenceId)?.response !==
26
- 'yes' &&
27
- countYesRsvps(post, recurrenceId) >= event.maxAttendees;
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: t('events.rsvp.scope.title', {
66
- defaultValue: 'Which dates?',
67
- }) }) }), _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', {
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
- ? ` — ${t('events.rsvp.full', {
82
- defaultValue: 'Event is full',
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: t('events.rsvp.scope.confirm', {
90
- defaultValue: 'Confirm',
91
- }), onAction: confirm, disabled: confirmDisabled })] }) }));
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
  }
@@ -124,9 +124,15 @@ export function PollContent({ post }) {
124
124
  // fill is a circle at the start of the track.
125
125
  width: votePercent === 0 ? 8 : `${votePercent}%`,
126
126
  } }) })] })] }, `${option.content}-${index}`));
127
- }) }), canVote ? (_jsx(Button, { variant: "default", className: "mt-4", title: t('posts.poll.vote', { defaultValue: 'Vote' }), action: handleVote, children: t('posts.form.poll.submit', { defaultValue: 'Vote' }) })) : null, _jsxs("div", { className: "text-muted-foreground mt-4 flex flex-wrap items-center gap-3 text-sm", children: [_jsxs("span", { children: [votes.length || 0, " ", t('posts.vote.count', { defaultValue: 'votes' })] }), pollData.expiresAt ? (_jsx("span", { children: hasPollEnded
127
+ }) }), canVote ? (_jsx(Button, { variant: "default", className: "mt-4", title: t('posts.poll.vote', { defaultValue: 'Vote' }), action: handleVote, children: t('posts.form.poll.submit', { defaultValue: 'Vote' }) })) : null, _jsxs("div", { className: "text-muted-foreground mt-4 flex flex-wrap items-center gap-3 text-sm", children: [_jsx("span", { children: t('posts.vote.count', {
128
+ count: votes.length || 0,
129
+ defaultValue: 'votes',
130
+ }) }), pollData.expiresAt ? (_jsx("span", { children: hasPollEnded
128
131
  ? t('posts.poll.ended', { defaultValue: 'Poll ended' })
129
- : `${formatDistanceToNow(pollData.expiresAt)} ${t('posts.poll.timeLeft', { defaultValue: 'left' })}` })) : null, hasVoted && !hasPollEnded ? (_jsx(Button, { variant: "ghost", className: "h-auto min-h-0 px-0 font-semibold", title: t('posts.poll.undoVoteTitle', {
132
+ : t('posts.poll.timeLeft', {
133
+ time: formatDistanceToNow(pollData.expiresAt),
134
+ defaultValue: '{{time}} left',
135
+ }) })) : null, hasVoted && !hasPollEnded ? (_jsx(Button, { variant: "ghost", className: "h-auto min-h-0 px-0 font-semibold", title: t('posts.poll.undoVoteTitle', {
130
136
  defaultValue: 'Undo your vote',
131
137
  }), action: handleClearVote, children: t('posts.poll.undoVote', { defaultValue: 'Undo vote' }) })) : null] })] }));
132
138
  }
@@ -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 | null;
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
- if (!me)
11
- return null;
12
- const actionClass = 'hover:bg-surface rounded-button flex gap-2 p-2 text-sm disabled:opacity-60';
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
- return (_jsxs("div", { className: "mx-auto grid w-full grid-cols-3 items-center p-2", onClick: (e) => {
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: `${actionClass} justify-self-start`, title: t('posts.actions.reply', { defaultValue: 'Reply' }), action: reply, disabled: previewMode || !canReply, children: [_jsx(Reply, { className: "h-4 w-4" }), compact ? post.replyCount || null : replyLabel] }), _jsxs(Button, { variant: "unstyled", className: `${actionClass} justify-self-center ${myRepost ? 'text-primary' : ''}`, title: t('posts.actions.repost', { defaultValue: 'Repost' }), action: toggleRepost, disabled: previewMode || !canRepost, 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: `${actionClass} justify-self-end ${iReacted ? 'text-primary' : ''}`, title: t('posts.actions.react', { defaultValue: 'React' }), action: toggleReaction, disabled: previewMode || !canReact, spinnerOnlyOnLoading: true, children: [_jsx(ThumbsUp, { className: "h-4 w-4" }), compact
20
- ? post.reactions?.length
21
- ? ` · ${postReactionStats(post)}`
22
- : null
23
- : likeLabel] })] }));
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;