@openpeepshq/react 0.4.0 → 0.5.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.
@@ -5,5 +5,5 @@ import { UnreadPostIndicator } from '../post/pieces/UnreadPostIndicator.js';
5
5
  export function ConversationMessageBubble({ message, unread = false, }) {
6
6
  const me = useCurrentProfile();
7
7
  const mine = message.profile.id === me?.id;
8
- return (_jsxs("div", { className: `mt-4 flex w-full items-center gap-2 ${mine ? 'justify-end' : 'justify-start'}`, children: [_jsx("div", { className: `w-[80%] rounded-t-xl p-3 md:w-[60%] ${mine ? 'bg-primary/10 rounded-bl-xl' : 'bg-surface-2 rounded-br-xl'}`, children: _jsx(FeedPostContent, { post: message }) }), !mine ? (_jsx(UnreadPostIndicator, { show: unread, className: "relative inset-auto shrink-0 translate-y-0" })) : null] }));
8
+ return (_jsxs("div", { className: `mt-4 flex w-full items-center gap-2 ${mine ? 'justify-end' : 'justify-start'}`, children: [_jsx("div", { className: `w-[80%] rounded-t-xl p-3 ${mine ? 'bg-primary/10 rounded-bl-xl' : 'bg-surface-2 rounded-br-xl'}`, children: _jsx(FeedPostContent, { post: message }) }), !mine ? (_jsx(UnreadPostIndicator, { show: unread, className: "relative inset-auto shrink-0 translate-y-0" })) : null] }));
9
9
  }
@@ -39,5 +39,5 @@ export function MessageInThread({ previous, message, multipleParticipants = true
39
39
  ? t('conversations.messageInThread.addedBy', { name })
40
40
  : t('conversations.messageInThread.startedBy', { name }) })), previous &&
41
41
  inAudience(previous, message.profile) &&
42
- !inAudience(message, message.profile) && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Avatar, { profile: message.profile, size: 2.5, borderless: true, navigate: true }), t('conversations.messageInThread.left', { name })] })), previous && added.length > 0 && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "flex -space-x-2", children: added.map((p) => (_jsx(Avatar, { profile: p, size: 2.5, borderless: true, navigate: true }, p.id))) }), t('conversations.messageInThread.addedBy', { name })] })), removedOthers.length > 0 && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "flex -space-x-2", children: removedOthers.map((p) => (_jsx(Avatar, { profile: p, size: 2.5, borderless: true, navigate: true }, p.id))) }), t('conversations.messageInThread.removedBy', { name })] })), _jsxs("article", { ref: postViewRef, className: "flex", children: [!isMe && multipleParticipants && (_jsx(Avatar, { containerClassName: "mt-6 mr-2", profile: message.profile, navigate: true })), _jsx("div", { className: "min-w-0 flex-1", children: _jsx(ConversationMessageBubble, { message: message, unread: isUnread }) })] }), _jsxs("div", { className: `mt-2 w-full text-sm ${isMe ? 'text-right' : 'text-left'}`, children: [multipleParticipants && !isMe && _jsxs("span", { children: [name, " \u00B7 "] }), _jsx(UpdatingDate, { date: message.createdAt })] })] }));
42
+ !inAudience(message, message.profile) && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Avatar, { profile: message.profile, size: 2.5, borderless: true, navigate: true }), t('conversations.messageInThread.left', { name })] })), previous && added.length > 0 && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "flex -space-x-2", children: added.map((p) => (_jsx(Avatar, { profile: p, size: 2.5, borderless: true, navigate: true }, p.id))) }), t('conversations.messageInThread.addedBy', { name })] })), removedOthers.length > 0 && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "flex -space-x-2", children: removedOthers.map((p) => (_jsx(Avatar, { profile: p, size: 2.5, borderless: true, navigate: true }, p.id))) }), t('conversations.messageInThread.removedBy', { name })] })), _jsxs("article", { ref: postViewRef, className: "flex", children: [!isMe && multipleParticipants && (_jsx(Avatar, { containerClassName: "mt-6 mr-2", profile: message.profile, size: 2.5, borderless: true, navigate: true })), _jsx("div", { className: "min-w-0 flex-1", children: _jsx(ConversationMessageBubble, { message: message, unread: isUnread }) })] }), _jsxs("div", { className: `mt-2 w-full text-sm ${isMe ? 'text-right' : 'text-left'}`, children: [multipleParticipants && !isMe && _jsxs("span", { children: [name, " \u00B7 "] }), _jsx(UpdatingDate, { date: message.createdAt })] })] }));
43
43
  }
