@vvedantb/native-ui 0.22.0 → 0.24.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.
package/README.md CHANGED
@@ -22,7 +22,7 @@ Peers the app must already have (Expo SDK 57 / RN 0.76+):
22
22
  Optional, only if you import those components:
23
23
 
24
24
  - `@rn-primitives/portal` — `Select`. Mount one `<PortalHost />` from this package at the app root (for example in the root layout), outside any `Modal`. The package does not re-export it, so install it with `@rn-primitives/select`.
25
- - `@gorhom/bottom-sheet` — `BottomSheetContainer`
25
+ - `@swmansion/react-native-bottom-sheet` — `BottomSheetContainer`. It needs the New Architecture, React Native 0.82 or later and a native build (no Expo Go), and no root provider.
26
26
  - `@react-native-community/datetimepicker` and `dayjs` — `DateTimeField`
27
27
  - `@clerk/clerk-expo`, `convex`, `expo-auth-session`, `expo-web-browser` and `expo-router` — `@vvedantb/native-ui/auth` (0.7.0). `expo-router` also for `@vvedantb/native-ui/expo-web-root`.
28
28
  - `react-native-gesture-handler` (`>=2.0.0`) — `@vvedantb/native-ui/gesture-handler` (Unreleased). Wrap the app in `GestureHandlerRootView`, and put `GestureHandlerProvider` from that entry inside it: the sheet drags (`SheetContent`, the compact `DialogContent`) then run on Gesture Handler, on the UI thread, and each overlay's `Modal` gets its own root view (Android needs one in every `Modal`). It also turns on the `SwipeableRow` swipe. Without the provider, the sheets drag with `PanResponder`, with the same rules, and a `SwipeableRow` does not swipe. Only that entry imports the peer, so an app without it bundles as before. In a Metro monorepo, resolve the peer from the app (one copy), as for `react`.
@@ -75,7 +75,7 @@ The `Select` note stays: mount one `<PortalHost />` from `@rn-primitives/portal`
75
75
 
76
76
  ## Entry points
77
77
 
78
- The root entry exports everything. It still imports `BottomSheetContainer` and `DateTimeField`, so Metro resolves `@gorhom/bottom-sheet`, `@react-native-community/datetimepicker` and `dayjs` for any import from it. Apps without those peers, such as V Store, should import from the smaller entries below. Between them, they export every name the root exports.
78
+ The root entry exports everything. It still imports `BottomSheetContainer` and `DateTimeField`, so Metro resolves `@swmansion/react-native-bottom-sheet`, `@react-native-community/datetimepicker` and `dayjs` for any import from it. Apps without those peers, such as V Store, should import from the smaller entries below. Between them, they export every name the root exports.
79
79
 
80
80
  | Entry | Exports | Optional peers it reaches |
81
81
  | --- | --- | --- |
@@ -94,7 +94,7 @@ The root entry exports everything. It still imports `BottomSheetContainer` and `
94
94
  | `@vvedantb/native-ui/ambient` | `AmbientBackground` | `expo-linear-gradient` (loader) |
95
95
  | `@vvedantb/native-ui/blur`, `/haptics` | the loaders | `expo-blur`, `expo-haptics` (loaders) |
96
96
  | `@vvedantb/native-ui/push` | `useExpoPushRegistration`, `getExpoPushToken`, `showPushesInForeground`, the three loaders and the types (0.9.0). Pass `register` from your backend (for `@vvedantb/server`: `useMutation(api.push.register)`) and route taps in `onNotificationTap` | `expo-notifications`, `expo-constants`, `expo-device` (loaders) |
97
- | `@vvedantb/native-ui/bottom-sheet` | `BottomSheetContainer` | `@gorhom/bottom-sheet` (import), `expo-blur` (loader) |
97
+ | `@vvedantb/native-ui/bottom-sheet` | `BottomSheetContainer` | `@swmansion/react-native-bottom-sheet` (import) |
98
98
  | `@vvedantb/native-ui/gesture-handler` | `GestureHandlerProvider` (Unreleased): the sheet drags on Gesture Handler, and the `SwipeableRow` swipe | `react-native-gesture-handler` (import) |
99
99
  | `@vvedantb/native-ui/keyboard-controller` | `KeyboardControllerProvider` (Unreleased): the composer, transcript and forms follow the keyboard | `react-native-keyboard-controller` (import) |
100
100
  | `@vvedantb/native-ui/date-time` | `DateTimeField`, `DateTimeFieldProps` (0.5.0) | `@react-native-community/datetimepicker`, `dayjs` (import) |
@@ -348,7 +348,7 @@ configureTheme({ font: { regular: "Inter_400Regular", medium: "Inter_500Medium",
348
348
  | Actions and fields | `Button` (`default`/`primary`, `secondary`, `outline`, `destructive`, `ghost`, `link`, `tinted`; `sm`/`small`, `default`/`medium`, `lg`/`large`, `icon`; `shape` `pill`/`rounded` from 0.6.0), `IconButton` (0.5.0), `CaptureButton` (0.5.0), `Input`, `SearchInput` (0.3.9), `PasswordInput` (0.11.0), `Textarea`, `Label`, `Select`, `Switch`, `Checkbox`, `LabeledSwitchRow`, `ColorSwatches` (0.5.0), `DateTimeField` (date-only, empty and clearable from 0.5.0) |
349
349
  | Display | `Card` (+ `CardHeader`, `CardTitle`, `CardDescription`, `CardContent`, `CardFooter`; `onPress` from 0.5.0), `Badge`, `StatusDot` (`info` from 0.5.0), `Avatar` (+ `AvatarImage`, `AvatarFallback`, `initials()`), `Separator`, `Progress`, `Spinner`, `CenteredSpinner`, `Skeleton`, `EmptyState` (+ `EmptyState.Root` and parts), `ListRow` (`leading`, `titleEnd`, `control`, `onLongPress` from 0.5.0), `StatGrid` (0.5.0), `SectionLabel` (0.5.0), `Chip`, `Text` (0.5.0, `/primitives` only) |
350
350
  | Navigation | `Tabs` (+ `TabsList`, `TabsTrigger` (`minHeight` from 0.14.0), `TabsContent`), `PillTabs`, `PageIndicator` (0.5.0), `FloatingTabBar`, `FloatingFAB`, `HeaderIconButton`, `ThemeToggle` (0.3.16), `StackPageHeader` (0.5.0) |
351
- | Overlays | `Dialog`, `AlertDialog`, `ConfirmDialog`, `Sheet` (RN `Modal`, each with the web part names; a `SheetContent` or compact `DialogContent` drags down to close), `SheetRow` (0.5.0), `BottomSheetContainer` (`@gorhom/bottom-sheet`), `DropdownMenu` (Unreleased; see below) |
351
+ | Overlays | `Dialog`, `AlertDialog`, `ConfirmDialog`, `Sheet` (RN `Modal`, each with the web part names; a `SheetContent` or compact `DialogContent` drags down to close), `SheetRow` (0.5.0), `BottomSheetContainer` (`@swmansion/react-native-bottom-sheet`; optional `detents`), `DropdownMenu` (Unreleased; see below) |
352
352
  | Selection | `BulkActionBar` (Unreleased; see below) |
353
353
  | Feedback | `toast()` and `<Toaster />` |
354
354
  | Brand and upgrade | `APP_ICONS`, `IconVibot` and the other `Icon*`, `AppMark`, `AppWordmark`, `GoogleMark` (0.3.15), `FAMILY_APPS`, `V_PRO_APP_BENEFITS`, `UpgradeToProCard`, `PricingModal` |
@@ -614,7 +614,7 @@ import {
614
614
  ```
