@openpeepshq/rn-components 0.3.5 → 0.3.7

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 (39) hide show
  1. package/README.md +2 -2
  2. package/metro/resolve-asset-source.js +19 -0
  3. package/metro.js +20 -1
  4. package/package.json +2 -2
  5. package/src/components/custom/common/empty-state-container.tsx +42 -114
  6. package/src/components/custom/headers/tab-screens-header.tsx +3 -4
  7. package/src/components/custom/navigation/side-menu.tsx +2 -2
  8. package/src/components/navigation/auth-wrapper.tsx +1 -1
  9. package/src/components/notifications/NotificationItem.tsx +1 -1
  10. package/src/components/notifications/NotificationsList.tsx +5 -1
  11. package/src/components/post/Feed.tsx +3 -1
  12. package/src/components/post/FeedPost.tsx +32 -37
  13. package/src/components/post/FeedPostContent.tsx +6 -8
  14. package/src/components/post/feed/events/EventsFeed.tsx +1 -0
  15. package/src/components/post/pieces/PostActions.tsx +46 -121
  16. package/src/components/post/pieces/PostInfoHeader.tsx +9 -5
  17. package/src/components/post/post-form/Footer.tsx +47 -64
  18. package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +3 -0
  19. package/src/components/post/post-form/PollComposerFields.tsx +2 -2
  20. package/src/components/post/post-form/PostForm.tsx +133 -129
  21. package/src/components/post/types/Note.tsx +1 -1
  22. package/src/components/post/types/Poll.tsx +1 -1
  23. package/src/components/post/types/article/CardArticle.tsx +1 -1
  24. package/src/components/post/types/event/CardEvent.tsx +1 -1
  25. package/src/components/post/types/event/FullEvent.tsx +21 -20
  26. package/src/components/profile/ProfileCard.tsx +1 -1
  27. package/src/components/profile/ProfileHeader.tsx +8 -10
  28. package/src/pages/Explore.tsx +30 -5
  29. package/src/pages/Members.tsx +2 -2
  30. package/src/pages/conversations/Index.tsx +1 -1
  31. package/src/pages/conversations/New.tsx +8 -1
  32. package/src/pages/groups/Index.tsx +8 -1
  33. package/src/pages/groups/Info.tsx +4 -4
  34. package/src/pages/groups/Show.tsx +42 -3
  35. package/src/pages/posts/Edit.tsx +43 -5
  36. package/src/pages/posts/New.tsx +121 -74
  37. package/src/pages/posts/Reply.tsx +77 -49
  38. package/src/pages/profile/Followers.tsx +4 -1
  39. package/src/pages/profile/Following.tsx +4 -1
package/README.md CHANGED
@@ -14,9 +14,9 @@ pnpm add @openpeepshq/rn-components
14
14
 
15
15
  Wrap your app with **`OpenpeepsProvider`** from `@openpeepshq/rn-components` (and a credentials store + `baseUrl`) so `useOpenpeeps()` and theme code work. This re-exports the web provider from `@openpeepshq/react` with React Native `AppState` foreground handling wired in — do not import `OpenpeepsProvider` from `@openpeepshq/react` in native apps.
16
16
 
17
- Configure **NativeWind** / Tailwind in the app (include this package in Tailwind `content`), load `src/global.css` from your entry, and supply **`react-native-config`** (or compatible env) for `BASE_URL` and related keys used by `~/lib/constants`.
17
+ Configure **NativeWind** / Tailwind in the app (include this package in Tailwind `content`), load `src/global.css` from your entry, and supply **`react-native-config`** (or compatible env) for `BASE_URL` and related keys.
18
18
 
19
- Wrap Metro with **`withOpenPeepsMetro`** (outside `withNativeWind`) so css-interop observables defer on React 19. Hosts should not patch `react-native-css-interop`.
19
+ Wrap Metro with **`withOpenPeepsMetro`** (outside `withNativeWind`) so css-interop observables defer on React 19 and `react-native-sound` 0.11.x can `require()` RN 0.80+ `resolveAssetSource`. Hosts should not patch `react-native-css-interop` or `react-native-sound`.
20
20
 
