@marktiderman/genesis-ui-native 3.7.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 (87) hide show
  1. package/README.md +4 -1
  2. package/dist/{chunk-KH2RVAI5.js → chunk-DHONOH6K.js} +24 -210
  3. package/dist/chunk-DHONOH6K.js.map +1 -0
  4. package/dist/{chunk-O4BMDV7I.js → chunk-FGIIBON3.js} +333 -21
  5. package/dist/chunk-FGIIBON3.js.map +1 -0
  6. package/dist/{chunk-YWDDDYDI.js → chunk-FOJJB6AB.js} +2 -2
  7. package/dist/{chunk-YWDDDYDI.js.map → chunk-FOJJB6AB.js.map} +1 -1
  8. package/dist/{chunk-IXC3LO2K.js → chunk-JZ7RAGDQ.js} +44 -36
  9. package/dist/chunk-JZ7RAGDQ.js.map +1 -0
  10. package/dist/{chunk-RTYO24SC.js → chunk-PWS2HLDE.js} +63 -31
  11. package/dist/chunk-PWS2HLDE.js.map +1 -0
  12. package/dist/{chunk-3KFUS7O6.js → chunk-PWYMRUAK.js} +43 -30
  13. package/dist/chunk-PWYMRUAK.js.map +1 -0
  14. package/dist/{chunk-GBNIBHSU.js → chunk-T7FEVT62.js} +53 -12
  15. package/dist/chunk-T7FEVT62.js.map +1 -0
  16. package/dist/{chunk-7NDKIIOT.js → chunk-UZCJDMGE.js} +353 -19
  17. package/dist/chunk-UZCJDMGE.js.map +1 -0
  18. package/dist/components/index.d.ts +229 -23
  19. package/dist/components/index.js +5 -6
  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 +7 -3
  24. package/dist/hooks/index.js +2 -3
  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 -9
  31. package/dist/layouts/index.d.ts +12 -3
  32. package/dist/layouts/index.js +5 -6
  33. package/dist/{native-modules-DEJJQhDx.d.ts → native-modules-CeAaO2Dh.d.ts} +26 -2
  34. package/package.json +49 -1
  35. package/src/__tests__/native-modules-lists.test.tsx +1 -0
  36. package/src/components/__tests__/bulk-bar.test.tsx +36 -0
  37. package/src/components/__tests__/button-haptic.test.tsx +22 -0
  38. package/src/components/__tests__/composer-bar.test.tsx +116 -1
  39. package/src/components/__tests__/gallery-grid.test.tsx +2 -2
  40. package/src/components/__tests__/library-round-5.test.tsx +121 -0
  41. package/src/components/__tests__/share-sheet.test.tsx +47 -0
  42. package/src/components/__tests__/swipe-row-context-menu.test.tsx +215 -0
  43. package/src/components/__tests__/tab-bar.test.tsx +43 -0
  44. package/src/components/__tests__/thread-list.test.tsx +137 -0
  45. package/src/components/__tests__/tier-badge.test.tsx +57 -0
  46. package/src/components/__tests__/whats-new-sheet.test.tsx +29 -0
  47. package/src/components/bulk-bar.tsx +91 -0
  48. package/src/components/button.tsx +74 -35
  49. package/src/components/choice-card.tsx +104 -0
  50. package/src/components/composer-bar.tsx +20 -19
  51. package/src/components/context-menu.tsx +101 -0
  52. package/src/components/gallery-grid.tsx +10 -4
  53. package/src/components/index.ts +18 -1
  54. package/src/components/inline-alert.tsx +36 -1
  55. package/src/components/input.tsx +3 -0
  56. package/src/components/progress.tsx +24 -2
  57. package/src/components/rating.tsx +35 -16
  58. package/src/components/share-sheet.tsx +127 -0
  59. package/src/components/sheet.tsx +9 -1
  60. package/src/components/swipe-row.tsx +74 -0
  61. package/src/components/tab-bar.tsx +133 -0
  62. package/src/components/tabs.tsx +2 -0
  63. package/src/components/text.tsx +3 -0
  64. package/src/components/textarea.tsx +3 -0
  65. package/src/components/thread-list.tsx +48 -23
  66. package/src/components/tier-badge.tsx +74 -0
  67. package/src/components/whats-new-sheet.tsx +89 -0
  68. package/src/data/resource-view/NativeRecordView.tsx +3 -8
  69. package/src/data/resource-view/use-native-resource-view.ts +2 -2
  70. package/src/hooks/index.ts +1 -1
  71. package/src/hooks/use-theme-roles.ts +3 -0
  72. package/src/icon-names.ts +12 -2
  73. package/src/icons/lucide.ts +27 -7
  74. package/src/layouts/__tests__/inbox-page.test.tsx +26 -7
  75. package/src/layouts/__tests__/thread-page.test.tsx +89 -2
  76. package/src/layouts/inbox-page.tsx +28 -12
  77. package/src/layouts/thread-page.tsx +69 -8
  78. package/src/native-modules.tsx +16 -0
  79. package/dist/chunk-3KFUS7O6.js.map +0 -1
  80. package/dist/chunk-7NDKIIOT.js.map +0 -1
  81. package/dist/chunk-CAI7LGN6.js +0 -39
  82. package/dist/chunk-CAI7LGN6.js.map +0 -1
  83. package/dist/chunk-GBNIBHSU.js.map +0 -1
  84. package/dist/chunk-IXC3LO2K.js.map +0 -1
  85. package/dist/chunk-KH2RVAI5.js.map +0 -1
  86. package/dist/chunk-O4BMDV7I.js.map +0 -1
  87. package/dist/chunk-RTYO24SC.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ /**
2
+ * WhatsNewSheet — release notes in a sheet, shown once and closed with "Got it".
3
+ *
4
+ * The one sheet behind genesis-native's updates block (`WhatsNewSheet`) and genesis-product's
5
+ * `ProductWhatsNew`: each maps its own notes onto `NativeWhatsNewNote` and renders this.
6
+ *
7
+ * @stability Beta
8
+ */
9
+ import { View } from "react-native";
10
+ import { NativeButton } from "./button";
11
+ import { NativeSheet, NativeSheetScrollView } from "./sheet";
12
+ import { NativeText } from "./text";
13
+
14
+ /** One note. */
15
+ export interface NativeWhatsNewNote {
16
+ /** Unique within the sheet (a version, a note id). */
17
+ key: string;
18
+ title: string;
19
+ body?: string;
20
+ /** With `onOpenNote`, the note gets "Learn more". */
21
+ url?: string;
22
+ }
23
+
24
+ export interface NativeWhatsNewSheetProps<N extends NativeWhatsNewNote = NativeWhatsNewNote> {
25
+ notes: readonly N[];
26
+ /** Close and remember. */
27
+ dismiss: () => void;
28
+ /** "Learn more" on a note with a `url`: the sheet closes (and is remembered), then this opens it. */
29
+ onOpenNote?: (note: N) => void;
30
+ /** Default "What's new". */
31
+ title?: string;
32
+ /** Default "Got it". */
33
+ doneLabel?: string;
34
+ /** Default "Learn more". */
35
+ learnMoreLabel?: string;
36
+ /** The sheet's; each note is `{testID}-{key}`, Done `{testID}-done`, Learn more `{testID}-open-{key}`. */
37
+ testID?: string;
38
+ /** A note's testID. Default `{testID}-{key}`. */
39
+ noteTestID?: (key: string) => string;
40
+ }
41
+
42
+ export function NativeWhatsNewSheet<N extends NativeWhatsNewNote = NativeWhatsNewNote>({
43
+ notes,
44
+ dismiss,
45
+ onOpenNote,
46
+ title = "What's new",
47
+ doneLabel = "Got it",
48
+ learnMoreLabel = "Learn more",
49
+ testID = "native-whats-new",
50
+ noteTestID = (key) => `${testID}-${key}`,
51
+ }: NativeWhatsNewSheetProps<N>) {
52
+ return (
53
+ <NativeSheet open onOpenChange={(open) => (open ? undefined : dismiss())} testID={testID}>
54
+ {/* The notes scroll once they pass the sheet's height. */}
55
+ <NativeSheetScrollView contentContainerStyle={{ gap: 16, padding: 24 }}>
56
+ <NativeText preset="h3" accessibilityRole="header">
57
+ {title}
58
+ </NativeText>
59
+ {notes.map((note) => (
60
+ <View key={note.key} style={{ gap: 4 }} testID={noteTestID(note.key)}>
61
+ <NativeText preset="label">{note.title}</NativeText>
62
+ {note.body ? (
63
+ <NativeText preset="body-sm" className="text-muted-foreground">
64
+ {note.body}
65
+ </NativeText>
66
+ ) : null}
67
+ {note.url && onOpenNote ? (
68
+ <NativeButton
69
+ variant="ghost"
70
+ size="sm"
71
+ onPress={() => {
72
+ // Closed first: the note's screen opens with "what's new" seen.
73
+ dismiss();
74
+ onOpenNote(note);
75
+ }}
76
+ testID={`${testID}-open-${note.key}`}
77
+ >
78
+ {learnMoreLabel}
79
+ </NativeButton>
80
+ ) : null}
81
+ </View>
82
+ ))}
83
+ <NativeButton onPress={dismiss} testID={`${testID}-done`}>
84
+ {doneLabel}
85
+ </NativeButton>
86
+ </NativeSheetScrollView>
87
+ </NativeSheet>
88
+ );
89
+ }
@@ -12,7 +12,7 @@
12
12
  import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