615
615
 
616
616
  - `Message`: `onLongPress`, `actions` (`{ key, label, icon?, destructive?, onPress }[]`), `actionSheetTitle`, `highlighted`. With neither `onLongPress` nor `actions` it is the same `View` as before. With either it is a `Pressable` with the same layout and view props, and it stays a non-accessible container so inner buttons keep focus: also offer Reply in a `MessageActionsBar` for screen reader users. `highlighted` draws a primary wash that fades over 1.4 seconds (`MESSAGE_HIGHLIGHT_MS`) and a ring while true; with Reduce Motion it holds still. Set it back to `false` after the scroll.
617
- - `MessageActionSheet` (`open`, `onClose`, `actions`, `title`, `cancelLabel`, `testID`): an RN `Modal` bottom sheet, no `@gorhom/bottom-sheet`. Closes on the backdrop, Cancel, Android back and after an action. Destructive rows use the danger colour. Rows are 48 high (56 with larger text).
617
+ - `MessageActionSheet` (`open`, `onClose`, `actions`, `title`, `cancelLabel`, `testID`): an RN `Modal` bottom sheet that needs no bottom-sheet library. Closes on the backdrop, Cancel, Android back and after an action. Destructive rows use the danger colour. Rows are 48 high (56 with larger text).
618
618
  - `ReplyQuoteChip` (`author`, `text`, `onDismiss`, `dismissLabel`, `accessibilityLabel`, `testID`): author and up to two lines of text, with an X (44 point target, "Dismiss reply quote"). Labelled "Replying to {author}". `PromptInput` `replyTo` draws it above `header`; passing it as `header` works too.
619
619
  - `MessageQuote` (`author`, `text`, `onPress`, `accessibilityLabel`, `testID`): a left border, the author and up to two lines. With `onPress` it is a button.
620
620
  - Bot label in a group chat (0.13.0): `<Message from="assistant" bot={{ name: "Planner", avatar: <Avatar size="xs" /> }}>`. Or leave `Message` alone and render `<MessageBotLabel name="Planner" />` above `MessageContent` in `ChatThread` `renderMessage`. `ChatThread` needs no change.
@@ -1,208 +1,301 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
- import BottomSheet, { BottomSheetBackdrop, BottomSheetView } from "@gorhom/bottom-sheet";
2
+ import { ModalBottomSheet } from "@swmansion/react-native-bottom-sheet";
3
3
  import { IconX } from "@tabler/icons-react-native";
4
- import React, { useCallback } from "react";
5
- import { Platform, Text, TouchableOpacity, View } from "react-native";
4
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
5
+ import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
6
6
  import { Colors } from "./colors";
7
7
  import { textStyle, typeStyle } from "./controlStyles";
8
8
  import { floatingSolidFill } from "./floating";
9
- import { GlassSheetBackground } from "./LiquidGlass";
9
+ import { withAlpha } from "./palette";
10
10
  import { useLargerText } from "./theme";
