@vvedantb/native-ui 0.35.0 → 0.36.1

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 (42) hide show
  1. package/README.md +16 -1
  2. package/dist/Button.jsx +29 -18
  3. package/dist/DropdownMenu.jsx +89 -39
  4. package/dist/ExpoWebRoot.jsx +42 -21
  5. package/dist/Field.jsx +309 -0
  6. package/dist/FloatingTabBar.jsx +98 -94
  7. package/dist/IconButton.jsx +74 -51
  8. package/dist/ai/conversation.jsx +1 -1
  9. package/dist/ai/icon-button.jsx +67 -60
  10. package/dist/ai/prompt-input.jsx +9 -8
  11. package/dist/blur.js +6 -0
  12. package/dist/controlStyles.js +24 -2
  13. package/dist/entries/primitives.js +1 -0
  14. package/dist/examples/ParityGallery.jsx +488 -475
  15. package/dist/glassBlur.jsx +1 -1
  16. package/dist/index.js +1 -0
  17. package/dist/primitives/window-layer.jsx +35 -28
  18. package/package.json +27 -3
  19. package/src/Button.tsx +18 -7
  20. package/src/DropdownMenu.tsx +53 -7
  21. package/src/ExpoWebRoot.tsx +18 -3
  22. package/src/Field.tsx +105 -0
  23. package/src/FloatingTabBar.tsx +17 -12
  24. package/src/IconButton.tsx +7 -4
  25. package/src/Spinner.tsx +2 -2
  26. package/src/ai/conversation.tsx +1 -1
  27. package/src/ai/icon-button.tsx +5 -4
  28. package/src/ai/message.tsx +2 -2
  29. package/src/ai/prompt-input.tsx +6 -4
  30. package/src/auth/AccountScreens.tsx +4 -4
  31. package/src/auth/SignInScreen.tsx +4 -4
  32. package/src/blur.ts +8 -0
  33. package/src/controlStyles.ts +29 -2
  34. package/src/entries/primitives.ts +2 -0
  35. package/src/examples/ParityGallery.tsx +22 -1
  36. package/src/glassBlur.tsx +5 -7
  37. package/src/index.ts +2 -0
  38. package/src/primitives/sheet-gesture.tsx +1 -2
  39. package/src/primitives/web-click-guard.ts +3 -3
  40. package/src/primitives/window-layer.tsx +8 -6
  41. package/src/tabBarRoutes.ts +4 -3
  42. package/src/webview/HtmlView.tsx +5 -2
@@ -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";
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/native-ui",
3
- "version": "0.35.0",
3
+ "version": "0.36.1",
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,13 +129,22 @@ 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;
134
140
 
135
141
  export type { ButtonProps, ButtonShape, ButtonSize, ButtonVariant };
136
142
 