@@ -1,4 +1,5 @@
1
1
  export interface PostDetailProps {
2
2
  postId: string;
3
+ occurrence?: string;
3
4
  }
4
- export declare function PostDetail({ postId }: PostDetailProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function PostDetail({ postId, occurrence }: PostDetailProps): import("react/jsx-runtime").JSX.Element;
@@ -6,13 +6,13 @@ import { FullArticle } from './types/article/FullArticle.js';
6
6
  import { FullPoll } from './types/poll/FullPoll.js';
7
7
  import { FullEvent } from './types/event/FullEvent.js';
8
8
  import { LoadingSpinner } from '@openpeepshq/react-ui';
9
- export function PostDetail({ postId }) {
9
+ export function PostDetail({ postId, occurrence }) {
10
10
  const t = useT();
11
11
  const { openpeepsApi } = useOpenpeeps();
12
12
  const postQuery = openpeepsApi.usePost(postId);
13
13
  const post = postQuery.data;
14
14
  if (postQuery.isLoading) {
15
- return (_jsx("div", { className: "flex h-32 items-center justify-center text-sm text-muted-foreground", children: _jsx(LoadingSpinner, {}) }));
15
+ return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: _jsx(LoadingSpinner, {}) }));
16
16
  }
17
17
  if (!post) {
18
18
  return (_jsx("div", { className: "flex h-full items-center justify-center p-8", children: _jsx("p", { className: "text-2xl font-bold", children: t('post.notFound', { defaultValue: 'Post not found' }) }) }));
@@ -21,7 +21,7 @@ export function PostDetail({ postId }) {
21
21
  case 'article':
22
22
  return _jsx(FullArticle, { post: post });
23
23
  case 'event':
24
- return _jsx(FullEvent, { post: post });
24
+ return _jsx(FullEvent, { post: post, occurrence: occurrence });
25
25
  case 'question':
26
26
  return _jsx(FullPoll, { post: post });
27
27
  case 'note':
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Avatar, ProfileLink } from '../../profile/index.js';
3
3
  import { UpdatingDate } from '@openpeepshq/react-ui';
4
4
  import { PostMenu } from './PostMenu.js';
5
- export function PostInfoHeader({ post, showMenu = false, deleteCallback, }) {
5
+ export function PostInfoHeader({ post, showMenu = true, deleteCallback, }) {
6
6
  const { profile } = post;
7
7
  return (_jsxs("div", { className: "flex justify-between py-2", children: [_jsxs("div", { className: "flex w-fit gap-2", children: [_jsx(ProfileLink, { profile: profile, children: _jsx(Avatar, { profile: profile, size: 3, borderless: true }) }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(ProfileLink, { profile: profile, className: "text-sm font-semibold hover:underline", children: profile.displayName || `@${profile.handle}` }), _jsxs("span", { className: "text-muted-foreground flex items-center gap-1 text-xs", children: ["@", profile.handle, _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsx(UpdatingDate, { date: post.createdAt })] })] })] }), showMenu && 'id' in post ? (_jsx(PostMenu, { post: post, deleteCallback: deleteCallback })) : null] }));
8
8
  }
@@ -4,4 +4,4 @@ export interface FullEventProps {
4
4
  /** Specific occurrence of a recurring event. */
5
5
  occurrence?: string;
6
6
  }
7
- export declare function FullEvent({ post }: FullEventProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function FullEvent({ post, occurrence }: FullEventProps): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Download, EyeOff, MoreHorizontal, Share, Trash2 } from 'lucide-react';
3
3
  import { useCallback, useMemo, useState } from 'react';
4
- import { useSearchParams } from 'react-router-dom';
5
4
  import { buildThreads, canAccessJamRecordings, canManageEventRsvps, canModerateJam, canViewJamAttendees, countYesRsvps, effectiveEventTimes, eventTimeZoneOptions, formatEventClockTime, formatEventRecurrence, getJamUrl, groupName, isCapacityEvent, parseOccurrenceQuery, listRsvpOccurrences, profileName, } from '@openpeepshq/common/lib';