11
+ import { tokens } from "./tokens";
11
12
  import { useScheme } from "./useScheme";
12
-
13
- // One snap point, set explicitly. With dynamic sizing the sheet can measure to
14
- // height 0 on Android and never appear.
15
- const SNAP_POINTS = ["40%"];
16
13
  const SHEET_RADIUS = 20;
17
14
 
18
- /**
19
- * Opaque sheet chrome for Android. The glass background needs a measured blur
20
- * target, which is not reliable once an RN `Modal` has been dismissed.
21
- */
22
- function SolidSheetBackground(t0) {
23
- const $ = _c(8);
24
- const {
25
- style,
26
- pointerEvents
27
- } = t0;
28
- const scheme = useScheme();
29
- const t1 = floatingSolidFill[scheme];
30
- let t2;
31
- if ($[0] !== t1) {
32
- t2 = {
33
- backgroundColor: t1,
34
- borderTopLeftRadius: SHEET_RADIUS,
35
- borderTopRightRadius: SHEET_RADIUS
36
- };
37
- $[0] = t1;
38
- $[1] = t2;
39
- } else {
40
- t2 = $[1];
41
- }
42
- let t3;
43
- if ($[2] !== style || $[3] !== t2) {
44
- t3 = [style, t2];
45
- $[2] = style;
46
- $[3] = t2;
47
- $[4] = t3;
48
- } else {
49
- t3 = $[4];
50
- }
51
- let t4;
52
- if ($[5] !== pointerEvents || $[6] !== t3) {
53
- t4 = <View pointerEvents={pointerEvents} style={t3} />;
54
- $[5] = pointerEvents;
55
- $[6] = t3;
56
- $[7] = t4;
57
- } else {
58
- t4 = $[7];
59
- }
60
- return t4;
61
- }
62
- function SheetBackdrop(props) {
63
- const $ = _c(2);
64
- let t0;
65
- if ($[0] !== props) {
66
- t0 = <BottomSheetBackdrop {...props} appearsOnIndex={0} disappearsOnIndex={-1} opacity={0.5} />;
67
- $[0] = props;
68
- $[1] = t0;
69
- } else {
70
- t0 = $[1];
71
- }
72
- return t0;
73
- }
15
+ // A single open detent at 40% by default. A caller can pass several detents for
16
+ // multi-detent sizing. The closed detent (0) is added by the component.
17
+ const DEFAULT_DETENTS = ["40%"];
18
+
19
+ // A dimming scrim. The library scales this alpha to 0 at the closed detent and to
20
+ // full at an open one.
21
+ const SCRIM_COLOR = "rgba(0, 0, 0, 0.5)";
74
22
 
75
23
  /**
76
- * A controlled bottom sheet over the screen, built on gorhom's default-export
77
- * `BottomSheet` (the named `BottomSheet` export is undefined).
24
+ * A controlled bottom sheet over the screen, driven by `visible` and `onClose`,
25
+ * with a title and a close button.
26
+ *
27
+ * It is built on `ModalBottomSheet` from Software Mansion's
28
+ * `@swmansion/react-native-bottom-sheet` in `windowOverlay` mode, so it needs no
29
+ * root provider. The library needs the New Architecture, React Native 0.82 or
30
+ * later and a native build (no Expo Go).
78
31
  *
79
- * It renders nothing while `visible` is false. A closed gorhom sheet still lays
80
- * out an absolute-fill host that can cover the triggers beneath it, and
81
- * `BottomSheetModal.present()` did nothing after an RN `Modal` had been
82
- * dismissed on Android.
32
+ * `detents` sets the open detents, shortest first. The default is a single 40%
33
+ * detent. The closed detent is added by the component.
83
34
  */
