@openpeepshq/rn-components 0.13.0 → 0.13.3

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/icons/index.ts +2 -0
  3. package/src/components/jams/JamDeviceSelectors.tsx +31 -3
  4. package/src/components/jams/JamLobby.tsx +104 -5
  5. package/src/components/jams/JamVideoCall.tsx +157 -3
  6. package/src/components/jams/JamVideoLayout.tsx +9 -2
  7. package/src/components/jams/useLateTrackMediaStream.test.ts +145 -0
  8. package/src/components/jams/useLateTrackMediaStream.ts +61 -0
  9. package/src/components/layout/ContentHeader.tsx +6 -2
  10. package/src/components/layout/HeaderMobile.tsx +48 -22
  11. package/src/components/layout/PlusButton.tsx +1 -7
  12. package/src/components/layout/pageChrome.test.tsx +213 -0
  13. package/src/components/post/feed/events/EventsCalendar.test.tsx +144 -0
  14. package/src/components/post/feed/events/EventsCalendar.tsx +4 -8
  15. package/src/components/post/feed/events/EventsView.tsx +5 -13
  16. package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +14 -5
  17. package/src/components/post/post-form/PostForm.tsx +1 -0
  18. package/src/components/profile/ProfileCard.test.tsx +16 -1
  19. package/src/components/profile/ProfileCard.tsx +14 -3
  20. package/src/lib/dmMessageGate.test.ts +58 -0
  21. package/src/lib/livekit/useStableLiveKitRoom.ts +23 -13
  22. package/src/lib/utils.ts +4 -1
  23. package/src/pages/conversations/NewDraft.tsx +2 -3
  24. package/src/pages/conversations/Show.tsx +25 -30
  25. package/src/pages/events/Index.tsx +1 -5
  26. package/src/pages/events/My.tsx +1 -2
  27. package/src/pages/groups/Show.tsx +10 -2
  28. package/src/pages/posts/Edit.tsx +16 -6
  29. package/src/pages/posts/New.tsx +15 -5
  30. package/src/pages/posts/Reply.tsx +15 -6
@@ -5,12 +5,14 @@ import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
5
5
  import { useCurrentProfile } from '@openpeepshq/react';
6
6
  import { goToParentOrBack } from '../navigation/parent-back';
7
7
  import type { MainStackParamList } from '../navigation/types';
8
+ import { useTranslation } from 'react-i18next';
8
9
  import { ChevronLeftIcon } from '../icons/index';
9
10
  import { ThemedText } from '../ui/themed-text';
10
11
  import { usePageChrome } from './pageChrome';
11
12
 
