@marktiderman/genesis-ui-native 3.6.0 → 3.8.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 (90) hide show
  1. package/README.md +48 -1
  2. package/dist/{chunk-NDXNSSM6.js → chunk-DHONOH6K.js} +24 -211
  3. package/dist/chunk-DHONOH6K.js.map +1 -0
  4. package/dist/{chunk-6PGLX6ET.js → chunk-FGIIBON3.js} +334 -24
  5. package/dist/chunk-FGIIBON3.js.map +1 -0
  6. package/dist/{chunk-ZRQAFFTN.js → chunk-FOJJB6AB.js} +2 -2
  7. package/dist/{chunk-ZRQAFFTN.js.map → chunk-FOJJB6AB.js.map} +1 -1
  8. package/dist/{chunk-SEJ6RBP7.js → chunk-JZ7RAGDQ.js} +117 -60
  9. package/dist/chunk-JZ7RAGDQ.js.map +1 -0
  10. package/dist/chunk-PWS2HLDE.js +137 -0
  11. package/dist/chunk-PWS2HLDE.js.map +1 -0
  12. package/dist/{chunk-AGTBABAH.js → chunk-PWYMRUAK.js} +43 -30
  13. package/dist/chunk-PWYMRUAK.js.map +1 -0
  14. package/dist/{chunk-FUMSL7VZ.js → chunk-T7FEVT62.js} +53 -12
  15. package/dist/chunk-T7FEVT62.js.map +1 -0
  16. package/dist/{chunk-2Z72MYHB.js → chunk-UZCJDMGE.js} +353 -19
  17. package/dist/chunk-UZCJDMGE.js.map +1 -0
  18. package/dist/components/index.d.ts +275 -24
  19. package/dist/components/index.js +5 -5
  20. package/dist/data/index.d.ts +2 -1
  21. package/dist/data/index.js +7 -12
  22. package/dist/data/index.js.map +1 -1
  23. package/dist/hooks/index.d.ts +36 -3
  24. package/dist/hooks/index.js +2 -2
  25. package/dist/icons/lucide.d.ts +1 -1
  26. package/dist/icons/lucide.js +13 -3
  27. package/dist/icons/lucide.js.map +1 -1
  28. package/dist/{inbox-page-B7_Oi2fS.d.ts → inbox-page-BGqR_cBs.d.ts} +4 -1
  29. package/dist/index.d.ts +4 -4
  30. package/dist/index.js +8 -8
  31. package/dist/layouts/index.d.ts +12 -3
  32. package/dist/layouts/index.js +5 -5
  33. package/dist/{native-modules-Cl3zw3kh.d.ts → native-modules-CeAaO2Dh.d.ts} +55 -3
  34. package/package.json +73 -2
  35. package/src/__tests__/doctor-rules.test.ts +27 -0
  36. package/src/__tests__/native-modules-lists.test.tsx +1 -0
  37. package/src/components/__tests__/bulk-bar.test.tsx +36 -0
  38. package/src/components/__tests__/button-haptic.test.tsx +74 -0
  39. package/src/components/__tests__/composer-bar.test.tsx +140 -1
  40. package/src/components/__tests__/gallery-grid.test.tsx +2 -2
  41. package/src/components/__tests__/library-round-5.test.tsx +121 -0
  42. package/src/components/__tests__/share-sheet.test.tsx +47 -0
  43. package/src/components/__tests__/swipe-row-context-menu.test.tsx +215 -0
  44. package/src/components/__tests__/tab-bar.test.tsx +43 -0
  45. package/src/components/__tests__/thread-list.test.tsx +200 -0
  46. package/src/components/__tests__/tier-badge.test.tsx +57 -0
  47. package/src/components/__tests__/whats-new-sheet.test.tsx +29 -0
  48. package/src/components/bulk-bar.tsx +91 -0
  49. package/src/components/button.tsx +81 -25
  50. package/src/components/choice-card.tsx +104 -0
  51. package/src/components/composer-bar.tsx +104 -25
  52. package/src/components/context-menu.tsx +101 -0
  53. package/src/components/gallery-grid.tsx +10 -4
  54. package/src/components/index.ts +19 -2
  55. package/src/components/inline-alert.tsx +36 -1
  56. package/src/components/input.tsx +3 -0
  57. package/src/components/progress.tsx +24 -2
  58. package/src/components/rating.tsx +35 -16
  59. package/src/components/share-sheet.tsx +127 -0
  60. package/src/components/sheet.tsx +9 -1
  61. package/src/components/swipe-row.tsx +74 -0
  62. package/src/components/tab-bar.tsx +133 -0
  63. package/src/components/tabs.tsx +2 -0
  64. package/src/components/text.tsx +3 -0
  65. package/src/components/textarea.tsx +3 -0
  66. package/src/components/thread-list.tsx +78 -23
  67. package/src/components/tier-badge.tsx +74 -0
  68. package/src/components/whats-new-sheet.tsx +89 -0
  69. package/src/data/resource-view/NativeRecordView.tsx +3 -8
  70. package/src/data/resource-view/use-native-resource-view.ts +2 -2
  71. package/src/hooks/__tests__/use-haptics.test.tsx +146 -0
  72. package/src/hooks/index.ts +3 -1
  73. package/src/hooks/use-haptics.ts +64 -0
  74. package/src/hooks/use-press-feedback.ts +87 -0
  75. package/src/hooks/use-theme-roles.ts +3 -0
  76. package/src/icon-names.ts +12 -2
  77. package/src/icons/lucide.ts +27 -7
  78. package/src/layouts/__tests__/inbox-page.test.tsx +26 -7
  79. package/src/layouts/__tests__/thread-page.test.tsx +89 -2
  80. package/src/layouts/inbox-page.tsx +28 -12
  81. package/src/layouts/thread-page.tsx +69 -8
  82. package/src/native-modules.tsx +20 -0
  83. package/dist/chunk-2Z72MYHB.js.map +0 -1
  84. package/dist/chunk-4OQOJ2OC.js +0 -80
  85. package/dist/chunk-4OQOJ2OC.js.map +0 -1
  86. package/dist/chunk-6PGLX6ET.js.map +0 -1
  87. package/dist/chunk-AGTBABAH.js.map +0 -1
  88. package/dist/chunk-FUMSL7VZ.js.map +0 -1
  89. package/dist/chunk-NDXNSSM6.js.map +0 -1
  90. package/dist/chunk-SEJ6RBP7.js.map +0 -1