6
5
  import { Button, Dialog, DialogActions, DialogContent, DialogHeader, DialogTitle, LoadingSpinner, UpdatingDate, } from '@openpeepshq/react-ui';
7
6
  import { useOpenpeeps } from '../../../../contexts/openpeeps/index.js';
@@ -23,13 +22,12 @@ import { EventRsvpButton } from '../../pieces/EventRsvpButton.js';
23
22
  import { EventRsvpList } from '../../pieces/EventRsvpList.js';
24
23
  import { ShareMenu } from '../../pieces/ShareMenu.js';
25
24
  import { VideoPlayer } from '../../pieces/VideoPlayer.js';
26
- export function FullEvent({ post }) {
25
+ export function FullEvent({ post, occurrence }) {
27
26
  const t = useT();
28
27
  const profile = useCurrentProfile();
29
28
  const serverInfo = useServerInfo();
30
29
  const livekitEnabled = serverInfo.jams.livekit.enabled;
31
- const [searchParams] = useSearchParams();
32
- const occurrenceId = parseOccurrenceQuery(searchParams.get('occurrence'));
30
+ const occurrenceId = parseOccurrenceQuery(occurrence);
33
31
  const { openCreateConversation } = useCreateNewConversation();
34
32
  const postViewRef = usePostViewRef(post.id);
35
33
  const { openpeepsApi, client } = useOpenpeeps();
@@ -12,5 +12,5 @@ export function PostPreview({ path }) {
12
12
  }
13
13
  if (!postQuery.data)
14
14
  return null;
15
- return (_jsxs(_Fragment, { children: [_jsx(PostInfoHeader, { post: postQuery.data }), _jsx(FeedPostContent, { post: postQuery.data })] }));
15
+ return (_jsxs(_Fragment, { children: [_jsx(PostInfoHeader, { post: postQuery.data, showMenu: false }), _jsx(FeedPostContent, { post: postQuery.data })] }));
16
16
  }
@@ -1,5 +1,5 @@
1
- import type { PublicProfile } from '@openpeepshq/common/types';
2
- export declare const useFollowProfile: (profile: PublicProfile, onSuccess?: () => void) => {
1
+ import type { PublicProfile, Profile } from '@openpeepshq/common/types';
2
+ export declare const useFollowProfile: (profile: PublicProfile | Profile, onSuccess?: () => void) => {
3
3
  me: import("@openpeepshq/common").ProfileWithMeta | undefined;
4
4
  isSelf: boolean;
5
5
  isFollowing: boolean;
@@ -1,12 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
- import { Link, useParams } from 'react-router-dom';
3
+ import { Link, useSearchParams, useParams } from 'react-router-dom';
4
+ import { parseOccurrenceQuery } from '@openpeepshq/common/lib';
4
5
  import { useT, useSetPageHeader } from '../index.js';
5
6
  import { usePostDetailTitle } from '../hooks/posts/usePostDetailTitle.js';
6
7
  import { PostDetail as PostDetailComponent } from '../components/index.js';
7
8
  export function PostDetail() {
8
9
  const t = useT();
9
10
  const { postId = '' } = useParams();
11
+ const [searchParams] = useSearchParams();
12
+ const occurrence = parseOccurrenceQuery(searchParams.get('occurrence'));
10
13
  const { kindTitle, groupHandle, groupLabel, inGroup } = usePostDetailTitle(postId);
11
14
  const title = useMemo(() => {
12
15
  if (!inGroup)
@@ -14,5 +17,5 @@ export function PostDetail() {
14
17
  return (_jsxs("h1", { className: "flex min-w-0 items-baseline gap-x-1 text-xl font-semibold", children: [_jsx("span", { className: "truncate", children: kindTitle }), _jsx("span", { className: "shrink-0", children: t('post.detail.inGroup', { defaultValue: 'in' }) }), _jsx(Link, { to: `/groups/@${groupHandle}`, className: "text-primary min-w-0 truncate hover:underline", children: groupLabel })] }));
15
18
  }, [groupHandle, groupLabel, inGroup, kindTitle, t]);
16
19
  useSetPageHeader(title);
17
- return _jsx(PostDetailComponent, { postId: postId });
20
+ return _jsx(PostDetailComponent, { postId: postId, occurrence: occurrence });
18
21
  }
@@ -10,6 +10,8 @@ export * from './lib/analyticsClicks';
10
10
  export * from './lib/unseenCountsOptimistic';
11
11
  export * from './lib/postUnread';
12
12
  export * from './lib/notificationBadge';
13
+ export { getInitials, hueFromHandle, initialsBackground, } from './lib/initialsAvatar';
14
+ export { svgCoverSrc } from './lib/svgCover';
13
15
  export * from './lib/capabilityMatrix';
14
16
  export * from './lib/groupFormErrors';
15
17
  export * from './lib/passwordStrength';
@@ -10,6 +10,8 @@ export * from './lib/analyticsClicks.js';
10
10
  export * from './lib/unseenCountsOptimistic.js';
11
11
  export * from './lib/postUnread.js';
12
12
  export * from './lib/notificationBadge.js';
13
+ export { getInitials, hueFromHandle, initialsBackground, } from './lib/initialsAvatar.js';
14
+ export { svgCoverSrc } from './lib/svgCover.js';
13
15
  export * from './lib/capabilityMatrix.js';
14
16
  export * from './lib/groupFormErrors.js';
15
17
  export * from './lib/passwordStrength.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/react",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -51,9 +51,9 @@
51
51
  "simple-icons": "^16.31.0",
52
52
  "uuidv7": "^1.0.2",
53
53
  "@openpeepshq/client": "^0.2.0",
54
- "@openpeepshq/react-ui": "^0.2.0",
55
- "@openpeepshq/greenscreen": "^0.2.0",
56
- "@openpeepshq/common": "^0.2.0"
54
+ "@openpeepshq/common": "^0.2.0",
55
+ "@openpeepshq/react-ui": "^0.3.0",
56
+ "@openpeepshq/greenscreen": "^0.2.0"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "react": "^18.3.0 || ^19.0.0",
@@ -18,7 +18,7 @@ export function ConversationMessageBubble({
18
18
  className={`mt-4 flex w-full items-center gap-2 ${mine ? 'justify-end' : 'justify-start'}`}
19
19
  >
20
20
  <div
21
- className={`w-[80%] rounded-t-xl p-3 md:w-[60%] ${
21
+ className={`w-[80%] rounded-t-xl p-3 ${
22
22
  mine ? 'bg-primary/10 rounded-bl-xl' : 'bg-surface-2 rounded-br-xl'
23
23
  }`}
24
24
  >
@@ -101,6 +101,8 @@ export function MessageInThread({
101
101
  <Avatar
102
102
  containerClassName="mt-6 mr-2"
103
103
  profile={message.profile}
104
+ size={2.5}
105
+ borderless
104
106
  navigate
105
107
  />
106
108
  )}
@@ -8,9 +8,10 @@ import { LoadingSpinner } from '@openpeepshq/react-ui';
8
8
 
9
9
  export interface PostDetailProps {
10
10
  postId: string;
11
+ occurrence?: string;
11
12
  }
12
13
 
13
- export function PostDetail({ postId }: PostDetailProps) {
14
+ export function PostDetail({ postId, occurrence }: PostDetailProps) {
14
15
  const t = useT();
15
16
  const { openpeepsApi } = useOpenpeeps();
16
17
  const postQuery = openpeepsApi.usePost(postId);
@@ -18,9 +19,9 @@ export function PostDetail({ postId }: PostDetailProps) {
18
19
 
19
20
  if (postQuery.isLoading) {
20
21
  return (
21
- <div className="flex h-32 items-center justify-center text-sm text-muted-foreground">
22
+ <div className="text-muted-foreground flex h-32 items-center justify-center text-sm">
22
23
  <LoadingSpinner />
23
- </div>
24
+ </div>
24
25
  );
25
26
  }
26
27
 
@@ -38,7 +39,7 @@ export function PostDetail({ postId }: PostDetailProps) {
38
39
  case 'article':
39
40
  return <FullArticle post={post} />;
40
41
  case 'event':
41
- return <FullEvent post={post} />;
42
+ return <FullEvent post={post} occurrence={occurrence} />;
42
43
  case 'question':
43
44
  return <FullPoll post={post} />;
44
45
  case 'note':
@@ -11,7 +11,7 @@ export interface PostInfoHeaderProps {
11
11
 
12
12
  export function PostInfoHeader({
13
13
  post,
14
- showMenu = false,
14
+ showMenu = true,
15
15
  deleteCallback,
16
16
  }: PostInfoHeaderProps) {
17
17
  const { profile } = post;
@@ -1,6 +1,5 @@
1
1
  import { Download, EyeOff, MoreHorizontal, Share, Trash2 } from 'lucide-react';
2
2
  import { useCallback, useMemo, useState } from 'react';
3
- import { useSearchParams } from 'react-router-dom';
4
3
  import type {
5
4
  Event,
6
5
  JamRecording,
@@ -68,13 +67,12 @@ type EventTab =
68
67
  | 'attendees'
69
68
  | 'recordings';
70
69
 
71
- export function FullEvent({ post }: FullEventProps) {
70
+ export function FullEvent({ post, occurrence }: FullEventProps) {
72
71
  const t = useT();
73
72
  const profile = useCurrentProfile();
74
73
  const serverInfo = useServerInfo();
75
74
  const livekitEnabled = serverInfo.jams.livekit.enabled;
76
- const [searchParams] = useSearchParams();
77
- const occurrenceId = parseOccurrenceQuery(searchParams.get('occurrence'));
75
+ const occurrenceId = parseOccurrenceQuery(occurrence);
78
76
  const { openCreateConversation } = useCreateNewConversation();
79
77
  const postViewRef = usePostViewRef(post.id);
80
78
  const { openpeepsApi, client } = useOpenpeeps();
@@ -24,7 +24,7 @@ export function PostPreview({ path }: PostPreviewProps) {
24
24
 
25
25
  return (
26
26
  <>
27
- <PostInfoHeader post={postQuery.data} />
27
+ <PostInfoHeader post={postQuery.data} showMenu={false} />
28
28
  <FeedPostContent post={postQuery.data} />
29
29
  </>
30
30
  );
@@ -1,9 +1,9 @@
1
- import type { PublicProfile } from '@openpeepshq/common/types';
1
+ import type { PublicProfile, Profile } from '@openpeepshq/common/types';
2
2
  import { useOpenpeeps } from '../../contexts/openpeeps';
3
3
  import { useCurrentProfile } from '../../components/layout/IdentityContext';
4
4
 
5
5
  export const useFollowProfile = (
6
- profile: PublicProfile,
6
+ profile: PublicProfile | Profile,
7
7
  onSuccess?: () => void,
8
8
  ) => {
9
9
  const me = useCurrentProfile();
@@ -1,5 +1,6 @@
1
1
  import { useMemo, type ReactNode } from 'react';
2
- import { Link, useParams } from 'react-router-dom';
2
+ import { Link, useSearchParams, useParams } from 'react-router-dom';
3
+ import { parseOccurrenceQuery } from '@openpeepshq/common/lib';
3
4
  import { useT, useSetPageHeader } from '../index';
4
5
  import { usePostDetailTitle } from '../hooks/posts/usePostDetailTitle';
5
6
  import { PostDetail as PostDetailComponent } from '../components';
@@ -7,6 +8,8 @@ import { PostDetail as PostDetailComponent } from '../components';
7
8
  export function PostDetail() {
8
9
  const t = useT();
9
10
  const { postId = '' } = useParams<{ postId: string }>();
11
+ const [searchParams] = useSearchParams();
12
+ const occurrence = parseOccurrenceQuery(searchParams.get('occurrence'));
10
13
  const { kindTitle, groupHandle, groupLabel, inGroup } =
11
14
  usePostDetailTitle(postId);
12
15
 
@@ -31,5 +34,5 @@ export function PostDetail() {
31
34
 
32
35
  useSetPageHeader(title);
33
36
 
34
- return <PostDetailComponent postId={postId} />;
37
+ return <PostDetailComponent postId={postId} occurrence={occurrence} />;
35
38
  }
@@ -10,6 +10,12 @@ export * from './lib/analyticsClicks';
10
10
  export * from './lib/unseenCountsOptimistic';
11
11
  export * from './lib/postUnread';
12
12
  export * from './lib/notificationBadge';
13
+ export {
14
+ getInitials,
15
+ hueFromHandle,
16
+ initialsBackground,
17
+ } from './lib/initialsAvatar';
18
+ export { svgCoverSrc } from './lib/svgCover';
13
19
  export * from './lib/capabilityMatrix';
14
20
  export * from './lib/groupFormErrors';
15
21
  export * from './lib/passwordStrength';