@openpeepshq/rn-components 0.14.1 → 0.15.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 (30) hide show
  1. package/package.json +3 -3
  2. package/src/components/buttonOverflow.test.tsx +8 -0
  3. package/src/components/conversations/ConversationParticipantsModal.tsx +1 -6
  4. package/src/components/jams/JamChatDrawer.test.tsx +263 -0
  5. package/src/components/jams/JamChatDrawer.tsx +117 -52
  6. package/src/components/jams/JamConference.tsx +5 -0
  7. package/src/components/jams/JamParticipantConference.tsx +7 -4
  8. package/src/components/jams/JamPeopleDrawer.test.tsx +216 -0
  9. package/src/components/jams/JamPeopleDrawer.tsx +32 -2
  10. package/src/components/jams/JamRoomIndicators.test.tsx +190 -38
  11. package/src/components/jams/JamRoomIndicators.tsx +62 -20
  12. package/src/components/jams/useTrackSubscriptionBump.test.ts +294 -0
  13. package/src/components/jams/useTrackSubscriptionBump.ts +44 -0
  14. package/src/components/post/feed/events/EventsCalendar.test.tsx +33 -18
  15. package/src/components/post/pieces/ShareMenu.test.tsx +217 -0
  16. package/src/components/post/pieces/ShareMenu.tsx +107 -61
  17. package/src/components/post/post-form/VisibilitySheet.test.tsx +153 -0
  18. package/src/components/post/post-form/VisibilitySheet.tsx +6 -5
  19. package/src/components/profile/Avatar.test.tsx +147 -0
  20. package/src/components/profile/Avatar.tsx +26 -0
  21. package/src/components/profile/ProfileCard.test.tsx +165 -8
  22. package/src/components/profile/ProfileCard.tsx +63 -10
  23. package/src/components/profile/ProfileSelector.test.tsx +147 -5
  24. package/src/components/profile/ProfileSelector.tsx +64 -18
  25. package/src/pages/conversations/New.test.tsx +340 -0
  26. package/src/pages/conversations/New.tsx +35 -30
  27. package/src/pages/events/Index.tsx +4 -1
  28. package/src/pages/events/My.tsx +1 -1
  29. package/src/pages/groups/Show.tsx +1 -1
  30. package/src/theme/useThemeOpacity.test.ts +70 -0
@@ -1,18 +1,19 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { ThemedView } from '../../components/ui/themed-view';
3
- import { ProfileCard } from '../../components/profile/index';
3
+ import { MiniProfileCard, ProfileCard } from '../../components/profile/index';
4
4
  import { HeaderActionButton, useSetPageHeader } from '../../components/layout';
5
5
  import { EmptyStateContainer } from '../../components/custom/common/index';
6
6
  import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
7
7
  import { useOpenpeeps } from '@openpeepshq/react';
8
- import { CheckIcon, XIcon } from '../../components/icons/index';
8
+ import { CheckIcon } from '../../components/icons/index';
9
9
  import { ThemedText } from '../../components/ui/themed-text';
10
- import { ActivityIndicator, Pressable, View } from 'react-native';
10
+ import { ActivityIndicator, View } from 'react-native';
11
11
  import { MainScreenProps } from '../../components/navigation/types/index';
12
12
  import { useNewConversationStore } from '../../stores/useNewConversationStore';
13
13
  import { Input } from '../../components/ui/input';
14
14
  import { profileMatchesQuery } from '../../lib/utils';
15
15
  import { blockedPairIds } from '@openpeepshq/common/lib';
16
+ import type { Profile, PublicProfile } from '@openpeepshq/common';
16
17
  import { useTranslation } from 'react-i18next';
17
18
 
18
19
  type SelectPrivateMessageMembersProps =
@@ -46,7 +47,7 @@ export const NewConversation = ({
46
47
  }, [currentProfile, allProfiles, searchQuery]);
47
48
 