@@ -0,0 +1,87 @@
1
+ /**
2
+ * usePressFeedback: how a pressable answers a touch, the same for buttons, rows and cards. It
3
+ * shrinks a little while held (on the motion tokens' `press` duration) and springs back on release
4
+ * (`snappy`), and can play a haptic when the press lands. Under Reduce Motion (or brand motion
5
+ * `none`) it dims instead of moving.
6
+ *
7
+ * const press = usePressFeedback({ haptic: "light" });
8
+ * <Pressable onPress={save} onPressIn={press.onPressIn} onPressOut={press.onPressOut}>
9
+ * <Animated.View style={press.style}>…</Animated.View>
10
+ * </Pressable>
11
+ *
12
+ * The haptic plays on `onPressIn` for `select` (a tick under the finger, as iOS does). Any other
13
+ * kind plays when you call `press.confirm()` from `onPress`, so a press cancelled by scrolling
14
+ * stays quiet.
15
+ *
16
+ * Built on React Native's `Animated`, so it works without Reanimated.
17
+ *
18
+ * @stability Beta
19
+ */
20
+ import { useCallback, useEffect, useMemo, useRef } from "react";
21
+ import { Animated } from "react-native";
22
+ import { useMotion, type UseMotionOptions } from "./use-motion";
23
+ import { useHaptics, type HapticKind } from "./use-haptics";
24
+
25
+ type AnimatedValue = InstanceType<typeof Animated.Value>;
26
+
27
+ export interface PressFeedbackOptions {
28
+ /** A haptic when the press counts (`confirm()`), or `select` as a tick on press-in. Default none. */
29
+ haptic?: HapticKind | false;
30
+ /** How far it shrinks while held. Default 0.97. */
31
+ scale?: number;
32
+ /** Under Reduce Motion: how far it dims while held. Default 0.6. */
33
+ dimTo?: number;
34
+ /** No feedback (a disabled button). */
35
+ disabled?: boolean;
36
+ /** The brand's motion level, as `useMotion` takes it. */
37
+ level?: UseMotionOptions["level"];
38
+ }
39
+
40
+ export interface PressFeedback {
41
+ onPressIn: () => void;
42
+ onPressOut: () => void;
43
+ /** Call from `onPress`: plays the haptic for a press that counted. */
44
+ confirm: () => void;
45
+ /** For an `Animated.View` around the pressable's content. */
46
+ style: { transform?: { scale: AnimatedValue }[]; opacity?: AnimatedValue };
47
+ }
48
+
49
+ export function usePressFeedback({ haptic = false, scale = 0.97, dimTo = 0.6, disabled = false, level }: PressFeedbackOptions = {}): PressFeedback {
50
+ const motion = useMotion(level ? { level } : {});
51
+ const play = useHaptics();
52
+ const value = useRef(new Animated.Value(1)).current;
53
+ const reduced = motion.reduced;
54
+
55
+ const to = useCallback(
56
+ (target: number, held: boolean) => {
57
+ if (held || reduced) {
58
+ Animated.timing(value, { toValue: target, duration: motion.duration.press, useNativeDriver: true }).start();
59
+ } else {
60
+ const s = motion.spring.snappy;
61
+ Animated.spring(value, { toValue: target, damping: s.damping, stiffness: s.stiffness, mass: s.mass, useNativeDriver: true }).start();
62
+ }
63
+ },
64
+ [value, motion, reduced],
65
+ );
66
+
67
+ const onPressIn = useCallback(() => {
68
+ if (disabled) return;
69
+ to(reduced ? dimTo : scale, true);
70
+ if (haptic === "select") play("select");
71
+ }, [disabled, reduced, dimTo, scale, to, haptic, play]);
72
+
73
+ // Always let go, even if the pressable was disabled mid-press (a send that started), and start
74
+ // from rest whenever it's disabled, so it never comes back still shrunk.
75
+ const onPressOut = useCallback(() => to(1, false), [to]);
76
+ useEffect(() => {
77
+ if (disabled) value.setValue(1);
78
+ }, [disabled, value]);
79
+
80
+ const confirm = useCallback(() => {
81
+ if (!disabled && haptic && haptic !== "select") play(haptic);
82
+ }, [disabled, haptic, play]);
83
+
84
+ const style = useMemo(() => (disabled ? {} : reduced ? { opacity: value } : { transform: [{ scale: value }] }), [disabled, reduced, value]);
85
+
86
+ return { onPressIn, onPressOut, confirm, style };
87
+ }
@@ -43,3 +43,6 @@ export function useThemeRoles(options: UseThemeRolesOptions = {}): ThemeRoleColo
43
43
  [scheme, tint, androidDynamic],
