@marktiderman/genesis-ui-native 2.0.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 (129) hide show
  1. package/dist/chunk-BAU4YQZV.js +760 -0
  2. package/dist/chunk-BAU4YQZV.js.map +1 -0
  3. package/dist/chunk-DGUM43GV.js +10 -0
  4. package/dist/chunk-DGUM43GV.js.map +1 -0
  5. package/dist/chunk-HNIEFTEL.js +43 -0
  6. package/dist/chunk-HNIEFTEL.js.map +1 -0
  7. package/dist/chunk-N4WHTQIO.js +20 -0
  8. package/dist/chunk-N4WHTQIO.js.map +1 -0
  9. package/dist/chunk-OHZD7KRO.js +11 -0
  10. package/dist/chunk-OHZD7KRO.js.map +1 -0
  11. package/dist/chunk-PTJ2KCLM.js +160 -0
  12. package/dist/chunk-PTJ2KCLM.js.map +1 -0
  13. package/dist/chunk-TXJT55JC.js +2213 -0
  14. package/dist/chunk-TXJT55JC.js.map +1 -0
  15. package/dist/chunk-ULS7I6ZS.js +183 -0
  16. package/dist/chunk-ULS7I6ZS.js.map +1 -0
  17. package/dist/chunk-ZVF6PONU.js +522 -0
  18. package/dist/chunk-ZVF6PONU.js.map +1 -0
  19. package/dist/components/index.d.ts +908 -0
  20. package/dist/components/index.js +8 -0
  21. package/dist/components/index.js.map +1 -0
  22. package/dist/data/index.d.ts +117 -0
  23. package/dist/data/index.js +770 -0
  24. package/dist/data/index.js.map +1 -0
  25. package/dist/hooks/index.d.ts +31 -0
  26. package/dist/hooks/index.js +5 -0
  27. package/dist/hooks/index.js.map +1 -0
  28. package/dist/index.d.ts +11 -0
  29. package/dist/index.js +11 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/layouts/index.d.ts +364 -0
  32. package/dist/layouts/index.js +8 -0
  33. package/dist/layouts/index.js.map +1 -0
  34. package/dist/utils.d.ts +5 -0
  35. package/dist/utils.js +4 -0
  36. package/dist/utils.js.map +1 -0
  37. package/package.json +127 -0
  38. package/src/components/__tests__/accordion.test.tsx +122 -0
  39. package/src/components/__tests__/chip-group.test.tsx +45 -0
  40. package/src/components/__tests__/combobox.test.tsx +97 -0
  41. package/src/components/__tests__/drawer.test.tsx +98 -0
  42. package/src/components/__tests__/empty-state.test.tsx +66 -0
  43. package/src/components/__tests__/header-card.test.tsx +31 -0
  44. package/src/components/__tests__/layout.test.tsx +109 -0
  45. package/src/components/__tests__/list-item.test.tsx +31 -0
  46. package/src/components/__tests__/number-input.test.tsx +46 -0
  47. package/src/components/__tests__/pagination.test.tsx +43 -0
  48. package/src/components/__tests__/search-bar.test.tsx +41 -0
  49. package/src/components/__tests__/segmented-empty-alert.test.tsx +79 -0
  50. package/src/components/__tests__/slider.test.tsx +134 -0
  51. package/src/components/__tests__/stepper.test.tsx +25 -0
  52. package/src/components/__tests__/toast.test.tsx +63 -0
  53. package/src/components/accordion.tsx +223 -0
  54. package/src/components/alert.tsx +131 -0
  55. package/src/components/avatar.tsx +68 -0
  56. package/src/components/badge.tsx +80 -0
  57. package/src/components/button.tsx +118 -0
  58. package/src/components/card.tsx +120 -0
  59. package/src/components/checkbox.tsx +60 -0
  60. package/src/components/chip-group.tsx +127 -0
  61. package/src/components/combobox.tsx +137 -0
  62. package/src/components/date-time-picker.tsx +127 -0
  63. package/src/components/dialog.tsx +131 -0
  64. package/src/components/drawer.tsx +131 -0
  65. package/src/components/dropdown-menu.tsx +133 -0
  66. package/src/components/empty-state.tsx +161 -0
  67. package/src/components/header-card.tsx +116 -0
  68. package/src/components/index.ts +259 -0
  69. package/src/components/inline-alert.tsx +150 -0
  70. package/src/components/input.tsx +51 -0
  71. package/src/components/label.tsx +35 -0
  72. package/src/components/layout/box.tsx +115 -0
  73. package/src/components/layout/flex.ts +24 -0
  74. package/src/components/layout/grid.tsx +73 -0
  75. package/src/components/layout/index.ts +27 -0
  76. package/src/components/layout/inline.tsx +63 -0
  77. package/src/components/layout/spacing.ts +116 -0
  78. package/src/components/layout/stack.tsx +58 -0
  79. package/src/components/list-item.tsx +108 -0
  80. package/src/components/number-input.tsx +119 -0
  81. package/src/components/pagination.tsx +132 -0
  82. package/src/components/popover.tsx +198 -0
  83. package/src/components/progress.tsx +50 -0
  84. package/src/components/radio-group.tsx +92 -0
  85. package/src/components/refresh-control.tsx +73 -0
  86. package/src/components/search-bar.tsx +128 -0
  87. package/src/components/section-list.tsx +54 -0
  88. package/src/components/segmented-control.tsx +79 -0
  89. package/src/components/select.tsx +178 -0
  90. package/src/components/separator.tsx +31 -0
  91. package/src/components/sheet.tsx +192 -0
  92. package/src/components/skeleton.tsx +104 -0
  93. package/src/components/slider.tsx +223 -0
  94. package/src/components/stepper.tsx +96 -0
  95. package/src/components/switch.tsx +35 -0
  96. package/src/components/tabs.tsx +147 -0
  97. package/src/components/text.tsx +62 -0
  98. package/src/components/textarea.tsx +52 -0
  99. package/src/components/toast.tsx +228 -0
  100. package/src/components/toggle.tsx +85 -0
  101. package/src/components/tooltip.tsx +104 -0
  102. package/src/data/NativeDataFilters.tsx +100 -0
  103. package/src/data/NativeDataPageShell.tsx +111 -0
  104. package/src/data/NativeDetailPanel.tsx +130 -0
  105. package/src/data/NativeEmptyState.tsx +46 -0
  106. package/src/data/NativeResourceForm.tsx +157 -0
  107. package/src/data/NativeResourceFormField.tsx +280 -0
  108. package/src/data/NativeResourcePage.tsx +505 -0
  109. package/src/data/index.ts +9 -0
  110. package/src/hooks/index.ts +16 -0
  111. package/src/hooks/use-genesis-extension.ts +81 -0
  112. package/src/hooks/use-reduced-motion.ts +32 -0
  113. package/src/hooks/use-theme-mode.ts +31 -0
  114. package/src/index.ts +5 -0
  115. package/src/layouts/__tests__/auth.test.tsx +150 -0
  116. package/src/layouts/__tests__/nav-bar.test.tsx +86 -0
  117. package/src/layouts/__tests__/notifications-page.test.tsx +94 -0
  118. package/src/layouts/__tests__/screen-container.test.tsx +79 -0
  119. package/src/layouts/__tests__/settings-page.test.tsx +107 -0
  120. package/src/layouts/__tests__/settings-sub-page.test.tsx +53 -0
  121. package/src/layouts/auth.tsx +352 -0
  122. package/src/layouts/index.ts +61 -0
  123. package/src/layouts/nav-bar.tsx +200 -0
  124. package/src/layouts/notifications-page.tsx +274 -0
  125. package/src/layouts/screen-container.tsx +213 -0
  126. package/src/layouts/settings-page.tsx +195 -0
  127. package/src/layouts/settings-sub-page.tsx +183 -0
  128. package/src/nativewind.d.ts +40 -0
  129. package/src/utils.ts +6 -0