13
13
  import { ActionSheetIOS, Alert, Platform, Pressable, ScrollView, View } from "react-native";
14
14
  import { useQuery, useQueryClient } from "@tanstack/react-query";
15
- import { DataWriteError, isDataWriteError, resourceKeys, useCapabilities, useDataProvider, useResource, useViewer, writeConflict, type BaseRecord, type DataRow, type ResourceContract, type WriteConflict } from "@marktiderman/genesis-core";
15
+ import { DataWriteError, isDataWriteError, NO_ROWS_MATCHED, resourceKeys, useCapabilities, useDataProvider, useResource, useViewer, writeConflict, type BaseRecord, type DataRow, type ResourceContract, type WriteConflict } from "@marktiderman/genesis-core";
16
16
  import { readinessChip, type ReadinessLabels } from "@marktiderman/genesis-core/resource";
17
17
  import { sameFormValue, type Allowed, type RecordView as RecordViewDef, type RecordViewHeaderAction } from "@marktiderman/genesis-core/resource-view";
18
18
  import { NativeBadge } from "../../components/badge";
@@ -559,12 +559,6 @@ function SettingsGroup({
559
559
  // directly: a save made while another of this record is in flight is checked against the
560
560
  // version that one commits, and the version this one commits goes into every cached copy.
561
561
  const saved = await update(recordView.recordId(row), data as Partial<DataRow & BaseRecord>, version != null ? { expectedVersion: String(version) } : undefined);
562
- // A write that matched no rows is a refusal, never a silent success.
563
- if (saved === null || saved === undefined) {
564
- lastFailure.current = fill(words.notChanged, { noun: view.noun });
565
- setRefusal(lastFailure.current);
566
- return "failed";
567
- }
568
562
  // The next edit builds on this save's version, even before the record refetches.
569
563
  if (versionField && saved[versionField] != null) editBase.current = { ...(editBase.current ?? row), [versionField]: saved[versionField] };
570
564
  setConflict(null);
@@ -576,7 +570,8 @@ function SettingsGroup({
576
570
  setConflict({ conflict: found, values, row: error.current, message: error.message });
577
571
  return "conflict";
578
572
  }
579
- lastFailure.current = refusalMessage(error, words.failed);
573
+ // A write that matched no rows is a refusal, in this screen's words.
574
+ lastFailure.current = isDataWriteError(error) && error.code === NO_ROWS_MATCHED ? fill(words.notChanged, { noun: view.noun }) : refusalMessage(error, words.failed);
580
575
  setRefusal(lastFailure.current);
581
576
  return "failed";
582
577
  } finally {
@@ -151,7 +151,7 @@ export function screenLists(...filters: (Filter | undefined)[]): Record<string,
151
151
  /** Pages kept loaded by default (cursor paging). */
152
152
  export const DEFAULT_MAX_PAGES = 10;
153
153
 
154
- type ServerSort = { field: string; order: "asc" | "desc" };
154
+ type ServerSort = { field: string; order: "asc" | "desc"; nulls?: "first" | "last" };
155
155
 
156
156
  /**
157
157
  * The server sorts: the `groupBy` field first, so every page arrives in section order and a later
@@ -161,7 +161,7 @@ type ServerSort = { field: string; order: "asc" | "desc" };
161
161
  export function serverSorts<T extends Row>(view: AnyResourceView<T>): ServerSort[] {
162
162
  const groupBy = view.definition.groupBy as string | undefined;
163
163
  const orderBy = view.definition.orderBy;
164
- const order: ServerSort | undefined = orderBy ? { field: orderBy.field as string, order: orderBy.direction ?? "asc" } : undefined;
164
+ const order: ServerSort | undefined = orderBy ? { field: orderBy.field as string, order: orderBy.direction ?? "asc", ...(orderBy.nulls ? { nulls: orderBy.nulls } : {}) } : undefined;
165
165
  if (!groupBy) return order ? [order] : [];
166
166
  if (order?.field === groupBy) return [order];
167
167
  return [{ field: groupBy, order: "asc" }, ...(order ? [order] : [])];
@@ -13,7 +13,7 @@ export { useHaptics, playHaptic, type HapticKind, type GenesisHapticsModule } fr
13
13
  export { usePressFeedback, type PressFeedbackOptions, type PressFeedback } from "./use-press-feedback";
14
14
  export { useMotion, animateMotion, motionSpring, motionTiming, type UseMotionOptions, type MotionHow, type MotionSpringConfig, type MotionTimingConfig } from "./use-motion";
15
15
  export { useThemeMode, type ThemeMode } from "./use-theme-mode";
16
- export { useThemeRoles, type ThemeRoleColors, type UseThemeRolesOptions } from "./use-theme-roles";
16
+ export { useThemeRoles, type ThemeRoleColors, type UseThemeRolesOptions, sentBubbleColor } from "./use-theme-roles";
17
17
  export {
18
18
  BrandExtensionsProvider,
19
19
  useGenesisExtension,
@@ -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 }}