44
44
  );
45
45
  }
46
+
47
+ /** The colour of a message you sent, on every thread on the phone. Its text is `text-primary-foreground`. */
48
+ export const sentBubbleColor = <C,>(roles: { tint: C }): C => roles.tint;
package/src/icon-names.ts CHANGED
@@ -7,19 +7,19 @@
7
7
  * @stability Beta
8
8
  */
9
9
  export const SF_SYMBOLS = {
10
+ aperture: "camera.aperture",
10
11
  "arrow-left": "arrow.left",
11
12
  "arrow-up": "arrow.up",
12
- aperture: "camera.aperture",
13
13
  bell: "bell",
14
14
  calendar: "calendar",
15
15
  camera: "camera",
16
16
  "camera-flip": "arrow.triangle.2.circlepath.camera",
17
17
  check: "checkmark",
18
- clapperboard: "movieclapper",
19
18
  "chevron-down": "chevron.down",
20
19
  "chevron-left": "chevron.left",
21
20
  "chevron-right": "chevron.right",
22
21
  "chevron-up": "chevron.up",
22
+ clapperboard: "movieclapper",
23
23
  clock: "clock",
24
24
  close: "xmark",
25
25
  compose: "square.and.pencil",
@@ -29,13 +29,18 @@ export const SF_SYMBOLS = {
29
29
  error: "xmark.circle",
30
30
  expand: "arrow.up.left.and.arrow.down.right",
31
31
  "external-link": "arrow.up.right.square",
32
+ eye: "eye",
32
33
  file: "doc",
33
34
  filter: "line.3.horizontal.decrease",
34
35
  "folder-plus": "folder.badge.plus",
36
+ grid: "square.grid.2x2",
37
+ grip: "line.3.horizontal",
35
38
  heart: "heart",
36
39
  home: "house",
37
40
  image: "photo",
38
41
  info: "info.circle",
42
+ link: "link",
43
+ list: "list.bullet",
39
44
  lock: "lock",
40
45
  "log-out": "rectangle.portrait.and.arrow.right",
41
46
  mail: "envelope",
@@ -51,6 +56,7 @@ export const SF_SYMBOLS = {
51
56
  play: "play.fill",
52
57
  plus: "plus",
53
58
  radio: "dot.radiowaves.left.and.right",
59
+ redo: "arrow.uturn.forward",
54
60
  refresh: "arrow.clockwise",
55
61
  reply: "arrowshape.turn.up.left",
56
62
  search: "magnifyingglass",
@@ -58,10 +64,14 @@ export const SF_SYMBOLS = {
58
64
  "settings-2": "slider.horizontal.3",
59
65
  share: "square.and.arrow.up",
60
66
  smile: "face.smiling",
67
+ sort: "arrow.up.arrow.down",
61
68
  star: "star",
62
69
  stop: "stop.fill",
63
70
  success: "checkmark.circle",
71
+ table: "tablecells",
64
72
  trash: "trash",
73
+ undo: "arrow.uturn.backward",
74
+ upload: "tray.and.arrow.up",
65
75
  user: "person",
66
76
  video: "video",
67
77
  volume: "speaker.wave.2.fill",
@@ -12,34 +12,40 @@ import {
12
12
  Aperture,
13
13
  ArrowLeft,
14
14
  ArrowUp,
15
+ ArrowUpDown,
15
16
  Bell,
16
17
  Calendar,
17
18
  Camera,
18
19
  Check,
19
- Clapperboard,
20
20
  ChevronDown,
21
21
  ChevronLeft,
22
22
  ChevronRight,
23
23
  ChevronUp,
24
24
  CircleCheck,
25
25
  CircleX,
26
+ Clapperboard,
26
27
  Clock,
27
28
  Copy,
28
29
  Download,
29
30
  Ellipsis,
30
31
  ExternalLink,
32
+ Eye,
31
33
  File,
32
34
  FolderPlus,
33
35
  Funnel,
36
+ GripVertical,
34
37
  Heart,
35
38
  House,
36
39
  Image,
37
40
  Info,
38
- Maximize,
39
- Maximize2,
41
+ LayoutGrid,
42
+ Link,
43
+ List,
40
44
  Lock,
41
45
  LogOut,
42
46
  Mail,
47
+ Maximize,
48
+ Maximize2,
43
49
  Menu,
44
50
  MessageCircle,
45
51
  Mic,
@@ -51,19 +57,23 @@ import {
51
57
  Play,
52
58
  Plus,
53
59
  Radio,
60
+ Redo2,
54
61
  RefreshCw,
55
62
  Reply,
56
63
  Search,
57
- Square,
58
- SwitchCamera,
59
64
  Settings,
60
65
  Settings2,
61
66
  Share,
62
67
  Smile,
68
+ Square,
63
69
  SquarePen,
64
70
  Star,
71
+ SwitchCamera,
72
+ Table,
65
73
  Trash2,
66
74
  TriangleAlert,
75
+ Undo2,
76
+ Upload,
67
77
  User,
68
78
  Video,
69
79
  Volume2,
@@ -74,19 +84,19 @@ import type { NativeIconName } from "../icon-names";
74
84
  import type { GenesisIconComponent } from "../native-modules";
75
85
 
76
86
  export const lucideIcons: Record<NativeIconName, GenesisIconComponent> = {
87
+ aperture: Aperture,
77
88
  "arrow-left": ArrowLeft,
78
89
  "arrow-up": ArrowUp,
79
- aperture: Aperture,
80
90
  bell: Bell,
81
91
  calendar: Calendar,
82
92
  camera: Camera,
83
93
  "camera-flip": SwitchCamera,
84
94
  check: Check,
85
- clapperboard: Clapperboard,
86
95
  "chevron-down": ChevronDown,
87
96
  "chevron-left": ChevronLeft,
88
97
  "chevron-right": ChevronRight,
89
98
  "chevron-up": ChevronUp,
99
+ clapperboard: Clapperboard,
90
100
  clock: Clock,
91
101
  close: X,
92
102
  compose: SquarePen,
@@ -96,13 +106,18 @@ export const lucideIcons: Record<NativeIconName, GenesisIconComponent> = {
96
106
  error: CircleX,
97
107
  expand: Maximize2,
98
108
  "external-link": ExternalLink,
109
+ eye: Eye,
99
110
  file: File,
100
111
  filter: Funnel,
101
112
  "folder-plus": FolderPlus,
113
+ grid: LayoutGrid,
114
+ grip: GripVertical,
102
115
  heart: Heart,
103
116
  home: House,
104
117
  image: Image,
105
118
  info: Info,
119
+ link: Link,
120
+ list: List,
106
121
  lock: Lock,
107
122
  "log-out": LogOut,
108
123
  mail: Mail,
@@ -118,6 +133,7 @@ export const lucideIcons: Record<NativeIconName, GenesisIconComponent> = {
118
133
  play: Play,
119
134
  plus: Plus,
120
135
  radio: Radio,
136
+ redo: Redo2,
121
137
  refresh: RefreshCw,
122
138
  reply: Reply,
123
139
  search: Search,
@@ -125,10 +141,14 @@ export const lucideIcons: Record<NativeIconName, GenesisIconComponent> = {
125
141
  "settings-2": Settings2,
126
142
  share: Share,
127
143
  smile: Smile,
144
+ sort: ArrowUpDown,
128
145
  star: Star,
129
146
  stop: Square,
130
147
  success: CircleCheck,
148
+ table: Table,
131
149
  trash: Trash2,
150
+ undo: Undo2,
151
+ upload: Upload,
132
152
  user: User,
133
153
  video: Video,
134
154
  volume: Volume2,
@@ -1,8 +1,9 @@
1
1
  // @feat:inbox-thread
2
2
  import type { ReactNode } from "react";
3
- import { fireEvent, render, screen } from "@testing-library/react";
3
+ import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
4
4
  import { afterEach, describe, expect, it, vi } from "vitest";
5
5
  import { Alert, Platform, StyleSheet } from "react-native";
6
+ import { GenesisModulesProvider } from "../../native-modules";
6
7
  import { InboxPage, formatInboxTime, getInboxPageStackOptions, type InboxItem } from "../inbox-page";
7
8
 
8
9
  const NOW = new Date(2026, 9, 24, 15, 0);
@@ -84,7 +85,7 @@ describe("InboxPage", () => {
84
85
  expect(items[0]!.onPress).toHaveBeenCalled();
85
86
  });
86
87
 
87
- it("offers swipe actions as accessibility actions and on long press, without a gesture library", () => {
88
+ it("offers swipe actions as accessibility actions and on long press, without a gesture library", async () => {
88
89
  const remove = vi.fn();
89
90
  const markRead = vi.fn();
90
91
  render(
@@ -99,11 +100,29 @@ describe("InboxPage", () => {
99
100
  row.dispatchEvent(new CustomEvent("accessibilityaction", { detail: "delete" }));
100
101
  expect(remove).toHaveBeenCalledTimes(1);
101
102
  fireEvent.contextMenu(row);
102
- const [title, , buttons] = vi.mocked(Alert.alert).mock.calls[0]!;
103
- expect(title).toBe("Thread");
104
- expect(buttons?.map((b) => [b.text, b.style])).toEqual([["Mark read", "default"], ["Delete", "destructive"], ["Cancel", "cancel"]]);
105
- buttons?.[0]?.onPress?.();
106
- expect(markRead).toHaveBeenCalled();
103
+ await act(async () => {});
104
+ expect(Alert.alert).not.toHaveBeenCalled();
105
+ expect(screen.getByTestId("inbox-menu-title").textContent).toBe("Thread");
106
+ expect(screen.getByTestId("inbox-menu-action-read").textContent).toBe("Mark read");
107
+ expect(screen.getByTestId("inbox-menu-action-delete").textContent).toBe("Delete");
108
+ expect(screen.getByTestId("inbox-menu-cancel")).toBeTruthy();
109
+ fireEvent.click(screen.getByTestId("inbox-menu-action-read"));
110
+ await waitFor(() => expect(markRead).toHaveBeenCalled());
111
+ });
112
+
113
+ it("swipes through NativeSwipeRow once the app gave the module", () => {
114
+ const Swipeable = ({ children, testID, renderRightActions }: { children?: ReactNode; testID: string; renderRightActions?: () => ReactNode }) => (
115
+ <div data-testid={testID}>
116
+ {renderRightActions?.()}
117
+ {children}
118
+ </div>
119
+ );
120
+ render(
121
+ <GenesisModulesProvider modules={{ swipeable: Swipeable as never }}>
122
+ <InboxPage testID="inbox" items={[{ id: "x", title: "Thread", swipeActions: [{ id: "delete", label: "Delete", onPress: vi.fn(), destructive: true }] }]} />
123
+ </GenesisModulesProvider>,
124
+ );
125
+ expect(screen.getByTestId("inbox-row-x-swipe-action-delete")).toBeTruthy();
107
126
  });
108
127
 
109
128
  it("wraps rows with actions in the swipeable slot, and a null slot leaves them bare", () => {
@@ -1,6 +1,7 @@
1
1
  // @feat:inbox-thread
2
- import type { ReactNode } from "react";
3
- import { fireEvent, render, screen } from "@testing-library/react";
2
+ import { forwardRef, useImperativeHandle, type ReactNode } from "react";
3
+ import { fireEvent, render, screen, waitFor } from "@testing-library/react";
4
+ import { Linking } from "react-native";
4
5
  import { describe, expect, it, vi } from "vitest";
5
6
  import { ThreadPage, getThreadPageStackOptions, readReceiptFor, type ThreadMessage } from "../thread-page";
6
7
  import { GenesisModulesProvider } from "../../native-modules";
@@ -226,3 +227,89 @@ describe("ThreadPage", () => {
226
227
  expect(getThreadPageStackOptions({ headerTitle: "Report" })).toEqual({ title: "Report" });
227
228
  });
228
229
  });
230
+
231
+ describe("ThreadPage: files, errors and the modes' name", () => {
232
+ const withFile = (uri: string): ThreadMessage[] => [
233
+ { id: "1", body: "See attached", mine: false, timestamp: "2026-10-01T09:00:00Z", attachments: [{ id: "f", kind: "file", uri, name: "a.pdf" }] },
234
+ ];
235
+
236
+ it("shows a file by name and opens its link", () => {
237
+ const open = vi.spyOn(Linking, "openURL").mockResolvedValue(true as never);
238
+ render(<ThreadPage testID="t" messages={withFile("https://example.test/a.pdf")} composer={null} />);
239
+ const file = screen.getByTestId("t-attachment-f");
240
+ expect(file.textContent).toBe("a.pdf");
241
+ fireEvent.click(file);
242
+ expect(open).toHaveBeenCalledWith("https://example.test/a.pdf");
243
+ open.mockRestore();
244
+ });
245
+
246
+ it("won't open a file at another scheme", () => {
247
+ const open = vi.spyOn(Linking, "openURL").mockResolvedValue(true as never);
248
+ render(<ThreadPage testID="t" messages={withFile("someapp://do-a-thing")} composer={null} />);
249
+ fireEvent.click(screen.getByTestId("t-attachment-f"));
250
+ expect(open).not.toHaveBeenCalled();
251
+ open.mockRestore();
252
+ });
253
+
254
+ it("opens a local file only on your own message", () => {
255
+ const open = vi.spyOn(Linking, "openURL").mockResolvedValue(true as never);
256
+ const local = (mine: boolean): ThreadMessage[] => [{ ...withFile("file:///a.pdf")[0]!, mine }];
257
+ const { rerender } = render(<ThreadPage testID="t" messages={local(false)} composer={null} />);
258
+ fireEvent.click(screen.getByTestId("t-attachment-f"));
259
+ expect(open).not.toHaveBeenCalled();
260
+ rerender(<ThreadPage testID="t" messages={local(true)} composer={null} />);
261
+ fireEvent.click(screen.getByTestId("t-attachment-f"));
262
+ expect(open).toHaveBeenCalledWith("file:///a.pdf");
263
+ open.mockRestore();
264
+ });
265
+
266
+ it("has an error state, with Try again", () => {
267
+ const onRetry = vi.fn();
268
+ render(<ThreadPage testID="t" messages={[]} composer={null} error onRetry={onRetry} />);
269
+ expect(screen.getByTestId("t-error").textContent).toContain("Couldn't load this conversation");
270
+ fireEvent.click(screen.getByTestId("t-error-action"));
271
+ expect(onRetry).toHaveBeenCalled();
272
+ });
273
+
274
+ it("names the mode picker from the composer", () => {
275
+ render(<ThreadPage testID="t" messages={messages} composer={composer({ modesLabel: "Envoyer comme", modes: [{ id: "a", label: "A" }, { id: "b", label: "B" }] })} />);
276
+ expect(screen.getByTestId("t-composer-modes").getAttribute("aria-label")).toBe("Envoyer comme");
277
+ });
278
+ });
279
+
280
+ describe("ThreadPage's jumpId", () => {
281
+ it("goes to a message by jumpId when its id is the client's: that row, highlighted, and nothing gone", async () => {
282
+ const scrollToIndex = vi.fn();
283
+ const List = forwardRef<unknown, Record<string, any>>(function List(props, ref) {
284
+ useImperativeHandle(ref, () => ({ scrollToIndex, scrollToEnd: vi.fn(), scrollToOffset: vi.fn() }));
285
+ return (
286
+ <div>
287
+ {props.data.map((item: ThreadMessage, index: number) => (
288
+ <div key={props.keyExtractor(item)}>{props.renderItem({ item, index })}</div>
289
+ ))}
290
+ </div>
291
+ );
292
+ });
293
+ const onJumpFailed = vi.fn();
294
+ const Message = ({ id, highlighted }: { id: string; highlighted: boolean }) => <span data-testid={`m-${id}`} data-highlighted={String(highlighted)} />;
295
+ render(
296
+ <GenesisModulesProvider modules={{ list: List as never }}>
297
+ <ThreadPage
298
+ testID="jump"
299
+ messages={[
300
+ { id: "c1", jumpId: "m1", body: "first", mine: false, timestamp: "2026-10-01T09:00:00Z" },
301
+ { id: "c2", jumpId: "m2", body: "second", mine: true, timestamp: "2026-10-01T09:01:00Z" },
302
+ ]}
303
+ composer={null}
304
+ jumpTo="m2"
305
+ onJumpFailed={onJumpFailed}
306
+ slots={{ message: Message as never }}
307
+ />
308
+ </GenesisModulesProvider>,
309
+ );
310
+ await waitFor(() => expect(scrollToIndex).toHaveBeenCalledWith(expect.objectContaining({ index: 1 })));
311
+ await waitFor(() => expect(screen.getByTestId("m-c2").getAttribute("data-highlighted")).toBe("true"));
312
+ expect(screen.getByTestId("m-c1").getAttribute("data-highlighted")).toBe("false");
313
+ expect(onJumpFailed).not.toHaveBeenCalled();
314
+ });
315
+ });
@@ -11,9 +11,10 @@
11
11
  *
12
12
  * Swipe actions: each row's `swipeActions` are always reachable without a
13
13
  * gesture library, as VoiceOver / TalkBack custom actions and on long press
14
- * (a menu). For the swipe itself, fill the `swipeable` slot with your
15
- * gesture-handler wrapper (`ReanimatedSwipeable` from
16
- * react-native-gesture-handler, an optional peer); it receives the actions
14
+ * (`NativeContextMenu`). The swipe itself is `NativeSwipeRow`, once the app
15
+ * passes `GenesisModules.swipeable` (`ReanimatedSwipeable` from
16
+ * react-native-gesture-handler, an optional peer), with each action's `side`.
17
+ * The `swipeable` slot takes your own wrapper instead; it receives the actions
17
18
  * and the row.
18
19
  *
19
20
  * Rows: `avatar` puts a picture of who it is between the unread dot and the
@@ -29,7 +30,7 @@
29
30
  *
30
31
  * @stability Beta
31
32
  */
32
- import { Fragment, useState, type ReactNode } from "react";
33
+ import { createContext, Fragment, useContext, useState, type ReactNode } from "react";
33
34
  import { renderSlot, type SlotPropsFor, type Slots } from "@marktiderman/genesis-core/slots";
34
35
  import { Alert, FlatList, Platform, Pressable, ScrollView, StyleSheet, View } from "react-native";
35
36
  import { SafeAreaView } from "react-native-safe-area-context";
@@ -38,7 +39,9 @@ import { NativeEmptyState } from "../components/empty-state";
38
39
  import { NativeText } from "../components/text";
39
40
  import { NativeButton } from "../components/button";
40
41
  import { NativeBadge } from "../components/badge";
42
+ import { NativeContextMenu } from "../components/context-menu";
41
43
  import { NativeRefreshControl } from "../components/refresh-control";
44
+ import { NativeSwipeRow } from "../components/swipe-row";
42
45
  import { NativeLoadingState } from "../components/loading-state";
43
46
  import { composeHeaderOptions, type ScreenHeaderProps } from "./screen-container";
44
47
  import { formatInboxTime, type InboxItem, type InboxSwipeAction } from "@marktiderman/genesis-core/conversation";
@@ -102,6 +105,9 @@ export function getInboxPageStackOptions(props: ScreenHeaderProps & { headerTitl
102
105
  });
103
106
  }
104
107
 
108
+ /** Opens the page's one actions menu for a row. */
109
+ const OpenRowMenu = createContext<(row: InboxPageSlotMap["row"]) => void>(() => undefined);
110
+
105
111
  /** The row's leading padding, the unread dot's column, an avatar's default size and its gap to the text. */
106
112
  const ROW_PADDING = 16;
107
113
  const LEADING_WIDTH = 18;
@@ -139,6 +145,9 @@ export function InboxPage({
139
145
  }: InboxPageProps) {
140
146
  const colors = useThemeRoles();
141
147
  const clock = now();
148
+ // One menu for the page: its row stays set while the sheet goes, so its words don't vanish first.
149
+ const [menuRow, setMenuRow] = useState<InboxPageSlotMap["row"] | null>(null);
150
+ const [menuOpen, setMenuOpen] = useState(false);
142
151
  const rows: InboxPageSlotMap["row"][] = items.map((item, index) => ({
143
152
  ...item,
144
153
  testID: item.testID ?? `${testID}-row-${item.id}`,
@@ -201,6 +210,12 @@ export function InboxPage({
201
210
 
202
211
  return (
203
212
  <SafeAreaView testID={testID} edges={["left", "right", "bottom"]} style={{ flex: 1, backgroundColor: colors.groupedBackground }}>
213
+ <OpenRowMenu.Provider
214
+ value={(row) => {
215
+ setMenuRow(row);
216
+ setMenuOpen(true);
217
+ }}
218
+ >
204
219
  <FlatList
205
220
  testID={`${testID}-list`}
206
221
  data={rows}
@@ -221,12 +236,14 @@ export function InboxPage({
221
236
  return (
222
237
  <Fragment>
223
238
  {actions.length && slots.swipeable !== null
224
- ? renderSlot(PassThroughSwipeable, slots.swipeable, { actions, testID: `${row.testID}-swipe`, children: content }, slotProps.swipeable)
239
+ ? renderSlot(NativeSwipeRow, slots.swipeable, { actions, testID: `${row.testID}-swipe`, children: content }, slotProps.swipeable)
225
240
  : content}
226
241
  </Fragment>
227
242
  );
228
243
  }}
229
244
  />
245
+ </OpenRowMenu.Provider>
246
+ {menuRow ? <NativeContextMenu open={menuOpen} onOpenChange={setMenuOpen} title={menuRow.title} actions={menuRow.swipeActions ?? []} testID={`${testID}-menu`} /> : null}
230
247
  </SafeAreaView>
231
248
  );
232
249
  }
@@ -235,11 +252,6 @@ function EmptyPart(_props: InboxPageSlotMap["header"]) {
235
252
  return null;
236
253
  }
237
254
 
238
- /** The default `swipeable`: no gesture, just the row (its actions are on long press and in the accessibility actions). */
239
- function PassThroughSwipeable({ children }: InboxPageSlotMap["swipeable"]) {
240
- return <>{children}</>;
241
- }
242
-
243
255
  function SectionTitle({ title, testID }: { title: string; testID: string }) {
244
256
  const colors = useThemeRoles();
245
257
  const ios = Platform.OS === "ios";
@@ -259,7 +271,10 @@ function SectionTitle({ title, testID }: { title: string; testID: string }) {
259
271
  );
260
272
  }
261
273
 
262
- /** Opens a row's actions as a menu (long press). */
274
+ /**
275
+ * Opens a row's actions as the system alert. `InboxPage` now opens `NativeContextMenu`; `NativeResourceView`
276
+ * still uses this.
277
+ */
263
278
  export function showInboxActions(title: string, actions: InboxSwipeAction[], cancelLabel = "Cancel"): void {
264
279
  Alert.alert(title, undefined, [
265
280
  ...actions.map((a) => ({ text: a.label, style: a.destructive ? ("destructive" as const) : ("default" as const), onPress: a.onPress })),
@@ -271,6 +286,7 @@ function DefaultRow(row: InboxPageSlotMap["row"]) {
271
286
  const colors = useThemeRoles();
272
287
  const ios = Platform.OS === "ios";
273
288
  const [pressed, setPressed] = useState(false);
289
+ const openMenu = useContext(OpenRowMenu);
274
290
  const actions = row.swipeActions ?? [];
275
291
  const radius = iosGroupRadius();
276
292
  const unreadLabel = row.unreadCount && row.unreadCount > 0 ? `${row.unreadCount} unread` : row.unread ? "Unread" : null;
@@ -303,7 +319,7 @@ function DefaultRow(row: InboxPageSlotMap["row"]) {
303
319
  accessibilityActions={actions.map((a) => ({ name: a.id, label: a.label }))}
304
320
  onAccessibilityAction={(event) => actions.find((a) => a.id === event.nativeEvent.actionName)?.onPress()}
305
321
  onPress={row.onPress}
306
- onLongPress={actions.length ? () => showInboxActions(row.title, actions) : undefined}
322
+ onLongPress={actions.length ? () => openMenu(row) : undefined}
307
323
  onPressIn={() => setPressed(true)}
308
324
  onPressOut={() => setPressed(false)}
309
325
  style={{ flexDirection: "row", alignItems: "center", paddingHorizontal: ROW_PADDING, paddingVertical: 11, minHeight: 60, backgroundColor: (pressed && row.onPress) || row.selected ? colors.fill : undefined }}