@openpeepshq/react 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/components/markdown/compileMarkdown.js +1 -0
  2. package/dist/components/navigation/FooterMobile.js +4 -3
  3. package/dist/components/navigation/HeaderMobile.js +5 -2
  4. package/dist/components/navigation/MobileMenuItem.d.ts +3 -1
  5. package/dist/components/navigation/MobileMenuItem.js +7 -2
  6. package/dist/components/navigation/NavWithTooltip.d.ts +9 -0
  7. package/dist/components/navigation/NavWithTooltip.js +4 -0
  8. package/dist/components/navigation/index.d.ts +2 -0
  9. package/dist/components/navigation/index.js +1 -0
  10. package/dist/components/navigation/sideBarNavLinkClass.d.ts +6 -4
  11. package/dist/components/navigation/sideBarNavLinkClass.js +6 -2
  12. package/dist/components/post/CompactReplyParent.js +5 -6
  13. package/dist/components/post/TruncatedMarkdown.d.ts +27 -0
  14. package/dist/components/post/TruncatedMarkdown.js +37 -0
  15. package/dist/components/post/helpers.d.ts +2 -2
  16. package/dist/components/post/helpers.js +3 -16
  17. package/dist/components/post/index.d.ts +2 -0
  18. package/dist/components/post/index.js +1 -0
  19. package/dist/components/post/pieces/EventLocation.js +14 -0
  20. package/dist/components/post/pieces/EventRsvpButton.js +3 -1
  21. package/dist/components/post/pieces/PollContent.js +8 -2
  22. package/dist/components/post/post-form/ArticleForm.js +1 -1
  23. package/dist/components/post/post-form/ComposeAttachments.d.ts +5 -1
  24. package/dist/components/post/post-form/ComposeAttachments.js +20 -6
  25. package/dist/components/post/post-form/ComposeAttachments.test.d.ts +1 -0
  26. package/dist/components/post/post-form/ComposeAttachments.test.js +131 -0
  27. package/dist/components/post/post-form/EventForm.js +23 -3
  28. package/dist/components/post/post-form/ResourceForm.d.ts +3 -1
  29. package/dist/components/post/post-form/ResourceForm.js +51 -7
  30. package/dist/components/post/post-form/VisibilitySelector.js +9 -3
  31. package/dist/components/post/types/Article.js +2 -3
  32. package/dist/components/post/types/Event.js +10 -1
  33. package/dist/components/post/types/resource/FullResource.js +3 -3
  34. package/dist/components/preview-link/local/WelcomePreview.js +4 -2
  35. package/dist/components/resources/ResourceCard.d.ts +5 -1
  36. package/dist/components/resources/ResourceCard.js +94 -37
  37. package/dist/components/resources/ResourceCard.test.d.ts +1 -0
  38. package/dist/components/resources/ResourceCard.test.js +75 -0
  39. package/dist/components/resources/ResourceLibrary.js +1 -1
  40. package/dist/hooks/events/useEventRsvp.d.ts +1 -0
  41. package/dist/hooks/events/useEventRsvp.js +15 -7
  42. package/dist/hooks/posts/useResourceComposer.d.ts +2 -0
  43. package/dist/hooks/posts/useResourceComposer.js +131 -25
  44. package/dist/hooks/resources/useResourceLibrary.d.ts +1 -1
  45. package/dist/hooks/resources/useResourceLibrary.js +6 -2
  46. package/dist/hooks/useWelcomePreview.d.ts +3 -0
  47. package/dist/hooks/useWelcomePreview.js +1 -0
  48. package/dist/navigation/menuItems.js +15 -0
  49. package/dist/navigation/targets.d.ts +2 -0
  50. package/dist/pages/admin/community/CommunityMarkdownPage.js +2 -1
  51. package/dist/pages/auth/Register.js +3 -1
  52. package/dist/pages/resources/Edit.js +3 -3
  53. package/dist/pages/resources/New.js +2 -2
  54. package/dist/pages/settings/Account.js +30 -2
  55. package/package.json +2 -2
  56. package/src/components/markdown/compileMarkdown.ts +1 -0
  57. package/src/components/navigation/FooterMobile.tsx +41 -33
  58. package/src/components/navigation/HeaderMobile.tsx +55 -41
  59. package/src/components/navigation/MobileMenuItem.tsx +15 -2
  60. package/src/components/navigation/NavWithTooltip.tsx +26 -0
  61. package/src/components/navigation/index.ts +2 -0
  62. package/src/components/navigation/sideBarNavLinkClass.ts +9 -6
  63. package/src/components/post/CompactReplyParent.tsx +17 -10
  64. package/src/components/post/TruncatedMarkdown.tsx +91 -0
  65. package/src/components/post/helpers.ts +4 -18
  66. package/src/components/post/index.ts +2 -0
  67. package/src/components/post/pieces/EventLocation.tsx +27 -0
  68. package/src/components/post/pieces/EventRsvpButton.tsx +3 -0
  69. package/src/components/post/pieces/PollContent.tsx +8 -2
  70. package/src/components/post/post-form/ArticleForm.tsx +1 -1
  71. package/src/components/post/post-form/ComposeAttachments.tsx +24 -3
  72. package/src/components/post/post-form/EventForm.tsx +43 -15
  73. package/src/components/post/post-form/ResourceForm.tsx +135 -4
  74. package/src/components/post/post-form/VisibilitySelector.tsx +11 -3
  75. package/src/components/post/types/Article.tsx +5 -5
  76. package/src/components/post/types/Event.tsx +68 -7
  77. package/src/components/post/types/resource/FullResource.tsx +9 -1
  78. package/src/components/preview-link/local/WelcomePreview.tsx +11 -2
  79. package/src/components/resources/ResourceCard.tsx +184 -62
  80. package/src/components/resources/ResourceLibrary.tsx +2 -2
  81. package/src/hooks/events/useEventRsvp.ts +19 -7
  82. package/src/hooks/posts/useResourceComposer.ts +157 -33
  83. package/src/hooks/resources/useResourceLibrary.ts +6 -2
  84. package/src/hooks/useWelcomePreview.ts +4 -0
  85. package/src/navigation/menuItems.ts +16 -0
  86. package/src/navigation/targets.ts +2 -0
  87. package/src/pages/admin/community/CommunityMarkdownPage.tsx +5 -1
  88. package/src/pages/auth/Register.tsx +12 -0
  89. package/src/pages/resources/Edit.tsx +3 -2
  90. package/src/pages/resources/New.tsx +6 -1
  91. package/src/pages/settings/Account.tsx +51 -1
