@openpeepshq/rn-components 0.3.13 → 0.4.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.
- package/package.json +2 -2
- package/src/components/configuration/ConfigMenuButton.tsx +6 -2
- package/src/components/navigation/nativeRouter.tsx +30 -0
- package/src/components/notifications/NotificationWrapper.tsx +2 -2
- package/src/components/notifications/NotificationsList.tsx +15 -4
- package/src/components/post/FeedPost.tsx +4 -1
- package/src/components/post/NewEventButton.tsx +4 -0
- package/src/components/post/NewNoteButton.tsx +2 -0
- package/src/components/post/pieces/UnreadPostIndicator.tsx +15 -2
- package/src/components/post/types/Article.tsx +2 -2
- package/src/components/post/types/Note.tsx +2 -2
- package/src/components/post/types/Poll.tsx +4 -2
- package/src/components/post/types/article/CardArticle.tsx +1 -1
- package/src/components/post/types/event/CardEvent.tsx +1 -1
- package/src/components/post/types/event/FullEvent.tsx +1 -1
- package/src/components/post/types/event/ProfileEventRelationship.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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.
|
|
144
|
+
"@openpeepshq/react": "^0.4.0"
|
|
145
145
|
},
|
|
146
146
|
"devDependencies": {
|
|
147
147
|
"@babel/core": "^7.26.7",
|
|
@@ -6,7 +6,10 @@ import { ChevronRightIcon } from '../icons/index';
|
|
|
6
6
|
|
|
7
7
|
export interface ConfigMenuButtonProps {
|
|
8
8
|
translationPrefix: string;
|
|
9
|
-
|
|
9
|
+
/** URL path (web). On RN, use onPress instead — URL navigation is not supported. */
|
|
10
|
+
action?: string;
|
|
11
|
+
/** Click handler. */
|
|
12
|
+
onPress?: () => void;
|
|
10
13
|
titleFallback?: string;
|
|
11
14
|
descriptionFallback?: string;
|
|
12
15
|
}
|
|
@@ -19,9 +22,10 @@ export const ConfigMenuButton = ({
|
|
|
19
22
|
descriptionFallback,
|
|
20
23
|
}: ConfigMenuButtonProps) => {
|
|
21
24
|
const { t } = useTranslation();
|
|
25
|
+
const handlePress = onPress ?? (() => {});
|
|
22
26
|
return (
|
|
23
27
|
<Pressable
|
|
24
|
-
onPress={
|
|
28
|
+
onPress={handlePress}
|
|
25
29
|
className="py-2 mb-2 flex-row justify-between items-center gap-x-4"
|
|
26
30
|
>
|
|
27
31
|
<View className="flex-1">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
+
import { Linking } from 'react-native';
|
|
2
3
|
import {
|
|
3
4
|
CommonActions,
|
|
4
5
|
createNavigationContainerRef,
|
|
@@ -188,6 +189,35 @@ export const navigateToTarget = (target: NavTarget) => {
|
|
|
188
189
|
go('Auth', { screen: 'Login' });
|
|
189
190
|
}
|
|
190
191
|
break;
|
|
192
|
+
case 'admin':
|
|
193
|
+
// RN has no admin screens — fall back to settings tab.
|
|
194
|
+
go('Main', { screen: 'TabNavigator', params: { screen: 'Settings' } });
|
|
195
|
+
break;
|
|
196
|
+
case 'docs':
|
|
197
|
+
// Docs are web-only; open in the system browser.
|
|
198
|
+
if (target.path) {
|
|
199
|
+
Linking.openURL(
|
|
200
|
+
target.path.startsWith('/') ? `${target.path}` : target.path
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
case 'paymentSuccess':
|
|
205
|
+
go('Main', { screen: 'TabNavigator', params: { screen: 'Onboarding' } });
|
|
206
|
+
break;
|
|
207
|
+
case 'external':
|
|
208
|
+
Linking.openURL(target.href);
|
|
209
|
+
break;
|
|
210
|
+
case 'path':
|
|
211
|
+
// Try to open as a URL; if it's a local path, fall back to home.
|
|
212
|
+
if (
|
|
213
|
+
target.path.startsWith('http://') ||
|
|
214
|
+
target.path.startsWith('https://')
|
|
215
|
+
) {
|
|
216
|
+
Linking.openURL(target.path);
|
|
217
|
+
} else {
|
|
218
|
+
go('Main', { screen: 'TabNavigator', params: { screen: 'Home' } });
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
191
221
|
default:
|
|
192
222
|
break;
|
|
193
223
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { Group,
|
|
3
|
+
import type { Group, PublicProfile } from '@openpeepshq/common/types';
|
|
4
4
|
import { DotIcon, UsersIcon, UserIcon } from '../icons/index';
|
|
5
5
|
import { ThemedView } from '../ui/themed-view';
|
|
6
6
|
import { ProfileAvatar } from '../profile/Avatar';
|
|
7
7
|
import { GroupAvatar } from '../groups/GroupAvatar';
|
|
8
8
|
|
|
9
9
|
interface NotificationWrapperProps {
|
|
10
|
-
profile:
|
|
10
|
+
profile: PublicProfile;
|
|
11
11
|
seen?: boolean;
|
|
12
12
|
group?: Group | null;
|
|
13
13
|
showProfile?: boolean;
|
|
@@ -2,22 +2,33 @@ import { ScrollView, RefreshControl, ActivityIndicator } from 'react-native';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { PublicNotification } from '@openpeepshq/common';
|
|
4
4
|
import { useFocusEffect } from '@react-navigation/native';
|
|
5
|
+
import { useOpenpeeps } from '@openpeepshq/react';
|
|
5
6
|
import { handleScroll } from '../../lib/utils';
|
|
6
7
|
import { EmptyStateContainer } from '../custom/common/empty-state-container';
|
|
7
8
|
import { NotificationItem } from './NotificationItem';
|
|
8
9
|
import { InfiniteQueryResult } from '../../types';
|
|
9
10
|
|
|
10
|
-
interface
|
|
11
|
-
query
|
|
11
|
+
export interface NotificationsListProps {
|
|
12
|
+
/** Supply your own query to control fetching externally. When omitted, the
|
|
13
|
+
* component fetches `useCurrentProfileNotifications` internally. */
|
|
14
|
+
query?: InfiniteQueryResult<PublicNotification>;
|
|
15
|
+
pageSize?: number;
|
|
12
16
|
isNotificationFeed?: boolean;
|
|
13
17
|
onRefresh?: () => Promise<unknown>;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
export const NotificationsList = ({
|
|
17
|
-
query,
|
|
21
|
+
query: externalQuery,
|
|
22
|
+
pageSize = 15,
|
|
18
23
|
isNotificationFeed = true,
|
|
19
24
|
onRefresh,
|
|
20
|
-
}:
|
|
25
|
+
}: NotificationsListProps) => {
|
|
26
|
+
const { openpeepsApi } = useOpenpeeps();
|
|
27
|
+
const internalQuery = openpeepsApi.useCurrentProfileNotifications({
|
|
28
|
+
limit: pageSize,
|
|
29
|
+
});
|
|
30
|
+
const query = externalQuery ?? internalQuery;
|
|
31
|
+
|
|
21
32
|
const [refreshing, setRefreshing] = React.useState(false);
|
|
22
33
|
const refetchRef = React.useRef(query.refetch);
|
|
23
34
|
refetchRef.current = query.refetch;
|
|
@@ -3,6 +3,7 @@ import { useFeedPostPresentation } from '@openpeepshq/react';
|
|
|
3
3
|
import { useNavigation } from '@react-navigation/native';
|
|
4
4
|
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
5
5
|
import { Pressable } from 'react-native';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
6
7
|
import { MainStackParamList } from '../navigation/types/index';
|
|
7
8
|
import {
|
|
8
9
|
PostInfoHeader,
|
|
@@ -29,6 +30,7 @@ export interface FeedPostProps {
|
|
|
29
30
|
hideReply?: boolean;
|
|
30
31
|
previewMode?: boolean;
|
|
31
32
|
showMenu?: boolean;
|
|
33
|
+
className?: string;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
export const FeedPost = ({
|
|
@@ -41,6 +43,7 @@ export const FeedPost = ({
|
|
|
41
43
|
hideReply,
|
|
42
44
|
previewMode = false,
|
|
43
45
|
showMenu = true,
|
|
46
|
+
className,
|
|
44
47
|
}: FeedPostProps) => {
|
|
45
48
|
const navigation =
|
|
46
49
|
useNavigation<NativeStackNavigationProp<MainStackParamList>>();
|
|
@@ -77,7 +80,7 @@ export const FeedPost = ({
|
|
|
77
80
|
<Pressable disabled={previewMode} onPress={handlePostPress}>
|
|
78
81
|
<ThemedView
|
|
79
82
|
ref={postViewRef}
|
|
80
|
-
className=
|
|
83
|
+
className={cn('relative border-b border-border p-4', className)}
|
|
81
84
|
>
|
|
82
85
|
<UnreadPostIndicator show={isUnread} />
|
|
83
86
|
{hasReactionHeader && (
|
|
@@ -16,6 +16,10 @@ export interface NewEventButtonProps {
|
|
|
16
16
|
visibility: VisibilityType;
|
|
17
17
|
currentProfile?: ProfileWithMeta;
|
|
18
18
|
group?: GroupWithMeta;
|
|
19
|
+
/** When false, only registers the floating plus button (no inline button). */
|
|
20
|
+
showButton?: boolean;
|
|
21
|
+
/** Optional custom navigation callback (replaces default screen navigation). */
|
|
22
|
+
onNavigate?: () => void;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
/** Registers the RootLayout plus button for creating an event. */
|
|
@@ -14,6 +14,8 @@ export interface NewNoteButtonProps {
|
|
|
14
14
|
visibility: VisibilityType;
|
|
15
15
|
currentProfile?: ProfileWithMeta;
|
|
16
16
|
group?: GroupWithMeta;
|
|
17
|
+
/** When false, only registers the floating plus button (no inline feed button). */
|
|
18
|
+
inline?: boolean;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/** Registers the RootLayout plus button for creating a note. */
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { cn } from '../../../lib/utils';
|
|
3
4
|
|
|
4
5
|
interface UnreadPostIndicatorProps {
|
|
5
6
|
show: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
/** `corner` is a top-left fold on feed cards; `dot` is the in-flow mark.
|
|
9
|
+
* On RN only `dot` is supported — `corner` renders nothing (CSS-only effect). */
|
|
10
|
+
variant?: 'dot' | 'corner';
|
|
6
11
|
}
|
|
7
12
|
|
|
8
13
|
/**
|
|
9
14
|
* Subtle unread marker positioned in the host's left margin.
|
|
10
15
|
* Absolutely positioned so visibility changes never shift layout.
|
|
11
16
|
*/
|
|
12
|
-
export const UnreadPostIndicator = ({
|
|
17
|
+
export const UnreadPostIndicator = ({
|
|
18
|
+
show,
|
|
19
|
+
className,
|
|
20
|
+
variant = 'dot',
|
|
21
|
+
}: UnreadPostIndicatorProps) => {
|
|
13
22
|
if (!show) return null;
|
|
23
|
+
if (variant === 'corner') return null;
|
|
14
24
|
|
|
15
25
|
return (
|
|
16
26
|
<View
|
|
17
27
|
pointerEvents="none"
|
|
18
|
-
className=
|
|
28
|
+
className={cn(
|
|
29
|
+
'absolute left-1.5 top-6 size-1.5 rounded-full bg-muted-foreground/45',
|
|
30
|
+
className
|
|
31
|
+
)}
|
|
19
32
|
/>
|
|
20
33
|
);
|
|
21
34
|
};
|
|
@@ -13,11 +13,11 @@ import { MainStackParamList } from '../../navigation/types/index';
|
|
|
13
13
|
import { useTranslation } from 'react-i18next';
|
|
14
14
|
import { CachedImage } from '../../custom/common/index';
|
|
15
15
|
|
|
16
|
-
interface
|
|
16
|
+
export interface FeedArticleProps {
|
|
17
17
|
post: PublicPost;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const FeedArticle = ({ post }:
|
|
20
|
+
export const FeedArticle = ({ post }: FeedArticleProps) => {
|
|
21
21
|
const article = useMemo(() => post.data as Article, [post]);
|
|
22
22
|
|
|
23
23
|
const previewContent = useMemo(
|
|
@@ -7,11 +7,11 @@ import { View } from 'react-native';
|
|
|
7
7
|
import { ThemedText } from '../../ui/themed-text';
|
|
8
8
|
import { OpenpeepsMarkdown } from '../../markdown/index';
|
|
9
9
|
|
|
10
|
-
interface
|
|
10
|
+
export interface FeedNoteProps {
|
|
11
11
|
post: PublicPost;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const FeedNote = ({ post }:
|
|
14
|
+
export const FeedNote = ({ post }: FeedNoteProps) =>
|
|
15
15
|
post?.data?.type === 'note' ? (
|
|
16
16
|
<View>
|
|
17
17
|
<Attachments {...{ post }} />
|
|
@@ -8,11 +8,13 @@ import { OpenpeepsMarkdown } from '../../markdown/index';
|
|
|
8
8
|
import { ThemedText } from '../../ui/themed-text';
|
|
9
9
|
import { PollContent } from '../pieces/PollContent';
|
|
10
10
|
|
|
11
|
-
interface
|
|
11
|
+
export interface FeedPollProps {
|
|
12
12
|
post: PublicPost;
|
|
13
|
+
/** When false, show static options only (no voting). */
|
|
14
|
+
interactive?: boolean;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
export const FeedPoll = ({ post }:
|
|
17
|
+
export const FeedPoll = ({ post, interactive = true }: FeedPollProps) =>
|
|
16
18
|
post?.data?.type === 'question' ? (
|
|
17
19
|
<View>
|
|
18
20
|
<Attachments {...{ post }} />
|
|
@@ -8,7 +8,7 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
|
8
8
|
import { MainStackParamList } from '../../../navigation/types/index';
|
|
9
9
|
import { CachedImage } from '../../../custom/common/index';
|
|
10
10
|
|
|
11
|
-
interface CardArticleProps {
|
|
11
|
+
export interface CardArticleProps {
|
|
12
12
|
post: PublicPost;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -16,7 +16,7 @@ import { ProfileEventRelationship } from './ProfileEventRelationship';
|
|
|
16
16
|
import { useTranslation } from 'react-i18next';
|
|
17
17
|
|
|
18
18
|
import { ParticipantsCard } from '../../index';
|
|
19
|
-
interface CardEventProps {
|
|
19
|
+
export interface CardEventProps {
|
|
20
20
|
post: PublicPost;
|
|
21
21
|
showEventDate?: boolean;
|
|
22
22
|
}
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
} from '../../index';
|
|
77
77
|
import { ReportProfileOrPostModal } from '../../../profile/index';
|
|
78
78
|
import { OpenpeepsMarkdown } from '../../../markdown/index';
|
|
79
|
-
interface FullEventProps {
|
|
79
|
+
export interface FullEventProps {
|
|
80
80
|
post: PublicPost;
|
|
81
81
|
occurrence?: string;
|
|
82
82
|
}
|
|
@@ -9,7 +9,7 @@ import { useOpenpeeps } from '@openpeepshq/react';
|
|
|
9
9
|
import { ThemedText } from '../../../ui/themed-text';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
|
|
12
|
-
interface ProfileEventRelationshipProps {
|
|
12
|
+
export interface ProfileEventRelationshipProps {
|
|
13
13
|
post: PublicPost;
|
|
14
14
|
}
|
|
15
15
|
|