@vvedantb/native-ui 0.35.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";
@@ -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.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`).
@@ -1,5 +1,5 @@
1
- import { useRef, useState, type ReactNode } from "react";
2
- import type { TextInput } from "react-native";
1
+ import { useRef, useState, type ComponentRef, type ReactNode } from "react";
2
+ import { TextInput } from "react-native";
3
3
  import { useUser } from "@clerk/expo";
4
4
  import { useRouter, type Href } from "expo-router";
5
5
  import { Button } from "../Button";
@@ -86,8 +86,8 @@ export function ChangePasswordScreen({
86
86
  const [confirm, setConfirm] = useState("");
87
87
  const [error, setError] = useState("");
88
88
  const [submitting, setSubmitting] = useState(false);
89
- const nextField = useRef<TextInput>(null);
90
- const confirmField = useRef<TextInput>(null);
89
+ const nextField = useRef<ComponentRef<typeof TextInput>>(null);
90
+ const confirmField = useRef<ComponentRef<typeof TextInput>>(null);
91
91
  const id = (name: string) => `${testIDPrefix}-${name}`;
92
92
  // Until the user loads, show the current-password field: most accounts have one.
93
93
  const hasPassword = user ? user.passwordEnabled : true;
@@ -1,5 +1,5 @@
1
- import { useRef, useState, type ReactNode } from "react";
2
- import { Text, View, type TextInput } from "react-native";
1
+ import { useRef, useState, type ComponentRef, type ReactNode } from "react";
2
+ import { Text, TextInput, View } from "react-native";
3
3
  import { useSignIn, useSignUp } from "@clerk/expo";
4
4
  import { useRouter, type Href } from "expo-router";
5
5
  import { Button } from "../Button";
@@ -237,8 +237,8 @@ export function SignInScreen({
237
237
  const [error, setError] = useState("");
238
238
  const [submitting, setSubmitting] = useState(false);
239
239
  // The field each "next" key moves to.
240
- const passwordField = useRef<TextInput>(null);
241
- const confirmField = useRef<TextInput>(null);
240
+ const passwordField = useRef<ComponentRef<typeof TextInput>>(null);
241
+ const confirmField = useRef<ComponentRef<typeof TextInput>>(null);
242
242
  const signUp = mode === "sign-up";
243
243
  const reset = mode === "reset-password";
244
244
  const id = (name: string) => `${testIDPrefix ?? mode}-${name}`;
package/src/blur.ts CHANGED
@@ -2,6 +2,14 @@ import type * as ExpoBlur from "expo-blur";
2
2
 
3
3
  export type ExpoBlurModule = typeof ExpoBlur;
4
4
 
5
+ /**
6
+ * The ref an expo-blur `BlurView` blurs (its `blurTarget` prop, and the ref a
7
+ * `BlurTargetView` takes). Derived from expo-blur's own type so the two match
8
+ * under any React Native version.
9
+ */
10
+ export type BlurTargetRef = NonNullable<ExpoBlur.BlurViewProps["blurTarget"]>;
11
+ export type BlurTargetElement = NonNullable<BlurTargetRef["current"]>;
12
+
5
13
  let expoBlur: ExpoBlurModule | null | undefined;
6
14
 
7
15
  /**
@@ -14,17 +14,29 @@ type Scheme = "light" | "dark";
14
14
 
15
15
  /**
16
16
  * `primary` and `default` are the same (`default` is the web name). `outline`
17
- * is the web bordered neutral button. `tinted` is the pink tint that `outline`
18
- * drew before 0.3.0.
17
+ * is the web bordered neutral button. `tertiary` is the web name for `ghost`
18
+ * and `danger` for `destructive`. `success`, `warning` and `flat` match the web
19
+ * variants. `tinted` is a legacy alias: the pink tint that `outline` drew
20
+ * before 0.3.0 (it keeps its NativeWind classes).
21
+ *
22
+ * Hierarchy: `primary`/`default` is the one main action, `secondary` an
23
+ * alternative, `tertiary`/`ghost` a dismissive action, `destructive`/`danger`
24
+ * a destructive action, `success` and `warning` show status, and `outline`,
25
+ * `link` and `flat` are visual.
19
26
  */
20
27
  export type ButtonVariant =
21
28
  | "primary"
22
29
  | "default"
23
30
  | "secondary"
31
+ | "tertiary"
24
32
  | "outline"
25
33
  | "destructive"
34
+ | "danger"
26
35
  | "ghost"
27
36
  | "link"
37
+ | "success"
38
+ | "warning"
39
+ | "flat"
28
40
  | "tinted";
29
41
 
30
42
  export type ButtonColors = {
@@ -54,9 +66,24 @@ export function buttonColors(variant: ButtonVariant, scheme: Scheme): ButtonColo
54
66
  color: tokens.color.foreground[scheme],
55
67
  };
56
68
  case "destructive":
69
+ case "danger":
57
70
  return { backgroundColor: palette.destructive, borderColor: none, color: tokens.color.white };
58
71
  case "ghost":
72
+ case "tertiary":
73
+ case "flat":
59
74
  return { backgroundColor: none, borderColor: none, color: tokens.color.muted[scheme] };
75
+ case "success":
76
+ return {
77
+ backgroundColor: palette.success[scheme],
78
+ borderColor: none,
79
+ color: palette.successForeground[scheme],
80
+ };
81
+ case "warning":
82
+ return {
83
+ backgroundColor: palette.warning[scheme],
84
+ borderColor: none,
85
+ color: palette.warningForeground[scheme],
86
+ };
60
87
  case "link":
61
88
  return { backgroundColor: none, borderColor: none, color: palette.primary[scheme] };
62
89
  case "tinted":
@@ -15,6 +15,8 @@ export { Textarea } from "../Textarea";
15
15
  export type { TextareaProps } from "../Textarea";
16
16
  export { Label } from "../Label";
17
17
  export type { LabelProps } from "../Label";
18
+ export { Field, FieldControl, FieldDescription, FieldError, FieldLabel } from "../Field";
19
+ export type { FieldProps } from "../Field";
18
20
  export { Select } from "../Select";
19
21
  export type { SelectOption, SelectProps } from "../Select";
20
22
  export { Switch } from "../Switch";