@@ -0,0 +1,352 @@
1
+ /**
2
+ * Auth primitive group (PRD-07 simplification #3).
3
+ *
4
+ * Auth flows are the most consumer-divergent screen in any app. Instead
5
+ * of shipping a god-component with a sea of variants, Genesis ships
6
+ * three small primitives that consumers compose on a regular `<View>`:
7
+ *
8
+ * - <AuthBranding> — slot for branded logo + headline + subhead
9
+ * - <SocialAuthRow> — provider buttons (Apple / Google / GitHub / …)
10
+ * - <AuthForm> — email + password (or magic link) + submit
11
+ *
12
+ * Composition lives in `apps/<consumer>/...` — see
13
+ * `standards/usage-doctrine.md` § Auth composition for worked examples.
14
+ *
15
+ * @stability Beta
16
+ */
17
+ import { useCallback, useState, type ReactNode } from "react";
18
+ import { Pressable, Text, View } from "react-native";
19
+ import { NativeButton } from "../components/button";
20
+ import { NativeInput } from "../components/input";
21
+ import { NativeText } from "../components/text";
22
+ import { cn } from "../utils";
23
+
24
+ // ---------------------------------------------------------------------------
25
+ // AuthBranding — branding slot above the form
26
+ // ---------------------------------------------------------------------------
27
+
28
+ export interface AuthBrandingProps {
29
+ /** Brand mark (logo node). */
30
+ logo?: ReactNode;
31
+ /** Headline text. Renders as h1. */
32
+ headline?: string;
33
+ /** Subhead under the headline. Renders as muted body. */
34
+ subhead?: string;
35
+ /** Override the root container styling. */
36
+ className?: string;
37
+ testID?: string;
38
+ }
39
+
40
+ export function AuthBranding({
41
+ logo,
42
+ headline,
43
+ subhead,
44
+ className,
45
+ testID = "auth-branding",
46
+ }: AuthBrandingProps) {
47
+ return (
48
+ <View
49
+ testID={testID}
50
+ accessibilityRole="header"
51
+ className={cn("items-center gap-3 pb-8", className)}
52
+ >
53
+ {logo ? (
54
+ <View testID={`${testID}-logo`} className="mb-2">
55
+ {logo}
56
+ </View>
57
+ ) : null}
58
+ {headline ? (
59
+ <NativeText
60
+ preset="h1"
61
+ testID={`${testID}-headline`}
62
+ className="text-center"
63
+ >
64
+ {headline}
65
+ </NativeText>
66
+ ) : null}
67
+ {subhead ? (
68
+ <NativeText
69
+ preset="body"
70
+ testID={`${testID}-subhead`}
71
+ className="text-center text-muted-foreground"
72
+ >
73
+ {subhead}
74
+ </NativeText>
75
+ ) : null}
76
+ </View>
77
+ );
78
+ }
79
+
80
+ // ---------------------------------------------------------------------------
81
+ // SocialAuthRow — provider buttons
82
+ // ---------------------------------------------------------------------------
83
+
84
+ export type SocialAuthProvider = {
85
+ /** Stable id used as React key + testID suffix. */
86
+ id: string;
87
+ /** Visible label, e.g., "Continue with Apple". */
88
+ label: string;
89
+ /** Optional leading icon node. */
90
+ icon?: ReactNode;
91
+ /** Press handler. */
92
+ onPress: () => void | Promise<void>;
93
+ /** When true, the button is disabled (e.g., loading). */
94
+ disabled?: boolean;
95
+ };
96
+
97
+ export interface SocialAuthRowProps {
98
+ providers: SocialAuthProvider[];
99
+ /**
100
+ * Optional separator label rendered between social row and the form
101
+ * below (e.g., "or"). Pass `null` to suppress. Default `"or"`.
102
+ */
103
+ separator?: string | null;
104
+ /** Override root container styling. */
105
+ className?: string;
106
+ testID?: string;
107
+ }
108
+
109
+ export function SocialAuthRow({
110
+ providers,
111
+ separator = "or",
112
+ className,
113
+ testID = "social-auth-row",
114
+ }: SocialAuthRowProps) {
115
+ if (providers.length === 0) return null;
116
+ return (
117
+ <View testID={testID} className={cn("gap-3", className)}>
118
+ <View className="gap-2">
119
+ {providers.map((p) => (
120
+ <NativeButton
121
+ key={p.id}
122
+ testID={`${testID}-${p.id}`}
123
+ variant="outline"
124
+ disabled={p.disabled}
125
+ onPress={() => {
126
+ void p.onPress();
127
+ }}
128
+ >
129
+ <View className="flex-row items-center gap-2">
130
+ {p.icon}
131
+ <Text className="text-sm font-medium text-foreground">
132
+ {p.label}
133
+ </Text>
134
+ </View>
135
+ </NativeButton>
136
+ ))}
137
+ </View>
138
+ {separator !== null && separator !== undefined ? (
139
+ <View
140
+ testID={`${testID}-separator`}
141
+ className="my-2 flex-row items-center gap-3"
142
+ accessibilityElementsHidden
143
+ >
144
+ <View className="h-px flex-1 bg-border" />
145
+ <Text className="text-xs uppercase tracking-wider text-muted-foreground">
146
+ {separator}
147
+ </Text>
148
+ <View className="h-px flex-1 bg-border" />
149
+ </View>
150
+ ) : null}
151
+ </View>
152
+ );
153
+ }
154
+
155
+ // ---------------------------------------------------------------------------
156
+ // AuthForm — email + password (or magic link) + submit
157
+ // ---------------------------------------------------------------------------
158
+
159
+ export interface AuthFormValues {
160
+ email: string;
161
+ /** Empty string when `mode === "magic-link"`. */
162
+ password: string;
163
+ }
164
+
165
+ export interface AuthFormProps {
166
+ /**
167
+ * `"password"` (default) renders email + password.
168
+ * `"magic-link"` renders email only and the submit button label
169
+ * defaults to "Send magic link".
170
+ */
171
+ mode?: "password" | "magic-link";
172
+ /** Submit handler. Receives the current form values. */
173
+ onSubmit: (values: AuthFormValues) => void | Promise<void>;
174
+ /**
175
+ * Optional validation slot — return `null` to allow submission, or a
176
+ * string error message to block. Called on every submit.
177
+ */
178
+ validate?: (values: AuthFormValues) => string | null;
179
+ /** Override the submit button label. */
180
+ submitLabel?: string;
181
+ /** When true, submit button is disabled and shows a busy indicator. */
182
+ loading?: boolean;
183
+ /**
184
+ * Top-level error (set by the consumer after a server-side rejection,
185
+ * e.g., "Invalid credentials"). Shown above the submit button.
186
+ */
187
+ errorMessage?: string;
188
+ /** Initial email. Useful for "log in as <user>" deep links. */
189
+ initialEmail?: string;
190
+ /** Slot rendered AFTER the inputs but BEFORE the submit (e.g., "Forgot password" link). */
191
+ belowFields?: ReactNode;
192
+ /** Override root container styling. */
193
+ className?: string;
194
+ testID?: string;
195
+ }
196
+
197
+ export function AuthForm({
198
+ mode = "password",
199
+ onSubmit,
200
+ validate,
201
+ submitLabel,
202
+ loading,
203
+ errorMessage,
204
+ initialEmail = "",
205
+ belowFields,
206
+ className,
207
+ testID = "auth-form",
208
+ }: AuthFormProps) {
209
+ const [email, setEmail] = useState(initialEmail);
210
+ const [password, setPassword] = useState("");
211
+ const [localError, setLocalError] = useState<string | null>(null);
212
+ const [submitting, setSubmitting] = useState(false);
213
+
214
+ const isMagic = mode === "magic-link";
215
+ const resolvedSubmitLabel =
216
+ submitLabel ?? (isMagic ? "Send magic link" : "Sign in");
217
+
218
+ const handleSubmit = useCallback(async () => {
219
+ // Guard against double-tap and stacked submits — the user's onSubmit
220
+ // is async, so we own a local `submitting` flag in addition to the
221
+ // parent-controlled `loading` prop.
222
+ if (submitting || loading) return;
223
+
224
+ setLocalError(null);
225
+ const values: AuthFormValues = {
226
+ email: email.trim(),
227
+ password: isMagic ? "" : password,
228
+ };
229
+ if (validate) {
230
+ const err = validate(values);
231
+ if (err) {
232
+ setLocalError(err);
233
+ return;
234
+ }
235
+ }
236
+ if (!values.email) {
237
+ setLocalError("Email is required");
238
+ return;
239
+ }
240
+ if (!isMagic && !values.password) {
241
+ setLocalError("Password is required");
242
+ return;
243
+ }
244
+
245
+ // Await the consumer's onSubmit so we surface unhandled rejections
246
+ // as a local error string instead of dropping them on the floor.
247
+ setSubmitting(true);
248
+ try {
249
+ await onSubmit(values);
250
+ } catch (err) {
251
+ const message = err instanceof Error ? err.message : String(err);
252
+ setLocalError(message);
253
+ } finally {
254
+ setSubmitting(false);
255
+ }
256
+ }, [email, password, isMagic, validate, onSubmit, submitting, loading]);
257
+
258
+ const visibleError = errorMessage ?? localError ?? null;
259
+
260
+ return (
261
+ <View testID={testID} className={cn("gap-3", className)}>
262
+ <View className="gap-1">
263
+ <Text className="text-sm font-medium text-foreground">Email</Text>
264
+ <NativeInput
265
+ testID={`${testID}-email`}
266
+ accessibilityLabel="Email"
267
+ value={email}
268
+ onChangeText={setEmail}
269
+ placeholder="you@example.com"
270
+ autoCapitalize="none"
271
+ autoCorrect={false}
272
+ keyboardType="email-address"
273
+ returnKeyType={isMagic ? "send" : "next"}
274
+ editable={!loading && !submitting}
275
+ // In magic-link mode the email field is the last input, so the
276
+ // return key dispatches submit. In password mode the next return
277
+ // moves focus to password (default RN behavior); the password
278
+ // field's onSubmitEditing handles the actual send.
279
+ onSubmitEditing={isMagic ? handleSubmit : undefined}
280
+ />
281
+ </View>
282
+
283
+ {isMagic ? null : (
284
+ <View className="gap-1">
285
+ <Text className="text-sm font-medium text-foreground">Password</Text>
286
+ <NativeInput
287
+ testID={`${testID}-password`}
288
+ accessibilityLabel="Password"
289
+ value={password}
290
+ onChangeText={setPassword}
291
+ placeholder="••••••••"
292
+ secureTextEntry
293
+ autoCapitalize="none"
294
+ autoCorrect={false}
295
+ returnKeyType="send"
296
+ editable={!loading && !submitting}
297
+ onSubmitEditing={handleSubmit}
298
+ />
299
+ </View>
300
+ )}
301
+
302
+ {belowFields}
303
+
304
+ {visibleError ? (
305
+ <Text
306
+ testID={`${testID}-error`}
307
+ accessibilityRole="alert"
308
+ className="text-sm text-destructive"
309
+ >
310
+ {visibleError}
311
+ </Text>
312
+ ) : null}
313
+
314
+ <NativeButton
315
+ testID={`${testID}-submit`}
316
+ onPress={() => {
317
+ void handleSubmit();
318
+ }}
319
+ loading={loading || submitting}
320
+ disabled={loading || submitting}
321
+ >
322
+ {resolvedSubmitLabel}
323
+ </NativeButton>
324
+ </View>
325
+ );
326
+ }
327
+
328
+ // Convenience: a "Forgot password?" link consumers can drop into the
329
+ // `belowFields` slot. Kept as a simple Pressable so it inherits brand
330
+ // tokens via the consumer's tailwind config.
331
+ export function ForgotPasswordLink({
332
+ onPress,
333
+ label = "Forgot password?",
334
+ testID = "auth-forgot-password",
335
+ }: {
336
+ onPress: () => void;
337
+ label?: string;
338
+ testID?: string;
339
+ }) {
340
+ return (
341
+ <Pressable
342
+ testID={testID}
343
+ accessibilityRole="link"
344
+ accessibilityLabel={label}
345
+ onPress={onPress}
346
+ hitSlop={8}
347
+ className="self-end"
348
+ >
349
+ <Text className="text-sm font-medium text-primary">{label}</Text>
350
+ </Pressable>
351
+ );
352
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Genesis UI-native page layouts.
3
+ *
4
+ * Layer-2 primitive: ScreenContainer (composable chrome).
5
+ * Layer-3/4 layouts: SettingsPage, SettingsSubPage, NotificationsPage,
6
+ * AuthForm + SocialAuthRow + AuthBranding.
7
+ *
8
+ * See standards/usage-doctrine.md for the Layer 1-4 progression.
9
+ */
10
+
11
+ export {
12
+ ScreenContainer,
13
+ composeHeaderOptions,
14
+ type ScreenContainerProps,
15
+ type ScreenHeaderProps,
16
+ type SafeAreaEdge,
17
+ type ScrollEdgeBehavior,
18
+ } from "./screen-container";
19
+
20
+ export {
21
+ NavBarSaveButton,
22
+ NavBarSearchBar,
23
+ NavBarTitle,
24
+ type NavBarSaveButtonProps,
25
+ type NavBarSearchBarProps,
26
+ type NavBarTitleProps,
27
+ } from "./nav-bar";
28
+
29
+ export {
30
+ SettingsPage,
31
+ getSettingsPageStackOptions,
32
+ type SettingsPageProps,
33
+ type SettingsPageSection,
34
+ type SettingsPageRow,
35
+ } from "./settings-page";
36
+
37
+ export {
38
+ SettingsSubPage,
39
+ confirmDiscardChanges,
40
+ getSettingsSubPageStackOptions,
41
+ type SettingsSubPageProps,
42
+ } from "./settings-sub-page";
43
+
44
+ export {
45
+ NotificationsPage,
46
+ getNotificationsPageStackOptions,
47
+ type NotificationsPageProps,
48
+ type NotificationItem,
49
+ } from "./notifications-page";
50
+
51
+ export {
52
+ AuthForm,
53
+ SocialAuthRow,
54
+ AuthBranding,
55
+ ForgotPasswordLink,
56
+ type AuthFormProps,
57
+ type AuthFormValues,
58
+ type SocialAuthRowProps,
59
+ type SocialAuthProvider,
60
+ type AuthBrandingProps,
61
+ } from "./auth";
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Nav-bar sub-primitives — escape hatches for `<Stack.Screen>` `headerLeft`,
3
+ * `headerRight`, and custom title view.
4
+ *
5
+ * Use these when the named-prop slots on a layout aren't enough — e.g.,
6
+ * a screen needs a save button on the right that's wired to dirty-state,
7
+ * or a search bar replaces the title on a results screen.
8
+ *
9
+ * Pass directly into `headerLeft={() => <NavBarSearchBar ... />}` or
10
+ * compose into a custom `headerTitle={() => <NavBarTitle ... />}` slot.
11
+ *
12
+ * @stability Beta
13
+ */
14
+ import { Pressable, Text, TextInput, View } from "react-native";
15
+ import { cn } from "../utils";
16
+
17
+ // ---------------------------------------------------------------------------
18
+ // NavBarSaveButton
19
+ // ---------------------------------------------------------------------------
20
+
21
+ export interface NavBarSaveButtonProps {
22
+ /** Press handler. Disabled when not provided OR when `disabled`/`loading`. */
23
+ onPress?: () => void;
24
+ /** Visible label. Default `"Save"`. */
25
+ label?: string;
26
+ /** When true, the button is muted and not pressable. Use this for clean / pristine forms. */
27
+ disabled?: boolean;
28
+ /** When true, label switches to a busy indicator and presses are blocked. */
29
+ loading?: boolean;
30
+ /** When true, render label in destructive tone. */
31
+ destructive?: boolean;
32
+ className?: string;
33
+ testID?: string;
34
+ }
35
+
36
+ export function NavBarSaveButton({
37
+ onPress,
38
+ label = "Save",
39
+ disabled,
40
+ loading,
41
+ destructive,
42
+ className,
43
+ testID,
44
+ }: NavBarSaveButtonProps) {
45
+ const isDisabled = !!disabled || !!loading || !onPress;
46
+ return (
47
+ <Pressable
48
+ testID={testID ?? "nav-bar-save-button"}
49
+ accessibilityRole="button"
50
+ accessibilityLabel={label}
51
+ accessibilityState={{ disabled: isDisabled, busy: !!loading }}
52
+ onPress={isDisabled ? undefined : onPress}
53
+ disabled={isDisabled}
54
+ className={cn("min-h-[44px] justify-center px-3", className)}
55
+ hitSlop={8}
56
+ >
57
+ <Text
58
+ className={cn(
59
+ "text-base font-semibold",
60
+ destructive ? "text-destructive" : "text-primary",
61
+ isDisabled && "opacity-40"
62
+ )}
63
+ >
64
+ {loading ? "…" : label}
65
+ </Text>
66
+ </Pressable>
67
+ );
68
+ }
69
+
70
+ // ---------------------------------------------------------------------------
71
+ // NavBarTitle
72
+ // ---------------------------------------------------------------------------
73
+
74
+ export interface NavBarTitleProps {
75
+ /** Title text. */
76
+ title: string;
77
+ /** Optional smaller subtitle line under the title. */
78
+ subtitle?: string;
79
+ /** Optional press handler — turns the title row into a tap target (e.g., reveal a picker). */
80
+ onPress?: () => void;
81
+ className?: string;
82
+ testID?: string;
83
+ }
84
+
85
+ export function NavBarTitle({
86
+ title,
87
+ subtitle,
88
+ onPress,
89
+ className,
90
+ testID,
91
+ }: NavBarTitleProps) {
92
+ const inner = (
93
+ <View className={cn("items-center justify-center", className)}>
94
+ <Text
95
+ testID={testID ? `${testID}-title` : undefined}
96
+ className="text-base font-semibold text-foreground"
97
+ numberOfLines={1}
98
+ >
99
+ {title}
100
+ </Text>
101
+ {subtitle ? (
102
+ <Text
103
+ testID={testID ? `${testID}-subtitle` : undefined}
104
+ className="text-xs text-muted-foreground"
105
+ numberOfLines={1}
106
+ >
107
+ {subtitle}
108
+ </Text>
109
+ ) : null}
110
+ </View>
111
+ );
112
+
113
+ if (onPress) {
114
+ return (
115
+ <Pressable
116
+ testID={testID ?? "nav-bar-title"}
117
+ accessibilityRole="button"
118
+ accessibilityLabel={subtitle ? `${title}, ${subtitle}` : title}
119
+ onPress={onPress}
120
+ hitSlop={8}
121
+ >
122
+ {inner}
123
+ </Pressable>
124
+ );
125
+ }
126
+
127
+ return (
128
+ <View testID={testID ?? "nav-bar-title"} accessibilityRole="header">
129
+ {inner}
130
+ </View>
131
+ );
132
+ }
133
+
134
+ // ---------------------------------------------------------------------------
135
+ // NavBarSearchBar
136
+ // ---------------------------------------------------------------------------
137
+
138
+ export interface NavBarSearchBarProps {
139
+ value: string;
140
+ onChangeText: (next: string) => void;
141
+ placeholder?: string;
142
+ /** Called when the user submits the search (return key). */
143
+ onSubmit?: () => void;
144
+ /** Render a clear (X) button when value is non-empty. Default true. */
145
+ clearable?: boolean;
146
+ className?: string;
147
+ testID?: string;
148
+ }
149
+
150
+ /**
151
+ * Inline search input meant to occupy the title slot on a search results
152
+ * screen. For a sticky search-below-the-header pattern, prefer the
153
+ * standalone <NativeSearchBar> primitive.
154
+ */
155
+ export function NavBarSearchBar({
156
+ value,
157
+ onChangeText,
158
+ placeholder = "Search",
159
+ onSubmit,
160
+ clearable = true,
161
+ className,
162
+ testID,
163
+ }: NavBarSearchBarProps) {
164
+ return (
165
+ <View
166
+ testID={testID ?? "nav-bar-search"}
167
+ className={cn(
168
+ "min-h-[36px] flex-row items-center rounded-full bg-muted px-3",
169
+ className
170
+ )}
171
+ >
172
+ <TextInput
173
+ testID={testID ? `${testID}-input` : undefined}
174
+ accessibilityLabel={placeholder}
175
+ value={value}
176
+ onChangeText={onChangeText}
177
+ onSubmitEditing={onSubmit}
178
+ placeholder={placeholder}
179
+ placeholderTextColor="#9ca3af"
180
+ returnKeyType="search"
181
+ autoCorrect={false}
182
+ autoCapitalize="none"
183
+ clearButtonMode={clearable ? "while-editing" : "never"}
184
+ className="flex-1 text-base text-foreground"
185
+ />
186
+ {clearable && value.length > 0 ? (
187
+ <Pressable
188
+ testID={testID ? `${testID}-clear` : undefined}
189
+ accessibilityRole="button"
190
+ accessibilityLabel="Clear search"
191
+ onPress={() => onChangeText("")}
192
+ hitSlop={8}
193
+ className="ml-2 px-1"
194
+ >
195
+ <Text className="text-base text-muted-foreground">×</Text>
196
+ </Pressable>
197
+ ) : null}
198
+ </View>
199
+ );
200
+ }