@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,26 @@
1
+ import type { ReactElement } from 'react';
2
+ import {
3
+ TooltipContent,
4
+ TooltipRoot,
5
+ TooltipTrigger,
6
+ } from '@openpeepshq/react-ui';
7
+
8
+ export type NavTooltipSide = 'top' | 'bottom' | 'left' | 'right';
9
+
10
+ export type NavWithTooltipProps = {
11
+ label: string;
12
+ side?: NavTooltipSide;
13
+ children: ReactElement;
14
+ };
15
+
16
+ /** Hover tooltip for a single nav control; wrap the list in `TooltipProvider`. */
17
+ export const NavWithTooltip = ({
18
+ label,
19
+ side = 'right',
20
+ children,
21
+ }: NavWithTooltipProps) => (
22
+ <TooltipRoot>
23
+ <TooltipTrigger asChild>{children}</TooltipTrigger>
24
+ <TooltipContent side={side}>{label}</TooltipContent>
25
+ </TooltipRoot>
26
+ );
@@ -11,6 +11,8 @@ export { FooterMobile } from './FooterMobile';
11
11
  export type { FooterMobileProps } from './FooterMobile';
12
12
  export { MobileMenuItem } from './MobileMenuItem';
13
13
  export type { MobileMenuItemProps } from './MobileMenuItem';
14
+ export { NavWithTooltip } from './NavWithTooltip';
15
+ export type { NavWithTooltipProps, NavTooltipSide } from './NavWithTooltip';
14
16
  export { ContentHeader } from './ContentHeader';
15
17
  export { PageHeaderAction } from './PageHeaderAction';
16
18
  export type { PageHeaderActionProps } from './PageHeaderAction';
@@ -1,8 +1,11 @@
1
1
  import { cn } from '@openpeepshq/react-ui';
2
2
 
3
- /** Active/inactive classes for sidebar nav links (parity with Svelte `MenuItem.svelte`). */
4
- export const sideBarNavLinkClass = ({ isActive }: { isActive: boolean }) =>
5
- cn(
6
- 'flex items-center gap-2 rounded-md px-3 py-2 hover:bg-surface',
7
- isActive ? 'text-primary font-bold' : 'text-foreground/70',
8
- );
3
+ /**
4
+ * Sidebar nav link classes. A string so Radix Tooltip's Slot can merge
5
+ * `className` — a NavLink callback gets stringified and the flex row is lost.
6
+ * Active state uses `aria-current="page"`, which NavLink sets itself.
7
+ */
8
+ export const sideBarNavLinkClass = cn(
9
+ 'flex items-center gap-2 rounded-md px-3 py-2 text-foreground/70 hover:bg-surface',
10
+ 'aria-[current=page]:font-bold aria-[current=page]:text-primary',
11
+ );
@@ -11,7 +11,9 @@ import type { ReactNode } from 'react';
11
11
  import { profileName, groupName } from '@openpeepshq/common';
12
12
  import {
13
13
  isRsvpCancelNotice,
14
+ isWaitlistOfferNotice,
14
15
  rsvpCancelWhenLabels,
16
+ waitlistClaimPath,
15
17
  } from '@openpeepshq/common/lib';