12
13
  export const ContentHeader = () => {
13
14
  const { header } = usePageChrome();
15
+ const { t } = useTranslation();
14
16
  const navigation =
15
17
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
16
18
  const route = useRoute();
@@ -20,11 +22,13 @@ export const ContentHeader = () => {
20
22
  const titleIsString = typeof title === 'string';
21
23
 
22
24
  return (
23
- <View className="border-border flex-row items-center justify-between border-b px-4 py-2">
25
+ <View className="bg-background border-border h-16 flex-row items-center justify-between border-b px-4">
24
26
  <View className="min-w-0 flex-1 flex-row items-center gap-2">
25
27
  <Pressable
26
28
  accessibilityRole="button"
27
- accessibilityLabel="Back"
29
+ accessibilityLabel={t('common.actions.back', {
30
+ defaultValue: 'Back',
31
+ })}
28
32
  onPress={() => {
29
33
  if (header?.onBack) {
30
34
  header.onBack();
@@ -10,6 +10,7 @@ import { SafeAreaView } from 'react-native-safe-area-context';
10
10
  import { useNavigation } from '@react-navigation/native';
11
11
  import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
12
12
  import { useOpenpeeps } from '@openpeepshq/react';
13
+ import { useTranslation } from 'react-i18next';
13
14
  import { useDrawer } from '../../contexts/drawer-context';
14
15
  import { useWindowSize } from '../../hooks/index';
15
16
  import { BASE_URL, isProduction } from '../../lib/constants';
@@ -19,10 +20,16 @@ import { Avatar, AvatarFallback, AvatarImage } from '../ui/avatar';
19
20
  import { Button } from '../ui/button';
20
21
  import { ThemedText } from '../ui/themed-text';
21
22
  import { SvgImage } from '../ui/svg-image';
22
- import { MessageSquareTextIcon, UserIcon } from '../icons/index';
23
+ import { MenuIcon, MessageSquareTextIcon, UserIcon } from '../icons/index';
23
24
  import type { MainStackParamList } from '../navigation/types/index';
24
25
 
26
+ /**
27
+ * Mobile app bar, mirroring the web `HeaderMobile` (slim single row:
28
+ * avatar drawer trigger / small logo / messages shortcut, no theme
29
+ * background). Hidden on tablet widths, matching web's `md:hidden`.
30
+ */
25
31
  export const HeaderMobile = () => {
32
+ const { t } = useTranslation();
26
33
  const { openDrawer } = useDrawer();
27
34
  const { isMediumScreenOrLarger } = useWindowSize();
28
35
  const { openpeepsApi, currentProfile } = useOpenpeeps();
@@ -31,6 +38,11 @@ export const HeaderMobile = () => {
31
38
  const { data: serverInfo } = openpeepsApi.useServerInfo();
32
39
  const { data: profileSettings } = openpeepsApi.useCurrentProfileSettings();
33
40
 
41
+ const menuLabel = t('navigation.openMenu', { defaultValue: 'Open menu' });
42
+ const messagesLabel = t('navigation.openMessages', {
43
+ defaultValue: 'Open messages',
44
+ });
45
+
34
46
  // Mirrors web HeaderMobile: resolve branding per active theme mode. The
35
47
  // system scheme must come from RN: getTheme's default cannot read it.
36
48
  const systemColorScheme = useColorScheme();
@@ -39,22 +51,14 @@ export const HeaderMobile = () => {
39
51
  ? getTheme(serverInfo.communityConfig, profileSettings, systemScheme)
40
52
  : undefined;
41
53
  const logoUri = toAbsoluteMediaUrl(resolvedTheme?.logoSmall);
42
- const backgroundUri = toAbsoluteMediaUrl(resolvedTheme?.background);
43
54
 
44
55
  if (isMediumScreenOrLarger) {
45
56
  return null;
46
57
  }
47
58
 
48
59
  return (
49
- <View style={styles.header} className="px-4 pb-3">
50
- {backgroundUri ? (
51
- <SvgImage
52
- uri={backgroundUri}
53
- className="absolute inset-0"
54
- resizeMode="cover"
55
- />
56
- ) : null}
57
- <SafeAreaView edges={['top']}>
60
+ <View style={styles.header} className="bg-background">
61
+ <SafeAreaView edges={['top']} className="px-4 py-2">
58
62
  {!isProduction && (
59
63
  <View className="mb-2 w-full rounded-lg bg-white/50 p-2">
60
64
  <ThemedText className="text-center text-destructive">
@@ -64,29 +68,51 @@ export const HeaderMobile = () => {
64
68
  )}
65
69
  <View className="flex-row items-center justify-between">
66
70
  <Button
67
- variant="outline"
71
+ variant="ghost"
68
72
  size="icon"
69
73
  onPress={openDrawer}
70
- className="native:px-0 active:bg-none rounded-full bg-black"
74
+ accessibilityLabel={menuLabel}
75
+ className="native:px-0 active:bg-none"
71
76
  >
72
- <Avatar alt={(currentProfile?.displayName as string) || 'Profile'}>
73
- {currentProfile?.avatar ? (
77
+ {currentProfile?.avatar ? (
78
+ <Avatar alt={currentProfile.displayName || 'Profile'}>
74
79
  <AvatarImage source={{ uri: currentProfile.avatar }} />
75
- ) : (
76
- <AvatarFallback className="-bottom-2 -right-2 h-6 w-6 bg-black">
80
+ </Avatar>
81
+ ) : currentProfile ? (
82
+ <Avatar alt={currentProfile.displayName || 'Profile'}>
83
+ <AvatarFallback className="bg-muted">
77
84
  <UserIcon size={20} className="text-muted-foreground" />
78
85
  </AvatarFallback>
79
- )}
80
- </Avatar>
86
+ </Avatar>
87
+ ) : (
88
+ <MenuIcon size={24} className="text-foreground" />
89
+ )}
81
90
  </Button>
82
- <SvgImage uri={logoUri} className="h-[64px] w-[216px]" />
91
+ {logoUri ? (
92
+ <Button
93
+ variant="ghost"
94
+ onPress={() =>
95
+ navigation.navigate('TabNavigator', { screen: 'Home' })
96
+ }
97
+ accessibilityLabel={t('navigation.home', {
98
+ defaultValue: 'Home',
99
+ })}
100
+ // Pin the button height to the 40px icon-row (the default
101
+ // size variant is 48px tall on native) so the slim app bar
102
+ // matches web's single-row height.
103
+ className="native:h-10 native:px-4 active:bg-none"
104
+ >
105
+ <SvgImage uri={logoUri} className="h-6 w-36" />
106
+ </Button>
107
+ ) : null}
83
108
  <Button
84
- variant="outline"
109
+ variant="ghost"
85
110
  size="icon"
86
111
  onPress={() =>
87
112
  navigation.navigate('TabNavigator', { screen: 'Messages' })
88
113
  }
89
- accessibilityLabel="Messages"
114
+ accessibilityLabel={messagesLabel}
115
+ className="native:px-0 active:bg-none"
90
116
  >
91
117
  <MessageSquareTextIcon
92
118
  className="text-muted-foreground"
@@ -3,11 +3,6 @@ import { Pressable } from 'react-native';
3
3
  import { PlusIcon } from '../icons/index';
4
4
  import { usePageChrome } from './pageChrome';
5
5
 
6
- // PlusButton is always fully round — it doesn't use the theme's buttonRadius
7
- // setting (which is for regular buttons). On web, circular elements have a
8
- // separate theme token; on RN we use a static 9999px (same as rounded-full).
9
- const PLUS_BUTTON_RADIUS = 9999;
10
-
11
6
  export const PlusButton = () => {
12
7
  const { plus } = usePageChrome();
13
8
  if (!plus || Array.isArray(plus)) return null;
@@ -25,8 +20,7 @@ export const PlusButton = () => {
25
20
  accessibilityRole="button"
26
21
  accessibilityLabel={plus.title || 'New'}
27
22
  onPress={onPress}
28
- style={{ borderRadius: PLUS_BUTTON_RADIUS }}
29
- className="bg-primary absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-button"
23
+ className="bg-primary absolute bottom-10 right-6 z-20 size-16 items-center justify-center rounded-full"
30
24
  >
31
25
  <Icon size={24} className="text-primary-foreground" />
32
26
  </Pressable>
@@ -19,6 +19,124 @@ import {
19
19
  useSetPlusButtonActions,
20
20
  } from './pageChrome';
21
21
 
22
+ // The two rebuilt layout components (HeaderMobile, ContentHeader) pull in
23
+ // navigation, i18n, drawer, window and theme hooks plus a few UI primitives.
24
+ // Mock that whole dependency surface so the real components can be rendered in
25
+ // the node test environment; the real pageChrome scaffolding above is reused
26
+ // (the provider is what ContentHeader reads its title / onBack from).
27
+ const React = require('react');
28
+
29
+ let mockServerInfo: unknown;
30
+ let mockTheme: unknown;
31
+ let mockCurrentProfile: unknown;
32
+ const mockNavigate = jest.fn();
33
+ const mockOpenDrawer = jest.fn();
34
+ const mockGoToParentOrBack = jest.fn();
35
+ const mockOnBack = jest.fn();
36
+
37
+ jest.mock('react-native', () => ({
38
+ Platform: { OS: 'ios' },
39
+ StatusBar: { currentHeight: 0 },
40
+ StyleSheet: { create: (s: Record<string, unknown>) => s },
41
+ View: (props: { children?: unknown }) =>
42
+ React.createElement('View', props, props.children),
43
+ Pressable: (props: { children?: unknown }) =>
44
+ React.createElement('Pressable', props, props.children),
45
+ useColorScheme: () => 'light',
46
+ }));
47
+
48
+ jest.mock('react-native-safe-area-context', () => ({
49
+ SafeAreaView: (props: { children?: unknown }) =>
50
+ React.createElement('SafeAreaView', props, props.children),
51
+ }));
52
+
53
+ jest.mock('@react-navigation/native', () => ({
54
+ useNavigation: () => ({ navigate: mockNavigate }),
55
+ useRoute: () => ({ name: 'Test', params: undefined }),
56
+ }));
57
+
58
+ jest.mock('@openpeepshq/react', () => ({
59
+ useOpenpeeps: () => ({
60
+ currentProfile: mockCurrentProfile,
61
+ openpeepsApi: {
62
+ useServerInfo: () => ({ data: mockServerInfo }),
63
+ useCurrentProfileSettings: () => ({ data: undefined }),
64
+ },
65
+ }),
66
+ useCurrentProfile: () => mockCurrentProfile,
67
+ }));
68
+
69
+ jest.mock('@openpeepshq/common', () => ({
70
+ getTheme: () => mockTheme,
71
+ }));
72
+
73
+ jest.mock('react-i18next', () => ({
74
+ useTranslation: () => ({ t: (key: string) => key }),
75
+ }));
76
+
77
+ jest.mock('../../contexts/drawer-context', () => ({
78
+ useDrawer: () => ({ openDrawer: mockOpenDrawer }),
79
+ }));
80
+
81
+ jest.mock('../../hooks/index', () => ({
82
+ useWindowSize: () => ({
83
+ windowWidth: 390,
84
+ windowHeight: 844,
85
+ isMediumScreenOrLarger: false,
86
+ }),
87
+ }));
88
+
89
+ jest.mock('../../lib/constants', () => ({
90
+ BASE_URL: 'https://example.test',
91
+ isProduction: true,
92
+ }));
93
+
94
+ jest.mock('../../lib/media-url', () => ({
95
+ toAbsoluteMediaUrl: (url?: string) => url,
96
+ }));
97
+
98
+ jest.mock('../navigation/parent-back', () => ({
99
+ goToParentOrBack: mockGoToParentOrBack,
100
+ }));
101
+
102
+ jest.mock('../ui/avatar', () => ({
103
+ Avatar: (props: { children?: unknown }) =>
104
+ React.createElement('Avatar', props, props.children),
105
+ AvatarFallback: (props: { children?: unknown }) =>
106
+ React.createElement('AvatarFallback', props, props.children),
107
+ AvatarImage: (props: { children?: unknown }) =>
108
+ React.createElement('AvatarImage', props, props.children),
109
+ }));
110
+
111
+ jest.mock('../ui/button', () => ({
112
+ Button: (props: { children?: unknown }) =>
113
+ React.createElement('Button', props, props.children),
114
+ }));
115
+
116
+ jest.mock('../ui/themed-text', () => ({
117
+ ThemedText: (props: { children?: unknown }) =>
118
+ React.createElement('ThemedText', props, props.children),
119
+ }));
120
+
121
+ jest.mock('../ui/svg-image', () => ({
122
+ SvgImage: (props: { children?: unknown }) =>
123
+ React.createElement('SvgImage', props, props.children),
124
+ }));
125
+
126
+ jest.mock('../icons/index', () => ({
127
+ MenuIcon: (props: Record<string, unknown>) =>
128
+ React.createElement('MenuIcon', props),
129
+ MessageSquareTextIcon: (props: Record<string, unknown>) =>
130
+ React.createElement('MessageSquareTextIcon', props),
131
+ UserIcon: (props: Record<string, unknown>) =>
132
+ React.createElement('UserIcon', props),
133
+ ChevronLeftIcon: (props: Record<string, unknown>) =>
134
+ React.createElement('ChevronLeftIcon', props),
135
+ }));
136
+
137
+ import { ContentHeader } from './ContentHeader';
138
+ import { HeaderMobile } from './HeaderMobile';
139
+
22
140
  const MAX_RENDER_GUARD = 20;
23
141
 
24
142
  const Text = ({ children }: { children?: ReactNode }) => (
@@ -145,3 +263,98 @@ test('page chrome hooks throw outside RootLayout', () => {
145
263
  });
146
264
  }).toThrow('Page chrome hooks must be used within RootLayout');
147
265
  });
266
+
267
+ // The two rebuilt layout components (issue #1971). The existing tests above
268
+ // exercise the pageChrome context but never the components that render it;
269
+ // these pin their structure and navigation wiring so a regression in the
270
+ // consolidated chrome fails CI instead of only typechecking clean.
271
+ describe('rebuilt layout components (issue #1971)', () => {
272
+ beforeEach(() => {
273
+ mockNavigate.mockReset();
274
+ mockOpenDrawer.mockReset();
275
+ mockGoToParentOrBack.mockReset();
276
+ mockServerInfo = undefined;
277
+ mockTheme = undefined;
278
+ mockCurrentProfile = undefined;
279
+ });
280
+
281
+ const renderHeader = () => {
282
+ let tree!: ReactTestRenderer.ReactTestRenderer;
283
+ ReactTestRenderer.act(() => {
284
+ tree = ReactTestRenderer.create(<HeaderMobile />);
285
+ });
286
+ return tree;
287
+ };
288
+
289
+ const RegisterHeader = () => {
290
+ useSetPageHeader('Conversations', undefined, mockOnBack);
291
+ return null;
292
+ };
293
+
294
+ test('HeaderMobile: a guest (no current profile) renders the menu-icon trigger', () => {
295
+ const tree = renderHeader();
296
+ // currentProfile is undefined → the guest fallback MenuIcon is the drawer
297
+ // trigger (web renders an avatar for signed-in users, a menu icon for
298
+ // guests); no logo (server info / theme absent) so no navigation logo.
299
+ expect(tree.root.findAllByType('MenuIcon')).toHaveLength(1);
300
+ expect(tree.root.findAllByType('Avatar')).toHaveLength(0);
301
+ expect(tree.root.findAllByType('SvgImage')).toHaveLength(0);
302
+ // The menu trigger button carries the (mocked to its key) label.
303
+ const menuButtons = tree.root
304
+ .findAllByType('Button')
305
+ .filter(
306
+ (node: { props: Record<string, unknown> }) =>
307
+ node.props.accessibilityLabel === 'navigation.openMenu'
308
+ );
309
+ expect(menuButtons).toHaveLength(1);
310
+ tree.unmount();
311
+ });
312
+
313
+ test('HeaderMobile: the logo button navigates to Home (guest branch)', () => {
314
+ // A configured theme with a small logo renders the logo button.
315
+ mockServerInfo = { communityConfig: {} };
316
+ mockTheme = { logoSmall: '/logo.svg' };
317
+ const tree = renderHeader();
318
+ const logoButton = tree.root.find(
319
+ (node: { props?: Record<string, unknown> }) =>
320
+ node.props && node.props.accessibilityLabel === 'navigation.home'
321
+ );
322
+ expect(logoButton).toBeDefined();
323
+ ReactTestRenderer.act(() => {
324
+ logoButton.props.onPress();
325
+ });
326
+ expect(mockNavigate).toHaveBeenCalledWith('TabNavigator', {
327
+ screen: 'Home',
328
+ });
329
+ tree.unmount();
330
+ });
331
+
332
+ test('ContentHeader: renders the fixed h-16 bg-background row and the back button', () => {
333
+ let tree!: ReactTestRenderer.ReactTestRenderer;
334
+ ReactTestRenderer.act(() => {
335
+ tree = ReactTestRenderer.create(
336
+ <PageChromeProvider>
337
+ <ContentHeader />
338
+ <RegisterHeader />
339
+ </PageChromeProvider>
340
+ );
341
+ });
342
+ // The fixed-height background row renders.
343
+ const rows = tree.root.findAll(
344
+ (node: { type?: unknown; props: Record<string, unknown> }) =>
345
+ node.type === 'View' &&
346
+ node.props.className ===
347
+ 'bg-background border-border h-16 flex-row items-center justify-between border-b px-4'
348
+ );
349
+ expect(rows).toHaveLength(1);
350
+ // The back button exposes the (mocked to its key) common.actions.back label.
351
+ const backButtons = tree.root
352
+ .findAllByType('Pressable')
353
+ .filter(
354
+ (node: { props: Record<string, unknown> }) =>
355
+ node.props.accessibilityLabel === 'common.actions.back'
356
+ );
357
+ expect(backButtons).toHaveLength(1);
358
+ tree.unmount();
359
+ });
360
+ });
@@ -0,0 +1,144 @@
1
+ /**
2
+ * RN parity lock (issue #2131), updated for issue #2128: the native
3
+ * EventsCalendar must render exactly what the shared `useEventsCalendar` hook
4
+ * from `@openpeepshq/react` returns — the single source of truth, with no
5
+ * separate RN implementation. Since #2128 the hook is a date-range calendar:
6
+ * it reads one row per occurrence from the server's month-window range feed
7
+ * and buckets the rows by browser-local day keys. The mock below emulates
8
+ * that contract — it returns the rows for the selected day only, and an event
9
+ * the range feed did not return must not appear. If the native component ever
10
+ * rendered events from any other source (a query of its own, its own
11
+ * filtering), these assertions fail.
12
+ *
13
+ * `@openpeepshq/react` is mocked because the package's jest transform only
14
+ * covers this package — the same pattern every RN test here uses.
15
+ */
16
+ import React from 'react';
17
+ import ReactTestRenderer from 'react-test-renderer';
18
+ import type { PublicPost } from '@openpeepshq/common/types';
19
+
20
+ // --- react-native: host elements render as plain host tags ----------------
21
+ jest.mock('react-native', () => {
22
+ const React = require('react');
23
+ const make =
24
+ (tag: string) =>
25
+ (props: { children?: React.ReactNode; onPress?: () => void }) =>
26
+ React.createElement(tag, { onPress: props.onPress }, props.children);
27
+ return {
28
+ View: make('View'),
29
+ Pressable: make('Pressable'),
30
+ ActivityIndicator: () => null,
31
+ ScrollView: make('ScrollView'),
32
+ RefreshControl: () => null,
33
+ };
34
+ });
35
+
36
+ jest.mock('@react-navigation/native', () => ({
37
+ useNavigation: () => ({ navigate: jest.fn() }),
38
+ useFocusEffect: jest.fn(),
39
+ }));
40
+
41
+ jest.mock('react-i18next', () => ({
42
+ useTranslation: () => ({
43
+ t: (_key: string, opts?: { defaultValue?: string }) =>
44
+ opts?.defaultValue ?? _key,
45
+ }),
46
+ }));
47
+
48
+ jest.mock('../../../../theme/useThemeOpacity', () => ({
49
+ useThemeOpacity: () => ({ background: () => ({}) }),
50
+ }));
51
+
52
+ jest.mock('../../../navigation/types/index', () => ({
53
+ MainStackParamList: {},
54
+ }));
55
+
56
+ jest.mock('../../../../lib/utils', () => ({
57
+ cn: (...args: unknown[]) => args.filter(Boolean).join(' '),
58
+ }));
59
+
60
+ jest.mock('../../../ui/themed-text', () => ({
61
+ ThemedText: (props: Record<string, unknown>) =>
62
+ React.createElement('Text', props, props.children),
63
+ }));
64
+
65
+ jest.mock('../../../icons/index', () => ({
66
+ ChevronLeftIcon: () => null,
67
+ ChevronRightIcon: () => null,
68
+ }));
69
+
70
+ // --- shared hook contract: one row per occurrence, bucketed by local day ---
71
+ const future = {
72
+ id: 'future-event',
73
+ data: {
74
+ type: 'event',
75
+ name: 'future-event',
76
+ start: '2026-11-19T10:00:00.000Z',
77
+ end: '2026-11-19T11:00:00.000Z',
78
+ wholeDay: false,
79
+ },
80
+ } as unknown as PublicPost;
81
+
82
+ jest.mock('@openpeepshq/react', () => ({
83
+ useEventsCalendar: () => ({
84
+ cells: [
85
+ { key: '2026-11-18', inMonth: true },
86
+ { key: '2026-11-19', inMonth: true },
87
+ ],
88
+ byDay: new Map([['2026-11-19', [future]]]),
89
+ todayKey: '2026-11-18',
90
+ selected: '2026-11-19',
91
+ selectedEvents: [future],
92
+ selectedLabel: 'Selected day',
93
+ setSelectedKey: () => undefined,
94
+ monthLabel: 'Parity month',
95
+ weekdayLabels: ['S', 'M'],
96
+ isLoading: false,
97
+ isFetchingNextPage: false,
98
+ shiftMonth: () => undefined,
99
+ goToday: () => undefined,
100
+ }),
101
+ calendarDayNumber: (key: string) => key,
102
+ calendarEventName: (post: PublicPost) =>
103
+ post.data.type === 'event' ? (post.data.name ?? '') : '',
104
+ eventStartIso: (post: PublicPost) =>
105
+ post.occurrenceStart ?? (post.data as { start?: string }).start,
106
+ eventEndIso: (post: PublicPost) =>
107
+ post.occurrenceEnd ?? (post.data as { end?: string }).end,
108
+ }));
109
+
110
+ import { EventsCalendar } from './EventsCalendar';
111
+
112
+ const renderCalendar = async (props: Record<string, unknown> = {}) => {
113
+ jest.spyOn(console, 'error').mockImplementation(() => undefined);
114
+ jest.spyOn(console, 'warn').mockImplementation(() => undefined);
115
+ const renderer = ReactTestRenderer.create(<EventsCalendar {...props} />);
116
+ await ReactTestRenderer.act(async () => undefined);
117
+ return renderer;
118
+ };
119
+
120
+ describe('EventsCalendar (native) shared-hook parity', () => {
121
+ it('renders the shared hook output through the scope prop', async () => {
122
+ const renderer = await renderCalendar({});
123
+ const tree = renderer.toJSON();
124
+ expect(tree).not.toBeNull();
125
+ const text = JSON.stringify(tree);
126
+ expect(text).toContain('Parity month');
127
+ expect(text).toContain('Selected day');
128
+ });
129
+
130
+ it('shows the range-feed row on the selected day list', async () => {
131
+ const renderer = await renderCalendar({});
132
+ const text = JSON.stringify(renderer.toJSON());
133
+ expect(text).toContain('future-event');
134
+ });
135
+
136
+ it('never shows an event the shared hook did not return', async () => {
137
+ const renderer = await renderCalendar({});
138
+ const text = JSON.stringify(renderer.toJSON());
139
+ // The component has no query of its own; anything it shows came from the
140
+ // hook's `selectedEvents`. An event absent from that list must not leak
141
+ // into the grid or the day list.
142
+ expect(text).not.toContain('past-event');
143
+ });
144
+ });
@@ -10,8 +10,7 @@ import {
10
10
  eventEndIso,
11
11
  eventStartIso,
12
12
  useEventsCalendar,
13
- type EventsAgendaWindow,
14
- type EventsCalendarQuery,
13
+ type CalendarScopeProps,
15
14
  } from '@openpeepshq/react';
16
15
  import { ChevronLeftIcon, ChevronRightIcon } from '../../../icons/index';
17
16
  import { useThemeOpacity } from '../../../../theme/useThemeOpacity';
@@ -19,15 +18,12 @@ import { MainStackParamList } from '../../../navigation/types/index';
19
18
  import { ThemedText } from '../../../ui/themed-text';
20
19
  import { cn } from '../../../../lib/utils';
21
20
 
22
- export interface EventsCalendarProps {
23
- query: EventsCalendarQuery;
24
- agenda: EventsAgendaWindow;
25
- }
21
+ export type EventsCalendarProps = CalendarScopeProps;
26
22
 
27
23
  const postKey = (post: PublicPost) =>
28
24
  `${post.id}:${post.occurrenceRecurrenceId ?? ''}`;
29
25
 
30
- export const EventsCalendar = ({ query, agenda }: EventsCalendarProps) => {
26
+ export const EventsCalendar = (props: EventsCalendarProps) => {
31
27
  const { t } = useTranslation();
32
28
  const { background } = useThemeOpacity();
33
29
  const navigation =
@@ -46,7 +42,7 @@ export const EventsCalendar = ({ query, agenda }: EventsCalendarProps) => {
46
42
  isFetchingNextPage,
47
43
  shiftMonth,
48
44
  goToday,
49
- } = useEventsCalendar(query, agenda);
45
+ } = useEventsCalendar(props);
50
46
 
51
47
  const openEvent = (post: PublicPost) =>
52
48
  navigation.navigate('Post', {
@@ -1,30 +1,22 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { View } from 'react-native';
3
- import {
4
- useEventView,
5
- type EventsAgendaWindow,
6
- type EventsCalendarQuery,
7
- } from '@openpeepshq/react';
3
+ import { useEventView, type CalendarScopeProps } from '@openpeepshq/react';
8
4
  import { EventViewSwitch } from '../../EventViewSwitch';
9
5
  import { EventsCalendar } from './EventsCalendar';
10
6
 
11
7
  export interface EventsViewProps {
12
- query: EventsCalendarQuery;
13
- agenda: EventsAgendaWindow;
8
+ /** Scope for calendar — lists don't use this. */
9
+ calendar?: CalendarScopeProps;
14
10
  list: ReactNode;
15
11
  }
16
12
 
17
13
  /** List (the existing layout) or a month calendar, shared across event pages. */
18
- export const EventsView = ({ query, agenda, list }: EventsViewProps) => {
14
+ export const EventsView = ({ calendar, list }: EventsViewProps) => {
19
15
  const { view } = useEventView();
20
16
  return (
21
17
  <View className="flex-1">
22
18
  <EventViewSwitch />
23
- {view === 'calendar' ? (
24
- <EventsCalendar key={agenda} query={query} agenda={agenda} />
25
- ) : (
26
- list
27
- )}
19
+ {view === 'calendar' ? <EventsCalendar {...(calendar ?? {})} /> : list}
28
20
  </View>
29
21
  );
30
22
  };
@@ -7,7 +7,7 @@ import {
7
7
  type NativeSyntheticEvent,
8
8
  type TextInputSelectionChangeEventData,
9
9
  } from 'react-native';
10
- import type { PublicProfile } from '@openpeepshq/common';
10
+ import { visibleTextLength, type PublicProfile } from '@openpeepshq/common';
11
11
  import { useOpenpeeps } from '@openpeepshq/react';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import { OpenpeepsMarkdown } from '../../markdown/index';
@@ -21,8 +21,13 @@ import { cn, maxContentLength } from '../../../lib/utils';
21
21
  export interface OpenpeepsMarkdownInputProps {
22
22
  value: string;
23
23
  onChange: (value: string) => void;
24
- /** Character budget; the counter turns red once exceeded. */
24
+ /** Visible-text character budget; the counter turns red once exceeded. */
25
25
  maxLength?: number;
26
+ /**
27
+ * Hard-stop typing at the budget. For forms that do not validate the
28
+ * length on submit.
29
+ */
30
+ blockOverflow?: boolean;
26
31
  placeholder?: string;
27
32
  rows?: number;
28
33
  /** Show the preview toggle button (mirrors web `previewButton`). */
@@ -47,6 +52,7 @@ export const OpenpeepsMarkdownInput = ({
47
52
  value,
48
53
  onChange,
49
54
  maxLength = maxContentLength,
55
+ blockOverflow = true,
50
56
  placeholder,
51
57
  rows = 5,
52
58
  previewButton = true,
@@ -134,7 +140,10 @@ export const OpenpeepsMarkdownInput = ({
134
140
  }
135
141
  };
136
142
 
137
- const overLimit = value.length > maxLength;
143
+ // With the native cap on (blockOverflow) the counter tracks the raw length
144
+ // it enforces; otherwise it tracks the visible text the submit check uses.
145
+ const shownLength = blockOverflow ? value.length : visibleTextLength(value);
146
+ const overLimit = shownLength > maxLength;
138
147
 
139
148
  return (
140
149
  <View className="relative w-full">
@@ -203,7 +212,7 @@ export const OpenpeepsMarkdownInput = ({
203
212
  autoFocus={autoFocus}
204
213
  numberOfLines={rows}
205
214
  value={value}
206
- maxLength={maxLength}
215
+ maxLength={blockOverflow ? maxLength : undefined}
207
216
  placeholder={placeholder ?? t('posts.form.content')}
208
217
  onChangeText={handleChange}
209
218
  onSelectionChange={handleSelectionChange}
@@ -217,7 +226,7 @@ export const OpenpeepsMarkdownInput = ({
217
226
  <ThemedText
218
227
  className={cn('text-right text-sm', overLimit && 'text-destructive')}
219
228
  >
220
- {value.length} / {maxLength}
229
+ {shownLength} / {maxLength}
221
230
  </ThemedText>
222
231
  </View>
223
232
  </View>