48
49
  useSetPageHeader(
49
- t('conversations.selectMembers'),
50
+ t('conversations.createNew.title'),
50
51
  <HeaderActionButton
51
52
  title={t('common.next', { defaultValue: 'Next' })}
52
53
  onPress={() => navigation.navigate('DraftMessage')}
@@ -59,7 +60,7 @@ export const NewConversation = ({
59
60
  <View className="w-full flex flex-row justify-between items-center p-4">
60
61
  <Input
61
62
  className="flex-1"
62
- placeholder="Enter name or handle"
63
+ placeholder={t('conversations.createNew.searchPlaceholder')}
63
64
  value={searchQuery}
64
65
  onChangeText={setSearchQuery}
65
66
  />
@@ -68,46 +69,50 @@ export const NewConversation = ({
68
69
  {isLoading && <ActivityIndicator size={'small'} />}
69
70
 
70
71
  {members.length > 0 && (
71
- <ThemedView className=" my-4 w-full grid grid-cols-2 gap-2">
72
- {members.map((profile, index) => (
73
- <ThemedView key={index} className="col-span-1">
74
- <ProfileCard
75
- profile={profile}
76
- hasAction={true}
77
- actionType="select"
78
- handleSelectProfile={() => removeMember(profile)}
79
- rightComponent={
80
- <Pressable onPress={() => removeMember(profile)}>
81
- <XIcon className="text-foreground" />
82
- </Pressable>
83
- }
84
- />
85
- </ThemedView>
72
+ <ThemedView className="my-4 w-full flex-row flex-wrap gap-2">
73
+ {members.map((member) => (
74
+ <MiniProfileCard
75
+ key={member.id}
76
+ profile={member as PublicProfile}
77
+ onPress={() => removeMember(member as Profile)}
78
+ />
86
79
  ))}
87
80
  </ThemedView>
88
81
  )}
89
82
  {members.length > 0 && (
90
83
  <ThemedText className="text-center">
91
- {members.length} selected
84
+ {t('conversations.createNew.selectedCount', {
85
+ count: members.length,
86
+ })}
92
87
  </ThemedText>
93
88
  )}
94
89
 
95
- {filteredProfiles?.map((profile, index) => {
90
+ {filteredProfiles?.map((profile) => {
91
+ const selected = members.some((m) => m.id === profile.id);
92
+ // The candidate rows are bare `ProfileCard` rows with no accessible
93
+ // wrapper, so they carry their own screen-reader identity: without
94
+ // it the whole DM picker is invisible to screen readers (issue
95
+ // #1666 round-10 review S1).
96
+ const rowLabel = selected
97
+ ? t('profile.selector.rowSelected', {
98
+ name: profile.displayName || `@${profile.handle}`,
99
+ })
100
+ : profile.displayName || `@${profile.handle}`;
96
101
  return (
97
102
  <ProfileCard
98
- key={index}
103
+ key={profile.id}
99
104
  profile={profile}
100
- hasAction={true}
101
105
  actionType="select"
106
+ accessibilityRole="button"
107
+ accessibilityLabel={rowLabel}
108
+ accessibilityState={{ selected }}
102
109
  rightComponent={
103
- <>
104
- {members.includes(profile) ? (
105
- <CheckIcon className="text-foreground" />
106
- ) : null}
107
- </>
110
+ selected ? (
111
+ <CheckIcon size={16} className="text-primary" />
112
+ ) : null
108
113
  }
109
114
  handleSelectProfile={() => {
110
- if (members.includes(profile)) {
115
+ if (selected) {
111
116
  removeMember(profile);
112
117
  } else {
113
118
  setMember(profile);
@@ -88,7 +88,10 @@ export const EventsIndex = ({
88
88
  },
89
89
  ]}
90
90
  />
91
- <EventsView list={<EventsFeed query={activeQuery} />} />
91
+ <EventsView
92
+ calendar={{ window: tab }}
93
+ list={<EventsFeed query={activeQuery} />}
94
+ />
92
95
  <NewEventButton visibility={visibility} currentProfile={currentProfile} />
93
96
  </ThemedView>
94
97
  );
@@ -51,7 +51,7 @@ export const EventsMy: React.FC<MainScreenProps<'MyEvents'>> = () => {
51
51
  ]}
52
52
  />
53
53
  <EventsView
54
- calendar={{ mine: true }}
54
+ calendar={{ mine: true, window: tab }}
55
55
  list={<Feed query={activeQuery} formatSwitch={false} />}
56
56
  />
57
57
  </ThemedView>
@@ -174,7 +174,7 @@ export const GroupShow = ({ route, navigation }: GroupProps) => {
174
174
  </Pressable>
175
175
  </View>
176
176
  <EventsView
177
- calendar={{ groupId: group.id }}
177
+ calendar={{ groupId: group.id, window: eventsTab }}
178
178
  list={
179
179
  <EventsFeed
180
180
  query={
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Contract test for the real (unmocked) useThemeOpacity hook (issue #1666
3
+ * review S5).
4
+ *
5
+ * The picker-row tint tests in ProfileSelector.test.tsx assert against a
6
+ * MOCKED useThemeOpacity whose values are copied from theme/defaults.ts. If
7
+ * the real hook's signature or the token shape ever changes, that mock would
8
+ * silently drift and the mocked tests would keep passing. This suite pins
9
+ * the real hook directly: it must resolve `background(name, opacity)` to the
10
+ * documented `rgba(...)` shape by feeding the token hex into the real
11
+ * hexWithOpacity color math.
12
+ */
13
+
14
+ const React = require('react');
15
+ const ReactTestRenderer = require('react-test-renderer');
16
+
17
+ jest.mock('./OpenPeepsThemeProvider', () => ({
18
+ // Mirrors the context shape the real hook reads. Values come from
19
+ // theme/defaults.ts (the default light theme) so the assertions are pinned
20
+ // to the documented palette.
21
+ useOpenPeepsTheme: () => ({
22
+ colors: {
23
+ primary: '#16161a',
24
+ secondary: '#f4f4f5',
25
+ },
26
+ }),
27
+ }));
28
+
29
+ import { useThemeOpacity } from './useThemeOpacity';
30
+
31
+ const UseThemeOpacityProbe = () => {
32
+ const opacity = useThemeOpacity();
33
+ return React.createElement('useThemeOpacityProbe', {
34
+ background: opacity.background,
35
+ border: opacity.border,
36
+ text: opacity.text,
37
+ });
38
+ };
39
+
40
+ const renderProbe = () => {
41
+ let tree: ReturnType<typeof ReactTestRenderer.create>;
42
+ ReactTestRenderer.act(() => {
43
+ tree = ReactTestRenderer.create(React.createElement(UseThemeOpacityProbe));
44
+ });
45
+ return tree.root.findByType('useThemeOpacityProbe').props as {
46
+ background: (name: string, opacity: number) => Record<string, unknown>;
47
+ border: (name: string, opacity: number) => Record<string, unknown>;
48
+ text: (name: string, opacity: number) => Record<string, unknown>;
49
+ };
50
+ };
51
+
52
+ describe('useThemeOpacity (real hook, issue #1666 review S5)', () => {
53
+ it('resolves background(primary, opacity) to the documented rgba shape', () => {
54
+ const { background } = renderProbe();
55
+ expect(background('primary', 0.15)).toEqual({
56
+ backgroundColor: 'rgba(22, 22, 26, 0.15)',
57
+ });
58
+ expect(background('secondary', 0.4)).toEqual({
59
+ backgroundColor: 'rgba(244, 244, 245, 0.4)',
60
+ });
61
+ });
62
+
63
+ it('exposes border/text variants on the same hex', () => {
64
+ const { border, text } = renderProbe();
65
+ expect(border('primary', 0.5)).toEqual({
66
+ borderColor: 'rgba(22, 22, 26, 0.5)',
67
+ });
68
+ expect(text('primary', 1)).toEqual({ color: 'rgba(22, 22, 26, 1)' });
69
+ });
70
+ });