@openpeepshq/rn-components 0.3.13 → 0.5.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 (33) hide show
  1. package/package.json +2 -2
  2. package/src/components/configuration/ConfigMenuButton.tsx +6 -2
  3. package/src/components/groups/GroupAvatar.tsx +41 -12
  4. package/src/components/navigation/nativeRouter.tsx +30 -0
  5. package/src/components/navigation/tab-navigator.tsx +11 -8
  6. package/src/components/notifications/NotificationWrapper.tsx +2 -2
  7. package/src/components/notifications/NotificationsList.tsx +15 -4
  8. package/src/components/post/FeedPost.tsx +4 -1
  9. package/src/components/post/NewEventButton.tsx +4 -0
  10. package/src/components/post/NewNoteButton.tsx +2 -0
  11. package/src/components/post/pieces/PostActions.tsx +2 -0
  12. package/src/components/post/pieces/PostMenu.tsx +315 -340
  13. package/src/components/post/pieces/ShareMenu.tsx +68 -67
  14. package/src/components/post/pieces/UnreadPostIndicator.tsx +15 -2
  15. package/src/components/post/types/Article.tsx +2 -2
  16. package/src/components/post/types/Note.tsx +2 -2
  17. package/src/components/post/types/Poll.tsx +4 -2
  18. package/src/components/post/types/article/CardArticle.tsx +1 -1
  19. package/src/components/post/types/event/CardEvent.tsx +1 -1
  20. package/src/components/post/types/event/FullEvent.tsx +1 -1
  21. package/src/components/post/types/event/ProfileEventRelationship.tsx +1 -1
  22. package/src/components/profile/Avatar.tsx +24 -8
  23. package/src/components/profile/FollowUnfollowButton.tsx +4 -2
  24. package/src/components/profile/ProfileCard.tsx +48 -18
  25. package/src/components/ui/badge.tsx +36 -0
  26. package/src/components/ui/index.ts +6 -0
  27. package/src/components/ui/loading-spinner.tsx +24 -0
  28. package/src/components/ui/popup-menu-button.tsx +99 -0
  29. package/src/components/ui/popup-menu-section.tsx +21 -0
  30. package/src/components/ui/popup-menu-separator.tsx +10 -0
  31. package/src/components/ui/popup-menu.tsx +75 -0
  32. package/src/lib/utils.ts +11 -23
  33. package/src/pages/Members.tsx +1 -1
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { View } from 'react-native';
3
+ import { ThemedText } from './themed-text';
4
+ import { cn } from '../../lib/utils';
5
+
6
+ export interface PopupSectionProps {
7
+ title: string;
8
+ }
9
+
10
+ /**
11
+ * Section header for PopupMenu, mirrors @openpeepshq/react-ui's PopupSection.
12
+ */
13
+ export const PopupSection = ({ title }: PopupSectionProps) => {
14
+ return (
15
+ <View className="w-full py-2">
16
+ <ThemedText className={cn('text-xs font-semibold text-muted-foreground')}>
17
+ {title}
18
+ </ThemedText>
19
+ </View>
20
+ );
21
+ };
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { View } from 'react-native';
3
+ import { DropdownMenuSeparator } from './dropdown-menu';
4
+
5
+ /**
6
+ * Separator for PopupMenu, mirrors @openpeepshq/react-ui's PopupSeparator.
7
+ */
8
+ export const PopupSeparator = () => {
9
+ return <DropdownMenuSeparator className="my-1" />;
10
+ };
@@ -0,0 +1,75 @@
1
+ import * as React from 'react';
2
+ import { Pressable } from 'react-native';
3
+ import {
4
+ DropdownMenu,
5
+ DropdownMenuContent,
6
+ DropdownMenuTrigger,
7
+ } from './dropdown-menu';
8
+ import { cn } from '../../lib/utils';
9
+ import { EllipsisIcon } from '../icons';
10
+
11
+ export type PopupPlacement = 'top' | 'bottom';
12
+
13
+ export interface PopupMenuProps {
14
+ className?: string;
15
+ iconSize?: number;
16
+ compact?: boolean;
17
+ menuButton?: React.ReactNode;
18
+ children?: React.ReactNode;
19
+ title?: string;
20
+ triggerIcon?: React.ReactNode;
21
+ }
22
+
23
+ const DEFAULT_ICON_SIZE = 22;
24
+
25
+ /**
26
+ * Popover-style menu that wraps the RN DropdownMenu to provide the same API
27
+ * surface as @openpeepshq/react-ui's PopupMenu.
28
+ */
29
+ export const PopupMenu = ({
30
+ className,
31
+ iconSize = DEFAULT_ICON_SIZE,
32
+ compact = false,
33
+ menuButton,
34
+ children,
35
+ title = 'Open menu',
36
+ triggerIcon,
37
+ }: PopupMenuProps) => {
38
+ const actionName = title;
39
+ const [open, setOpen] = React.useState(false);
40
+
41
+ const TriggerIcon = () => {
42
+ if (triggerIcon) return <>{triggerIcon}</>;
43
+ return <EllipsisIcon className="text-foreground" size={iconSize} />;
44
+ };
45
+
46
+ const triggerProps = {
47
+ accessibilityRole: 'button' as const,
48
+ accessibilityLabel: actionName || 'Open menu',
49
+ };
50
+
51
+ return (
52
+ <DropdownMenu onOpenChange={setOpen}>
53
+ <DropdownMenuTrigger asChild>
54
+ {menuButton ?? (
55
+ <Pressable
56
+ {...triggerProps}
57
+ className={cn(
58
+ 'rounded-button inline-flex items-center justify-center',
59
+ compact ? 'h-8 w-8' : 'h-10 w-10'
60
+ )}
61
+ >
62
+ <TriggerIcon />
63
+ </Pressable>
64
+ )}
65
+ </DropdownMenuTrigger>
66
+ <DropdownMenuContent
67
+ side="bottom"
68
+ align="end"
69
+ className={cn('flex flex-col p-2', compact ? 'w-16' : 'w-52')}
70
+ >
71
+ {children}
72
+ </DropdownMenuContent>
73
+ </DropdownMenu>
74
+ );
75
+ };
package/src/lib/utils.ts CHANGED
@@ -72,22 +72,6 @@ export const formatEventDate = (dateString: string) => {
72
72
  });