16
18
  import type {
17
19
  GroupWithMeta,
@@ -388,6 +390,54 @@ function RsvpCanceledNotification({
388
390
  );
389
391
  }
390
392
 
393
+ function WaitlistOfferNotification({
394
+ notification,
395
+ }: {
396
+ notification: PublicNotification;
397
+ }) {
398
+ const t = useT();
399
+ const profile = notification.senderProfile ?? notification.post?.profile;
400
+ const post = notification.post;
401
+ const event =
402
+ post?.data?.type === 'event' ? post.data.name?.trim() : undefined;
403
+ const notice = isWaitlistOfferNotice(notification.data)
404
+ ? notification.data
405
+ : undefined;
406
+ const href = post
407
+ ? waitlistClaimPath(post.id, notice?.recurrenceId)
408
+ : '/notifications';
409
+ if (!profile) return null;
410
+ return (
411
+ <NotificationWrapper
412
+ profile={profile}
413
+ seen={notification.seen}
414
+ showProfile={false}
415
+ >
416
+ <a href={href} className="block w-full px-4 py-2">
417
+ <p className="mb-1 text-sm font-semibold">
418
+ {t('notification.waitlistOffer.text', {
419
+ defaultValue: 'A spot opened at {{eventName}}',
420
+ eventName:
421
+ event ||
422
+ t('notification.waitlistOffer.eventFallback', {
423
+ defaultValue: 'an event',
424
+ }),
425
+ })}
426
+ </p>
427
+ {notice?.offerExpiresAt ? (
428
+ <p className="text-muted-foreground mb-2 text-sm">
429
+ {t('notification.waitlistOffer.expires', {
430
+ defaultValue: 'Claim it before {{until}}.',
431
+ until: new Date(notice.offerExpiresAt).toLocaleString(),
432
+ })}
433
+ </p>
434
+ ) : null}
435
+ {post ? <FeedPost post={post} /> : null}
436
+ </a>
437
+ </NotificationWrapper>
438
+ );
439
+ }
440
+
391
441
  function GroupAvatarThumb({ group }: { group: GroupWithMeta }) {
392
442
  return <GroupAvatar group={group} size={2.5} borderless />;
393
443
  }
@@ -577,21 +627,42 @@ function JamNotification({
577
627
  const t = useT();
578
628
  const profile = notification.senderProfile!;
579
629
  const name = profileName(profile);
580
- const message = t(`notification.${notification.type}.text`, {
581
- defaultValue: `${name} — ${notification.type}`,
582
- profileName: name,
583
- groupName: notification.group?.displayName,
584
- });
630
+ const eventName =
631
+ notification.post?.data?.type === 'event'
632
+ ? notification.post.data.name?.trim()
633
+ : undefined;
634
+ const message = t(
635
+ notification.type === 'jamStarted'
636
+ ? eventName
637
+ ? 'notification.jamStarted.text'
638
+ : 'notification.jamStarted.textNoEvent'
639
+ : `notification.${notification.type}.text`,
640
+ {
641
+ defaultValue:
642
+ notification.type === 'jamStarted'
643
+ ? eventName
644
+ ? '{{profileName}} started a jam: {{eventName}}'
645
+ : '{{profileName}} started a jam'
646
+ : `${name} — ${notification.type}`,
647
+ profileName: name,
648
+ groupName: notification.group?.displayName,
649
+ eventName,
650
+ },
651
+ );
652
+ const postId = notification.post?.id;
653
+ const occurrence = notification.post?.occurrenceRecurrenceId;
654
+ const href = postId
655
+ ? `/posts/${postId}${
656
+ occurrence ? `?occurrence=${encodeURIComponent(occurrence)}` : ''
657
+ }`
658
+ : `/posts/${postId}`;
585
659
  return (
586
660
  <NotificationWrapper
587
661
  profile={profile}
588
662
  group={notification.group}
589
663
  seen={notification.seen}
590
664
  >
591
- <a
592
- href={`/posts/${notification.post?.id}`}
593
- className="block w-full px-4 py-2"
594
- >
665
+ <a href={href} className="block w-full px-4 py-2">
595
666
  <p className="mb-2 flex items-center gap-2 text-sm font-semibold">
596
667
  {message}
597
668
  <span className="text-muted-foreground text-xs font-normal">
@@ -664,6 +735,7 @@ const TYPED: Partial<
664
735
  pollEnded: PollEndedNotification,
665
736
  rsvp: RsvpNotification,
666
737
  rsvpCanceled: RsvpCanceledNotification,
738
+ waitlistOffer: WaitlistOfferNotification,
667
739
  groupAdded: NewGroupInvitationNotification,
668
740
  groupMemberJoined: NewGroupMemberNotification,
669
741
  groupMemberLeft: GroupMemberExitNotification,
@@ -8,16 +8,13 @@ import type {
8
8
  PublicReplyPost,
9
9
  Question,
10
10
  } from '@openpeepshq/common/types';
11
- import {
12
- formatEventWhen,
13
- isHiddenPost,
14
- markdownPlainText,
15
- } from '@openpeepshq/common/lib';
11
+ import { formatEventWhen, isHiddenPost } from '@openpeepshq/common/lib';
16
12
  import { AudioLines, Calendar, CirclePlay, Paperclip } from 'lucide-react';
17
13
  import { cn } from '@openpeepshq/react-ui';
18
14
  import { useT } from '../../i18n';
19
15
  import { Avatar } from '../profile';
20
16
  import { isAudioAttachment } from './pieces/AudioAttachment';
17
+ import { TruncatedMarkdown } from './TruncatedMarkdown';
21
18
 
22
19
  export type CompactPost = Pick<
23
20
  PublicReplyPost,
@@ -119,7 +116,6 @@ const compactThumb = (post: CompactPost, t: TFunction): ReactNode => {
119
116
  const CompactNoteBody = ({ post, t }: { post: CompactPost; t: TFunction }) => {
120
117
  if (post.data?.type !== 'note') return null;
121
118
  const attachments = attachmentsOf(post);
122
- const text = markdownPlainText(post.data.content);
123
119
  const hasVisual = !!visualAttachment(attachments);
124
120
  const file = !hasVisual ? attachments[0] : undefined;
125
121
  const audio = !!file && isAudioAttachment(file);
@@ -129,10 +125,16 @@ const CompactNoteBody = ({ post, t }: { post: CompactPost; t: TFunction }) => {
129
125
  ? t('posts.compact.audio', { defaultValue: 'Audio' })
130
126
  : t('posts.compact.document', { defaultValue: 'Document' }))
131
127
  : undefined;
132
- if (!text && !docName) return null;
128
+ if (!post.data.content && !docName) return null;
133
129
  return (
134
130
  <>
135
- {text ? <p className="line-clamp-2 break-words text-sm">{text}</p> : null}
131
+ <TruncatedMarkdown
132
+ source={post.data.content ?? ''}
133
+ maxBlocks={1}
134
+ maxChars={80}
135
+ maxLines={1}
136
+ className="break-words text-sm text-muted-foreground"
137
+ />
136
138
  {docName ? (
137
139
  <p className="text-muted-foreground flex items-center gap-1 text-xs">
138
140
  {audio ? (
@@ -156,11 +158,16 @@ const CompactQuestionBody = ({
156
158
  }) => {
157
159
  if (post.data?.type !== 'question') return null;
158
160
  const data = post.data as Question;
159
- const text = markdownPlainText(data.content);
160
161
  const optionCount = data.options?.length ?? 0;
161
162
  return (
162
163
  <>
163
- {text ? <p className="line-clamp-2 break-words text-sm">{text}</p> : null}
164
+ <TruncatedMarkdown
165
+ source={data.content ?? ''}
166
+ maxBlocks={1}
167
+ maxChars={80}
168
+ maxLines={1}
169
+ className="break-words text-sm text-muted-foreground"
170
+ />
164
171
  {optionCount > 0 ? (
165
172
  <p className="text-muted-foreground truncate text-xs">
166
173
  {t('posts.compact.pollOptions', {
@@ -1,2 +1,8 @@
1
- export { OpenpeepsMarkdown, OpenpeepsMarkdown as PostMarkdown } from '../markdown';
2
- export type { OpenpeepsMarkdownProps, OpenpeepsMarkdownProps as PostMarkdownProps } from '../markdown';
1
+ export {
2
+ OpenpeepsMarkdown,
3
+ OpenpeepsMarkdown as PostMarkdown,
4
+ } from '../markdown';
5
+ export type {
6
+ OpenpeepsMarkdownProps,
7
+ OpenpeepsMarkdownProps as PostMarkdownProps,
8
+ } from '../markdown';
@@ -0,0 +1,91 @@
1
+ import { type ReactNode } from 'react';
2
+ import { truncateMarkdown } from '@openpeepshq/common/lib';
3
+ import { Popover, PopoverContent, PopoverTrigger } from '@openpeepshq/react-ui';
4
+ import { useT } from '../../i18n';
5
+ import { PostMarkdown } from './Markdown';
6
+ import { OPENPEEPS_POST_CAPTION_CLASS } from '../markdown/classes';
7
+
8
+ export interface TruncatedMarkdownProps {
9
+ /** Full markdown content; rendered in the popover when `interactive`. */
10
+ source: string;
11
+ /** Pre-truncated excerpt. When omitted, computed via `truncateMarkdown`. */
12
+ snippet?: string;
13
+ maxBlocks?: number;
14
+ maxChars?: number;
15
+ /** Lines the excerpt is clamped to (only when `interactive`). */
16
+ maxLines?: number;
17
+ /**
18
+ * When true, the excerpt is clamped and a "Show more" control reveals the
19
+ * full content in a popover (click/tap; hover on desktop via the popover).
20
+ * When false, the excerpt renders as-is — callers that own their own
21
+ * navigation keep it plain.
22
+ */
23
+ interactive?: boolean;
24
+ className?: string;
25
+ }
26
+
27
+ const clampClass = (n: number) => `line-clamp-${n as 1 | 2 | 3 | 4 | 5 | 6}`;
28
+
29
+ /**
30
+ * Single rendering surface for abbreviated markdown. The excerpt is always
31
+ * produced by the markdown-aware `truncateMarkdown` (links, images and
32
+ * emphasis are never severed), so every abbreviated preview renders as real
33
+ * markdown instead of raw text. Call sites with their own read-more navigation
34
+ * (e.g. Article) keep `interactive` off and render the link themselves.
35
+ */
36
+ export const TruncatedMarkdown = ({
37
+ source,
38
+ snippet: snippetProp,
39
+ maxBlocks = 2,
40
+ maxChars = 240,
41
+ maxLines = 2,
42
+ interactive = true,
43
+ className,
44
+ }: TruncatedMarkdownProps): ReactNode => {
45
+ const t = useT();
46
+ const excerpt = snippetProp ?? truncateMarkdown(source, maxBlocks, maxChars);
47
+ if (!excerpt) return null;
48
+
49
+ const excerptClass = [
50
+ OPENPEEPS_POST_CAPTION_CLASS,
51
+ interactive && maxLines > 0 ? clampClass(maxLines) : '',
52
+ className ?? '',
53
+ ]
54
+ .join(' ')
55
+ .trim();
56
+
57
+ const body = <PostMarkdown source={excerpt} className={excerptClass} />;
58
+
59
+ if (!interactive) return body;
60
+
61
+ return (
62
+ <div className="inline-block max-w-full align-baseline">
63
+ {body}
64
+ <Popover>
65
+ <PopoverTrigger asChild>
66
+ <button
67
+ type="button"
68
+ onClick={(e) => {
69
+ e.stopPropagation();
70
+ e.preventDefault();
71
+ }}
72
+ aria-label={t('posts.truncatedMarkdown.showHint', {
73
+ defaultValue: 'Show more',
74
+ })}
75
+ className="text-primary inline-flex items-center gap-1 text-xs font-medium underline decoration-transparent underline-offset-2 hover:decoration-inherit"
76
+ >
77
+ {t('posts.truncatedMarkdown.show', { defaultValue: 'Show more' })}
78
+ </button>
79
+ </PopoverTrigger>
80
+ <PopoverContent
81
+ side="top"
82
+ align="start"
83
+ sideOffset={8}
84
+ className="bg-popover text-popover-foreground z-50 max-w-xs rounded-md border p-3 shadow-md"
85
+ >
86
+ <PostMarkdown source={source} />
87
+ </PopoverContent>
88
+ </Popover>
89
+ </div>
90
+ );
91
+ };
@@ -18,7 +18,5 @@ export const resolveAttachmentPreviewUrl = (
18
18
  localPreviewUrl,
19
19
  ].filter((url): url is string => !!url);
20
20
 
21
- return (
22
- candidates.find((url) => !isBlobUrl(url)) ?? candidates[0] ?? ''
23
- );
21
+ return candidates.find((url) => !isBlobUrl(url)) ?? candidates[0] ?? '';
24
22
  };
@@ -1,4 +1,8 @@
1
1
  import type { PublicPost } from '@openpeepshq/common/types';
2
+ import { firstNWords as _firstNWords } from '@openpeepshq/common/lib';
3
+
4
+ /** @deprecated Use `firstNWords` from `@openpeepshq/common/lib` directly. */
5
+ export const firstNWords = _firstNWords;
2
6
 
3
7
  /** Splits a string into user-visible grapheme clusters (so emojis don't get chopped). */
4
8
  export const stringToSegments = (text: string) =>
@@ -12,21 +16,3 @@ export const postReactionStats = (post: PublicPost): string => {
12
16
  ].join('');
13
17
  return `${uniqueEmojis} ${post.reactions?.length ?? 0}`;
14
18
  };
15
-
16
- /** Truncates markdown to roughly the first N words, preserving links. */
17
- export const firstNWords = (
18
- markdown: string | undefined,
19
- n: number,
20
- ): string => {
21
- if (!markdown) return '';
22
- const regex = /\[.*?\]\(.*?\)|(\w+)/g;
23
- let wordCount = 0;
24
- const out: string[] = [];
25
- let match: RegExpExecArray | null;
26
- while ((match = regex.exec(markdown)) !== null) {
27
- if (wordCount >= n) break;
28
- out.push(match[0]);
29
- wordCount++;
30
- }
31
- return out.join(' ');
32
- };
@@ -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';
@@ -29,14 +29,44 @@ export function Attachments({ post }: AttachmentsProps) {
29
29
 
30
30
  if (attachments.length === 0) return null;
31
31
 
32
- const indexed = attachments.map((att, idx) => ({ att, idx }));
33
- const visual = indexed.filter(({ att }) => !isAudioAttachment(att));
34
- const audio = indexed.filter(({ att }) => isAudioAttachment(att));
32
+ // A lone audio or video file plays inline. Anything else stays a gallery
33
+ // tile, including an audio or video file that shares the post with others.
34
+ const sole = attachments.length === 1 ? attachments[0] : undefined;
35
+ const inline =
36
+ sole && (isAudioAttachment(sole) || isVideo(sole)) ? sole : undefined;
35
37
 
36
- const single = visual.length === 1;
38
+ if (inline && isVideo(inline)) {
39
+ return (
40
+ <div className="bg-surface mt-2 w-full overflow-hidden rounded-md">
41
+ <video
42
+ src={inline.url}
43
+ poster={inline.previewUrl ?? undefined}
44
+ controls
45
+ playsInline
46
+ preload="metadata"
47
+ className="max-h-[70vh] w-full"
48
+ />
49
+ </div>
50
+ );
51
+ }
52
+
53
+ if (inline) {
54
+ return (
55
+ <div className="mt-2">
56
+ <AudioAttachment
57
+ src={inline.url}
58
+ label={inline.filename ?? inline.description}
59
+ size={inline.meta?.size}
60
+ />
61
+ </div>
62
+ );
63
+ }
64
+
65
+ const indexed = attachments.map((att, idx) => ({ att, idx }));
66
+ const single = indexed.length === 1;
37
67
  const cols = single
38
68
  ? ''
39
- : visual.length === 2
69
+ : indexed.length === 2
40
70
  ? 'grid grid-cols-2'
41
71
  : 'grid grid-cols-2 grid-rows-2';
42
72
  // With a single attachment the grid has no fixed height, so the children
@@ -51,81 +81,66 @@ export function Attachments({ post }: AttachmentsProps) {
51
81
 
52
82
  return (
53
83
  <>
54
- <div className="mt-2 flex w-full flex-col gap-2">
55
- {visual.length > 0 ? (
56
- <div
57
- className={`w-full gap-1 overflow-hidden rounded-md ${cols} ${height}`}
58
- >
59
- {visual.map(({ att, idx }) => {
60
- const tile = (
61
- <>
62
- {isImage(att) && (att.previewUrl || att.url) ? (
63
- <img
64
- src={att.previewUrl ?? att.url ?? ''}
65
- alt={att.description ?? `attachment ${idx + 1}`}
66
- className={mediaClass}
67
- />
68
- ) : isVideo(att) && (att.previewUrl || att.url) ? (
69
- <div className="relative h-full w-full">
70
- <img
71
- src={att.previewUrl ?? att.url ?? ''}
72
- alt={att.description ?? `attachment ${idx + 1}`}
73
- className={mediaClass}
74
- />
75
- <VideoPlayOverlay video />
76
- </div>
77
- ) : (
78
- <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">
79
- <span className="text-foreground break-all font-medium">
80
- {att.filename ??
81
- att.description ??
82
- `Attachment ${idx + 1}`}
83
- </span>
84
- {att.meta?.mimetype ? (
85
- <span className="uppercase">{att.meta.mimetype}</span>
86
- ) : null}
87
- </div>
88
- )}
89
- </>
90
- );
91
-
92
- if (staticRender) {
93
- return (
94
- <div
95
- key={`${att.url ?? idx}-${idx}`}
96
- className={`${tileClass} bg-surface overflow-hidden`}
97
- >
98
- {tile}
99
- </div>
100
- );
101
- }
84
+ <div
85
+ className={`mt-2 w-full gap-1 overflow-hidden rounded-md ${cols} ${height}`}
86
+ >
87
+ {indexed.map(({ att, idx }) => {
88
+ const tile = (
89
+ <>
90
+ {isImage(att) && (att.previewUrl || att.url) ? (
91
+ <img
92
+ src={att.previewUrl ?? att.url ?? ''}
93
+ alt={att.description ?? `attachment ${idx + 1}`}
94
+ className={mediaClass}
95
+ />
96
+ ) : isVideo(att) && (att.previewUrl || att.url) ? (
97
+ <div className="relative h-full w-full">
98
+ <img
99
+ src={att.previewUrl ?? att.url ?? ''}
100
+ alt={att.description ?? `attachment ${idx + 1}`}
101
+ className={mediaClass}
102
+ />
103
+ <VideoPlayOverlay video />
104
+ </div>
105
+ ) : (
106
+ <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">
107
+ <span className="text-foreground break-all font-medium">
108
+ {att.filename ?? att.description ?? `Attachment ${idx + 1}`}
109
+ </span>
110
+ {att.meta?.mimetype ? (
111
+ <span className="uppercase">{att.meta.mimetype}</span>
112
+ ) : null}
113
+ </div>
114
+ )}
115
+ </>
116
+ );
102
117
 
103
- return (
104
- <button
105
- key={`${att.url ?? idx}-${idx}`}
106
- type="button"
107
- className={`${tileClass} bg-surface overflow-hidden`}
108
- onClick={(e) => {
109
- e.preventDefault();
110
- e.stopPropagation();
111
- setGalleryIndex(idx);
112
- }}
113
- >
114
- {tile}
115
- </button>
116
- );
117
- })}
118
- </div>
119
- ) : null}
118
+ if (staticRender) {
119
+ return (
120
+ <div
121
+ key={`${att.url ?? idx}-${idx}`}
122
+ className={`${tileClass} bg-surface overflow-hidden`}
123
+ >
124
+ {tile}
125
+ </div>
126
+ );
127
+ }
120
128
 
121
- {audio.map(({ att, idx }) => (
122
- <AudioAttachment
123
- key={`${att.url ?? idx}-${idx}`}
124
- src={att.url}
125
- label={att.filename ?? att.description}
126
- size={att.meta?.size}
127
- />
128
- ))}
129
+ return (
130
+ <button
131
+ key={`${att.url ?? idx}-${idx}`}
132
+ type="button"
133
+ className={`${tileClass} bg-surface overflow-hidden`}
134
+ onClick={(e) => {
135
+ e.preventDefault();
136
+ e.stopPropagation();
137
+ setGalleryIndex(idx);
138
+ }}
139
+ >
140
+ {tile}
141
+ </button>
142
+ );
143
+ })}
129
144
  </div>
130
145
 
131
146
  {galleryIndex !== null ? (
@@ -44,6 +44,33 @@ export function EventLocation({
44
44
  : undefined;
45
45
  const jamLink = getJamUrl(post.id, origin, occurrence);
46
46
 
47
+ if (preview && staticRender) {
48
+ if (physicalLocation) {
49
+ return (
50
+ <span className="text-sm">
51
+ {truncate
52
+ ? truncateText(physicalLocation.text)
53
+ : physicalLocation.text}
54
+ </span>
55
+ );
56
+ }
57
+ if (event.jam) {
58
+ return (
59
+ <a href={jamLink} className="text-primary text-sm underline">
60
+ {t('events.location.jam', { defaultValue: 'Jam Event' })}
61
+ </a>
62
+ );
63
+ }
64
+ if (event.url) {
65
+ return (
66
+ <a href={event.url} className="text-primary text-sm underline">
67
+ {t('events.location.online', { defaultValue: 'Online' })}
68
+ </a>
69
+ );
70
+ }
71
+ return null;
72
+ }
73
+
47
74
  if (preview) {
48
75
  return (
49
76
  <div className="flex items-center gap-1 text-sm">