84
35
  export function BottomSheetContainer(t0) {
85
- const $ = _c(29);
36
+ const $ = _c(54);
86
37
  const {
87
38
  visible,
88
39
  onClose,
89
40
  title,
90
41
  children,
91
- closeTestID
42
+ closeTestID,
43
+ detents: t1
92
44
  } = t0;
45
+ const detents = t1 === undefined ? DEFAULT_DETENTS : t1;
93
46
  const largerText = useLargerText();
94
- const isDark = useScheme() === "dark";
95
- const renderBackdrop = _temp;
96
- if (!visible) {
97
- return null;
98
- }
99
- const t1 = isDark ? Colors.white : Colors.neutral[800];
47
+ const scheme = useScheme();
48
+ const isDark = scheme === "dark";
100
49
  let t2;
101
- if ($[0] !== t1) {
102
- t2 = {
103
- backgroundColor: t1
104
- };
105
- $[0] = t1;
50
+ if ($[0] !== detents) {
51
+ t2 = [0, ...detents];
52
+ $[0] = detents;
106
53
  $[1] = t2;
107
54
  } else {
108
55
  t2 = $[1];
109
56
  }
57
+ const detentList = t2;
58
+ const [index, setIndex] = useState(0);
110
59
  let t3;
111
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
112
- t3 = {
113
- padding: 20,
114
- paddingBottom: 48
60
+ let t4;
61
+ if ($[2] !== visible) {
62
+ t3 = () => {
63
+ setIndex(current => visible ? current === 0 ? 1 : current : 0);
115
64
  };
116
- $[2] = t3;
65
+ t4 = [visible];
66
+ $[2] = visible;
67
+ $[3] = t3;
68
+ $[4] = t4;
117
69
  } else {
118
- t3 = $[2];
70
+ t3 = $[3];
71
+ t4 = $[4];
119
72
  }
120
- const t4 = `${largerText ? "text-2xl" : "text-xl"} flex-1 font-instrument-sans-semibold`;
121
- const t5 = isDark ? "dark" : "light";
122
- let t6;
123
- if ($[3] !== t5) {
124
- t6 = textStyle("foreground", t5);
125
- $[3] = t5;
126
- $[4] = t6;
73
+ useEffect(t3, t4);
74
+ let t5;
75
+ if ($[5] !== onClose) {
76
+ t5 = next => {
77
+ setIndex(next);
78
+ if (next === 0) {
79
+ onClose();
80
+ }
81
+ };
82
+ $[5] = onClose;
83
+ $[6] = t5;
127
84
  } else {
128
- t6 = $[4];
85
+ t5 = $[6];
129
86
  }
130
- let t7;
131
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
132
- t7 = typeStyle("semibold");
133
- $[5] = t7;
87
+ const handleIndexChange = t5;
88
+ let t6;
89
+ if ($[7] !== onClose) {
90
+ t6 = () => {
91
+ setIndex(0);
92
+ onClose();
93
+ };
94
+ $[7] = onClose;
95
+ $[8] = t6;
134
96
  } else {
135
- t7 = $[5];
97
+ t6 = $[8];
136
98
  }
99
+ const handleCloseRequest = t6;
100
+ const t7 = floatingSolidFill[scheme];
137
101
  let t8;
138
- if ($[6] !== t6) {
139
- t8 = [t6, t7];
140
- $[6] = t6;
141
- $[7] = t8;
102
+ if ($[9] !== t7) {
103
+ t8 = <View style={[StyleSheet.absoluteFill, {
104
+ backgroundColor: t7
105
+ }]} />;
106
+ $[9] = t7;
107
+ $[10] = t8;
142
108
  } else {
143
- t8 = $[7];
109
+ t8 = $[10];
144
110
  }
111
+ const surface = t8;
145
112
  let t9;
146
- if ($[8] !== t4 || $[9] !== t8 || $[10] !== title) {
147
- t9 = <Text accessibilityRole="header" className={t4} style={t8}>{title}</Text>;
148
- $[8] = t4;
149
- $[9] = t8;
150
- $[10] = title;
113
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
114
+ t9 = {
115
+ borderTopLeftRadius: SHEET_RADIUS,
116
+ borderTopRightRadius: SHEET_RADIUS
117
+ };
151
118
  $[11] = t9;
152
119
  } else {
153
120
  t9 = $[11];
154
121
  }
155
- const t10 = largerText ? 32 : 28;
156
- const t11 = isDark ? "white" : "black";
157
- let t12;
158
- if ($[12] !== t10 || $[13] !== t11) {
159
- t12 = <IconX size={t10} color={t11} />;
122
+ let t10;
123
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
124
+ t10 = {
125
+ flex: 1,
126
+ paddingTop: 12
127
+ };
160
128
  $[12] = t10;
129
+ } else {
130
+ t10 = $[12];
131
+ }
132
+ const t11 = tokens.color.muted[scheme];
133
+ let t12;
134
+ if ($[13] !== t11) {
135
+ t12 = withAlpha(t11, 0.4);
161
136
  $[13] = t11;
162
137
  $[14] = t12;
163
138
  } else {
164
139
  t12 = $[14];
165
140
  }
166
141
  let t13;
167
- if ($[15] !== closeTestID || $[16] !== onClose || $[17] !== t12) {
168
- t13 = <TouchableOpacity testID={closeTestID} accessibilityRole="button" accessibilityLabel="Close" onPress={onClose} className="-mr-2 h-12 w-12 items-center justify-center" hitSlop={8} activeOpacity={0.7}>{t12}</TouchableOpacity>;
169
- $[15] = closeTestID;
170
- $[16] = onClose;
171
- $[17] = t12;
172
- $[18] = t13;
142
+ if ($[15] !== t12) {
143
+ t13 = <View accessibilityElementsHidden={true} importantForAccessibility="no-hide-descendants" style={{
144
+ alignSelf: "center",
145
+ height: 6,
146
+ width: 40,
147
+ borderRadius: 999,
148
+ backgroundColor: t12
149
+ }} />;
150
+ $[15] = t12;
151
+ $[16] = t13;
173
152
  } else {
174
- t13 = $[18];
153
+ t13 = $[16];
175
154
  }
176
155
  let t14;
177
- if ($[19] !== t13 || $[20] !== t9) {
178
- t14 = <View className="mb-4 flex-row items-center justify-between gap-3">{t9}{t13}</View>;
179
- $[19] = t13;
180
- $[20] = t9;
181
- $[21] = t14;
156
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
157
+ t14 = {
158
+ flexDirection: "row",
159
+ alignItems: "center",
160
+ justifyContent: "space-between",
161
+ gap: 12,
162
+ paddingHorizontal: 20,
163
+ marginTop: 16,
164
+ marginBottom: 16
165
+ };
166
+ $[17] = t14;
167
+ } else {
168
+ t14 = $[17];
169
+ }
170
+ const t15 = largerText ? 24 : 20;
171
+ let t16;
172
+ if ($[18] !== t15) {
173
+ t16 = {
174
+ flex: 1,
175
+ fontSize: t15
176
+ };
177
+ $[18] = t15;
178
+ $[19] = t16;
182
179
  } else {
183
- t14 = $[21];
180
+ t16 = $[19];
184
181
  }
185
- let t15;
186
- if ($[22] !== children || $[23] !== t14) {
187
- t15 = <BottomSheetView style={t3}>{t14}{children}</BottomSheetView>;
188
- $[22] = children;
189
- $[23] = t14;
190
- $[24] = t15;
182
+ let t17;
183
+ if ($[20] !== scheme) {
184
+ t17 = textStyle("foreground", scheme);
185
+ $[20] = scheme;
186
+ $[21] = t17;
191
187
  } else {
192
- t15 = $[24];
188
+ t17 = $[21];
193
189
  }
194
- let t16;
195
- if ($[25] !== onClose || $[26] !== t15 || $[27] !== t2) {
196
- t16 = <BottomSheet index={0} snapPoints={SNAP_POINTS} enableDynamicSizing={false} enablePanDownToClose={true} enableContentPanningGesture={false} enableHandlePanningGesture={true} keyboardBehavior="interactive" onClose={onClose} backdropComponent={renderBackdrop} backgroundComponent={Platform.OS === "android" ? SolidSheetBackground : GlassSheetBackground} handleIndicatorStyle={t2}>{t15}</BottomSheet>;
197
- $[25] = onClose;
198
- $[26] = t15;
199
- $[27] = t2;
200
- $[28] = t16;
190
+ let t18;
191
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
192
+ t18 = typeStyle("semibold");
193
+ $[22] = t18;
201
194
  } else {
202
- t16 = $[28];
195
+ t18 = $[22];
203
196
  }
204
- return t16;
205
- }
206
- function _temp(props) {
207
- return <SheetBackdrop {...props} />;
197
+ let t19;
198
+ if ($[23] !== t16 || $[24] !== t17) {
199
+ t19 = [t16, t17, t18];
200
+ $[23] = t16;
201
+ $[24] = t17;
202
+ $[25] = t19;
203
+ } else {
204
+ t19 = $[25];
205
+ }
206
+ let t20;
207
+ if ($[26] !== t19 || $[27] !== title) {
208
+ t20 = <Text accessibilityRole="header" style={t19}>{title}</Text>;
209
+ $[26] = t19;
210
+ $[27] = title;
211
+ $[28] = t20;
212
+ } else {
213
+ t20 = $[28];
214
+ }
215
+ let t21;
216
+ if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
217
+ t21 = {
218
+ marginRight: -8,
219
+ height: 48,
220
+ width: 48,
221
+ alignItems: "center",
222
+ justifyContent: "center"
223
+ };
224
+ $[29] = t21;
225
+ } else {
226
+ t21 = $[29];
227
+ }
228
+ const t22 = largerText ? 32 : 28;
229
+ const t23 = isDark ? Colors.white : Colors.black;
230
+ let t24;
231
+ if ($[30] !== t22 || $[31] !== t23) {
232
+ t24 = <IconX size={t22} color={t23} />;
233
+ $[30] = t22;
234
+ $[31] = t23;
235
+ $[32] = t24;
236
+ } else {
237
+ t24 = $[32];
238
+ }
239
+ let t25;
240
+ if ($[33] !== closeTestID || $[34] !== handleCloseRequest || $[35] !== t24) {
241
+ t25 = <TouchableOpacity testID={closeTestID} accessibilityRole="button" accessibilityLabel="Close" onPress={handleCloseRequest} style={t21} hitSlop={8} activeOpacity={0.7}>{t24}</TouchableOpacity>;
242
+ $[33] = closeTestID;
243
+ $[34] = handleCloseRequest;
244
+ $[35] = t24;
245
+ $[36] = t25;
246
+ } else {
247
+ t25 = $[36];
248
+ }
249
+ let t26;
250
+ if ($[37] !== t20 || $[38] !== t25) {
251
+ t26 = <View style={t14}>{t20}{t25}</View>;
252
+ $[37] = t20;
253
+ $[38] = t25;
254
+ $[39] = t26;
255
+ } else {
256
+ t26 = $[39];
257
+ }
258
+ let t27;
259
+ if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
260
+ t27 = {
261
+ flex: 1,
262
+ paddingHorizontal: 20,
263
+ paddingBottom: 48
264
+ };
265
+ $[40] = t27;
266
+ } else {
267
+ t27 = $[40];
268
+ }
269
+ let t28;
270
+ if ($[41] !== children) {
271
+ t28 = <View style={t27}>{children}</View>;
272
+ $[41] = children;
273
+ $[42] = t28;
274
+ } else {
275
+ t28 = $[42];
276
+ }
277
+ let t29;
278
+ if ($[43] !== t13 || $[44] !== t26 || $[45] !== t28) {
279
+ t29 = <View style={t10}>{t13}{t26}{t28}</View>;
280
+ $[43] = t13;
281
+ $[44] = t26;
282
+ $[45] = t28;
283
+ $[46] = t29;
284
+ } else {
285
+ t29 = $[46];
286
+ }
287
+ let t30;
288
+ if ($[47] !== detentList || $[48] !== handleCloseRequest || $[49] !== handleIndexChange || $[50] !== index || $[51] !== surface || $[52] !== t29) {
289
+ t30 = <ModalBottomSheet index={index} detents={detentList} lazy={true} windowOverlay={true} scrimColor={SCRIM_COLOR} scrimAccessibilityLabel="Close" surface={surface} surfaceStyle={t9} onIndexChange={handleIndexChange} onCloseRequest={handleCloseRequest}>{t29}</ModalBottomSheet>;
290
+ $[47] = detentList;
291
+ $[48] = handleCloseRequest;
292
+ $[49] = handleIndexChange;
293
+ $[50] = index;
294
+ $[51] = surface;
295
+ $[52] = t29;
296
+ $[53] = t30;
297
+ } else {
298
+ t30 = $[53];
299
+ }
300
+ return t30;
208
301
  }
package/dist/Sheet.jsx CHANGED
@@ -11,7 +11,7 @@ import { SheetDragView } from "./primitives/sheet-drag";
11
11
  import { OverlayClose, OverlayModal, OverlayRoot, OverlayTrigger } from "./primitives/overlay";
12
12
  const SHEET_RADIUS = tokens.radius.card;
13
13
  /**
14
- * Bottom sheet in an RN `Modal`, with no `@gorhom/bottom-sheet`. Same open
14
+ * Bottom sheet in an RN `Modal`, with no bottom-sheet library. Same open
15
15
  * state API as `Dialog`.
16
16
  */
17
17
  export function Sheet(props) {
@@ -18,7 +18,7 @@ import { chatTextSize } from "./chat-text";
18
18
  export const MESSAGE_ACTIONS_TITLE = "Message actions";
19
19
  /**
20
20
  * The sheet that opens on a long press of a chat message: a bottom sheet in
21
- * an RN `Modal` (no `@gorhom/bottom-sheet`) with one pressable row per action
21
+ * an RN `Modal` (no bottom-sheet library) with one pressable row per action
22
22
  * and a Cancel row. It closes on the backdrop, Cancel, Android back and after
23
23
  * an action. A `selectionHaptic()` fires when it opens (`expo-haptics` is an
24
24
  * optional peer). Row testIDs are `{testID}-action-{key}`.
@@ -1,2 +1,3 @@
1
- // `@vvedantb/native-ui/bottom-sheet`. Imports `@gorhom/bottom-sheet`.
1
+ // `@vvedantb/native-ui/bottom-sheet`. Imports `@swmansion/react-native-bottom-sheet`
2
+ // (an optional peer).
2
3
  export { BottomSheetContainer } from "../BottomSheetContainer";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/native-ui",
3
- "version": "0.22.0",
3
+ "version": "0.24.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",
@@ -186,13 +186,13 @@
186
186
  "peerDependencies": {
187
187
  "@clerk/clerk-expo": "*",
188
188
  "@expo/vector-icons": "*",
189
- "@gorhom/bottom-sheet": ">=5",
190
189
  "@json-render/core": ">=0.21.0",
191
190
  "@json-render/react-native": ">=0.21.0",
192
191
  "@react-native-community/datetimepicker": "*",
193
192
  "@rn-primitives/select": "*",
194
193
  "@rn-primitives/slot": "*",
195
194
  "@rn-primitives/switch": "*",
195
+ "@swmansion/react-native-bottom-sheet": ">=1.1.0",
196
196
  "@tabler/icons-react-native": "*",
197
197
  "@vvedantb/server": ">=0.17.1",
198
198
  "class-variance-authority": ">=0.7.0",
@@ -228,7 +228,7 @@
228
228
  "@clerk/clerk-expo": {
229
229
  "optional": true
230
230
  },
231
- "@gorhom/bottom-sheet": {
231
+ "@swmansion/react-native-bottom-sheet": {
232
232
  "optional": true
233
233
  },
234
234
  "@json-render/core": {
@@ -1,75 +1,37 @@
1
- import BottomSheet, {
2
- BottomSheetBackdrop,
3
- BottomSheetView,
4
- } from "@gorhom/bottom-sheet";
5
- import type { BottomSheetDefaultBackdropProps } from "@gorhom/bottom-sheet/lib/typescript/components/bottomSheetBackdrop/types";
1
+ import { ModalBottomSheet } from "@swmansion/react-native-bottom-sheet";
2
+ import type { ModalDetent } from "@swmansion/react-native-bottom-sheet";
6
3
  import { IconX } from "@tabler/icons-react-native";
7
- import React, { useCallback } from "react";
8
- import {
9
- Platform,
10
- Text,
11
- TouchableOpacity,
12
- View,
13
- type ViewProps,
14
- } from "react-native";
4
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
5
+ import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
15
6
  import { Colors } from "./colors";
16
7
  import { textStyle, typeStyle } from "./controlStyles";
17
8
  import { floatingSolidFill } from "./floating";
18
- import { GlassSheetBackground } from "./LiquidGlass";
9
+ import { withAlpha } from "./palette";
19
10
  import { useLargerText } from "./theme";
11
+ import { tokens } from "./tokens";
20
12
  import { useScheme } from "./useScheme";
21
13
 
22
- // One snap point, set explicitly. With dynamic sizing the sheet can measure to
23
- // height 0 on Android and never appear.
24
- const SNAP_POINTS = ["40%"];
25
14
  const SHEET_RADIUS = 20;
26
15
 
27
- /**
28
- * Opaque sheet chrome for Android. The glass background needs a measured blur
29
- * target, which is not reliable once an RN `Modal` has been dismissed.
30
- */
31
- function SolidSheetBackground({
32
- style,
33
- pointerEvents,
34
- }: {
35
- style?: ViewProps["style"];
36
- pointerEvents?: ViewProps["pointerEvents"];
37
- }) {
38
- const scheme = useScheme();
39
- return (
40
- <View
41
- pointerEvents={pointerEvents}
42
- style={[
43
- style,
44
- {
45
- backgroundColor: floatingSolidFill[scheme],
46
- borderTopLeftRadius: SHEET_RADIUS,
47
- borderTopRightRadius: SHEET_RADIUS,
48
- },
49
- ]}
50
- />
51
- );
52
- }
16
+ // A single open detent at 40% by default. A caller can pass several detents for
17
+ // multi-detent sizing. The closed detent (0) is added by the component.
18
+ const DEFAULT_DETENTS: readonly ModalDetent[] = ["40%"];
53
19
 
54
- function SheetBackdrop(props: BottomSheetDefaultBackdropProps) {
55
- return (
56
- <BottomSheetBackdrop
57
- {...props}
58
- appearsOnIndex={0}
59
- disappearsOnIndex={-1}
60
- opacity={0.5}
61
- />
62
- );
63
- }
20
+ // A dimming scrim. The library scales this alpha to 0 at the closed detent and to
21
+ // full at an open one.
22
+ const SCRIM_COLOR = "rgba(0, 0, 0, 0.5)";
64
23
 
65
24
  /**
66
- * A controlled bottom sheet over the screen, built on gorhom's default-export
67
- * `BottomSheet` (the named `BottomSheet` export is undefined).
25
+ * A controlled bottom sheet over the screen, driven by `visible` and `onClose`,
26
+ * with a title and a close button.
27
+ *
28
+ * It is built on `ModalBottomSheet` from Software Mansion's
29
+ * `@swmansion/react-native-bottom-sheet` in `windowOverlay` mode, so it needs no
30
+ * root provider. The library needs the New Architecture, React Native 0.82 or
31
+ * later and a native build (no Expo Go).
68
32
  *
69
- * It renders nothing while `visible` is false. A closed gorhom sheet still lays
70
- * out an absolute-fill host that can cover the triggers beneath it, and
71
- * `BottomSheetModal.present()` did nothing after an RN `Modal` had been
72
- * dismissed on Android.
33
+ * `detents` sets the open detents, shortest first. The default is a single 40%
34
+ * detent. The closed detent is added by the component.
73
35
  */
74
36
  export function BottomSheetContainer({
75
37
  visible,
@@ -77,50 +39,98 @@ export function BottomSheetContainer({
77
39
  title,
78
40
  children,
79
41
  closeTestID,
42
+ detents = DEFAULT_DETENTS,
80
43
  }: {
81
44
  visible: boolean;
82
45
  onClose: () => void;
83
46
  title: string;
84
47
  children: React.ReactNode;
85
48
  closeTestID?: string;
49
+ /** Open detents, shortest first. The closed detent is added automatically. */
50
+ detents?: readonly ModalDetent[];
86
51
  }) {
87
52
  const largerText = useLargerText();
88
- const isDark = useScheme() === "dark";
89
- const renderBackdrop = useCallback(
90
- (props: BottomSheetDefaultBackdropProps) => <SheetBackdrop {...props} />,
91
- [],
53
+ const scheme = useScheme();
54
+ const isDark = scheme === "dark";
55
+
56
+ // The library sheet is controlled by a detent index. The first detent is the
57
+ // closed state (0); the open detents follow.
58
+ const detentList = useMemo<ModalDetent[]>(() => [0, ...detents], [detents]);
59
+ const [index, setIndex] = useState(0);
60
+
61
+ // Keep the index in step with `visible`: open to the first detent, close to 0.
62
+ useEffect(() => {
63
+ setIndex((current) => (visible ? (current === 0 ? 1 : current) : 0));
64
+ }, [visible]);
65
+
66
+ // A user-driven drag to the closed detent reports here; tell the parent.
67
+ const handleIndexChange = useCallback(
68
+ (next: number) => {
69
+ setIndex(next);
70
+ if (next === 0) onClose();
71
+ },
72
+ [onClose],
92
73
  );
93
74
 
94
- if (!visible) {
95
- return null;
96
- }
75
+ // A scrim tap or system Back asks the sheet to close; close it and tell the parent.
76
+ const handleCloseRequest = useCallback(() => {
77
+ setIndex(0);
78
+ onClose();
79
+ }, [onClose]);
80
+
81
+ const surface = (
82
+ <View
83
+ style={[StyleSheet.absoluteFill, { backgroundColor: floatingSolidFill[scheme] }]}
84
+ />
85
+ );
97
86
 
98
87
  return (
99
- <BottomSheet
100
- index={0}
101
- snapPoints={SNAP_POINTS}
102
- enableDynamicSizing={false}
103
- enablePanDownToClose
104
- enableContentPanningGesture={false}
105
- enableHandlePanningGesture
106
- keyboardBehavior="interactive"
107
- onClose={onClose}
108
- backdropComponent={renderBackdrop}
109
- backgroundComponent={
110
- Platform.OS === "android" ? SolidSheetBackground : GlassSheetBackground
111
- }
112
- handleIndicatorStyle={{
113
- backgroundColor: isDark ? Colors.white : Colors.neutral[800],
88
+ <ModalBottomSheet
89
+ index={index}
90
+ detents={detentList}
91
+ // Unmount the content once the sheet settles closed.
92
+ lazy
93
+ windowOverlay
94
+ scrimColor={SCRIM_COLOR}
95
+ scrimAccessibilityLabel="Close"
96
+ surface={surface}
97
+ surfaceStyle={{
98
+ borderTopLeftRadius: SHEET_RADIUS,
99
+ borderTopRightRadius: SHEET_RADIUS,
114
100
  }}
101
+ onIndexChange={handleIndexChange}
102
+ onCloseRequest={handleCloseRequest}
115
103
  >
116
- {/* Padding is a style, not a NativeWind class: `BottomSheetView` does not
117
- always apply `className`, and an unpadded sheet can measure too small. */}
118
- <BottomSheetView style={{ padding: 20, paddingBottom: 48 }}>
119
- <View className="mb-4 flex-row items-center justify-between gap-3">
104
+ <View style={{ flex: 1, paddingTop: 12 }}>
105
+ <View
106
+ accessibilityElementsHidden
107
+ importantForAccessibility="no-hide-descendants"
108
+ style={{
109
+ alignSelf: "center",
110
+ height: 6,
111
+ width: 40,
112
+ borderRadius: 999,
113
+ backgroundColor: withAlpha(tokens.color.muted[scheme], 0.4),
114
+ }}
115
+ />
116
+ <View
117
+ style={{
118
+ flexDirection: "row",
119
+ alignItems: "center",
120
+ justifyContent: "space-between",
121
+ gap: 12,
122
+ paddingHorizontal: 20,
123
+ marginTop: 16,
124
+ marginBottom: 16,
125
+ }}
126
+ >
120
127
  <Text
121
128
  accessibilityRole="header"
122
- className={`${largerText ? "text-2xl" : "text-xl"} flex-1 font-instrument-sans-semibold`}
123
- style={[textStyle("foreground", isDark ? "dark" : "light"), typeStyle("semibold")]}
129
+ style={[
130
+ { flex: 1, fontSize: largerText ? 24 : 20 },
131
+ textStyle("foreground", scheme),
132
+ typeStyle("semibold"),
133
+ ]}
124
134
  >
125
135
  {title}
126
136
  </Text>
@@ -128,16 +138,18 @@ export function BottomSheetContainer({
128
138
  testID={closeTestID}
129
139
  accessibilityRole="button"
130
140
  accessibilityLabel="Close"
131
- onPress={onClose}
132
- className="-mr-2 h-12 w-12 items-center justify-center"
141
+ onPress={handleCloseRequest}
142
+ style={{ marginRight: -8, height: 48, width: 48, alignItems: "center", justifyContent: "center" }}
133
143
  hitSlop={8}
134
144
  activeOpacity={0.7}
135
145
  >
136
- <IconX size={largerText ? 32 : 28} color={isDark ? "white" : "black"} />
146
+ <IconX size={largerText ? 32 : 28} color={isDark ? Colors.white : Colors.black} />
137
147
  </TouchableOpacity>
138
148
  </View>
139
- {children}
140
- </BottomSheetView>
141
- </BottomSheet>
149
+ <View style={{ flex: 1, paddingHorizontal: 20, paddingBottom: 48 }}>
150
+ {children}
151
+ </View>
152
+ </View>
153
+ </ModalBottomSheet>
142
154
  );
143
155
  }
package/src/Sheet.tsx CHANGED
@@ -21,7 +21,7 @@ const SHEET_RADIUS = tokens.radius.card;
21
21
  export type SheetProps = OverlayRootProps;
22
22
 
23
23
  /**
24
- * Bottom sheet in an RN `Modal`, with no `@gorhom/bottom-sheet`. Same open
24
+ * Bottom sheet in an RN `Modal`, with no bottom-sheet library. Same open
25
25
  * state API as `Dialog`.
26
26
  */
27
27
  export function Sheet(props: SheetProps) {
@@ -39,7 +39,7 @@ export type MessageActionSheetProps = {
39
39
 
40
40
  /**
41
41
  * The sheet that opens on a long press of a chat message: a bottom sheet in
42
- * an RN `Modal` (no `@gorhom/bottom-sheet`) with one pressable row per action
42
+ * an RN `Modal` (no bottom-sheet library) with one pressable row per action
43
43
  * and a Cancel row. It closes on the backdrop, Cancel, Android back and after
44
44
  * an action. A `selectionHaptic()` fires when it opens (`expo-haptics` is an
45
45
  * optional peer). Row testIDs are `{testID}-action-{key}`.
@@ -1,2 +1,3 @@
1
- // `@vvedantb/native-ui/bottom-sheet`. Imports `@gorhom/bottom-sheet`.
1
+ // `@vvedantb/native-ui/bottom-sheet`. Imports `@swmansion/react-native-bottom-sheet`
2
+ // (an optional peer).
2
3
  export { BottomSheetContainer } from "../BottomSheetContainer";