@@ -1,5 +1,5 @@
1
1
  import { useMemo, useState } from 'react';
2
- import { canClaimYesRsvp, checkPostCapabilities, defaultRsvpRecurrenceId, displayRsvpForProfile, eventRsvpOpen, isCapacityEvent, isRecurringEvent, listRsvpOccurrences, offerStillOpen, seriesHasClaimableOccurrence, } from '@openpeepshq/common/lib';
2
+ import { canClaimYesRsvp, checkPostCapabilities, defaultRsvpRecurrenceId, displayRsvpForProfile, effectiveEventTimes, eventRsvpOpen, isCapacityEvent, isRecurringEvent, listRsvpOccurrences, occurrenceHasEnded, offerStillOpen, seriesHasClaimableOccurrence, } from '@openpeepshq/common/lib';
3
3
  import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
4
4
  import { useT } from '../../i18n/context.js';
5
5
  import { apiErrorMessage } from '../../lib/apiErrorMessage.js';
@@ -18,12 +18,17 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
18
18
  const [submitting, setSubmitting] = useState(false);
19
19
  const eventData = post.data?.type === 'event' ? post.data : undefined;
20
20
  const recurring = eventData ? isRecurringEvent(eventData) : false;
21
+ const viewedTimes = eventData
22
+ ? effectiveEventTimes(eventData, recurrenceId)
23
+ : undefined;
24
+ // Series home shows its first start. Once that time has passed, RSVP stays
25
+ // off that page; upcoming dates are opened from their own links.
26
+ const viewedEnded = !!viewedTimes && occurrenceHasEnded(viewedTimes.start, viewedTimes.end);
27
+ // A selected date, or a one-off, is closed on its own end time.
21
28
  const rsvpClosed = eventData
22
- ? !eventRsvpOpen(eventData, { recurrenceId, lockToOccurrence })
29
+ ? !eventRsvpOpen(eventData, recurrenceId ? { recurrenceId, lockToOccurrence: true } : undefined)
23
30
  : false;
24
- const queriedOccurrenceClosed = !!eventData &&
25
- !!recurrenceId &&
26
- !eventRsvpOpen(eventData, { recurrenceId, lockToOccurrence: true });
31
+ const queriedOccurrenceClosed = !!recurrenceId && rsvpClosed;
27
32
  const defaultId = eventData
28
33
  ? defaultRsvpRecurrenceId(eventData, queriedOccurrenceClosed ? undefined : recurrenceId)
29
34
  : undefined;
@@ -77,7 +82,7 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
77
82
  }
78
83
  };
79
84
  const requestJoinWaitlist = () => {
80
- if (rsvpClosed)
85
+ if (rsvpClosed || viewedEnded)
81
86
  return;
82
87
  if (!recurring || lockToOccurrence) {
83
88
  setError(null);
@@ -98,13 +103,15 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
98
103
  }
99
104
  };
100
105
  const claimSpot = () => {
106
+ if (rsvpClosed || viewedEnded)
107
+ return;
101
108
  const id = recurring
102
109
  ? (myRsvp?.recurrenceId ?? (lockToOccurrence ? recurrenceId : defaultId))
103
110
  : undefined;
104
111
  writeRsvp('yes', id ? [id] : undefined).catch(() => undefined);
105
112
  };