21
21
  ```js
22
22
  const { withNativeWind } = require('nativewind/metro');
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * RN >= 0.80 ships `Libraries/Image/resolveAssetSource` as ESM
5
+ * (`export default`). CJS `require()` then returns `{ default: fn }`
6
+ * instead of the function. `react-native-sound` 0.11.x calls the require
7
+ * result directly. Unwrap here so hosts do not patch that package.
8
+ *
9
+ * 0.12+ has this fix upstream but drops old-arch natives and has RN 0.82+
10
+ * Android codegen issues; community apps stay on 0.11.2 + this shim.
11
+ */
12
+ const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
13
+
14
+ module.exports =
15
+ typeof resolveAssetSource === 'function'
16
+ ? resolveAssetSource
17
+ : resolveAssetSource && typeof resolveAssetSource.default === 'function'
18
+ ? resolveAssetSource.default
19
+ : resolveAssetSource;
package/metro.js CHANGED
@@ -11,11 +11,21 @@ const patchedObservable = path.join(
11
11
  const CSS_INTEROP_OBSERVABLE_RE =
12
12
  /[/\\]react-native-css-interop[/\\]dist[/\\]runtime[/\\]observable\.js$/;
13
13
 
14
+ const SOUND_PACKAGE_RE = /[/\\]react-native-sound[/\\]/;
15
+
16
+ const patchedResolveAssetSource = path.join(
17
+ __dirname,
18
+ 'metro',
19
+ 'resolve-asset-source.js',
20
+ );
21
+
14
22
  /**
15
23
  * Metro wrapper for OpenPeeps community apps.
16
24
  *
17
25
  * Substitutes css-interop's synchronous observable with a React 19-safe
18
- * `queueMicrotask` implementation so hosts do not patch `node_modules`.
26
+ * `queueMicrotask` implementation, and unwraps RN 0.80+ ESM
27
+ * `resolveAssetSource` for `react-native-sound` 0.11.x, so hosts do not
28
+ * patch `node_modules`.
19
29
  *
20
30
  * Apply this *outside* other Metro wrappers so their `resolveRequest`
21
31
  * still runs:
@@ -29,6 +39,15 @@ const withOpenPeepsMetro = (config) => {
29
39
  resolver: {
30
40
  ...config.resolver,
31
41
  resolveRequest: (context, moduleName, platform) => {
42
+ if (
43
+ moduleName === 'react-native/Libraries/Image/resolveAssetSource' &&
44
+ SOUND_PACKAGE_RE.test(context.originModulePath || '')
45
+ ) {
46
+ return {
47
+ filePath: patchedResolveAssetSource,
48
+ type: 'sourceFile',
49
+ };
50
+ }
32
51
  const result = previous
33
52
  ? previous(context, moduleName, platform)
34
53
  : context.resolveRequest(context, moduleName, platform);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/rn-components",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./src/index.ts",
@@ -141,7 +141,7 @@
141
141
  "validator": "^13.15.23",
142
142
  "zustand": "^5.0.3",
143
143
  "@openpeepshq/common": "^0.2.0",
144
- "@openpeepshq/react": "^0.3.0"
144
+ "@openpeepshq/react": "^0.3.1"
145
145
  },
146
146
  "devDependencies": {
147
147
  "@babel/core": "^7.26.7",
@@ -1,5 +1,6 @@
1
1
  import { View } from 'react-native';
2
2
  import React from 'react';
3
+ import { useTranslation } from 'react-i18next';
3
4
  import { ThemedText } from '../../ui/themed-text';
4
5
  import {
5
6
  BellOffIcon,
@@ -10,121 +11,48 @@ import {
10
11
  UserRoundXIcon,
11
12
  } from '../../icons/index';
12
13
  import { EmptyStateContainerType } from '../../../types';
14
+
13
15
  interface EmptyStateContainerProps {
14
16
  type: EmptyStateContainerType;
17
+ copyKey: string;
18
+ defaultValue?: string;
15
19
  }
16
- export const EmptyStateContainer = ({ type }: EmptyStateContainerProps) => {
17
- switch (type) {
18
- case 'posts':
19
- return (
20
- <View className="flex flex-1 h-64 items-center justify-center">
21
- <RssIcon size={64} className="text-foreground" />
22
- <ThemedText className="mt-6">No posts yet</ThemedText>
23
- </View>
24
- );
25
- case 'reply':
26
- return (
27
- <View className="flex flex-1 h-64 items-center justify-center">
28
- <RssIcon size={64} className="text-foreground" />
29
- <ThemedText className="mt-6">No replies yet</ThemedText>
30
- </View>
31
- );
32
- case 'events':
33
- return (
34
- <View className="flex flex-1 h-64 items-center justify-center">
35
- <CalendarXIcon size={64} className="text-foreground" />
36
- <ThemedText className="mt-6">No events yet</ThemedText>
37
- </View>
38
- );
39
- case 'groups':
40
- return (
41
- <View className="flex flex-1 h-64 items-center justify-center">
42
- <UserRoundXIcon size={64} className="text-foreground" />
43
- <ThemedText className="mt-6">No Groups Found</ThemedText>
44
- </View>
45
- );
46
- case 'profiles':
47
- return (
48
- <View className="flex flex-1 h-64 items-center justify-center">
49
- <UserRoundXIcon size={64} className="text-foreground" />
50
- <ThemedText className="mt-6">No Profile Found</ThemedText>
51
- </View>
52
- );
53
- case 'followers':
54
- return (
55
- <View className="flex flex-1 h-64 items-center justify-center">
56
- <UserRoundXIcon size={64} className="text-foreground" />
57
- <ThemedText className="mt-6">No followers yet</ThemedText>
58
- </View>
59
- );
60
- case 'following':
61
- return (
62
- <View className="flex flex-1 h-64 items-center justify-center">
63
- <UserRoundXIcon size={64} className="text-foreground" />
64
- <ThemedText className="mt-6">No followings yet</ThemedText>
65
- </View>
66
- );
67
- case 'messages':
68
- return (
69
- <View className="flex flex-1 h-64 items-center justify-center">
70
- <MessageSquareOffIcon size={64} className="text-foreground" />
71
- <ThemedText className="mt-6">No conversations here</ThemedText>
72
- </View>
73
- );
74
- case 'notifications':
75
- return (
76
- <View className="flex flex-1 h-64 items-center justify-center">
77
- <BellOffIcon size={64} className="text-foreground" />
78
- <ThemedText className="mt-6">No Notifications yet</ThemedText>
79
- </View>
80
- );
81
- case 'live-jams':
82
- return (
83
- <View className="flex flex-1 h-64 items-center justify-center">
84
- <PhoneOffIcon size={64} className="text-foreground" />
85
- <ThemedText className="mt-6">No live jam to join yet</ThemedText>
86
- </View>
87
- );
88
- case 'upcoming-jams':
89
- return (
90
- <View className="flex flex-1 h-64 items-center justify-center">
91
- <PhoneOffIcon size={64} className="text-foreground" />
92
- <ThemedText className="mt-6">No upcoming jams yet</ThemedText>
93
- </View>
94
- );
95
- case 'my-jams':
96
- return (
97
- <View className="flex flex-1 h-64 items-center justify-center">
98
- <PhoneOffIcon size={64} className="text-foreground" />
99
- <ThemedText className="mt-6">No jams yet</ThemedText>
100
- </View>
101
- );
102
- case 'recorded-jams':
103
- return (
104
- <View className="flex flex-1 h-64 items-center justify-center">
105
- <PhoneOffIcon size={64} className="text-foreground" />
106
- <ThemedText className="mt-6">No jams yet</ThemedText>
107
- </View>
108
- );
109
- case 'event-attendees':
110
- return (
111
- <View className="flex flex-1 h-64 items-center justify-center">
112
- <UserRoundXIcon size={64} className="text-foreground" />
113
- <ThemedText className="mt-6">No attendees yet</ThemedText>
114
- </View>
115
- );
116
- case 'event-description':
117
- return (
118
- <View className="flex flex-1 h-64 items-center justify-center">
119
- <RssIcon size={64} className="text-foreground" />
120
- <ThemedText className="mt-6">No description added</ThemedText>
121
- </View>
122
- );
123
- default:
124
- return (
125
- <View className="flex flex-1 h-64 items-center justify-center">
126
- <ThemedText className="mt-6">Empty State Container</ThemedText>
127
- </View>
128
- );
129
- }
20
+
21
+ export const EmptyStateContainer = ({
22
+ type,
23
+ copyKey,
24
+ defaultValue,
25
+ }: EmptyStateContainerProps) => {
26
+ const { t } = useTranslation();
27
+ const iconClass = 'text-muted-foreground';
28
+ const icon =
29
+ type === 'events' ? (
30
+ <CalendarXIcon size={80} className={iconClass} />
31
+ ) : type === 'messages' ? (
32
+ <MessageSquareOffIcon size={80} className={iconClass} />
33
+ ) : type === 'notifications' ? (
34
+ <BellOffIcon size={80} className={iconClass} />
35
+ ) : type === 'live-jams' ||
36
+ type === 'upcoming-jams' ||
37
+ type === 'my-jams' ||
38
+ type === 'recorded-jams' ? (
39
+ <PhoneOffIcon size={80} className={iconClass} />
40
+ ) : type === 'groups' ||
41
+ type === 'profiles' ||
42
+ type === 'followers' ||
43
+ type === 'following' ||
44
+ type === 'event-attendees' ? (
45
+ <UserRoundXIcon size={80} className={iconClass} />
46
+ ) : (
47
+ <RssIcon size={80} className={iconClass} />
48
+ );
49
+
50
+ return (
51
+ <View className="h-96 w-full flex-col items-center justify-center gap-y-4 bg-surface">
52
+ {icon}
53
+ <ThemedText className="text-xl">
54
+ {t(copyKey, defaultValue ? { defaultValue } : undefined)}
55
+ </ThemedText>
56
+ </View>
57
+ );
130
58
  };
@@ -11,8 +11,7 @@ import {
11
11
  import { ThemedText } from '../../ui/themed-text';
12
12
  import { Avatar, AvatarImage, AvatarFallback } from '../../ui/avatar';
13
13
  import { Button } from '../../ui/button';
14
- import { BellIcon } from '../../icons/index';
15
- import { User } from 'lucide-react-native';
14
+ import { BellIcon, UserIcon } from '../../icons/index';
16
15
  import { useDrawer } from '../../../contexts/drawer-context';
17
16
  import { formatBadgeCount } from '@openpeepshq/common';
18
17
  import { useOpenpeeps } from '@openpeepshq/react';
@@ -104,7 +103,7 @@ export const TabScreensHeader = ({
104
103
  <SafeAreaView edges={['top']} className="">
105
104
  {!isProduction && (
106
105
  <View className="mb-2 w-full rounded-lg bg-white/50 p-2">
107
- <ThemedText className="text-center text-red-500">
106
+ <ThemedText className="text-center text-destructive">
108
107
  Test Backend ({BASE_URL})
109
108
  </ThemedText>
110
109
  </View>
@@ -125,7 +124,7 @@ export const TabScreensHeader = ({
125
124
  <AvatarImage source={{ uri: currentProfile.avatar }} />
126
125
  ) : (
127
126
  <AvatarFallback className="h-6 w-6 -bottom-2 -right-2 bg-black">
128
- <User size={20} color="#a3a5aaff" />
127
+ <UserIcon size={20} className="text-muted-foreground" />
129
128
  </AvatarFallback>
130
129
  )}
131
130
  </Avatar>
@@ -242,8 +242,8 @@ export const SideMenu = ({
242
242
  close?.();
243
243
  }}
244
244
  >
245
- <LogOutIcon size={20} className="text-red-700 mr-5" />
246
- <ThemedText className="text-red-700 native:text-lg tracking-wider -mt-1">
245
+ <LogOutIcon size={20} className="mr-5 text-destructive" />
246
+ <ThemedText className="-mt-1 tracking-wider text-destructive native:text-lg">
247
247
  {t('navigation.logOut')}
248
248
  </ThemedText>
249
249
  </Button>
@@ -13,7 +13,7 @@ import { toAbsoluteMediaUrl } from '../../lib/media-url';
13
13
  const DevBanner = () =>
14
14
  (!isProduction && (
15
15
  <View className="absolute bg-white/80 z-10 ml-8 mr-8 w-auto top-64 p-4 rounded-lg">
16
- <ThemedText className="text-red-800 text-center">
16
+ <ThemedText className="text-center text-destructive">
17
17
  Test Backend ({BASE_URL})
18
18
  </ThemedText>
19
19
  </View>
@@ -64,7 +64,7 @@ export const NotificationItem: React.FC<NotificationComponentProps> = ({
64
64
  if (!NotificationToRender) {
65
65
  return (
66
66
  <View className="p-4">
67
- <ThemedText className="text-red-500 font-bold">
67
+ <ThemedText className="font-bold text-destructive">
68
68
  Unknown notification type: {notification.type}
69
69
  </ThemedText>
70
70
  </View>
@@ -61,7 +61,11 @@ export const NotificationsList = ({
61
61
  {query.isFetchingNextPage && <ActivityIndicator size={'small'} />}
62
62
  </>
63
63
  ) : (
64
- <EmptyStateContainer type="notifications" />
64
+ <EmptyStateContainer
65
+ type="notifications"
66
+ copyKey="notification.empty"
67
+ defaultValue="No notifications"
68
+ />
65
69
  )}
66
70
  </>
67
71
  )}
@@ -82,7 +82,9 @@ export const Feed = ({
82
82
  );
83
83
  })}
84
84
  </View>
85
- {allPosts.length === 0 && <EmptyStateContainer type={type} />}
85
+ {allPosts.length === 0 && !pinnedPostId && (
86
+ <EmptyStateContainer type={type} copyKey="feed.empty" />
87
+ )}
86
88
  {query.isFetchingNextPage && <CustomLoader page="community" />}
87
89
  </>
88
90
  )}
@@ -2,6 +2,7 @@ import { type PublicPost } from '@openpeepshq/common';
2
2
  import { useFeedPostPresentation } from '@openpeepshq/react';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
5
+ import { Pressable } from 'react-native';
5
6
  import { MainStackParamList } from '../navigation/types/index';
6
7
  import {
7
8
  PostInfoHeader,
@@ -73,45 +74,39 @@ export const FeedPost = ({
73
74
  }
74
75
 
75
76
  return (
76
- <ThemedView
77
- ref={postViewRef}
78
- className="relative py-5 border-b border-border"
79
- >
80
- <UnreadPostIndicator show={isUnread} />
81
- {hasReactionHeader && (
82
- <PostReactionHeader
83
- post={post}
84
- inGroup={inGroup}
85
- hideReply={hideReply}
86
- previewMode={previewMode}
87
- />
88
- )}
89
- {showsReplyTo && displayedPost.replyTo ? (
90
- <CompactReplyParent post={displayedPost.replyTo as PublicPost} />
91
- ) : null}
77
+ <Pressable disabled={previewMode} onPress={handlePostPress}>
78
+ <ThemedView
79
+ ref={postViewRef}
80
+ className="relative border-b border-border p-4"
81
+ >
82
+ <UnreadPostIndicator show={isUnread} />
83
+ {hasReactionHeader && (
84
+ <PostReactionHeader
85
+ post={post}
86
+ inGroup={inGroup}
87
+ hideReply={hideReply}
88
+ previewMode={previewMode}
89
+ />
90
+ )}
91
+ {showsReplyTo && displayedPost.replyTo ? (
92
+ <CompactReplyParent post={displayedPost.replyTo as PublicPost} />
93
+ ) : null}
92
94
 
93
- <PostInfoHeader
94
- post={displayedPost}
95
- showMenu={!post.repost && !post.inReplyToId && !previewMode && showMenu}
96
- deleteCallback={deleteCallback}
97
- />
95
+ <PostInfoHeader
96
+ post={displayedPost}
97
+ showMenu={!hasReactionHeader && !previewMode && showMenu}
98
+ deleteCallback={deleteCallback}
99
+ />
98
100
 
99
- <ThemedView className="px-5">
100
- {content ?? <FeedPostContent post={displayedPost} />}
101
- </ThemedView>
102
- {hasStats && (
103
- <ThemedView className="px-5">
104
- <FeedPostStats post={displayedPost} />
101
+ <ThemedView>
102
+ {content ?? <FeedPostContent post={displayedPost} />}
105
103
  </ThemedView>
106
- )}
107
- <PostActions
108
- post={displayedPost}
109
- previewMode={previewMode}
110
- onPostPress={handlePostPress}
111
- />
112
- {!hideReply && showThreadPreview ? (
113
- <FeedThreadPreview post={displayedPost} />
114
- ) : null}
115
- </ThemedView>
104
+ {hasStats && <FeedPostStats post={displayedPost} />}
105
+ <PostActions post={displayedPost} previewMode={previewMode} />
106
+ {!hideReply && showThreadPreview ? (
107
+ <FeedThreadPreview post={displayedPost} />
108
+ ) : null}
109
+ </ThemedView>
110
+ </Pressable>
116
111
  );
117
112
  };
@@ -25,7 +25,11 @@ export const FeedPostContent = ({ post }: FeedPostContentProps) => {
25
25
  }
26
26
  if (post.deletedAt) {
27
27
  return (
28
- <View className="text-sm text-gray-500">This post has been deleted.</View>
28
+ <View>
29
+ <ThemedText className="text-sm text-muted-foreground">
30
+ {t('posts.compact.deleted')}
31
+ </ThemedText>
32
+ </View>
29
33
  );
30
34
  }
31
35
  if (post.type === 'note') {
@@ -40,11 +44,5 @@ export const FeedPostContent = ({ post }: FeedPostContentProps) => {
40
44
  if (post.type === 'article') {
41
45
  return <FeedArticle {...{ post }} />;
42
46
  }
43
- return (
44
- <View>
45
- <ThemedText className="text-red-500">
46
- This post type is not supported.
47
- </ThemedText>
48
- </View>
49
- );
47
+ return null;
50
48
  };
@@ -67,6 +67,7 @@ export const EventsFeed = ({ query, searchQuery, type = 'event' }: Props) => {
67
67
  ) : (
68
68
  <EmptyStateContainer
69
69
  type={type === 'event' ? 'events' : 'my-jams'}
70
+ copyKey="feed.empty"
70
71
  />
71
72
  )}
72
73
  </>