@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
@@ -5,28 +5,51 @@ import {
5
5
  PopupMenuButton,
6
6
  PopupSection,
7
7
  PopupSeparator,
8
+ type PopupMenuProps,
8
9
  } from '@openpeepshq/react-ui';
9
10
  import { useT } from '../../../i18n';
10
- import { useShareMenu } from '../../../hooks/posts/useShareMenu';
11
+ import {
12
+ postPublicPath,
13
+ useShareMenu,
14
+ } from '../../../hooks/posts/useShareMenu';
11
15
  import { useCreateNewConversation } from '../../conversations/CreateNewConversationContext';
16
+ import { useToast } from '../../layout/ToastProvider';
12
17
 
13
18
  export interface ShareMenuProps {
14
19
  post: PublicPost;
15
20
  menuButton?: React.ReactNode;
21
+ /** `unstyled` matches neighboring text actions, such as the post footer. */
22
+ variant?: PopupMenuProps['variant'] | 'unstyled';
23
+ className?: string;
24
+ text?: string;
16
25
  }
17
26
 
18
- export function ShareMenu({ post, menuButton }: ShareMenuProps) {
27
+ const absolutePostUrl = (post: PublicPost) => {
28
+ const path = postPublicPath(post);
29
+ return typeof window !== 'undefined'
30
+ ? `${window.location.origin}${path}`
31
+ : path;
32
+ };
33
+
34
+ export function ShareMenu({
35
+ post,
36
+ menuButton,
37
+ variant = 'outline',
38
+ className,
39
+ text,
40
+ }: ShareMenuProps) {
19
41
  const t = useT();
42
+ const { success, error: toastError } = useToast();
20
43
  const { openCreateConversation } = useCreateNewConversation();
21
-
22
- const postUrl =
23
- typeof window !== 'undefined'
24
- ? `${window.location.origin}/posts/${post.id}`
25
- : `/posts/${post.id}`;
44
+ const postUrl = absolutePostUrl(post);
26
45
  const { signedIn, isEvent, repost, eventIcsFile } = useShareMenu(
27
46
  post,
28
47
  postUrl,
29
48
  );
49
+ // Feature-detect. Desktop browsers often have no Web Share API; copy stays
50
+ // in the menu either way.
51
+ const canSystemShare =
52
+ typeof navigator !== 'undefined' && typeof navigator.share === 'function';
30
53
 
31
54
  const downloadEventIcs = () => {
32
55
  const file = eventIcsFile();
@@ -42,11 +65,34 @@ export function ShareMenu({ post, menuButton }: ShareMenuProps) {
42
65
  URL.revokeObjectURL(href);
43
66
  };
44
67
 
68
+ const copyLink = async () => {
69
+ try {
70
+ await navigator.clipboard.writeText(postUrl);
71
+ success(t('posts.shareMenu.linkCopied', { defaultValue: 'Link copied' }));
72
+ } catch {
73
+ toastError(
74
+ t('posts.shareMenu.copyFailed', {
75
+ defaultValue: "Couldn't copy the link",
76
+ }),
77
+ );
78
+ }
79
+ };
80
+
81
+ const systemShare = async () => {
82
+ try {
83
+ await navigator.share({ url: postUrl });
84
+ } catch (err) {
85
+ if (err instanceof DOMException && err.name === 'AbortError') return;
86
+ }
87
+ };
88
+
45
89
  return (
46
90
  <PopupMenu
47
91
  menuButton={menuButton ?? <Share className="size-4" />}
48
92
  title={t('posts.shareMenu.title', { defaultValue: 'Share' })}
49
- variant="outline"
93
+ variant={variant === 'unstyled' ? undefined : variant}
94
+ className={className}
95
+ text={text}
50
96
  >
51
97
  {signedIn ? (
52
98
  <>
@@ -93,11 +139,23 @@ export function ShareMenu({ post, menuButton }: ShareMenuProps) {
93
139
  action={downloadEventIcs}
94
140
  />
95
141
  ) : null}
142
+ {canSystemShare ? (
143
+ <PopupMenuButton
144
+ title={t('posts.shareMenu.systemShare', {
145
+ defaultValue: 'Share via…',
146
+ })}
147
+ text={t('posts.shareMenu.systemShare', {
148
+ defaultValue: 'Share via…',
149
+ })}
150
+ icon={Share}
151
+ action={() => void systemShare()}
152
+ />
153
+ ) : null}
96
154
  <PopupMenuButton
97
155
  title={t('posts.shareMenu.copyLink', { defaultValue: 'Copy link' })}
98
156
  text={t('posts.shareMenu.copyLink', { defaultValue: 'Copy link' })}
99
157
  icon={Copy}
100
- action={() => void navigator.clipboard.writeText(postUrl)}
158
+ action={() => void copyLink()}
101
159
  />
102
160
  </PopupMenu>
103
161
  );
@@ -62,7 +62,7 @@ export function ArticleForm({
62
62
  </h2>
63
63
 
64
64
  <Label
65
- title={t('articles.form.title', { defaultValue: 'New Article' })}
65
+ title={t('articles.form.titleInput', { defaultValue: 'Title' })}
66
66
  htmlFor="article-title"
67
67
  >
68
68
  <Input
@@ -7,6 +7,7 @@ import type {
7
7
  import {
8
8
  EVENT_HEADER_ASPECT_RATIO,
9
9
  parseEventMaxAttendeesInput,
10
+ parseEventWaitlistOfferMinutesInput,
10
11
  utcIsoToZonedDateTime,
11
12
  zonedDateTimeToUtcIso,
12
13
  } from '@openpeepshq/common/lib';
@@ -50,6 +51,7 @@ export const EventForm = ({
50
51
  }: EventFormProps) => {
51
52
  const t = useT();
52
53
  const [audienceOpen, setAudienceOpen] = useState(false);
54
+ const [endBeforeStart, setEndBeforeStart] = useState(false);
53
55
  const {
54
56
  event,
55
57
  eventTimeZone,
@@ -139,7 +141,14 @@ export const EventForm = ({
139
141
  value={dateToInputValue(event.start, eventTimeZone)}
140
142
  onChange={(e) => {
141
143
  const start = toIso(e.target.value, eventTimeZone);
142
- if (start) patchEvent({ start });
144
+ if (start) {
145
+ if (event.end && new Date(event.end) <= new Date(start)) {
146
+ setEndBeforeStart(true);
147
+ } else {
148
+ setEndBeforeStart(false);
149
+ }
150
+ patchEvent({ start });
151
+ }
143
152
  }}
144
153
  data-testid="events-start-input"
145
154
  />
@@ -159,20 +168,40 @@ export const EventForm = ({
159
168
  </Label>
160
169
 
161
170
  {showEndDate ? (
162
- <Label
163
- title={t('events.form.endDate', { defaultValue: 'End Date' })}
164
- htmlFor="event-end"
165
- >
166
- <Input
167
- id="event-end"
168
- type="datetime-local"
169
- step={60}
170
- value={dateToInputValue(event.end, eventTimeZone)}
171
- onChange={(e) =>
172
- patchEvent({ end: toIso(e.target.value, eventTimeZone) })
173
- }
174
- />
175
- </Label>
171
+ <>
172
+ <Label
173
+ title={t('events.form.endDate', { defaultValue: 'End Date' })}
174
+ htmlFor="event-end"
175
+ >
176
+ <Input
177
+ id="event-end"
178
+ type="datetime-local"
179
+ step={60}
180
+ value={dateToInputValue(event.end, eventTimeZone)}
181
+ onChange={(e) => {
182
+ const newEnd = toIso(e.target.value, eventTimeZone);
183
+ if (
184
+ newEnd &&
185
+ event.start &&
186
+ new Date(newEnd) <= new Date(event.start)
187
+ ) {
188
+ setEndBeforeStart(true);
189
+ return;
190
+ }
191
+ setEndBeforeStart(false);
192
+ patchEvent({ end: newEnd });
193
+ }}
194
+ />
195
+ </Label>
196
+ {endBeforeStart ? (
197
+ <p className="text-destructive text-sm">
198
+ {t('events.form.endBeforeStart', {
199
+ defaultValue:
200
+ 'The end date and time must be after the start date and time.',
201
+ })}
202
+ </p>
203
+ ) : null}
204
+ </>
176
205
  ) : null}
177
206
 
178
207
  <Label
@@ -422,6 +451,31 @@ export const EventForm = ({
422
451
  ) : null}
423
452
  </div>
424
453
  </Label>
454
+ {event.maxAttendees != null ? (
455
+ <Label
456
+ title={t('events.form.waitlistOfferMinutes', {
457
+ defaultValue: 'Waitlist response window (minutes)',
458
+ })}
459
+ description={t('events.form.waitlistOfferMinutesDescription', {
460
+ defaultValue:
461
+ 'How long the next person on the waitlist has to claim a freed spot. Leave empty for 60 minutes.',
462
+ })}
463
+ >
464
+ <Input
465
+ type="number"
466
+ min={1}
467
+ max={10080}
468
+ value={event.waitlistOfferMinutes ?? ''}
469
+ onChange={(e) => {
470
+ patchEvent({
471
+ waitlistOfferMinutes: parseEventWaitlistOfferMinutesInput(
472
+ e.target.value,
473
+ ),
474
+ });
475
+ }}
476
+ />
477
+ </Label>
478
+ ) : null}
425
479
  </div>
426
480
 
427
481
  {!isEdit ? (
@@ -5,7 +5,12 @@ import type {
5
5
  ResourceKind,
6
6
  ResourcePost,
7
7
  } from '@openpeepshq/common/types';
8
- import { RESOURCE_KINDS, normalizeResourceTags } from '@openpeepshq/common/lib';
8
+ import {
9
+ RESOURCE_KINDS,
10
+ RESOURCE_TITLE_MAX_LENGTH,
11
+ normalizeResourceTags,
12
+ resourceFormIssues,
13
+ } from '@openpeepshq/common/lib';
9
14
  import { Button, Input, Label } from '@openpeepshq/react-ui';
10
15
  import { useT } from '../../../i18n';
11
16
  import { useCurrentProfile } from '../../layout/IdentityContext';
@@ -21,19 +26,25 @@ export interface ResourceFormProps {
21
26
  postData: PostCreationData;
22
27
  onChange: (data: PostCreationData) => void;
23
28
  isEdit?: boolean;
29
+ /** Member can post this resource only to a group. */
30
+ groupOnly?: boolean;
24
31
  }
25
32
 
26
33
  export const ResourceForm = ({
27
34
  postData,
28
35
  onChange,
29
36
  isEdit = false,
37
+ groupOnly = false,
30
38
  }: ResourceFormProps) => {
31
39
  const t = useT();
32
40
  const me = useCurrentProfile();
33
41
  const resource = postData.data as ResourcePost;
34
42
  const [audienceOpen, setAudienceOpen] = useState(false);
35
43
  const [tagDraft, setTagDraft] = useState('');
36
- const library = useResourceLibrary(postData.groupId ?? undefined);
44
+ const library = useResourceLibrary(
45
+ postData.groupId ?? undefined,
46
+ !postData.groupId,
47
+ );
37
48
  const attachments = useComposeAttachments({
38
49
  attachments: resource.attachments ?? [],
39
50
  onChange: (next) => patchResource({ attachments: next }),
@@ -65,6 +76,26 @@ export const ResourceForm = ({
65
76
  }
66
77
  };
67
78
 
79
+ const issues = resourceFormIssues({
80
+ title: resource.title,
81
+ resourceKind: resource.resourceKind,
82
+ url: resource.url,
83
+ attachments: resource.attachments,
84
+ visibility: postData.visibility,
85
+ audience: postData.audience,
86
+ groupId: postData.groupId,
87
+ });
88
+ const titleMissing = issues.includes('title');
89
+ const titleTooLong = issues.includes('titleLength');
90
+ const urlIssue = issues.includes('url');
91
+ const urlInvalid = urlIssue && Boolean(resource.url?.trim());
92
+ const mediaMissing = issues.includes('media');
93
+ const audienceMissing = issues.includes('audience');
94
+ const groupMissing = issues.includes('group');
95
+ const urlMessage = t('resources.validation.url', {
96
+ defaultValue: 'Enter a real link, like https://example.com',
97
+ });
98
+
68
99
  const kindActions = useMemo(
69
100
  () => ({
70
101
  gallery: attachments.openImagePicker,
@@ -84,15 +115,51 @@ export const ResourceForm = ({
84
115
  </h2>
85
116
 
86
117
  <Label
87
- title={t('resources.form.name', { defaultValue: 'Title' })}
118
+ title={t('resources.form.nameRequired', {
119
+ defaultValue: 'Title (Required)',
120
+ })}
88
121
  htmlFor="resource-title"
89
122
  >
90
123
  <Input
91
124
  id="resource-title"
92
125
  data-testid="resources-title"
93
126
  value={resource.title}
127
+ maxLength={RESOURCE_TITLE_MAX_LENGTH}
128
+ aria-invalid={titleMissing || titleTooLong}
129
+ aria-describedby={
130
+ titleMissing
131
+ ? 'resource-title-error resource-title-count'
132
+ : 'resource-title-count'
133
+ }
94
134
  onChange={(event) => patchResource({ title: event.target.value })}
95
135
  />
136
+ {titleMissing ? (
137
+ <span
138
+ id="resource-title-error"
139
+ role="status"
140
+ className="text-muted-foreground mt-1 text-sm"
141
+ >
142
+ {t('resources.validation.titleRequired', {
143
+ defaultValue: 'Title is required',
144
+ })}
145
+ </span>
146
+ ) : null}
147
+ {titleTooLong ? (
148
+ <span role="alert" className="text-destructive mt-1 text-sm">
149
+ {t('resources.validation.titleTooLong', {
150
+ defaultValue: 'Title must be 200 characters or fewer',
151
+ })}
152
+ </span>
153
+ ) : null}
154
+ <span
155
+ id="resource-title-count"
156
+ className="block w-full px-2 text-right text-sm"
157
+ >
158
+ <span className={titleTooLong ? 'text-error' : undefined}>
159
+ {resource.title.length}
160
+ </span>{' '}
161
+ / {RESOURCE_TITLE_MAX_LENGTH}
162
+ </span>
96
163
  </Label>
97
164
 
98
165
  <div>
@@ -118,15 +185,39 @@ export const ResourceForm = ({
118
185
 
119
186
  {resource.resourceKind === 'link' ? (
120
187
  <Label
121
- title={t('resources.form.url', { defaultValue: 'URL' })}
188
+ title={t('resources.form.urlRequired', {
189
+ defaultValue: 'URL (Required)',
190
+ })}
122
191
  htmlFor="resource-url"
123
192
  >
124
193
  <Input
125
194
  id="resource-url"
126
195
  data-testid="resources-url"
127
196
  value={resource.url ?? ''}
197
+ placeholder={t('resources.form.urlPlaceholder', {
198
+ defaultValue: 'https://example.com',
199
+ })}
200
+ inputMode="url"
201
+ spellCheck={false}
202
+ error={urlInvalid}
203
+ aria-invalid={urlIssue}
204
+ aria-describedby={urlIssue ? 'resource-url-error' : undefined}
128
205
  onChange={(event) => patchResource({ url: event.target.value })}
129
206
  />
207
+ {urlIssue ? (
208
+ <span
209
+ id="resource-url-error"
210
+ role={urlInvalid ? 'alert' : 'status'}
211
+ data-testid="resources-url-error"
212
+ className={
213
+ urlInvalid
214
+ ? 'text-destructive mt-1 text-sm'
215
+ : 'text-muted-foreground mt-1 text-sm'
216
+ }
217
+ >
218
+ {urlMessage}
219
+ </span>
220
+ ) : null}
130
221
  </Label>
131
222
  ) : (
132
223
  <div className="space-y-2">
@@ -140,6 +231,13 @@ export const ResourceForm = ({
140
231
  </Button>
141
232
  {attachments.previews}
142
233
  {attachments.inputs}
234
+ {mediaMissing ? (
235
+ <p role="status" className="text-muted-foreground text-sm">
236
+ {t('resources.validation.mediaRequired', {
237
+ defaultValue: 'Add the media or link this resource needs',
238
+ })}
239
+ </p>
240
+ ) : null}
143
241
  </div>
144
242
  )}
145
243
 
@@ -217,6 +315,36 @@ export const ResourceForm = ({
217
315
  disabled={isEdit}
218
316
  showDirect
219
317
  />
318
+ {!isEdit && groupOnly ? (
319
+ <span role="status" className="text-muted-foreground mt-1 text-sm">
320
+ {t('resources.form.groupOnly', {
321
+ defaultValue: 'You can only share resources with a group.',
322
+ })}
323
+ </span>
324
+ ) : null}
325
+ {groupMissing ? (
326
+ <span
327
+ id="resource-group-error"
328
+ role="status"
329
+ className="text-muted-foreground mt-1 text-sm"
330
+ >
331
+ {t('resources.validation.groupRequired', {
332
+ defaultValue: 'Choose a group before creating this resource.',
333
+ })}
334
+ </span>
335
+ ) : null}
336
+ {audienceMissing ? (
337
+ <span
338
+ id="resource-audience-error"
339
+ role="status"
340
+ className="text-muted-foreground mt-1 text-sm"
341
+ >
342
+ {t('resources.validation.directAudience', {
343
+ defaultValue:
344
+ 'Choose at least one recipient for a direct resource.',
345
+ })}
346
+ </span>
347
+ ) : null}
220
348
  </Label>
221
349
  </div>
222
350
 
@@ -37,19 +37,26 @@ export const VisibilitySelector = ({
37
37
  );
38
38
 
39
39
  const selectedGroup = useMemo(
40
- () =>
41
- me?.memberships?.find((m) => m.group.id === postData.groupId)?.group,
40
+ () => me?.memberships?.find((m) => m.group.id === postData.groupId)?.group,
42
41
  [me?.memberships, postData.groupId],
43
42
  );
44
43
 
45
44
  const description = (visibility: string) =>
46
45
  audienceChoices.find((c) => c.value === visibility)?.description ?? '';
47
46
 
47
+ const choiceLabel = (visibility: string) =>
48
+ description(visibility) ||
49
+ (audienceChoices.length > 0
50
+ ? t('posts.form.chooseAudience', {
51
+ defaultValue: 'Choose who can see this',
52
+ })
53
+ : '');
54
+
48
55
  const content = () => {
49
56
  if (postData.visibility === 'group') {
50
57
  return (
51
58
  <span className="flex min-w-0 items-center gap-1 text-sm font-normal">
52
- <span className="shrink-0 pr-2">{description('group')}</span>
59
+ <span className="shrink-0 pr-2">{choiceLabel('group')}</span>
53
60
  {selectedGroup ? (
54
61
  <span className="flex min-w-0 items-center gap-1 truncate">
55
62
  <GroupAvatar group={selectedGroup} size={1.5} borderless />
@@ -64,7 +71,7 @@ export const VisibilitySelector = ({
64
71
  const audience = postData.audience ?? [];
65
72
  return (
66
73
  <span className="flex min-w-0 items-center gap-1 text-sm font-light">
67
- <span className="shrink-0 pr-2">{description('direct')}</span>
74
+ <span className="shrink-0 pr-2">{choiceLabel('direct')}</span>
68
75
  {audience.length ? (
69
76
  <span className="flex min-w-0 flex-wrap items-center gap-1">
70
77
  {audience.map((profile) => (
@@ -78,7 +85,7 @@ export const VisibilitySelector = ({
78
85
 
79
86
  return (
80
87
  <span className="text-sm font-light">
81
- {description(postData.visibility)}
88
+ {choiceLabel(postData.visibility)}
82
89
  </span>
83
90
  );
84
91
  };
@@ -2,8 +2,7 @@ import { ArrowRight } from 'lucide-react';
2
2
  import type { PublicPost } from '@openpeepshq/common/types';
3
3
  import { useT } from '../../../i18n';
4
4
  import { resolveStaticUrl, useStaticRender } from '../../markdown/staticRender';
5
- import { PostMarkdown } from '../Markdown';
6
- import { OPENPEEPS_POST_CAPTION_CLASS } from '../../markdown/classes';
5
+ import { TruncatedMarkdown } from '../TruncatedMarkdown';
7
6
  import { firstNWords } from '../helpers';
8
7
  import { minutesToRead } from '@openpeepshq/common/lib';
9
8
 
@@ -34,16 +33,17 @@ export function FeedArticle({ post }: FeedArticleProps) {
34
33
  />
35
34
  )}
36
35
  <div className="prose-sm">
37
- <h3>{article.title}</h3>
36
+ <h3 className="text-foreground">{article.title}</h3>
38
37
  {minutes > 0 && (
39
38
  <p className="text-muted-foreground text-xs">
40
39
  {t('posts.article.minutesToRead', { count: minutes })}
41
40
  </p>
42
41
  )}
43
42
  </div>
44
- <PostMarkdown
45
- source={`${previewContent}${showReadMore ? '...' : ''}`}
46
- className={OPENPEEPS_POST_CAPTION_CLASS}
43
+ <TruncatedMarkdown
44
+ source={article.content ?? ''}
45
+ snippet={previewContent}
46
+ interactive={false}
47
47
  />
48
48
  {showReadMore && (
49
49
  <div className="flex justify-end">
@@ -41,6 +41,72 @@ export function FeedEvent({ post }: FeedEventProps) {
41
41
  allDay: event.wholeDay,
42
42
  })
43
43
  : fmtRange(start, end);
44
+ const viewEventHref = resolveStaticUrl(
45
+ `/posts/${post.id}`,
46
+ staticRender ? baseUrl : undefined,
47
+ );
48
+
49
+ if (staticRender) {
50
+ return (
51
+ <table
52
+ role="presentation"
53
+ width="100%"
54
+ cellPadding={0}
55
+ cellSpacing={0}
56
+ style={{ width: '100%', borderCollapse: 'collapse' }}
57
+ >
58
+ <tbody>
59
+ {event.image ? (
60
+ <tr>
61
+ <td style={{ paddingBottom: '8px' }}>
62
+ <img
63
+ src={event.image}
64
+ alt={`image for ${event.name ?? 'event'}`}
65
+ width="100%"
66
+ style={{
67
+ display: 'block',
68
+ width: '100%',
69
+ maxWidth: '100%',
70
+ height: 'auto',
71
+ }}
72
+ />
73
+ </td>
74
+ </tr>
75
+ ) : null}
76
+ <tr>
77
+ <td className="text-destructive pb-2 text-sm">{when}</td>
78
+ </tr>
79
+ <tr>
80
+ <td className="pb-2 text-lg font-medium">{event.name}</td>
81
+ </tr>
82
+ {event.recurrence ? (
83
+ <tr>
84
+ <td className="text-muted-foreground pb-2 text-sm">
85
+ {formatEventRecurrence(event.recurrence, t, event.start)}
86
+ </td>
87
+ </tr>
88
+ ) : null}
89
+ {event.physicalLocation || event.jam || event.url ? (
90
+ <tr>
91
+ <td className="pb-2">
92
+ <EventLocation post={post} />
93
+ </td>
94
+ </tr>
95
+ ) : null}
96
+ <tr>
97
+ <td>
98
+ <a
99
+ href={viewEventHref}
100
+ className="text-primary text-sm underline"
101
+ >
102
+ {t('posts.event.viewEvent', { defaultValue: 'View Event' })}
103
+ </a>
104
+ </td>
105
+ </tr>
106
+ </tbody>
107
+ </table>
108
+ );
109
+ }
44
110
 
45
111
  return (
46
112
  <div className="flex w-full flex-col gap-2">
@@ -56,15 +122,10 @@ export function FeedEvent({ post }: FeedEventProps) {
56
122
  <div className="flex w-full items-center justify-between">
57
123
  <span className="text-destructive text-sm">
58
124
  {when}{' '}
59
- {staticRender ? null : (
60
- <span className="text-muted-foreground">(your local time)</span>
61
- )}
125
+ <span className="text-muted-foreground">(your local time)</span>
62
126
  </span>
63
127
  <Button
64
- action={resolveStaticUrl(
65
- `/posts/${post.id}`,
66
- staticRender ? baseUrl : undefined,
67
- )}
128
+ action={viewEventHref}
68
129
  variant="outline"
69
130
  compact
70
131
  className="shrink-0"
@@ -29,8 +29,8 @@ export function FullArticle({ post }: FullArticleProps) {
29
29
  alt={article.title ? `image for ${article.title}` : 'Article'}
30
30
  />
31
31
  ) : null}
32
- <div className="prose mb-6">
33
- <h1>{article.title}</h1>
32
+ <div className="prose dark:prose-invert mb-6">
33
+ <h1 className="text-foreground">{article.title}</h1>
34
34
  {minutes > 0 && (
35
35
  <p className="text-muted-foreground text-sm">
36
36
  {t('posts.article.minutesToRead', { count: minutes })}