137
- export function Button({
143
+ /**
144
+ * Forwards `ref` to the native view, so a parent (such as `DropdownMenuTrigger
145
+ * asChild`) can measure it.
146
+ */
147
+ export const Button = React.forwardRef<React.ElementRef<typeof PrimitiveButton>, ButtonProps>(function Button({
138
148
  onPress,
139
149
  variant = "primary",
140
150
  icon,
@@ -149,7 +159,7 @@ export function Button({
149
159
  shadowType = "flat",
150
160
  className,
151
161
  ...props
152
- }: ButtonProps) {
162
+ }, ref) {
153
163
  const scale = useLargerText() ? "larger" : "regular";
154
164
  const scheme = useScheme();
155
165
  const dialog = useDialogLayout();
@@ -180,6 +190,7 @@ export function Button({
180
190
 
181
191
  return (
182
192
  <PrimitiveButton
193
+ ref={ref}
183
194
  onPress={onPress}
184
195
  variant={PRIMITIVE_VARIANT[variant]}
185
196
  shape={shape}
@@ -233,4 +244,4 @@ export function Button({
233
244
  </View>
234
245
  </PrimitiveButton>
235
246
  );
236
- }
247
+ });
@@ -1,5 +1,15 @@
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
+ type Ref,
12
+ } from "react";
3
13
  import {
4
14
  Pressable,
5
15
  ScrollView,
@@ -102,19 +112,55 @@ export type DropdownMenuTriggerProps = PressableProps & {
102
112
  * native view, so the menu can measure it.
103
113
  */
104
114
  asChild?: boolean;
115
+ /** Also receives the native view; the menu keeps its own handle. */
116
+ ref?: Ref<ComponentRef<typeof View>>;
105
117
  };
106
118
 
119
+ /** A measured box is usable when it has a size: Android reports 0, 0, 0, 0 for a view it has not laid out. */
120
+ export function isMeasuredRect(rect: DropdownMenuRect): boolean {
121
+ return rect.width > 0 && rect.height > 0;
122
+ }
123
+
124
+ type Measurable = Pick<ComponentRef<typeof View>, "measureInWindow" | "measure">;
125
+
126
+ /**
127
+ * The view's box in window coordinates, or `null` when it cannot be measured.
128
+ * `measureInWindow` first; when it returns an empty box, `measure` (its
129
+ * `pageX` and `pageY` are window coordinates too) as a second reading.
130
+ */
131
+ export function measureAnchor(view: Measurable, done: (rect: DropdownMenuRect | null) => void) {
132
+ view.measureInWindow((x, y, width, height) => {
133
+ const rect = { x, y, width, height };
134
+ if (isMeasuredRect(rect)) return done(rect);
135
+ view.measure((_x, _y, w, h, pageX, pageY) => {
136
+ const second = { x: pageX, y: pageY, width: w, height: h };
137
+ done(isMeasuredRect(second) ? second : null);
138
+ });
139
+ });
140
+ }
141
+
107
142
  /**
108
143
  * Opens the menu, or closes it when open. On press it measures itself
109
- * (`measureInWindow`) and the menu opens under it. Reports `expanded`.
144
+ * (`measureInWindow`) and the menu opens under it. Reports `expanded`. A
145
+ * caller `ref` is kept: the menu's own handle never replaces it.
110
146
  */
111
- export function DropdownMenuTrigger({ asChild, onPress, accessibilityState, ...props }: DropdownMenuTriggerProps) {
147
+ export function DropdownMenuTrigger({
148
+ asChild,
149
+ onPress,
150
+ accessibilityState,
151
+ ref: callerRef,
152
+ ...props
153
+ }: DropdownMenuTriggerProps) {
112
154
  const { open, setOpen, setTrigger } = useMenu("DropdownMenuTrigger");
113
- const ref = useRef<View>(null);
155
+ const ref = useRef<ComponentRef<typeof View> | null>(null);
114
156
  const Component = asChild ? Slot.Pressable : Pressable;
115
157
  return (
116
158
  <Component
117
- ref={ref}
159
+ ref={(view: ComponentRef<typeof View> | null) => {
160
+ ref.current = view;
161
+ if (typeof callerRef === "function") callerRef(view);
162
+ else if (callerRef) callerRef.current = view;
163
+ }}
118
164
  accessibilityRole="button"
119
165
  {...props}
120
166
  accessibilityState={{ ...accessibilityState, expanded: open }}
@@ -123,8 +169,8 @@ export function DropdownMenuTrigger({ asChild, onPress, accessibilityState, ...p
123
169
  if (open) return setOpen(false);
124
170
  const view = ref.current;
125
171
  if (!view) return setOpen(true);
126
- view.measureInWindow((x, y, width, height) => {
127
- setTrigger({ x, y, width, height });
172
+ measureAnchor(view, (rect) => {
173
+ if (rect) setTrigger(rect);
128
174
  setOpen(true);
129
175
  });
130
176
  }}
@@ -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
 
@@ -1,4 +1,5 @@
1
- import type { ComponentType } from "react";
1
+ import { forwardRef, type ComponentRef, type ComponentType } from "react";
2
+ import { View } from "react-native";
2
3
  import type { IconProps } from "@tabler/icons-react-native";
3
4
  import { touchSlop } from "./controlStyles";
4
5
  import { AnimatedPressable, usePressScale } from "./pressScale";
@@ -54,7 +55,7 @@ export function iconButtonColors(variant: IconButtonVariant, scheme: "light" | "
54
55
  * 32, `md` 40) and 48, each reaching 44 with its hit slop. Not the AI chat
55
56
  * `ChatIconButton`.
56
57
  */
57
- export function IconButton({
58
+ export const IconButton = forwardRef<ComponentRef<typeof View>, IconButtonProps>(function IconButton({
58
59
  icon: Icon,
59
60
  label,
60
61
  onPress,
@@ -63,13 +64,14 @@ export function IconButton({
63
64
  size = "md",
64
65
  testID,
65
66
  iconColor,
66
- }: IconButtonProps) {
67
+ }, ref) {
67
68
  const scheme = useScheme();
68
69
  const largerText = useLargerText();
69
70
  const [diameter, iconSize] = METRICS[largerText ? "larger" : "regular"][size];
70
71
  const { color, ...frame } = iconButtonColors(variant, scheme);
71
72
  const press = usePressScale({ restOpacity: disabled ? 0.5 : 1, disabled });
72
73
  return (
74
+ <View ref={ref} collapsable={false} style={{ width: diameter, height: diameter }}>
73
75
  <AnimatedPressable
74
76
  testID={testID}
75
77
  accessibilityRole="button"
@@ -85,5 +87,6 @@ export function IconButton({
85
87
  >
86
88
  <Icon size={iconSize} color={iconColor ?? color} />
87
89
  </AnimatedPressable>
90
+ </View>
88
91
  );
89
- }
92
+ });
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 type { ComponentType } from "react";
1
+ import { forwardRef, type ComponentType, type ElementRef } from "react";
2
2
  import type { IconProps } from "@tabler/icons-react-native";
3
3
  import { Button, type ButtonProps } from "../Button";
4
4
  import { cn } from "../cn";
@@ -51,7 +51,7 @@ export type ChatIconButtonProps = Omit<ButtonProps, "children" | "size" | "icon"
51
51
  * actions, the composer tools and its send button, and the code copy button.
52
52
  * Round from the `Button` pill default; `shape="rounded"` gives radius 16.
53
53
  */
54
- export function ChatIconButton({
54
+ export const ChatIconButton = forwardRef<ElementRef<typeof Button>, ChatIconButtonProps>(function ChatIconButton({
55
55
  icon: Icon,
56
56
  label,
57
57
  iconColor,
@@ -60,7 +60,7 @@ export function ChatIconButton({
60
60
  slop = "square",
61
61
  className,
62
62
  ...props
63
- }: ChatIconButtonProps) {
63
+ }, ref) {
64
64
  const scheme = useScheme();
65
65
  const largerText = useLargerText();
66
66
  const metrics = largerText
@@ -69,6 +69,7 @@ export function ChatIconButton({
69
69
  const color = iconColor ?? buttonColors(variant, scheme)?.color ?? tokens.color.foreground[scheme];
70
70
  return (
71
71
  <Button
72
+ ref={ref}
72
73
  variant={variant}
73
74
  size="icon"
74
75
  accessibilityLabel={label}
@@ -83,4 +84,4 @@ export function ChatIconButton({
83
84
  <Icon size={metrics.icon} color={color} />
84
85
  </Button>
85
86
  );
86
- }
87
+ });