106
113
  const requestRespond = (response) => {
107
- if (rsvpClosed)
114
+ if (rsvpClosed || viewedEnded)
108
115
  return;
109
116
  if (!recurring || lockToOccurrence) {
110
117
  writeRsvp(response, recurrenceId ? [recurrenceId] : undefined).catch(() => undefined);
@@ -139,6 +146,7 @@ export const useEventRsvp = ({ post, recurrenceId, lockToOccurrence = false, onS
139
146
  myRsvp,
140
147
  canRsvp,
141
148
  rsvpClosed,
149
+ hideRsvpButton: rsvpClosed || viewedEnded,
142
150
  recurring,
143
151
  defaultId,
144
152
  occurrences,
@@ -360,6 +360,7 @@ export declare const useNewResource: () => {
360
360
  capabilitiesNeeded?: string[] | null | undefined;
361
361
  };
362
362
  setPostData: (data: PostCreationData) => void;
363
+ groupOnly: boolean;
363
364
  canSubmit: boolean;
364
365
  submitting: boolean;
365
366
  error: string | null;
@@ -12064,6 +12065,7 @@ export declare const useEditResource: (resourceId: string) => {
12064
12065
  capabilitiesNeeded?: string[] | null | undefined;
12065
12066
  } | null>>;
12066
12067
  resourceTitle: string | undefined;
12068
+ canSubmit: boolean;
12067
12069
  submitting: boolean;
12068
12070
  error: string | null;
12069
12071
  clearError: () => void;
@@ -1,9 +1,11 @@
1
- import { useCallback, useEffect, useState } from 'react';
2
- import { normalizeResourceTags, resourceHasRequiredMedia, } from '@openpeepshq/common/lib';
1
+ import { useCallback, useEffect, useMemo, useState } from 'react';
2
+ import { checkGroupCapabilities, normalizeResourceTags, resourceFormIssues, resourceVisibilityForCapabilities, } from '@openpeepshq/common/lib';
3
3
  import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
4
4
  import { useNavigate } from '../../contexts/router/index.js';
5
5
  import { useT } from '../../i18n/context.js';
6
+ import { useAuthData, useCurrentProfile, } from '../../components/layout/IdentityContext.js';
6
7
  import { useServerInfo } from '../../components/server-data/index.js';
8
+ import { buildAudienceChoiceValues } from '../../lib/audienceChoices.js';
7
9
  import { defaultNewResource, getNewPostStores } from '../../stores/index.js';
8
10
  const asResource = (data) => data?.type === 'resource' ? data : null;
9
11
  const preparedResource = (resource) => ({
@@ -13,12 +15,69 @@ const preparedResource = (resource) => ({
13
15
  categoryPath: (resource.categoryPath ?? [])
14
16
  .map((segment) => segment.trim())
15
17
  .filter(Boolean),
16
- url: resource.url?.trim() || undefined,
18
+ url: resource.resourceKind === 'link'
19
+ ? resource.url?.trim() || undefined
20
+ : undefined,
17
21
  });
22
+ const issuesFor = (postData) => {
23
+ const resource = asResource(postData.data);
24
+ if (!resource)
25
+ return ['title'];
26
+ return resourceFormIssues({
27
+ title: resource.title,
28
+ resourceKind: resource.resourceKind,
29
+ url: resource.url,
30
+ attachments: resource.attachments,
31
+ visibility: postData.visibility,
32
+ audience: postData.audience,
33
+ groupId: postData.groupId,
34
+ });
35
+ };
36
+ const issueMessage = (issue, t) => {
37
+ if (issue === 'title') {
38
+ return t('resources.validation.titleRequired', {
39
+ defaultValue: 'Title is required',
40
+ });
41
+ }
42
+ if (issue === 'titleLength') {
43
+ return t('resources.validation.titleTooLong', {
44
+ defaultValue: 'Title must be 200 characters or fewer',
45
+ });
46
+ }
47
+ if (issue === 'url') {
48
+ return t('resources.validation.url', {
49
+ defaultValue: 'Enter a real link, like https://example.com',
50
+ });
51
+ }
52
+ if (issue === 'media') {
53
+ return t('resources.validation.mediaRequired', {
54
+ defaultValue: 'Add the media or link this resource needs',
55
+ });
56
+ }
57
+ if (issue === 'group') {
58
+ return t('resources.validation.groupRequired', {
59
+ defaultValue: 'Choose a group before creating this resource.',
60
+ });
61
+ }
62
+ return t('resources.validation.directAudience', {
63
+ defaultValue: 'Choose at least one recipient for a direct resource.',
64
+ });
65
+ };
66
+ const submitErrorMessage = (err, t) => {
67
+ const message = err instanceof Error ? err.message : '';
68
+ if (message === 'Forbidden') {
69
+ return t('resources.validation.audienceForbidden', {
70
+ defaultValue: 'Choose a group you can post this resource in.',
71
+ });
72
+ }
73
+ return message;
74
+ };
18
75
  export const useNewResource = () => {
19
76
  const t = useT();
20
77
  const navigate = useNavigate();
21
78
  const serverInfo = useServerInfo();
79
+ const authData = useAuthData();
80
+ const me = useCurrentProfile();
22
81
  const { openpeepsApi } = useOpenpeeps();
23
82
  const createPost = openpeepsApi.createPostAction();
24
83
  const stores = getNewPostStores();
@@ -31,33 +90,71 @@ export const useNewResource = () => {
31
90
  });
32
91
  const [submitting, setSubmitting] = useState(false);
33
92
  const [error, setError] = useState(null);
93
+ const audience = useMemo(() => {
94
+ if (!authData.profile || authData.scopes.length === 0)
95
+ return null;
96
+ const choices = buildAudienceChoiceValues('resource', authData, t, {
97
+ publicContent: serverInfo.publicContent,
98
+ showDirect: true,
99
+ });
100
+ const memberships = me?.memberships;
101
+ const postableGroupIds = memberships == null
102
+ ? null
103
+ : memberships
104
+ .map((membership) => membership.group)
105
+ .filter((group) => checkGroupCapabilities(authData, ['core-posts-create-resource'], group).success)
106
+ .map((group) => group.id);
107
+ const next = resourceVisibilityForCapabilities({
108
+ visibility: postData.visibility,
109
+ groupId: postData.groupId,
110
+ allowed: choices.map((choice) => choice.value),
111
+ postableGroupIds,
112
+ });
113
+ return {
114
+ ...next,
115
+ groupOnly: choices.length === 1 && choices[0]?.value === 'group',
116
+ hasChoice: choices.length > 0,
117
+ };
118
+ }, [
119
+ authData,
120
+ me?.memberships,
121
+ postData.groupId,
122
+ postData.visibility,
123
+ serverInfo.publicContent,
124
+ t,
125
+ ]);
126
+ useEffect(() => {
127
+ if (!audience?.hasChoice)
128
+ return;
129
+ if (audience.visibility === postData.visibility &&
130
+ (audience.groupId ?? undefined) === (postData.groupId ?? undefined)) {
131
+ return;
132
+ }
133
+ const next = {
134
+ ...postData,
135
+ visibility: audience.visibility,
136
+ groupId: audience.groupId,
137
+ };
138
+ setPostDataState(next);
139
+ stores.resource = next;
140
+ }, [audience, postData, stores]);
34
141
  const resource = asResource(postData.data);
35
- const canSubmit = !!resource?.title.trim() &&
36
- !!resource &&
37
- resourceHasRequiredMedia(resource) &&
38
- !(postData.visibility === 'direct' && !postData.audience?.length);
142
+ const audienceReady = !!audience?.hasChoice &&
143
+ audience.visibility === postData.visibility &&
144
+ (audience.groupId ?? undefined) === (postData.groupId ?? undefined);
145
+ const canSubmit = audienceReady && issuesFor(postData).length === 0;
39
146
  const setPostData = (data) => {
40
147
  setPostDataState(data);
41
148
  stores.resource = data;
42
149
  };
43
150
  const submit = useCallback(async () => {
44
151
  setError(null);
45
- if (!resource?.title.trim()) {
46
- setError(t('resources.validation.titleRequired', {
47
- defaultValue: 'Title is required',
48
- }));
152
+ if (!audienceReady)
49
153
  return;
50
- }
51
- if (!resourceHasRequiredMedia(resource)) {
52
- setError(t('resources.validation.mediaRequired', {
53
- defaultValue: 'Add the media or link this resource needs',
54
- }));
55
- return;
56
- }
57
- if (postData.visibility === 'direct' && !postData.audience?.length) {
58
- setError(t('resources.validation.directAudience', {
59
- defaultValue: 'Choose at least one recipient for a direct resource.',
60
- }));
154
+ const issue = issuesFor(postData)[0];
155
+ if (!resource || issue) {
156
+ if (issue)
157
+ setError(issueMessage(issue, t));
61
158
  return;
62
159
  }
63
160
  setSubmitting(true);
@@ -71,15 +168,16 @@ export const useNewResource = () => {
71
168
  navigate({ type: 'post', id: created.id });
72
169
  }
73
170
  catch (err) {
74
- setError(err.message);
171
+ setError(submitErrorMessage(err, t));
75
172
  }
76
173
  finally {
77
174
  setSubmitting(false);
78
175
  }
79
- }, [createPost, navigate, postData, resource, stores, t]);
176
+ }, [audienceReady, createPost, navigate, postData, resource, stores, t]);
80
177
  return {
81
178
  postData,
82
179
  setPostData,
180
+ groupOnly: audience?.groupOnly ?? false,
83
181
  canSubmit,
84
182
  submitting,
85
183
  error,
@@ -88,6 +186,7 @@ export const useNewResource = () => {
88
186
  };
89
187
  };
90
188
  export const useEditResource = (resourceId) => {
189
+ const t = useT();
91
190
  const navigate = useNavigate();
92
191
  const { openpeepsApi } = useOpenpeeps();
93
192
  const postQuery = openpeepsApi.usePost(resourceId);
@@ -109,6 +208,7 @@ export const useEditResource = (resourceId) => {
109
208
  }
110
209
  }, [postQuery.data]);
111
210
  const resourceTitle = asResource(postQuery.data?.data)?.title;
211
+ const canSubmit = !!postData && issuesFor(postData).length === 0;
112
212
  const submit = useCallback(async () => {
113
213
  if (!postData)
114
214
  return;
@@ -116,6 +216,11 @@ export const useEditResource = (resourceId) => {
116
216
  if (!resource)
117
217
  return;
118
218
  setError(null);
219
+ const issue = issuesFor(postData)[0];
220
+ if (issue) {
221
+ setError(issueMessage(issue, t));
222
+ return;
223
+ }
119
224
  setSubmitting(true);
120
225
  try {
121
226
  await updatePost(preparedResource(resource));
@@ -127,12 +232,13 @@ export const useEditResource = (resourceId) => {
127
232
  finally {
128
233
  setSubmitting(false);
129
234
  }
130
- }, [navigate, postData, resourceId, updatePost]);
235
+ }, [navigate, postData, resourceId, t, updatePost]);
131
236
  return {
132
237
  postQuery,
133
238
  postData,
134
239
  setPostData,
135
240
  resourceTitle,
241
+ canSubmit,
136
242
  submitting,
137
243
  error,
138
244
  clearError: () => setError(null),
@@ -1,4 +1,4 @@
1
- export declare const useResourceLibrary: (groupId?: string) => {
1
+ export declare const useResourceLibrary: (groupId?: string, ungrouped?: boolean) => {
2
2
  query: import("@tanstack/react-query").UseInfiniteQueryResult<import("@tanstack/react-query").InfiniteData<{
3
3
  id: string;
4
4
  type: "event" | "resource" | "note" | "question" | "article";
@@ -2,12 +2,16 @@ import { useMemo, useState } from 'react';
2
2
  import { categoryTreeFromPaths, normalizeResourceTags, pathStartsWith, } from '@openpeepshq/common/lib';
3
3
  import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
4
4
  import { useFeedListParams } from '../useResolvedFeedFormat.js';
5
- export const useResourceLibrary = (groupId) => {
5
+ export const useResourceLibrary = (groupId, ungrouped) => {
6
6
  const { openpeepsApi } = useOpenpeeps();
7
7
  const params = useFeedListParams({ format: 'linear' });
8
8
  const query = openpeepsApi.usePostsByType('resource', {
9
9
  ...params,
10
- ...(groupId ? { groupId } : { ungrouped: 'true' }),
10
+ ...(groupId
11
+ ? { groupId }
12
+ : ungrouped
13
+ ? { ungrouped: 'true' }
14
+ : {}),
11
15
  });
12
16
  const bookmarkedIds = openpeepsApi.useCurrentProfileBookmarkedIds();
13
17
  const [search, setSearch] = useState('');
@@ -2,7 +2,10 @@ export type WelcomePreviewContent = {
2
2
  /** Short label above the title. Omitted when it would repeat the title. */
3
3
  eyebrow?: string;
4
4
  title: string;
5
+ /** Plain-text excerpt (image-stripped) for non-markdown consumers / fallback. */
5
6
  description: string;
7
+ /** Raw welcome markdown (image-bearing) for markdown rendering + overlays. */
8
+ markdown: string;
6
9
  imageUrl?: string;
7
10
  imageFit: 'cover' | 'contain';
8
11
  };
@@ -33,6 +33,7 @@ export const useWelcomePreview = (systemScheme) => {
33
33
  : t('welcome.defaultIntro', {
34
34
  defaultValue: 'Welcome to this community, hosted on AllPeep.',
35
35
  }),
36
+ markdown: configured,
36
37
  imageUrl: markdownImage || logo || undefined,
37
38
  imageFit: markdownImage ? 'cover' : 'contain',
38
39
  };
@@ -1,3 +1,4 @@
1
+ const navTooltip = (id) => `navigation.tooltips.${id}`;
1
2
  /** Default main-menu targets for hosts to render with their own icons/labels. */
2
3
  export const buildMainNavItems = (caps) => {
3
4
  const items = [
@@ -5,24 +6,28 @@ export const buildMainNavItems = (caps) => {
5
6
  id: 'community',
6
7
  target: { type: 'feed', feed: 'local' },
7
8
  labelKey: 'navigation.community',
9
+ tooltipKey: navTooltip('community'),
8
10
  icon: 'Home',
9
11
  },
10
12
  {
11
13
  id: 'welcome',
12
14
  target: { type: 'welcome' },
13
15
  labelKey: 'navigation.goToWelcomePage',
16
+ tooltipKey: navTooltip('welcome'),
14
17
  icon: 'BookCheck',
15
18
  },
16
19
  {
17
20
  id: 'explore',
18
21
  target: { type: 'explore' },
19
22
  labelKey: 'navigation.explore',
23
+ tooltipKey: navTooltip('explore'),
20
24
  icon: 'Search',
21
25
  },
22
26
  {
23
27
  id: 'myFeed',
24
28
  target: { type: 'feed', feed: 'my' },
25
29
  labelKey: 'navigation.myFeed',
30
+ tooltipKey: navTooltip('myFeed'),
26
31
  icon: 'Newspaper',
27
32
  },
28
33
  ];
@@ -31,6 +36,7 @@ export const buildMainNavItems = (caps) => {
31
36
  id: 'jams',
32
37
  target: { type: 'jams' },
33
38
  labelKey: 'navigation.jams',
39
+ tooltipKey: navTooltip('jams'),
34
40
  icon: 'PhoneCall',
35
41
  });
36
42
  }
@@ -38,41 +44,49 @@ export const buildMainNavItems = (caps) => {
38
44
  id: 'groups',
39
45
  target: { type: 'groups' },
40
46
  labelKey: 'navigation.groups',
47
+ tooltipKey: navTooltip('groups'),
41
48
  icon: 'Users',
42
49
  }, {
43
50
  id: 'events',
44
51
  target: { type: 'events' },
45
52
  labelKey: 'navigation.events',
53
+ tooltipKey: navTooltip('events'),
46
54
  icon: 'CalendarDays',
47
55
  }, {
48
56
  id: 'articles',
49
57
  target: { type: 'articles' },
50
58
  labelKey: 'navigation.articles',
59
+ tooltipKey: navTooltip('articles'),
51
60
  icon: 'ScrollText',
52
61
  }, {
53
62
  id: 'resources',
54
63
  target: { type: 'resources' },
55
64
  labelKey: 'navigation.resources',
65
+ tooltipKey: navTooltip('resources'),
56
66
  icon: 'Library',
57
67
  }, {
58
68
  id: 'messages',
59
69
  target: { type: 'conversation' },
60
70
  labelKey: 'navigation.messages',
71
+ tooltipKey: navTooltip('messages'),
61
72
  icon: 'MessageSquareText',
62
73
  }, {
63
74
  id: 'members',
64
75
  target: { type: 'members' },
65
76
  labelKey: 'navigation.members',
77
+ tooltipKey: navTooltip('members'),
66
78
  icon: 'BookUser',
67
79
  }, {
68
80
  id: 'bookmarks',
69
81
  target: { type: 'feed', feed: 'bookmarks' },
70
82
  labelKey: 'navigation.bookmarks',
83
+ tooltipKey: navTooltip('bookmarks'),
71
84
  icon: 'Bookmark',
72
85
  }, {
73
86
  id: 'settings',
74
87
  target: { type: 'settings' },
75
88
  labelKey: 'navigation.settings',
89
+ tooltipKey: navTooltip('settings'),
76
90
  icon: 'Settings',
77
91
  });
78
92
  if (caps.showAdmin) {
@@ -80,6 +94,7 @@ export const buildMainNavItems = (caps) => {
80
94
  id: 'admin',
81
95
  target: { type: 'admin' },
82
96
  labelKey: 'navigation.administration',
97
+ tooltipKey: navTooltip('administration'),
83
98
  icon: 'Bolt',
84
99
  });
85
100
  }
@@ -89,6 +89,8 @@ export type NavItemDef = {
89
89
  id: string;
90
90
  target: NavTarget;
91
91
  labelKey: string;
92
+ /** i18n key describing what happens when the item is activated. */
93
+ tooltipKey?: string;
92
94
  /** Lucide (or similar) icon component name — host maps to actual icon. */
93
95
  icon?: string;
94
96
  end?: boolean;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { useT, useSetPageHeader } from '../../../index.js';
4
+ import { Markdown } from '../../../lib/Markdown.js';
4
5
  import { OpenpeepsMarkdownInput } from '../../../components/index.js';
5
6
  import { Button, Toast, deepGet, deepSet } from '@openpeepshq/react-ui';
6
7
  import { useCommunityConfig } from './useCommunityConfig.js';
@@ -31,5 +32,5 @@ export function CommunityMarkdownPage({ path, titleKey, descriptionKey, }) {
31
32
  if (isLoading || !draft) {
32
33
  return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.form.loading', { defaultValue: 'Loading…' }) }));
33
34
  }
34
- return (_jsxs("div", { className: "flex flex-col gap-4 p-4", children: [_jsx("p", { className: "pb-2 pt-4", children: t(descriptionKey) }), _jsx(OpenpeepsMarkdownInput, { value: value, maxLength: 10000, rows: 18, className: "min-h-[30rem]", onChange: setContent }), _jsx(Button, { variant: "default", action: handleSubmit, title: t('configuration.community.save'), children: t('configuration.community.save') }), status ? (_jsx(Toast, { variant: status.type, onDismiss: () => setStatus(null), children: status.message })) : null] }));
35
+ return (_jsxs("div", { className: "flex flex-col gap-4 p-4", children: [_jsx(Markdown, { source: t(descriptionKey), className: "pb-2 pt-4 text-sm text-muted-foreground" }), _jsx(OpenpeepsMarkdownInput, { value: value, maxLength: 10000, rows: 18, className: "min-h-[30rem]", onChange: setContent }), _jsx(Button, { variant: "default", action: handleSubmit, title: t('configuration.community.save'), children: t('configuration.community.save') }), status ? (_jsx(Toast, { variant: status.type, onDismiss: () => setStatus(null), children: status.message })) : null] }));
35
36
  }
@@ -147,7 +147,9 @@ export function Register({ invite = false }) {
147
147
  defaultValue: 'Show password',
148
148
  }) })] })] }) }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "confirmPassword", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('auth.register.confirmPassword', {
149
149
  defaultValue: 'Confirm Password',
150
- }) }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "password", "data-testid": "auth-register-confirm-password" }) }), _jsx(FormMessage, { "data-testid": "auth-register-confirm-password-error" })] })) }), (password ?? '').length > 0 &&
150
+ }) }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "password", "data-testid": "auth-register-confirm-password" }) }), _jsx(FormMessage, { "data-testid": "auth-register-confirm-password-error" })] })) }), password && password.length > 0 && (_jsx("p", { "data-testid": "auth-register-password-rules", className: "text-xs text-muted-foreground", children: t('auth.register.passwordRules', {
151
+ defaultValue: '8+ characters, with an uppercase letter, lowercase letter, number, and symbol',
152
+ }) })), (password ?? '').length > 0 &&
151
153
  (confirmPassword ?? '').length === 0 && (_jsx("div", { className: "bg-surface border-border flex w-full justify-center rounded py-2", children: _jsx("p", { children: getStrengthMessage(calculatePasswordStrength(password)) }) })), _jsx(FormField, { control: form.control, name: "privacyPolicyAccepted", render: ({ field }) => (_jsxs(FormItem, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(FormControl, { children: _jsx(Input, { type: "checkbox", checked: field.value, onChange: (e) => field.onChange(e.target.checked), "data-testid": "auth-register-privacy-checkbox" }) }), _jsxs("p", { children: [t('auth.register.privacyPolicyAgreement', {
152
154
  defaultValue: 'I have read and agree to the',
153
155
  }), ' ', _jsx("a", { href: privacyPolicyLink, target: "_blank", rel: "noopener noreferrer", className: "anchor text-sm", children: t('auth.register.privacyPolicy', {
@@ -9,10 +9,10 @@ import { Button, LoadingSpinner, Toast } from '@openpeepshq/react-ui';
9
9
  export const EditResource = () => {
10
10
  const t = useT();
11
11
  const { resourceId = '' } = useParams();
12
- const { postQuery, postData, setPostData, resourceTitle, submitting, error, clearError, submit, } = useEditResource(resourceId);
13
- const headerActions = useMemo(() => (_jsx(Button, { title: t('resources.update.title', { defaultValue: 'Update resource' }), variant: "default", action: submit, disabled: submitting, children: submitting
12
+ const { postQuery, postData, setPostData, resourceTitle, canSubmit, submitting, error, clearError, submit, } = useEditResource(resourceId);
13
+ const headerActions = useMemo(() => (_jsx(Button, { title: t('resources.update.title', { defaultValue: 'Update resource' }), variant: "default", action: submit, disabled: submitting || !canSubmit, children: submitting
14
14
  ? t('common.saving', { defaultValue: 'Saving…' })
15
- : t('resources.update.title', { defaultValue: 'Update resource' }) })), [submit, submitting, t]);
15
+ : t('resources.update.title', { defaultValue: 'Update resource' }) })), [canSubmit, submit, submitting, t]);
16
16
  useSetPageHeader(resourceTitle
17
17
  ? `${t('resources.edit', { defaultValue: 'Edit resource' })} ${truncateText(resourceTitle)}`
18
18
  : t('resources.edit', { defaultValue: 'Edit resource' }), headerActions);
@@ -6,10 +6,10 @@ import { useNewResource } from '../../hooks/index.js';
6
6
  import { Button, Toast } from '@openpeepshq/react-ui';
7
7
  export const NewResource = () => {
8
8
  const t = useT();
9
- const { postData, setPostData, canSubmit, submitting, error, clearError, submit, } = useNewResource();
9
+ const { postData, setPostData, canSubmit, groupOnly, submitting, error, clearError, submit, } = useNewResource();
10
10
  const headerActions = useMemo(() => (_jsx(Button, { title: t('resources.create.title', { defaultValue: 'Create resource' }), variant: "default", action: submit, disabled: submitting || !canSubmit, "data-testid": "resources-submit", children: submitting
11
11
  ? t('common.submitting', { defaultValue: 'Publishing…' })
12
12
  : t('resources.create.title', { defaultValue: 'Create resource' }) })), [canSubmit, submit, submitting, t]);
13
13
  useSetPageHeader(t('resources.new', { defaultValue: 'New resource' }), headerActions);
14
- return (_jsxs("div", { className: "pb-12", children: [_jsx(ResourceForm, { postData: postData, onChange: setPostData }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
14
+ return (_jsxs("div", { className: "pb-12", children: [_jsx(ResourceForm, { postData: postData, onChange: setPostData, groupOnly: groupOnly }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
15
15
  };
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { useT, useOpenpeeps, useSetPageHeader } from '../../index.js';
4
- import { useCurrentAccount } from '../../components/index.js';
4
+ import { useCurrentAccount, useToast } from '../../components/index.js';
5
5
  import { Button, Input, Label, Toast } from '@openpeepshq/react-ui';
6
6
  export function AccountSettings() {
7
7
  const t = useT();
8
8
  const { openpeepsApi, client } = useOpenpeeps();
9
+ const { success, error: toastError } = useToast();
9
10
  const account = useCurrentAccount();
10
11
  const updateAccount = openpeepsApi.updateCurrentAccountAction();
11
12
  useSetPageHeader(t('settings.account.title', { defaultValue: 'Account' }));
@@ -60,6 +61,25 @@ export function AccountSettings() {
60
61
  setSubmitting(false);
61
62
  }
62
63
  };
64
+ const validateEmail = openpeepsApi.validationEmailAction();
65
+ const [verifying, setVerifying] = useState(false);
66
+ const handleVerifyEmail = async () => {
67
+ setVerifying(true);
68
+ try {
69
+ await validateEmail();
70
+ success(t('settings.account.verifyEmailSent', {
71
+ defaultValue: 'Verification email sent',
72
+ }));
73
+ }
74
+ catch {
75
+ toastError(t('settings.account.verifyEmailError', {
76
+ defaultValue: 'Failed to send verification email',
77
+ }));
78
+ }
79
+ finally {
80
+ setVerifying(false);
81
+ }
82
+ };
63
83
  const exportAccount = async () => {
64
84
  setExporting(true);
65
85
  try {
@@ -98,7 +118,15 @@ export function AccountSettings() {
98
118
  defaultValue: 'Required to change your email or password.',
99
119
  }) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "email", children: t('settings.account.email', { defaultValue: 'Email' }) }), _jsx(Input, { id: "email", type: "email", value: email, placeholder: t('settings.account.emailPlaceholder', {
100
120
  defaultValue: 'Enter your email',
101
- }), onChange: (e) => setEmail(e.target.value), "data-testid": "settings-email-input" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "newPassword", children: t('settings.account.newPassword', {
121
+ }), onChange: (e) => setEmail(e.target.value), "data-testid": "settings-email-input" })] }), !account?.emailValidated ? (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-muted-foreground text-sm", children: t('settings.account.verifyEmailDescription', {
122
+ defaultValue: 'Your email is not verified. Resend a verification email.',
123
+ }) }), _jsx(Button, { title: t('settings.account.verifyEmailButton', {
124
+ defaultValue: 'Verify email',
125
+ }), variant: "outline", action: handleVerifyEmail, loading: verifying, "data-testid": "settings-verify-email-button", children: verifying
126
+ ? t('common.submitting', { defaultValue: 'Sending...' })
127
+ : t('settings.account.verifyEmailButton', {
128
+ defaultValue: 'Verify email',
129
+ }) })] })) : null, _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "newPassword", children: t('settings.account.newPassword', {
102
130
  defaultValue: 'New password',
103
131
  }) }), _jsx(Input, { id: "newPassword", type: "password", autoComplete: "new-password", value: newPassword, placeholder: t('settings.account.newPasswordPlaceholder', {
104
132
  defaultValue: 'Enter your new password',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/react",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -52,8 +52,8 @@
52
52
  "simple-icons": "^16.31.0",
53
53
  "uuidv7": "^1.0.2",
54
54
  "@openpeepshq/client": "^0.2.1",
55
- "@openpeepshq/greenscreen": "^0.2.1",
56
55
  "@openpeepshq/common": "^0.4.0",
56
+ "@openpeepshq/greenscreen": "^0.2.1",
57
57
  "@openpeepshq/react-ui": "^0.4.1"
58
58
  },
59
59
  "peerDependencies": {
@@ -64,6 +64,7 @@ export const compileMarkdownToHtml = (
64
64
  }
65
65
  if (isExternalLink(cleaned, origin) || opensNewTab) {
66
66
  out += ' target="_blank" rel="noopener noreferrer"';
67
+ out += ' class="external-link"';
67
68
  }
68
69
  out += `>${text}</a>`;
69
70
  return out;