@vvedantb/native-ui 0.34.0 → 0.36.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.
@@ -128,7 +128,7 @@ export function GlassBlurTarget(t0) {
128
128
  const content = t4;
129
129
  let t5;
130
130
  if ($[11] !== content || $[12] !== props || $[13] !== style) {
131
- t5 = BlurTargetView ? <BlurTargetView ref={ref} style={[styles.fill, style]} {...props}>{content}</BlurTargetView> : <View ref={ref} style={[styles.fill, style]} {...props}>{content}</View>;
131
+ t5 = BlurTargetView ? <BlurTargetView ref={ref} style={[styles.fill, style]} {...props}>{content}</BlurTargetView> : <View style={[styles.fill, style]} {...props}>{content}</View>;
132
132
  $[11] = content;
133
133
  $[12] = props;
134
134
  $[13] = style;
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ export { SearchInput } from "./SearchInput";
17
17
  export { PasswordInput } from "./PasswordInput";
18
18
  export { Textarea } from "./Textarea";
19
19
  export { Label } from "./Label";
20
+ export { Field, FieldControl, FieldDescription, FieldError, FieldLabel } from "./Field";
20
21
  export { Select } from "./Select";
21
22
  export { Switch } from "./Switch";
22
23
  export { LabeledSwitchRow } from "./LabeledSwitchRow";
@@ -79,6 +80,7 @@ export { SettingsField } from "./settings/SettingsField";
79
80
  export { SettingsToggleRow } from "./settings/SettingsToggleRow";
80
81
  export { SettingsStack } from "./settings/SettingsStack";
81
82
  export { SettingsEmptyState } from "./settings/SettingsEmptyState";
83
+ export { ThemeModePicker, THEME_MODES } from "./settings/ThemeModePicker";
82
84
  export { PinnedBotTile, BotPinGrid } from "./PinnedBotTile";
83
85
  export { ArtifactList } from "./ArtifactList";
84
86
  export { MoreFromProjectV, FromProjectV } from "./settings/MoreFromProjectV";
@@ -1,7 +1,7 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useId, useLayoutEffect, useSyncExternalStore } from "react";
3
3
  import { BackHandler, Modal, StyleSheet, View } from "react-native";
4
- import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
4
+ import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
5
5
  import { useReduceMotion } from "../useReduceMotion";
6
6
 
7
7
  // Overlays drawn in the app's own window. A React Native `Modal` is a window
@@ -71,62 +71,69 @@ const hostRef = view => {
71
71
  * app under it is hidden from TalkBack and VoiceOver, as under a Modal.
72
72
  */
73
73
  export function WindowLayerHost(t0) {
74
- const $ = _c(12);
74
+ const $ = _c(18);
75
75
  const {
76
76
  children
77
77
  } = t0;
78
78
  const shown = useSyncExternalStore(subscribe, _temp, _temp2);
79
+ const reduceMotion = useReduceMotion();
79
80
  let t1;
80
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
81
- t1 = FadeIn.duration(200).reduceMotion(ReduceMotion.System);
82
- $[0] = t1;
81
+ if ($[0] !== reduceMotion) {
82
+ t1 = reduceMotion ? undefined : FadeIn.duration(200);
83
+ $[0] = reduceMotion;
84
+ $[1] = t1;
83
85
  } else {
84
- t1 = $[0];
86
+ t1 = $[1];
85
87
  }
86
88
  const enter = t1;
87
89
  let t2;
88
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
89
- t2 = FadeOut.duration(150).reduceMotion(ReduceMotion.System);
90
- $[1] = t2;
90
+ if ($[2] !== reduceMotion) {
91
+ t2 = reduceMotion ? undefined : FadeOut.duration(150);
92
+ $[2] = reduceMotion;
93
+ $[3] = t2;
91
94
  } else {
92
- t2 = $[1];
95
+ t2 = $[3];
93
96
  }
94
97
  const exit = t2;
95
98
  const t3 = shown.length > 0 ? "no-hide-descendants" : "auto";
96
99
  const t4 = shown.length > 0;
97
100
  let t5;
98
- if ($[2] !== children || $[3] !== t3 || $[4] !== t4) {
101
+ if ($[4] !== children || $[5] !== t3 || $[6] !== t4) {
99
102
  t5 = <View style={styles.fill} importantForAccessibility={t3} accessibilityElementsHidden={t4}>{children}</View>;
100
- $[2] = children;
101
- $[3] = t3;
102
- $[4] = t4;
103
- $[5] = t5;
103
+ $[4] = children;
104
+ $[5] = t3;
105
+ $[6] = t4;
106
+ $[7] = t5;
104
107
  } else {
105
- t5 = $[5];
108
+ t5 = $[7];
106
109
  }
107
110
  let t6;
108
- if ($[6] !== shown) {
111
+ if ($[8] !== enter || $[9] !== exit || $[10] !== shown) {
109
112
  let t7;
110
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
113
+ if ($[12] !== enter || $[13] !== exit) {
111
114
  t7 = layer => <Animated.View key={layer.id} entering={layer.fade ? enter : undefined} exiting={layer.fade ? exit : undefined} onLayout={() => showOnce(layer)} style={StyleSheet.absoluteFill} pointerEvents="box-none">{layer.node}</Animated.View>;
112
- $[8] = t7;
115
+ $[12] = enter;
116
+ $[13] = exit;
117
+ $[14] = t7;
113
118
  } else {
114
- t7 = $[8];
119
+ t7 = $[14];
115
120
  }
116
121
  t6 = shown.map(t7);
117
- $[6] = shown;
118
- $[7] = t6;
122
+ $[8] = enter;
123
+ $[9] = exit;
124
+ $[10] = shown;
125
+ $[11] = t6;
119
126
  } else {
120
- t6 = $[7];
127
+ t6 = $[11];
121
128
  }
122
129
  let t7;
123
- if ($[9] !== t5 || $[10] !== t6) {
130
+ if ($[15] !== t5 || $[16] !== t6) {
124
131
  t7 = <View ref={hostRef} style={styles.fill}>{t5}{t6}</View>;
125
- $[9] = t5;
126
- $[10] = t6;
127
- $[11] = t7;
132
+ $[15] = t5;
133
+ $[16] = t6;
134
+ $[17] = t7;
128
135
  } else {
129
- t7 = $[11];
136
+ t7 = $[17];
130
137
  }
131
138
  return t7;
132
139
  }
@@ -0,0 +1,135 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { IconCheck, IconCircleHalf, IconDeviceDesktop, IconMoon, IconSun } from "@tabler/icons-react-native";
3
+ import { Pressable, StyleSheet, Text, View } from "react-native";
4
+ import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
5
+ import { cn } from "../cn";
6
+ import { sizeStyle, typeStyle } from "../controlStyles";
7
+ import { palette, withAlpha } from "../palette";
8
+ import { useLargerText } from "../theme";
9
+ import { tokens } from "../tokens";
10
+ import { useScheme } from "../useScheme";
11
+
12
+ /** A theme the picker can show, as the web `ThemeModePicker`. Neutral is the dark scheme with a grey palette. */
13
+
14
+ /** Default order: light to dark, then system. */
15
+ export const THEME_MODES = ["light", "neutral", "dark", "system"];
16
+ const LABELS = {
17
+ light: "Light",
18
+ neutral: "Neutral",
19
+ dark: "Dark",
20
+ system: "System"
21
+ };
22
+ const ICONS = {
23
+ light: IconSun,
24
+ neutral: IconCircleHalf,
25
+ dark: IconMoon,
26
+ system: IconDeviceDesktop
27
+ };
28
+ /** Web `bg-zinc-900`. */
29
+ const ZINC_900 = "#18181b";
30
+ // Swatches and icons show the theme itself, so they use the web's fixed colours, not tokens.
31
+ // System has no swatch colour (it is a gradient) and a muted icon.
32
+ const SWATCHES = {
33
+ light: "#ffffff",
34
+ neutral: "#3f3f46",
35
+ dark: ZINC_900,
36
+ system: null
37
+ };
38
+ const ICON_COLOURS = {
39
+ light: "#f59e0b",
40
+ neutral: "#d4d4d8",
41
+ dark: "#93c5fd",
42
+ system: null
43
+ };
44
+ /** The web System swatch, `bg-linear-to-br from-white to-zinc-900`. */
45
+ function GradientSwatch() {
46
+ const $ = _c(1);
47
+ let t0;
48
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
49
+ t0 = <Svg width="100%" height="100%" style={StyleSheet.absoluteFill}><Defs><LinearGradient id="theme-mode-system" x1="0" y1="0" x2="1" y2="1"><Stop offset="0" stopColor="#ffffff" /><Stop offset="1" stopColor={ZINC_900} /></LinearGradient></Defs><Rect width="100%" height="100%" fill="url(#theme-mode-system)" /></Svg>;
50
+ $[0] = t0;
51
+ } else {
52
+ t0 = $[0];
53
+ }
54
+ return t0;
55
+ }
56
+
57
+ /**
58
+ * Theme tiles for an Appearance settings section, as the web
59
+ * `ThemeModePicker`: a swatch with the theme icon over the label, in one row
60
+ * that the tiles share evenly. The selected tile gets the border, a primary
61
+ * wash and a check badge. The app owns the stored mode and how Neutral paints.
62
+ */
63
+ export function ThemeModePicker(t0) {
64
+ const $ = _c(18);
65
+ const {
66
+ value,
67
+ onChange,
68
+ modes: t1,
69
+ className,
70
+ testID
71
+ } = t0;
72
+ const modes = t1 === undefined ? THEME_MODES : t1;
73
+ const scheme = useScheme();
74
+ const largerText = useLargerText();
75
+ const labelSize = largerText ? "text-base" : "text-sm";
76
+ let t2;
77
+ if ($[0] !== className) {
78
+ t2 = cn("flex-row gap-2", className);
79
+ $[0] = className;
80
+ $[1] = t2;
81
+ } else {
82
+ t2 = $[1];
83
+ }
84
+ let t3;
85
+ if ($[2] !== labelSize || $[3] !== modes || $[4] !== onChange || $[5] !== scheme || $[6] !== testID || $[7] !== value) {
86
+ let t4;
87
+ if ($[9] !== labelSize || $[10] !== onChange || $[11] !== scheme || $[12] !== testID || $[13] !== value) {
88
+ t4 = mode => {
89
+ const active = value === mode;
90
+ const Icon = ICONS[mode];
91
+ const swatch = SWATCHES[mode];
92
+ return <Pressable key={mode} testID={testID ? `${testID}-${mode}` : undefined} accessibilityRole="radio" accessibilityLabel={LABELS[mode]} accessibilityState={{
93
+ checked: active
94
+ }} onPress={() => onChange(mode)} className="flex-1 items-center gap-2 rounded-2xl border px-1 py-3 active:opacity-80" style={{
95
+ borderColor: active ? tokens.color.border[scheme] : "transparent",
96
+ backgroundColor: active ? withAlpha(palette.primary[scheme], 0.08) : withAlpha(tokens.color.surfaceSecondary[scheme], 0.4)
97
+ }}><View className="mx-2 h-12 items-center justify-center self-stretch overflow-hidden rounded-2xl" style={swatch ? {
98
+ backgroundColor: swatch
99
+ } : undefined}>{swatch ? null : <GradientSwatch />}<View className="absolute inset-0 items-center justify-center"><Icon size={22} color={ICON_COLOURS[mode] ?? tokens.color.muted[scheme]} /></View></View>{active ? <View className="absolute right-2 top-2 h-4 w-4 items-center justify-center rounded-full" style={{
100
+ backgroundColor: palette.primary[scheme]
101
+ }}><IconCheck size={10} strokeWidth={3} color={palette.primaryForeground[scheme]} /></View> : null}<Text numberOfLines={1} adjustsFontSizeToFit={true} className={cn("font-instrument-sans-medium", labelSize)} style={[sizeStyle(labelSize), typeStyle("medium"), {
102
+ color: active ? palette.primary[scheme] : tokens.color.muted[scheme]
103
+ }]}>{LABELS[mode]}</Text></Pressable>;
104
+ };
105
+ $[9] = labelSize;
106
+ $[10] = onChange;
107
+ $[11] = scheme;
108
+ $[12] = testID;
109
+ $[13] = value;
110
+ $[14] = t4;
111
+ } else {
112
+ t4 = $[14];
113
+ }
114
+ t3 = modes.map(t4);
115
+ $[2] = labelSize;
116
+ $[3] = modes;
117
+ $[4] = onChange;
118
+ $[5] = scheme;
119
+ $[6] = testID;
120
+ $[7] = value;
121
+ $[8] = t3;
122
+ } else {
123
+ t3 = $[8];
124
+ }
125
+ let t4;
126
+ if ($[15] !== t2 || $[16] !== t3) {
127
+ t4 = <View accessibilityRole="radiogroup" accessibilityLabel="Theme" className={t2}>{t3}</View>;
128
+ $[15] = t2;
129
+ $[16] = t3;
130
+ $[17] = t4;
131
+ } else {
132
+ t4 = $[17];
133
+ }
134
+ return t4;
135
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/native-ui",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "license": "MIT",
5
5
  "description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar, AI chat parts, the family app marks, a NativeWind preset, the Expo web root and Clerk + Convex auth screens.",
6
6
  "type": "module",
@@ -308,11 +308,35 @@
308
308
  }
309
309
  },
310
310
  "devDependencies": {
311
+ "@babel/core": "^7.29.13",
311
312
  "@clerk/expo": "4.17.2",
313
+ "@react-native-community/datetimepicker": "9.2.1",
312
314
  "@types/react": "^19.1.0",
315
+ "expo": "~58.0.26",
316
+ "expo-auth-session": "~58.0.19",
317
+ "expo-blur": "~58.0.6",
318
+ "expo-constants": "~58.0.16",
319
+ "expo-device": "~58.0.5",
320
+ "expo-haptics": "~58.0.8",
321
+ "expo-linear-gradient": "~58.0.4",
322
+ "expo-notifications": "~58.1.9",
323
+ "expo-router": "~58.0.32",
324
+ "expo-video": "~58.0.14",
325
+ "expo-web-browser": "~58.1.0",
326
+ "happy-dom": "18.0.1",
313
327
  "react": "^19.1.0",
314
- "typescript": "^5.9.0",
315
- "vitest": "^3.2.0"
328
+ "react-native": "0.88.1",
329
+ "react-native-gesture-handler": "~3.3.0",
330
+ "react-native-keyboard-controller": "1.22.7",
331
+ "react-native-reanimated": "4.7.1",
332
+ "react-native-safe-area-context": "~5.11.1",
333
+ "react-native-screens": "~4.30.1",
334
+ "react-native-svg": "15.16.0",
335
+ "react-native-webview": "14.0.1",
336
+ "react-native-worklets": "0.13.0",
337
+ "typescript": "7.0.2",
338
+ "vitest": "^3.2.0",
339
+ "@vvedantb/server": "0.17.1"
316
340
  },
317
341
  "scripts": {
318
342
  "build": "node scripts/build-dist.mjs && node scripts/check-exports.mjs",
package/src/Button.tsx CHANGED
@@ -13,8 +13,8 @@ import { useLargerText } from "./theme";
13
13
  import { tokens } from "./tokens";
14
14
  import { useScheme } from "./useScheme";
15
15
 
16
- /** `sm`, `default` and `lg` are the web names for `small`, `medium` and `large`. `icon` is a square button. */
17
- type ButtonSize = "small" | "medium" | "large" | "sm" | "default" | "lg" | "icon";
16
+ /** `sm`, `default` (or `md`) and `lg` are the web names for `small`, `medium` and `large`. `icon` is a square button. */
17
+ type ButtonSize = "small" | "medium" | "large" | "sm" | "md" | "default" | "lg" | "icon";
18
18
 
19
19
  /** The web `shape`. `"pill"` (default) is fully round; `"rounded"` is radius 16, the look before 0.6.0. */
20
20
  type ButtonShape = "pill" | "rounded";
@@ -57,6 +57,7 @@ const SIZE_ALIAS = {
57
57
  medium: "medium",
58
58
  large: "large",
59
59
  sm: "small",
60
+ md: "medium",
60
61
  default: "medium",
61
62
  lg: "large",
62
63
  icon: "icon",
@@ -109,8 +110,8 @@ const RADIUS: Record<ButtonShape, number> = {
109
110
  rounded: tokens.radius.lg,
110
111
  };
111
112
 
112
- // Colours come from `buttonColors` as styles, except `tinted`, which keeps
113
- // the pink classes that `outline` used before 0.3.0.
113
+ // Colours come from `buttonColors` as styles, except `tinted` (a legacy
114
+ // alias), which keeps the pink classes that `outline` used before 0.3.0.
114
115
  const VARIANT_CLASS: Partial<Record<ButtonVariant, string>> = {
115
116
  link: "h-auto border-0 px-0",
116
117
  tinted: "border-0 bg-pink-50 dark:bg-pink-900/20",
@@ -128,6 +129,11 @@ const PRIMITIVE_VARIANT = {
128
129
  secondary: "secondary",
129
130
  destructive: "destructive",
130
131
  ghost: "ghost",
132
+ tertiary: "ghost",
133
+ danger: "destructive",
134
+ success: "default",
135
+ warning: "default",
136
+ flat: "ghost",
131
137
  link: "link",
132
138
  tinted: "secondary",
133
139
  } as const;
@@ -1,5 +1,14 @@
1
1
  import * as Slot from "@rn-primitives/slot";
2
- import { createContext, useContext, useEffect, useRef, useState, type ComponentType, type ReactNode } from "react";
2
+ import {
3
+ createContext,
4
+ useContext,
5
+ useEffect,
6
+ useRef,
7
+ useState,
8
+ type ComponentRef,
9
+ type ComponentType,
10
+ type ReactNode,
11
+ } from "react";
3
12
  import {
4
13
  Pressable,
5
14
  ScrollView,
@@ -110,7 +119,7 @@ export type DropdownMenuTriggerProps = PressableProps & {
110
119
  */
111
120
  export function DropdownMenuTrigger({ asChild, onPress, accessibilityState, ...props }: DropdownMenuTriggerProps) {
112
121
  const { open, setOpen, setTrigger } = useMenu("DropdownMenuTrigger");
113
- const ref = useRef<View>(null);
122
+ const ref = useRef<ComponentRef<typeof View>>(null);
114
123
  const Component = asChild ? Slot.Pressable : Pressable;
115
124
  return (
116
125
  <Component
@@ -1,7 +1,17 @@
1
1
  import type { ReactNode } from "react";
2
- import { ScrollViewStyleReset } from "expo-router/html";
2
+ import * as expoRouterHtml from "expo-router/html";
3
3
  import { tokens } from "./tokens";
4
4
 
5
+ const { ScrollViewStyleReset } = expoRouterHtml;
6
+
7
+ // From Expo SDK 58 the static render no longer writes the page's CSS links and
8
+ // script tags into the HTML afterwards: it hands them to the root as nodes, and
9
+ // a root that leaves them out gives a blank page. Earlier SDKs have no such
10
+ // hook and still write the tags themselves.
11
+ type ServerDocument = ReturnType<NonNullable<typeof expoRouterHtml.useServerDocumentContext>>;
12
+ const emptyDocument: ServerDocument = {};
13
+ const useServerDocument = expoRouterHtml.useServerDocumentContext ?? (() => emptyDocument);
14
+
5
15
  /** `"native"` stops pinch-zoom so the page acts like the app; `"accessible"` allows it (WCAG 1.4.4). Both cover the notch. */
6
16
  export type ExpoWebRootViewport = "native" | "accessible";
7
17
 
@@ -65,8 +75,9 @@ export function ExpoWebRoot({
65
75
  darkBackground = tokens.color.background.dark,
66
76
  head,
67
77
  }: ExpoWebRootProps) {
78
+ const { htmlAttributes, headNodes, bodyAttributes, bodyNodes } = useServerDocument();
68
79
  return (
69
- <html lang={lang}>
80
+ <html lang={lang} {...htmlAttributes}>
70
81
  <head>
71
82
  <meta charSet="utf-8" />
72
83
  <meta httpEquiv="X-UA-Compatible" content="IE=edge" />
@@ -74,8 +85,12 @@ export function ExpoWebRoot({
74
85
  {scrollReset ? <ScrollViewStyleReset /> : null}
75
86
  <style dangerouslySetInnerHTML={{ __html: expoWebBackgroundCss(lightBackground, darkBackground) }} />
76
87
  {head}
88
+ {headNodes}
77
89
  </head>
78
- <body>{children}</body>
90
+ <body {...bodyAttributes}>
91
+ {children}
92
+ {bodyNodes}
93
+ </body>
79
94
  </html>
80
95
  );
81
96
  }
package/src/Field.tsx ADDED
@@ -0,0 +1,105 @@
1
+ import * as React from "react";
2
+ import { Text, View, type TextProps, type ViewProps } from "react-native";
3
+ import { cn } from "./cn";
4
+ import { Input, type InputProps } from "./Input";
5
+ import { Label, type LabelProps } from "./Label";
6
+ import { sizeStyle, textStyle, typeStyle } from "./controlStyles";
7
+ import { palette } from "./palette";
8
+ import { useLargerText } from "./theme";
9
+ import { useScheme } from "./useScheme";
10
+
11
+ interface FieldContextValue {
12
+ labelId: string;
13
+ hasLabel: boolean;
14
+ setHasLabel: (present: boolean) => void;
15
+ }
16
+
17
+ const FieldContext = React.createContext<FieldContextValue | null>(null);
18
+
19
+ function useField(part: string): FieldContextValue {
20
+ const value = React.useContext(FieldContext);
21
+ if (!value) throw new Error(`${part} must be used inside <Field>.`);
22
+ return value;
23
+ }
24
+
25
+ type FieldProps = ViewProps & {
26
+ className?: string;
27
+ /** The `nativeID` of the label. Default: a generated id. */
28
+ labelId?: string;
29
+ };
30
+
31
+ /**
32
+ * A labelled control: a `gap-2` column. It generates the `nativeID` that
33
+ * `FieldLabel` sets and `FieldControl` points at with `accessibilityLabelledBy`.
34
+ * A plain `Input` does not need it.
35
+ */
36
+ function Field({ className, labelId, ...props }: FieldProps) {
37
+ const generated = React.useId();
38
+ const [hasLabel, setHasLabel] = React.useState(false);
39
+ const id = labelId ?? `field-${generated}-label`;
40
+ const context = React.useMemo(() => ({ labelId: id, hasLabel, setHasLabel }), [id, hasLabel]);
41
+ return (
42
+ <FieldContext.Provider value={context}>
43
+ <View className={cn("gap-2", className)} {...props} />
44
+ </FieldContext.Provider>
45
+ );
46
+ }
47
+
48
+ /** `Label` with the `nativeID` of the nearest `Field`. */
49
+ function FieldLabel(props: LabelProps) {
50
+ const field = useField("FieldLabel");
51
+ const { setHasLabel } = field;
52
+ React.useLayoutEffect(() => {
53
+ setHasLabel(true);
54
+ return () => setHasLabel(false);
55
+ }, [setHasLabel]);
56
+ return <Label nativeID={field.labelId} {...props} />;
57
+ }
58
+
59
+ /**
60
+ * `Input` that names itself from the `FieldLabel` of the nearest `Field`
61
+ * (`accessibilityLabelledBy`, Android). With no `FieldLabel` rendered it
62
+ * keeps the `accessibilityLabel` you pass, which is the fallback on iOS too.
63
+ */
64
+ function FieldControl(props: InputProps) {
65
+ const field = useField("FieldControl");
66
+ return (
67
+ <Input
68
+ {...props}
69
+ {...(field.hasLabel ? { accessibilityLabelledBy: field.labelId } : null)}
70
+ />
71
+ );
72
+ }
73
+
74
+ /** Muted hint under the control. */
75
+ function FieldDescription({ className, style, ...props }: TextProps & { className?: string }) {
76
+ useField("FieldDescription");
77
+ const scheme = useScheme();
78
+ const size = useLargerText() ? "text-base" : "text-sm";
79
+ return (
80
+ <Text
81
+ className={cn("font-instrument-sans", size, className)}
82
+ style={[textStyle("muted", scheme), sizeStyle(size), style]}
83
+ {...props}
84
+ />
85
+ );
86
+ }
87
+
88
+ /** Error message under the control, read out when it appears. */
89
+ function FieldError({ className, style, ...props }: TextProps & { className?: string }) {
90
+ useField("FieldError");
91
+ const scheme = useScheme();
92
+ const size = useLargerText() ? "text-base" : "text-sm";
93
+ return (
94
+ <Text
95
+ accessibilityLiveRegion="polite"
96
+ accessibilityRole="alert"
97
+ className={cn("font-instrument-sans-medium", size, className)}
98
+ style={[{ color: palette.danger[scheme] }, sizeStyle(size), typeStyle("medium"), style]}
99
+ {...props}
100
+ />
101
+ );
102
+ }
103
+
104
+ export { Field, FieldControl, FieldDescription, FieldError, FieldLabel };
105
+ export type { FieldProps };
@@ -28,8 +28,9 @@ const PILL_SLIDE = { duration: 200, easing: Easing.bezier(0.22, 1, 0.36, 1) };
28
28
 
29
29
  /**
30
30
  * The fields this bar reads from the props Expo Router's `Tabs` passes to
31
- * `tabBar` (React Navigation's `BottomTabBarProps`, Expo SDK 57). Declared
32
- * here so the tab bar does not import `expo-router`.
31
+ * `tabBar` (its `BottomTabBarProps`, Expo SDK 58). Declared here so the tab
32
+ * bar does not import `expo-router`. SDK 58 replaced the `navigation` prop
33
+ * with an `emitter` (for `tabPress`) and `navigateToTab(routeKey)`.
33
34
  */
34
35
  export type FloatingTabBarProps = {
35
36
  state: {
@@ -37,14 +38,14 @@ export type FloatingTabBarProps = {
37
38
  routes: readonly { key: string; name: string; params?: object }[];
38
39
  };
39
40
  descriptors: Record<string, { options: FloatingTabOptions }>;
40
- navigation: {
41
+ emitter: {
41
42
  emit(event: {
42
43
  type: "tabPress";
43
44
  target: string;
44
45
  canPreventDefault: true;
45
46
  }): { defaultPrevented: boolean };
46
- navigate(name: string, params?: object): void;
47
47
  };
48
+ navigateToTab: (routeKey: string) => void;
48
49
  };
49
50
 
50
51
  /**
@@ -60,7 +61,8 @@ export type FloatingTabBarProps = {
60
61
  export function FloatingTabBar({
61
62
  state,
62
63
  descriptors,
63
- navigation,
64
+ emitter,
65
+ navigateToTab,
64
66
  }: FloatingTabBarProps) {
65
67
  const insets = useSafeAreaInsets();
66
68
  const largerText = useLargerText();
@@ -113,7 +115,8 @@ export function FloatingTabBar({
113
115
  <TabBarItem
114
116
  key={route.key}
115
117
  route={route}
116
- navigation={navigation}
118
+ emitter={emitter}
119
+ navigateToTab={navigateToTab}
117
120
  focused={focused}
118
121
  label={label}
119
122
  color={color}
@@ -132,7 +135,8 @@ export function FloatingTabBar({
132
135
 
133
136
  type TabBarItemProps = {
134
137
  route: FloatingTabBarProps["state"]["routes"][number];
135
- navigation: FloatingTabBarProps["navigation"];
138
+ emitter: FloatingTabBarProps["emitter"];
139
+ navigateToTab: FloatingTabBarProps["navigateToTab"];
136
140
  focused: boolean;
137
141
  label: string;
138
142
  color: ColorValue;
@@ -145,12 +149,13 @@ type TabBarItemProps = {
145
149
  /**
146
150
  * One tab. React Compiler (the package build) memoises it, so a switch
147
151
  * renders only the two tabs whose focus changed. Its props are stable between
148
- * switches: `route` and `navigation` keep their identity, and `tabBarIcon` is
149
- * the caller's function.
152
+ * switches: `route`, `emitter` and `navigateToTab` keep their identity, and
153
+ * `tabBarIcon` is the caller's function.
150
154
  */
151
155
  function TabBarItem({
152
156
  route,
153
- navigation,
157
+ emitter,
158
+ navigateToTab,
154
159
  focused,
155
160
  label,
156
161
  color,
@@ -161,14 +166,14 @@ function TabBarItem({
161
166
  }: TabBarItemProps) {
162
167
  const press = usePressed();
163
168
  const onPress = () => {
164
- const event = navigation.emit({
169
+ const event = emitter.emit({
165
170
  type: "tabPress",
166
171
  target: route.key,
167
172
  canPreventDefault: true,
168
173
  });
169
174
  if (!focused && !event.defaultPrevented) {
170
175
  selectionHaptic();
171
- navigation.navigate(route.name, route.params);
176
+ navigateToTab(route.key);
172
177
  }
173
178
  };
174
179
 
package/src/Spinner.tsx CHANGED
@@ -10,8 +10,8 @@ import { tokens } from "./tokens";
10
10
  import { useScheme } from "./useScheme";
11
11
 
12
12
  export type SpinnerProps = Omit<ActivityIndicatorProps, "size" | "color"> & {
13
- /** `sm` is 16, the web `sm` and the `Button` loading ring. `md` is the small system spinner (20), `lg` the large one. A number sets the size on Android; iOS picks small below 30. Default `"md"`. */
14
- size?: "sm" | "md" | "lg" | number;
13
+ /** `sm` is 16, the web `sm` and the `Button` loading ring. `md` is the small system spinner (20), `lg` the large one. `default` is an alias of `md`. A number sets the size on Android; iOS picks small below 30. Default `"md"`. */
14
+ size?: "sm" | "md" | "default" | "lg" | number;
15
15
  /** `"muted"` (default) uses the muted text colour, `"inherit"` the foreground. Native has no `currentColor`. */
16
16
  tone?: "muted" | "inherit";
17
17
  /** Overrides `tone`. */
@@ -287,7 +287,7 @@ export function ConversationList<T>({
287
287
  // only if the element takes a `style`: draw it the right way up instead.
288
288
  if (inverted && !hasRows) {
289
289
  const Empty = props.ListEmptyComponent;
290
- return <View style={styles.fill}>{isValidElement(Empty) ? Empty : Empty ? <Empty /> : null}</View>;
290
+ return <View style={styles.fill}>{isValidElement(Empty) ? Empty : typeof Empty === "function" ? <Empty /> : null}</View>;
291
291
  }
292
292
  // The newest message's offset: inverted, 0 less the space before it.
293
293
  const end = () =>
@@ -1,4 +1,4 @@
1
- import { createContext, useContext, useEffect, useRef, useState, type ComponentType, type ReactNode } from "react";
1
+ import { createContext, useContext, useEffect, useRef, useState, type ComponentRef, type ComponentType, type ReactNode } from "react";
2
2
  import { Pressable, StyleSheet, Text, View, type ViewProps } from "react-native";
3
3
  import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
4
4
  import {
@@ -143,7 +143,7 @@ export function Message({
143
143
  // The open context menu: where the message was and what it offers, read at the hold.
144
144
  const [held, setHeld] = useState<{ anchor: MessageMenuRect; menu: MessageMenu } | null>(null);
145
145
  // Measured at the hold: the menu draws the message again where it is on screen.
146
- const pressable = useRef<View>(null);
146
+ const pressable = useRef<ComponentRef<typeof View>>(null);
147
147
  const hasActions = actions != null && actions.length > 0;
148
148
  const longPressable = onLongPress != null || hasActions || menu != null;
149
149
  // In a thread, the menu freezes the list's keyboard handling until its close settles (see `overlay`).