73
73
  };
74
74
 
75
- export const getInitials = (profile?: Profile) => {
76
- if (!profile?.displayName) {
77
- return profile?.handle?.charAt(0)?.toUpperCase();
78
- }
79
- let initials = '';
80
- const [first, last] = profile?.displayName.split(' ');
81
- if (first) {
82
- initials += first.charAt(0).toUpperCase();
83
- }
84
- if (last) {
85
- initials += last.charAt(0).toUpperCase();
86
- }
87
-
88
- return initials;
89
- };
90
-
91
75
  export const ChatDateFormatter = (date: string) => {
92
76
  const options: Intl.DateTimeFormatOptions = {
93
77
  weekday: 'long',
@@ -216,13 +200,17 @@ export const isPostPath = (path: string) =>
216
200
  path.startsWith('/posts/') && path.substring(7);
217
201
 
218
202
  export const isLocalLink = (url: string, origin: string) => {
219
- const urlObj = new URL(url);
220
- return (
221
- urlObj.origin === origin &&
222
- (isPostPath(urlObj.pathname) ||
223
- isJamPath(urlObj.pathname) ||
224
- isGroupPath(urlObj.pathname))
225
- );
203
+ try {
204
+ const urlObj = new URL(url);
205
+ return (
206
+ urlObj.origin === origin &&
207
+ (isPostPath(urlObj.pathname) ||
208
+ isJamPath(urlObj.pathname) ||
209
+ isGroupPath(urlObj.pathname))
210
+ );
211
+ } catch {
212
+ return false;
213
+ }
226
214
  };
227
215
 
228
216
  export const isValidUrl = (url?: string) => {
@@ -100,7 +100,7 @@ export const Members: React.FC<DirectoryProps> = ({ navigation }) => {
100
100
  >
101
101
  <MessageSquareTextIcon className="size-10 text-foreground" />
102
102
  </Pressable>
103
- <FollowUnfollowButton profile={profile} />
103
+ <FollowUnfollowButton profile={profile} compact />
104
104
  </View>
105
105
  ) : null
106
106
  }