@marktiderman/genesis-ui-native 2.1.0 → 2.3.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 +134 -0
- package/dist/chunk-7PCWEY6R.js +27 -0
- package/dist/chunk-7PCWEY6R.js.map +1 -0
- package/dist/chunk-D5RKSPMH.js +24 -0
- package/dist/chunk-D5RKSPMH.js.map +1 -0
- package/dist/{chunk-5HRGIA6F.js → chunk-EFXCJ5AN.js} +76 -3
- package/dist/chunk-EFXCJ5AN.js.map +1 -0
- package/dist/{chunk-ULS7I6ZS.js → chunk-ERHGCWTY.js} +81 -12
- package/dist/chunk-ERHGCWTY.js.map +1 -0
- package/dist/{chunk-3LK5ZJ4M.js → chunk-FIITITXO.js} +67 -108
- package/dist/chunk-FIITITXO.js.map +1 -0
- package/dist/chunk-FZY2IXOX.js +1559 -0
- package/dist/chunk-FZY2IXOX.js.map +1 -0
- package/dist/{chunk-TXJT55JC.js → chunk-W7BK3ARU.js} +715 -293
- package/dist/chunk-W7BK3ARU.js.map +1 -0
- package/dist/components/index.d.ts +143 -17
- package/dist/components/index.js +6 -4
- package/dist/data/index.d.ts +7 -1
- package/dist/data/index.js +31 -6
- package/dist/data/index.js.map +1 -1
- package/dist/hooks/index.js +2 -1
- package/dist/icons/lucide.d.ts +7 -0
- package/dist/icons/lucide.js +47 -0
- package/dist/icons/lucide.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +7 -6
- package/dist/layouts/index.d.ts +399 -7
- package/dist/layouts/index.js +3 -3
- package/dist/native-modules-BSVaEb3D.d.ts +206 -0
- package/package.json +34 -5
- package/src/__tests__/fake-modules.tsx +134 -0
- package/src/__tests__/native-modules-lists.test.tsx +70 -0
- package/src/__tests__/native-modules.test.tsx +631 -0
- package/src/components/__tests__/sheet.test.tsx +193 -0
- package/src/components/__tests__/toast.test.tsx +15 -0
- package/src/components/avatar.tsx +69 -16
- package/src/components/date-time-picker.tsx +128 -10
- package/src/components/drawer.tsx +158 -68
- package/src/components/dropdown-menu.tsx +7 -6
- package/src/components/glass-surface.tsx +150 -0
- package/src/components/icon.tsx +66 -0
- package/src/components/image.tsx +89 -0
- package/src/components/index.ts +33 -2
- package/src/components/list-item.tsx +29 -9
- package/src/components/popover.tsx +12 -9
- package/src/components/segmented-control.tsx +7 -1
- package/src/components/sheet.tsx +276 -133
- package/src/components/skeleton.tsx +75 -53
- package/src/components/textarea.tsx +1 -0
- package/src/components/toast.tsx +185 -87
- package/src/data/NativeResourcePage.tsx +48 -3
- package/src/data/__tests__/resource-page-offline.test.tsx +47 -0
- package/src/hooks/use-reduced-motion.ts +24 -10
- package/src/icon-names.ts +49 -0
- package/src/icons/lucide.ts +88 -0
- package/src/layouts/__tests__/apple-sign-in.test.tsx +97 -0
- package/src/layouts/__tests__/google-sign-in.test.tsx +26 -0
- package/src/layouts/__tests__/inbox-page.test.tsx +155 -0
- package/src/layouts/__tests__/keyboard-scroll.test.tsx +42 -1
- package/src/layouts/__tests__/settings-page-native-look.test.tsx +142 -0
- package/src/layouts/__tests__/thread-page.test.tsx +128 -0
- package/src/layouts/apple-sign-in.tsx +136 -0
- package/src/layouts/auth-screen.tsx +17 -8
- package/src/layouts/auth.tsx +29 -19
- package/src/layouts/google-sign-in.tsx +42 -0
- package/src/layouts/inbox-page.tsx +408 -0
- package/src/layouts/index.ts +45 -2
- package/src/layouts/keyboard.tsx +61 -9
- package/src/layouts/notifications-page.tsx +133 -16
- package/src/layouts/screen-container.tsx +6 -2
- package/src/layouts/settings-page.tsx +117 -14
- package/src/layouts/settings-sub-page.tsx +9 -3
- package/src/layouts/thread-page.tsx +444 -0
- package/src/native-modules.tsx +186 -0
- package/dist/chunk-3LK5ZJ4M.js.map +0 -1
- package/dist/chunk-5HRGIA6F.js.map +0 -1
- package/dist/chunk-F2TGDKOO.js +0 -43
- package/dist/chunk-F2TGDKOO.js.map +0 -1
- package/dist/chunk-TXJT55JC.js.map +0 -1
- package/dist/chunk-U2SPACTV.js +0 -876
- package/dist/chunk-U2SPACTV.js.map +0 -1
- package/dist/chunk-ULS7I6ZS.js.map +0 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { useReducedMotion } from './chunk-7PCWEY6R.js';
|
|
2
|
+
import { useGenesisModules } from './chunk-EFXCJ5AN.js';
|
|
3
|
+
import { useThemeMode, useThemeRoles } from './chunk-Z3AQYVUA.js';
|
|
1
4
|
import { cn } from './chunk-OHZD7KRO.js';
|
|
2
5
|
import { __require } from './chunk-DGUM43GV.js';
|
|
3
|
-
import { View, Text, AccessibilityInfo, Animated, Pressable, Modal, Dimensions,
|
|
6
|
+
import { View, Text, Platform, AccessibilityInfo, Animated, Pressable, ScrollView, Modal, Dimensions, TextInput, PanResponder, Image } from 'react-native';
|
|
4
7
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
8
|
import { createContext, useState, useEffect, useCallback, useMemo, useRef, useContext, Children, cloneElement, isValidElement } from 'react';
|
|
9
|
+
import { SafeAreaProvider, useSafeAreaInsets, SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
|
6
10
|
import { cva } from 'class-variance-authority';
|
|
7
11
|
|
|
8
12
|
function NativeHeaderCard({
|
|
@@ -74,6 +78,82 @@ function NativeHeaderCard({
|
|
|
74
78
|
}
|
|
75
79
|
);
|
|
76
80
|
}
|
|
81
|
+
var availability = /* @__PURE__ */ new WeakMap();
|
|
82
|
+
function glassAvailable(glass) {
|
|
83
|
+
const known = availability.get(glass);
|
|
84
|
+
if (known !== void 0) return known;
|
|
85
|
+
let ok = false;
|
|
86
|
+
if (typeof glass.isLiquidGlassAvailable !== "function" || typeof glass.isGlassEffectAPIAvailable !== "function" || !glass.GlassView) {
|
|
87
|
+
warnDev(
|
|
88
|
+
'[genesis] modules.glass needs expo-glass-effect\'s GlassView, isLiquidGlassAvailable and isGlassEffectAPIAvailable (pass `import * as GlassEffect from "expo-glass-effect"`, SDK 54 or later). Surfaces stay solid.'
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
try {
|
|
92
|
+
ok = Boolean(glass.isLiquidGlassAvailable()) && Boolean(glass.isGlassEffectAPIAvailable());
|
|
93
|
+
} catch {
|
|
94
|
+
ok = false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
availability.set(glass, ok);
|
|
98
|
+
return ok;
|
|
99
|
+
}
|
|
100
|
+
function warnDev(message) {
|
|
101
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) console.warn(message);
|
|
102
|
+
}
|
|
103
|
+
var lastKnownReduceTransparency = null;
|
|
104
|
+
function useReduceTransparency() {
|
|
105
|
+
const canAsk = Platform.OS === "ios" && typeof AccessibilityInfo.isReduceTransparencyEnabled === "function";
|
|
106
|
+
const [reduced, setReduced] = useState(canAsk ? lastKnownReduceTransparency : false);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (!canAsk || typeof AccessibilityInfo.isReduceTransparencyEnabled !== "function") return void 0;
|
|
109
|
+
let mounted = true;
|
|
110
|
+
const set = (v) => {
|
|
111
|
+
lastKnownReduceTransparency = v;
|
|
112
|
+
if (mounted) setReduced(v);
|
|
113
|
+
};
|
|
114
|
+
AccessibilityInfo.isReduceTransparencyEnabled().then(set).catch(() => set(false));
|
|
115
|
+
const sub = AccessibilityInfo.addEventListener?.("reduceTransparencyChanged", set);
|
|
116
|
+
return () => {
|
|
117
|
+
mounted = false;
|
|
118
|
+
sub?.remove?.();
|
|
119
|
+
};
|
|
120
|
+
}, []);
|
|
121
|
+
return reduced;
|
|
122
|
+
}
|
|
123
|
+
function useLiquidGlass() {
|
|
124
|
+
const { glass } = useGenesisModules();
|
|
125
|
+
const reduceTransparency = useReduceTransparency();
|
|
126
|
+
if (Platform.OS !== "ios" || !glass || reduceTransparency !== false) return null;
|
|
127
|
+
return glassAvailable(glass) ? glass.GlassView : null;
|
|
128
|
+
}
|
|
129
|
+
function NativeGlassSurface({
|
|
130
|
+
children,
|
|
131
|
+
className,
|
|
132
|
+
fallbackClassName = "rounded-xl border border-border bg-card",
|
|
133
|
+
radius = 16,
|
|
134
|
+
tintColor,
|
|
135
|
+
interactive = false,
|
|
136
|
+
glassEffectStyle = "regular",
|
|
137
|
+
testID
|
|
138
|
+
}) {
|
|
139
|
+
const GlassView = useLiquidGlass();
|
|
140
|
+
const colorScheme = useThemeMode();
|
|
141
|
+
if (GlassView) {
|
|
142
|
+
return /* @__PURE__ */ jsx(
|
|
143
|
+
GlassView,
|
|
144
|
+
{
|
|
145
|
+
testID,
|
|
146
|
+
style: { borderRadius: radius, overflow: "hidden" },
|
|
147
|
+
glassEffectStyle,
|
|
148
|
+
colorScheme,
|
|
149
|
+
tintColor,
|
|
150
|
+
isInteractive: interactive,
|
|
151
|
+
children: /* @__PURE__ */ jsx(View, { className, children })
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
return /* @__PURE__ */ jsx(View, { testID, className: cn(fallbackClassName, className), children });
|
|
156
|
+
}
|
|
77
157
|
var ToastContext = createContext(null);
|
|
78
158
|
var nextId = 1;
|
|
79
159
|
function NativeToastProvider({
|
|
@@ -82,21 +162,7 @@ function NativeToastProvider({
|
|
|
82
162
|
disableAnimation = false
|
|
83
163
|
}) {
|
|
84
164
|
const [queue, setQueue] = useState([]);
|
|
85
|
-
const
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
let mounted = true;
|
|
88
|
-
AccessibilityInfo.isReduceMotionEnabled().then((v) => {
|
|
89
|
-
if (mounted) setReducedMotion(v);
|
|
90
|
-
});
|
|
91
|
-
const sub = AccessibilityInfo.addEventListener(
|
|
92
|
-
"reduceMotionChanged",
|
|
93
|
-
(v) => mounted && setReducedMotion(v)
|
|
94
|
-
);
|
|
95
|
-
return () => {
|
|
96
|
-
mounted = false;
|
|
97
|
-
sub.remove();
|
|
98
|
-
};
|
|
99
|
-
}, []);
|
|
165
|
+
const reducedMotion = useReducedMotion();
|
|
100
166
|
const dismiss = useCallback((id) => {
|
|
101
167
|
setQueue((q) => id == null ? q.slice(1) : q.filter((t) => t.id !== id));
|
|
102
168
|
}, []);
|
|
@@ -121,77 +187,147 @@ function NativeToastProvider({
|
|
|
121
187
|
) : null
|
|
122
188
|
] });
|
|
123
189
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
190
|
+
var ENTER_MS = 180;
|
|
191
|
+
function ToastView(props) {
|
|
192
|
+
const { reanimated } = useGenesisModules();
|
|
193
|
+
const GlassView = useLiquidGlass();
|
|
194
|
+
const glass = (props.toast.variant ?? "default") === "default" ? GlassView : null;
|
|
195
|
+
return reanimated ? /* @__PURE__ */ jsx(ReanimatedToastView, { ...props, glass, reanimated }) : /* @__PURE__ */ jsx(AnimatedToastView, { ...props, glass });
|
|
196
|
+
}
|
|
197
|
+
function fades(animate, glass) {
|
|
198
|
+
return animate && !glass;
|
|
199
|
+
}
|
|
200
|
+
function useAutoDismiss(toast, onDismiss) {
|
|
127
201
|
const onDismissRef = useRef(onDismiss);
|
|
128
202
|
useEffect(() => {
|
|
129
203
|
onDismissRef.current = onDismiss;
|
|
130
204
|
}, [onDismiss]);
|
|
131
205
|
useEffect(() => {
|
|
132
|
-
if (animate) {
|
|
133
|
-
Animated.parallel([
|
|
134
|
-
Animated.timing(opacity, {
|
|
135
|
-
toValue: 1,
|
|
136
|
-
duration: 180,
|
|
137
|
-
useNativeDriver: true
|
|
138
|
-
}),
|
|
139
|
-
Animated.timing(offset, {
|
|
140
|
-
toValue: 0,
|
|
141
|
-
duration: 180,
|
|
142
|
-
useNativeDriver: true
|
|
143
|
-
})
|
|
144
|
-
]).start();
|
|
145
|
-
}
|
|
146
206
|
const duration = toast.duration ?? 3500;
|
|
147
207
|
if (duration > 0) {
|
|
148
208
|
const t = setTimeout(() => onDismissRef.current(), duration);
|
|
149
209
|
return () => clearTimeout(t);
|
|
150
210
|
}
|
|
151
211
|
return void 0;
|
|
152
|
-
}, [
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
212
|
+
}, [toast.duration]);
|
|
213
|
+
}
|
|
214
|
+
function useEdgeStyle(position) {
|
|
215
|
+
const insets = useContext(SafeAreaInsetsContext);
|
|
216
|
+
return position === "top" && insets ? { top: insets.top + 8 } : null;
|
|
217
|
+
}
|
|
218
|
+
function startOffset(position) {
|
|
219
|
+
return position === "top" ? -16 : 16;
|
|
220
|
+
}
|
|
221
|
+
function ReanimatedToastView({
|
|
222
|
+
toast,
|
|
223
|
+
position,
|
|
224
|
+
animate,
|
|
225
|
+
onDismiss,
|
|
226
|
+
glass,
|
|
227
|
+
reanimated: R
|
|
228
|
+
}) {
|
|
229
|
+
const fade = fades(animate, glass);
|
|
230
|
+
const opacity = R.useSharedValue(fade ? 0 : 1);
|
|
231
|
+
const offset = R.useSharedValue(animate ? startOffset(position) : 0);
|
|
232
|
+
useAutoDismiss(toast, onDismiss);
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
if (!animate) return;
|
|
235
|
+
const easing = R.Easing.out(R.Easing.cubic);
|
|
236
|
+
if (fade) opacity.value = R.withTiming(1, { duration: ENTER_MS, easing });
|
|
237
|
+
offset.value = R.withTiming(0, { duration: ENTER_MS, easing });
|
|
238
|
+
}, []);
|
|
239
|
+
const animatedStyle = R.useAnimatedStyle(() => {
|
|
240
|
+
"worklet";
|
|
241
|
+
return { opacity: opacity.value, transform: [{ translateY: offset.value }] };
|
|
242
|
+
});
|
|
243
|
+
const AnimatedView = R.default.View;
|
|
244
|
+
const edge = useEdgeStyle(position);
|
|
245
|
+
return /* @__PURE__ */ jsx(AnimatedView, { ...regionProps(toast), className: regionClass(position), style: edge ? [edge, animatedStyle] : animatedStyle, children: /* @__PURE__ */ jsx(ToastBody, { toast, onDismiss, glass }) });
|
|
246
|
+
}
|
|
247
|
+
function AnimatedToastView({ toast, position, animate, onDismiss, glass }) {
|
|
248
|
+
const fade = fades(animate, glass);
|
|
249
|
+
const opacity = useRef(new Animated.Value(fade ? 0 : 1)).current;
|
|
250
|
+
const offset = useRef(new Animated.Value(animate ? startOffset(position) : 0)).current;
|
|
251
|
+
useAutoDismiss(toast, onDismiss);
|
|
252
|
+
const edge = useEdgeStyle(position);
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
if (!animate) return;
|
|
255
|
+
const slide = Animated.timing(offset, {
|
|
256
|
+
toValue: 0,
|
|
257
|
+
duration: ENTER_MS,
|
|
258
|
+
useNativeDriver: true
|
|
259
|
+
});
|
|
260
|
+
const fadeIn = Animated.timing(opacity, {
|
|
261
|
+
toValue: 1,
|
|
262
|
+
duration: ENTER_MS,
|
|
263
|
+
useNativeDriver: true
|
|
264
|
+
});
|
|
265
|
+
Animated.parallel(fade ? [fadeIn, slide] : [slide]).start();
|
|
266
|
+
}, []);
|
|
165
267
|
return /* @__PURE__ */ jsx(
|
|
166
268
|
Animated.View,
|
|
167
269
|
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
270
|
+
...regionProps(toast),
|
|
271
|
+
className: regionClass(position),
|
|
272
|
+
style: [edge, { opacity, transform: [{ translateY: offset }] }],
|
|
273
|
+
children: /* @__PURE__ */ jsx(ToastBody, { toast, onDismiss, glass })
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
function regionProps(toast) {
|
|
278
|
+
return {
|
|
279
|
+
accessible: true,
|
|
280
|
+
accessibilityRole: "alert",
|
|
281
|
+
accessibilityLiveRegion: "polite",
|
|
282
|
+
accessibilityLabel: toast.description ? `${toast.title}. ${toast.description}` : toast.title
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function regionClass(position) {
|
|
286
|
+
return cn("absolute left-4 right-4 items-center", position === "top" ? "top-12 self-center" : "bottom-10 self-center");
|
|
287
|
+
}
|
|
288
|
+
var variantClasses = {
|
|
289
|
+
default: "bg-foreground",
|
|
290
|
+
success: "bg-primary",
|
|
291
|
+
destructive: "bg-destructive"
|
|
292
|
+
};
|
|
293
|
+
var textClass = {
|
|
294
|
+
default: "text-background",
|
|
295
|
+
success: "text-primary-foreground",
|
|
296
|
+
destructive: "text-destructive-foreground"
|
|
297
|
+
};
|
|
298
|
+
function ToastBody({ toast, onDismiss, glass: Glass }) {
|
|
299
|
+
const colorScheme = useThemeMode();
|
|
300
|
+
const variant = toast.variant ?? "default";
|
|
301
|
+
const text = Glass ? "text-foreground" : textClass[variant];
|
|
302
|
+
const testID = toast.testID ?? "native-toast";
|
|
303
|
+
const pressable = /* @__PURE__ */ jsxs(
|
|
304
|
+
Pressable,
|
|
305
|
+
{
|
|
306
|
+
testID,
|
|
307
|
+
accessibilityRole: "button",
|
|
308
|
+
accessibilityLabel: "Dismiss notification",
|
|
309
|
+
accessibilityHint: "Dismisses this toast",
|
|
310
|
+
onPress: onDismiss,
|
|
172
311
|
className: cn(
|
|
173
|
-
"
|
|
174
|
-
|
|
312
|
+
"min-h-[44px] min-w-[200px] px-4 py-3",
|
|
313
|
+
Glass ? void 0 : cn("rounded-lg shadow-lg", variantClasses[variant])
|
|
175
314
|
),
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
]
|
|
193
|
-
}
|
|
194
|
-
)
|
|
315
|
+
children: [
|
|
316
|
+
/* @__PURE__ */ jsx(Text, { className: cn("text-base font-semibold", text), children: toast.title }),
|
|
317
|
+
toast.description ? /* @__PURE__ */ jsx(Text, { className: cn("mt-0.5 text-sm", text, "opacity-90"), children: toast.description }) : null
|
|
318
|
+
]
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
if (!Glass) return pressable;
|
|
322
|
+
return /* @__PURE__ */ jsx(
|
|
323
|
+
Glass,
|
|
324
|
+
{
|
|
325
|
+
testID: `${testID}-glass`,
|
|
326
|
+
glassEffectStyle: "regular",
|
|
327
|
+
colorScheme,
|
|
328
|
+
isInteractive: true,
|
|
329
|
+
style: { borderRadius: 16, overflow: "hidden" },
|
|
330
|
+
children: pressable
|
|
195
331
|
}
|
|
196
332
|
);
|
|
197
333
|
}
|
|
@@ -204,136 +340,197 @@ function useToast() {
|
|
|
204
340
|
}
|
|
205
341
|
return ctx;
|
|
206
342
|
}
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
function
|
|
343
|
+
var REQUIRED_EXPORTS = ["BottomSheetModal", "BottomSheetView", "BottomSheetBackdrop", "BottomSheetModalProvider"];
|
|
344
|
+
var SheetLibraryContext = createContext(null);
|
|
345
|
+
function NativeSheetProvider({ bottomSheet, children }) {
|
|
346
|
+
const [library] = useState(() => isSheetLibrary(bottomSheet) ? bottomSheet : null);
|
|
347
|
+
const [problem] = useState(() => library ? null : invalidLibraryMessage(bottomSheet));
|
|
348
|
+
useEffect(() => {
|
|
349
|
+
if (problem) console.error(problem);
|
|
350
|
+
}, [problem]);
|
|
351
|
+
if (!library) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
352
|
+
const Provider = library.BottomSheetModalProvider;
|
|
353
|
+
return /* @__PURE__ */ jsx(SheetLibraryContext.Provider, { value: library, children: /* @__PURE__ */ jsx(Provider, { children }) });
|
|
354
|
+
}
|
|
355
|
+
function isSheetLibrary(value) {
|
|
356
|
+
if (!value || typeof value !== "object") return false;
|
|
357
|
+
const mod = value;
|
|
358
|
+
return REQUIRED_EXPORTS.every((name) => mod[name] != null);
|
|
359
|
+
}
|
|
360
|
+
function invalidLibraryMessage(value) {
|
|
361
|
+
const mod = value && typeof value === "object" ? value : {};
|
|
362
|
+
const missing = REQUIRED_EXPORTS.filter((name) => mod[name] == null);
|
|
363
|
+
return `NativeSheetProvider: \`bottomSheet\` is missing ${missing.join(", ")}, so sheets use the native modal. Pass the whole module: \`import * as BottomSheet from "@gorhom/bottom-sheet"\`.`;
|
|
364
|
+
}
|
|
365
|
+
function NativeSheet(props) {
|
|
366
|
+
const library = useContext(SheetLibraryContext);
|
|
367
|
+
if (library) return /* @__PURE__ */ jsx(LibrarySheet, { library, ...props });
|
|
368
|
+
return /* @__PURE__ */ jsx(ModalSheet, { ...props });
|
|
369
|
+
}
|
|
370
|
+
function NativeSheetScrollView({ style, ...props }) {
|
|
371
|
+
const library = useContext(SheetLibraryContext);
|
|
372
|
+
const Scroll = library?.BottomSheetScrollView ?? ScrollView;
|
|
373
|
+
const own = { flexGrow: 0 };
|
|
374
|
+
return /* @__PURE__ */ jsx(Scroll, { style: [own, ...Array.isArray(style) ? style : style ? [style] : []], ...props });
|
|
375
|
+
}
|
|
376
|
+
function LibrarySheet({
|
|
377
|
+
library,
|
|
220
378
|
open,
|
|
221
379
|
onOpenChange,
|
|
222
380
|
snapPoints = ["50%", "90%"],
|
|
223
381
|
initialSnapIndex = 0,
|
|
224
382
|
disableBackdropDismiss = false,
|
|
225
|
-
children,
|
|
226
|
-
testID
|
|
227
|
-
}) {
|
|
228
|
-
if (GORHOM) {
|
|
229
|
-
return /* @__PURE__ */ jsx(
|
|
230
|
-
GorhomSheet,
|
|
231
|
-
{
|
|
232
|
-
gorhom: GORHOM,
|
|
233
|
-
open,
|
|
234
|
-
onOpenChange,
|
|
235
|
-
snapPoints,
|
|
236
|
-
initialSnapIndex,
|
|
237
|
-
disableBackdropDismiss,
|
|
238
|
-
testID,
|
|
239
|
-
children
|
|
240
|
-
}
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
return /* @__PURE__ */ jsx(
|
|
244
|
-
FallbackSheet,
|
|
245
|
-
{
|
|
246
|
-
open,
|
|
247
|
-
onOpenChange,
|
|
248
|
-
disableBackdropDismiss,
|
|
249
|
-
testID,
|
|
250
|
-
children
|
|
251
|
-
}
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
function GorhomSheet({
|
|
255
|
-
gorhom,
|
|
256
|
-
open,
|
|
257
|
-
onOpenChange,
|
|
258
|
-
snapPoints,
|
|
259
|
-
initialSnapIndex,
|
|
260
|
-
disableBackdropDismiss,
|
|
261
383
|
testID,
|
|
262
384
|
children
|
|
263
385
|
}) {
|
|
264
|
-
const
|
|
386
|
+
const sheet = useRef(null);
|
|
387
|
+
const wanted = useRef(open);
|
|
388
|
+
const onOpenChangeRef = useRef(onOpenChange);
|
|
389
|
+
onOpenChangeRef.current = onOpenChange;
|
|
265
390
|
useEffect(() => {
|
|
266
|
-
|
|
267
|
-
|
|
391
|
+
wanted.current = open;
|
|
392
|
+
if (open) sheet.current?.present();
|
|
393
|
+
else sheet.current?.dismiss();
|
|
268
394
|
}, [open]);
|
|
269
|
-
const
|
|
395
|
+
const BottomSheetModal = library.BottomSheetModal;
|
|
396
|
+
const BottomSheetView = library.BottomSheetView;
|
|
397
|
+
const BottomSheetBackdrop = library.BottomSheetBackdrop;
|
|
398
|
+
const onDismiss = useCallback(() => {
|
|
399
|
+
if (wanted.current) {
|
|
400
|
+
wanted.current = false;
|
|
401
|
+
onOpenChangeRef.current(false);
|
|
402
|
+
}
|
|
403
|
+
}, []);
|
|
404
|
+
const backdrop = useCallback(
|
|
405
|
+
(p) => /* @__PURE__ */ jsx(
|
|
406
|
+
BottomSheetBackdrop,
|
|
407
|
+
{
|
|
408
|
+
...p,
|
|
409
|
+
appearsOnIndex: 0,
|
|
410
|
+
disappearsOnIndex: -1,
|
|
411
|
+
pressBehavior: disableBackdropDismiss ? "none" : "close"
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
[BottomSheetBackdrop, disableBackdropDismiss]
|
|
415
|
+
);
|
|
270
416
|
return /* @__PURE__ */ jsx(
|
|
271
417
|
BottomSheetModal,
|
|
272
418
|
{
|
|
273
|
-
ref,
|
|
419
|
+
ref: sheet,
|
|
274
420
|
snapPoints,
|
|
275
421
|
index: initialSnapIndex,
|
|
276
|
-
|
|
422
|
+
enableDynamicSizing: false,
|
|
423
|
+
onDismiss,
|
|
277
424
|
enablePanDownToClose: !disableBackdropDismiss,
|
|
278
|
-
backdropComponent:
|
|
279
|
-
BottomSheetBackdrop,
|
|
280
|
-
{
|
|
281
|
-
...p,
|
|
282
|
-
appearsOnIndex: 0,
|
|
283
|
-
disappearsOnIndex: -1,
|
|
284
|
-
pressBehavior: disableBackdropDismiss ? "none" : "close"
|
|
285
|
-
}
|
|
286
|
-
),
|
|
425
|
+
backdropComponent: backdrop,
|
|
287
426
|
children: /* @__PURE__ */ jsx(BottomSheetView, { testID: testID ?? "native-sheet", children })
|
|
288
427
|
}
|
|
289
428
|
);
|
|
290
429
|
}
|
|
291
|
-
function
|
|
292
|
-
|
|
293
|
-
onOpenChange,
|
|
294
|
-
disableBackdropDismiss,
|
|
295
|
-
testID,
|
|
296
|
-
children
|
|
297
|
-
}) {
|
|
298
|
-
const [reducedMotion, setReducedMotion] = useState(false);
|
|
430
|
+
function useReduceMotionAnswer() {
|
|
431
|
+
const [reduced, setReduced] = useState(null);
|
|
299
432
|
useEffect(() => {
|
|
300
|
-
|
|
433
|
+
let mounted = true;
|
|
434
|
+
AccessibilityInfo.isReduceMotionEnabled().then(
|
|
435
|
+
(value) => mounted && setReduced(value),
|
|
436
|
+
() => mounted && setReduced(false)
|
|
437
|
+
);
|
|
438
|
+
const sub = AccessibilityInfo.addEventListener("reduceMotionChanged", (value) => setReduced(value));
|
|
439
|
+
return () => {
|
|
440
|
+
mounted = false;
|
|
441
|
+
sub?.remove?.();
|
|
442
|
+
};
|
|
301
443
|
}, []);
|
|
444
|
+
return reduced;
|
|
445
|
+
}
|
|
446
|
+
function ModalSheet({ open, onOpenChange, disableBackdropDismiss = false, testID, children }) {
|
|
447
|
+
const reducedMotion = useReduceMotionAnswer();
|
|
448
|
+
const roles = useThemeRoles();
|
|
449
|
+
const requestClose = () => {
|
|
450
|
+
if (!disableBackdropDismiss) onOpenChange(false);
|
|
451
|
+
};
|
|
452
|
+
const visible = open && reducedMotion !== null;
|
|
453
|
+
const animationType = reducedMotion ? "none" : "slide";
|
|
454
|
+
const id = testID ?? "native-sheet";
|
|
455
|
+
if (Platform.OS === "ios") {
|
|
456
|
+
return /* @__PURE__ */ jsx(
|
|
457
|
+
Modal,
|
|
458
|
+
{
|
|
459
|
+
visible,
|
|
460
|
+
animationType,
|
|
461
|
+
presentationStyle: "pageSheet",
|
|
462
|
+
allowSwipeDismissal: !disableBackdropDismiss,
|
|
463
|
+
backdropColor: roles.background,
|
|
464
|
+
onRequestClose: requestClose,
|
|
465
|
+
children: /* @__PURE__ */ jsx(SafeAreaProvider, { children: /* @__PURE__ */ jsx(
|
|
466
|
+
SheetBody,
|
|
467
|
+
{
|
|
468
|
+
testID: id,
|
|
469
|
+
onAccessibilityEscape: disableBackdropDismiss ? void 0 : requestClose,
|
|
470
|
+
style: { flex: 1, backgroundColor: roles.background },
|
|
471
|
+
children
|
|
472
|
+
}
|
|
473
|
+
) })
|
|
474
|
+
}
|
|
475
|
+
);
|
|
476
|
+
}
|
|
302
477
|
return /* @__PURE__ */ jsx(
|
|
303
478
|
Modal,
|
|
304
479
|
{
|
|
305
|
-
visible
|
|
480
|
+
visible,
|
|
306
481
|
transparent: true,
|
|
307
|
-
animationType
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
482
|
+
animationType,
|
|
483
|
+
statusBarTranslucent: true,
|
|
484
|
+
navigationBarTranslucent: true,
|
|
485
|
+
onRequestClose: requestClose,
|
|
486
|
+
children: /* @__PURE__ */ jsx(SafeAreaProvider, { children: /* @__PURE__ */ jsxs(View, { style: { flex: 1, justifyContent: "flex-end" }, children: [
|
|
487
|
+
/* @__PURE__ */ jsx(
|
|
488
|
+
Pressable,
|
|
489
|
+
{
|
|
490
|
+
testID: `${id}-backdrop`,
|
|
491
|
+
accessibilityRole: "button",
|
|
492
|
+
accessibilityLabel: "Close",
|
|
493
|
+
disabled: disableBackdropDismiss,
|
|
494
|
+
importantForAccessibility: disableBackdropDismiss ? "no-hide-descendants" : "auto",
|
|
495
|
+
onPress: requestClose,
|
|
496
|
+
style: { position: "absolute", top: 0, right: 0, bottom: 0, left: 0, backgroundColor: "rgba(0,0,0,0.4)" }
|
|
497
|
+
}
|
|
498
|
+
),
|
|
499
|
+
/* @__PURE__ */ jsxs(
|
|
500
|
+
SheetBody,
|
|
501
|
+
{
|
|
502
|
+
testID: id,
|
|
503
|
+
style: {
|
|
504
|
+
maxHeight: "90%",
|
|
505
|
+
borderTopLeftRadius: 28,
|
|
506
|
+
borderTopRightRadius: 28,
|
|
507
|
+
backgroundColor: roles.surface,
|
|
508
|
+
paddingTop: 12
|
|
509
|
+
},
|
|
510
|
+
children: [
|
|
511
|
+
/* @__PURE__ */ jsx(
|
|
512
|
+
View,
|
|
513
|
+
{
|
|
514
|
+
style: { alignSelf: "center", width: 32, height: 4, borderRadius: 2, marginBottom: 8, backgroundColor: roles.tertiaryLabel }
|
|
515
|
+
}
|
|
325
516
|
),
|
|
326
|
-
children
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
) })
|
|
332
|
-
}
|
|
333
|
-
)
|
|
517
|
+
children
|
|
518
|
+
]
|
|
519
|
+
}
|
|
520
|
+
)
|
|
521
|
+
] }) })
|
|
334
522
|
}
|
|
335
523
|
);
|
|
336
524
|
}
|
|
525
|
+
function SheetBody({
|
|
526
|
+
testID,
|
|
527
|
+
style,
|
|
528
|
+
onAccessibilityEscape,
|
|
529
|
+
children
|
|
530
|
+
}) {
|
|
531
|
+
const insets = useSafeAreaInsets();
|
|
532
|
+
return /* @__PURE__ */ jsx(View, { testID, accessibilityViewIsModal: true, onAccessibilityEscape, style: { ...style, paddingBottom: insets.bottom }, children });
|
|
533
|
+
}
|
|
337
534
|
var PopoverContext = createContext(null);
|
|
338
535
|
function NativePopover({
|
|
339
536
|
open: controlled,
|
|
@@ -432,18 +629,15 @@ function NativePopoverContent({
|
|
|
432
629
|
minWidth: width
|
|
433
630
|
},
|
|
434
631
|
children: /* @__PURE__ */ jsx(Pressable, { onPress: () => {
|
|
435
|
-
}, children: /* @__PURE__ */ jsx(
|
|
436
|
-
|
|
632
|
+
}, children: /* @__PURE__ */ jsx(View, { testID: testID ?? "native-popover-content", accessibilityViewIsModal: true, children: /* @__PURE__ */ jsx(
|
|
633
|
+
NativeGlassSurface,
|
|
437
634
|
{
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
className: cn(
|
|
441
|
-
"max-w-[280px] rounded-md border border-border bg-popover p-3 shadow-md",
|
|
442
|
-
className
|
|
443
|
-
),
|
|
635
|
+
radius: 14,
|
|
636
|
+
fallbackClassName: "rounded-md border border-border bg-popover shadow-md",
|
|
637
|
+
className: cn("max-w-[280px] p-3", className),
|
|
444
638
|
children
|
|
445
639
|
}
|
|
446
|
-
) })
|
|
640
|
+
) }) })
|
|
447
641
|
}
|
|
448
642
|
)
|
|
449
643
|
}
|
|
@@ -451,54 +645,101 @@ function NativePopoverContent({
|
|
|
451
645
|
}
|
|
452
646
|
);
|
|
453
647
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
648
|
+
var OPEN_MS = 220;
|
|
649
|
+
var SETTLE_MS = 180;
|
|
650
|
+
function NativeDrawer(props) {
|
|
651
|
+
const { reanimated } = useGenesisModules();
|
|
652
|
+
return reanimated ? /* @__PURE__ */ jsx(ReanimatedDrawer, { ...props, reanimated }) : /* @__PURE__ */ jsx(AnimatedDrawer, { ...props });
|
|
653
|
+
}
|
|
654
|
+
function closedOffset(side, width) {
|
|
655
|
+
return side === "left" ? -width : width;
|
|
656
|
+
}
|
|
657
|
+
function useSwipe(side, drawerWidth, onOpenChange, follow, settle) {
|
|
658
|
+
return useMemo(
|
|
659
|
+
() => PanResponder.create({
|
|
660
|
+
onMoveShouldSetPanResponder: (_, g) => Math.abs(g.dx) > 8,
|
|
661
|
+
onPanResponderMove: (_, g) => follow(side === "left" ? Math.min(0, g.dx) : Math.max(0, g.dx)),
|
|
662
|
+
onPanResponderRelease: (_, g) => {
|
|
663
|
+
const dismiss = side === "left" ? g.dx < -drawerWidth / 3 : g.dx > drawerWidth / 3;
|
|
664
|
+
if (dismiss) onOpenChange(false);
|
|
665
|
+
else settle();
|
|
666
|
+
},
|
|
667
|
+
// Another responder (a horizontal scroll inside, a system gesture)
|
|
668
|
+
// took the drag: put the panel back rather than leave it half open.
|
|
669
|
+
onPanResponderTerminate: () => settle()
|
|
670
|
+
}),
|
|
671
|
+
[drawerWidth, follow, onOpenChange, settle, side]
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
function ReanimatedDrawer({ reanimated: R, ...props }) {
|
|
675
|
+
const { open, side = "left", width } = props;
|
|
676
|
+
const drawerWidth = width ?? Math.min(Dimensions.get("window").width * 0.8, 360);
|
|
677
|
+
const reducedMotion = useReducedMotion();
|
|
678
|
+
const translate = R.useSharedValue(closedOffset(side, drawerWidth));
|
|
467
679
|
useEffect(() => {
|
|
468
|
-
|
|
680
|
+
const to = open ? 0 : closedOffset(side, drawerWidth);
|
|
681
|
+
translate.value = reducedMotion ? to : R.withTiming(to, { duration: OPEN_MS });
|
|
682
|
+
}, [drawerWidth, open, reducedMotion, side]);
|
|
683
|
+
const follow = useCallback((dx) => {
|
|
684
|
+
translate.value = dx;
|
|
469
685
|
}, []);
|
|
686
|
+
const settle = useCallback(() => {
|
|
687
|
+
translate.value = reducedMotion ? 0 : R.withTiming(0, { duration: SETTLE_MS });
|
|
688
|
+
}, [reducedMotion]);
|
|
689
|
+
const panResponder = useSwipe(side, drawerWidth, props.onOpenChange, follow, settle);
|
|
690
|
+
const animatedStyle = R.useAnimatedStyle(() => {
|
|
691
|
+
"worklet";
|
|
692
|
+
return { transform: [{ translateX: translate.value }] };
|
|
693
|
+
});
|
|
694
|
+
return /* @__PURE__ */ jsx(DrawerFrame, { ...props, side, drawerWidth, Panel: R.default.View, panelStyle: animatedStyle, panHandlers: panResponder.panHandlers });
|
|
695
|
+
}
|
|
696
|
+
function AnimatedDrawer(props) {
|
|
697
|
+
const { open, side = "left", width } = props;
|
|
698
|
+
const drawerWidth = width ?? Math.min(Dimensions.get("window").width * 0.8, 360);
|
|
699
|
+
const reducedMotion = useReducedMotion();
|
|
700
|
+
const translate = useRef(new Animated.Value(closedOffset(side, drawerWidth))).current;
|
|
470
701
|
useEffect(() => {
|
|
471
702
|
Animated.timing(translate, {
|
|
472
|
-
toValue: open ? 0 : side
|
|
473
|
-
duration: reducedMotion ? 0 :
|
|
703
|
+
toValue: open ? 0 : closedOffset(side, drawerWidth),
|
|
704
|
+
duration: reducedMotion ? 0 : OPEN_MS,
|
|
474
705
|
useNativeDriver: true
|
|
475
706
|
}).start();
|
|
476
707
|
}, [drawerWidth, open, reducedMotion, side, translate]);
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
},
|
|
487
|
-
onPanResponderRelease: (_, g) => {
|
|
488
|
-
const dismiss = side === "left" ? g.dx < -drawerWidth / 3 : g.dx > drawerWidth / 3;
|
|
489
|
-
if (dismiss) {
|
|
490
|
-
onOpenChange(false);
|
|
491
|
-
} else {
|
|
492
|
-
Animated.timing(translate, {
|
|
493
|
-
toValue: 0,
|
|
494
|
-
duration: 180,
|
|
495
|
-
useNativeDriver: true
|
|
496
|
-
}).start();
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}),
|
|
500
|
-
[drawerWidth, onOpenChange, side, translate]
|
|
708
|
+
const follow = useCallback((dx) => translate.setValue(dx), [translate]);
|
|
709
|
+
const settle = useCallback(
|
|
710
|
+
() => Animated.timing(translate, {
|
|
711
|
+
toValue: 0,
|
|
712
|
+
duration: reducedMotion ? 0 : SETTLE_MS,
|
|
713
|
+
useNativeDriver: true
|
|
714
|
+
}).start(),
|
|
715
|
+
[reducedMotion, translate]
|
|
501
716
|
);
|
|
717
|
+
const panResponder = useSwipe(side, drawerWidth, props.onOpenChange, follow, settle);
|
|
718
|
+
return /* @__PURE__ */ jsx(
|
|
719
|
+
DrawerFrame,
|
|
720
|
+
{
|
|
721
|
+
...props,
|
|
722
|
+
side,
|
|
723
|
+
drawerWidth,
|
|
724
|
+
Panel: Animated.View,
|
|
725
|
+
panelStyle: { transform: [{ translateX: translate }] },
|
|
726
|
+
panHandlers: panResponder.panHandlers
|
|
727
|
+
}
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
function DrawerFrame({
|
|
731
|
+
open,
|
|
732
|
+
onOpenChange,
|
|
733
|
+
side,
|
|
734
|
+
drawerWidth,
|
|
735
|
+
children,
|
|
736
|
+
className,
|
|
737
|
+
testID,
|
|
738
|
+
Panel,
|
|
739
|
+
panelStyle,
|
|
740
|
+
panHandlers
|
|
741
|
+
}) {
|
|
742
|
+
const insets = useContext(SafeAreaInsetsContext);
|
|
502
743
|
return /* @__PURE__ */ jsx(
|
|
503
744
|
Modal,
|
|
504
745
|
{
|
|
@@ -506,37 +747,43 @@ function NativeDrawer({
|
|
|
506
747
|
transparent: true,
|
|
507
748
|
animationType: "none",
|
|
508
749
|
onRequestClose: () => onOpenChange(false),
|
|
509
|
-
children: /* @__PURE__ */
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
750
|
+
children: /* @__PURE__ */ jsxs(View, { style: { flex: 1 }, children: [
|
|
751
|
+
/* @__PURE__ */ jsx(
|
|
752
|
+
Pressable,
|
|
753
|
+
{
|
|
754
|
+
testID: `${testID ?? "native-drawer"}-backdrop`,
|
|
755
|
+
accessibilityRole: "button",
|
|
756
|
+
accessibilityLabel: "Close drawer",
|
|
757
|
+
className: "bg-black/40",
|
|
758
|
+
style: { position: "absolute", top: 0, right: 0, bottom: 0, left: 0 },
|
|
759
|
+
onPress: () => onOpenChange(false)
|
|
760
|
+
}
|
|
761
|
+
),
|
|
762
|
+
/* @__PURE__ */ jsx(
|
|
763
|
+
Panel,
|
|
764
|
+
{
|
|
765
|
+
testID: testID ?? "native-drawer",
|
|
766
|
+
accessibilityViewIsModal: true,
|
|
767
|
+
...panHandlers,
|
|
768
|
+
style: [
|
|
769
|
+
{
|
|
523
770
|
position: "absolute",
|
|
524
771
|
top: 0,
|
|
525
772
|
bottom: 0,
|
|
526
773
|
[side]: 0,
|
|
527
|
-
width: drawerWidth
|
|
528
|
-
transform: [{ translateX: translate }]
|
|
774
|
+
width: drawerWidth
|
|
529
775
|
},
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
776
|
+
panelStyle
|
|
777
|
+
],
|
|
778
|
+
className: cn(
|
|
779
|
+
"border-border bg-background p-4 shadow-lg",
|
|
780
|
+
side === "left" ? "border-r" : "border-l",
|
|
781
|
+
className
|
|
782
|
+
),
|
|
783
|
+
children: /* @__PURE__ */ jsx(View, { className: "flex-1", style: { paddingTop: insets?.top ?? 0, paddingBottom: insets?.bottom ?? 0 }, children })
|
|
784
|
+
}
|
|
785
|
+
)
|
|
786
|
+
] })
|
|
540
787
|
}
|
|
541
788
|
);
|
|
542
789
|
}
|
|
@@ -746,7 +993,8 @@ function PickerButton({
|
|
|
746
993
|
className,
|
|
747
994
|
testID
|
|
748
995
|
}) {
|
|
749
|
-
const
|
|
996
|
+
const { datePicker: ExpoUiPicker } = useGenesisModules();
|
|
997
|
+
const Picker = ExpoUiPicker ? null : resolveDateTimePicker();
|
|
750
998
|
const [showAndroid, setShowAndroid] = useState(false);
|
|
751
999
|
const isIOS = Platform.OS === "ios";
|
|
752
1000
|
const label = useMemo(() => {
|
|
@@ -754,6 +1002,21 @@ function PickerButton({
|
|
|
754
1002
|
if (mode === "date") return value.toDateString();
|
|
755
1003
|
return value.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
756
1004
|
}, [formatLabel, mode, value]);
|
|
1005
|
+
if (ExpoUiPicker) {
|
|
1006
|
+
return /* @__PURE__ */ jsx(
|
|
1007
|
+
ExpoUiPickerButton,
|
|
1008
|
+
{
|
|
1009
|
+
Picker: ExpoUiPicker,
|
|
1010
|
+
value,
|
|
1011
|
+
onChange,
|
|
1012
|
+
mode,
|
|
1013
|
+
label,
|
|
1014
|
+
disabled,
|
|
1015
|
+
className,
|
|
1016
|
+
testID
|
|
1017
|
+
}
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
757
1020
|
if (!Picker) {
|
|
758
1021
|
return /* @__PURE__ */ jsxs(
|
|
759
1022
|
Text,
|
|
@@ -770,6 +1033,22 @@ function PickerButton({
|
|
|
770
1033
|
}
|
|
771
1034
|
);
|
|
772
1035
|
}
|
|
1036
|
+
if (isIOS) {
|
|
1037
|
+
return /* @__PURE__ */ jsx(
|
|
1038
|
+
Picker,
|
|
1039
|
+
{
|
|
1040
|
+
testID: testID ?? `native-${mode}-picker`,
|
|
1041
|
+
value,
|
|
1042
|
+
mode,
|
|
1043
|
+
display: "compact",
|
|
1044
|
+
disabled,
|
|
1045
|
+
style: disabled ? { opacity: 0.5 } : void 0,
|
|
1046
|
+
onChange: (_e, d) => {
|
|
1047
|
+
if (d && !disabled) onChange(d);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
773
1052
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
774
1053
|
/* @__PURE__ */ jsx(
|
|
775
1054
|
Pressable,
|
|
@@ -780,9 +1059,7 @@ function PickerButton({
|
|
|
780
1059
|
accessibilityValue: { text: label },
|
|
781
1060
|
accessibilityState: { disabled },
|
|
782
1061
|
disabled,
|
|
783
|
-
onPress: () =>
|
|
784
|
-
if (!isIOS) setShowAndroid(true);
|
|
785
|
-
},
|
|
1062
|
+
onPress: () => setShowAndroid(true),
|
|
786
1063
|
className: cn(
|
|
787
1064
|
"min-h-[44px] flex-row items-center rounded-md border border-input bg-background px-3",
|
|
788
1065
|
disabled && "opacity-50",
|
|
@@ -791,21 +1068,83 @@ function PickerButton({
|
|
|
791
1068
|
children: /* @__PURE__ */ jsx(Text, { className: "flex-1 text-base text-foreground", children: label })
|
|
792
1069
|
}
|
|
793
1070
|
),
|
|
794
|
-
|
|
1071
|
+
showAndroid ? /* @__PURE__ */ jsx(
|
|
795
1072
|
Picker,
|
|
796
1073
|
{
|
|
797
1074
|
testID: testID ? `${testID}-picker` : void 0,
|
|
798
1075
|
value,
|
|
799
1076
|
mode,
|
|
800
|
-
display:
|
|
1077
|
+
display: "default",
|
|
801
1078
|
onChange: (_e, d) => {
|
|
802
|
-
|
|
1079
|
+
setShowAndroid(false);
|
|
803
1080
|
if (d) onChange(d);
|
|
804
1081
|
}
|
|
805
1082
|
}
|
|
806
1083
|
) : null
|
|
807
1084
|
] });
|
|
808
1085
|
}
|
|
1086
|
+
function ExpoUiPickerButton({
|
|
1087
|
+
Picker,
|
|
1088
|
+
value,
|
|
1089
|
+
onChange,
|
|
1090
|
+
mode,
|
|
1091
|
+
label,
|
|
1092
|
+
disabled,
|
|
1093
|
+
className,
|
|
1094
|
+
testID
|
|
1095
|
+
}) {
|
|
1096
|
+
const [showAndroid, setShowAndroid] = useState(false);
|
|
1097
|
+
if (Platform.OS === "ios") {
|
|
1098
|
+
return /* @__PURE__ */ jsx(
|
|
1099
|
+
Picker,
|
|
1100
|
+
{
|
|
1101
|
+
testID: testID ?? `native-${mode}-picker`,
|
|
1102
|
+
value,
|
|
1103
|
+
mode,
|
|
1104
|
+
display: "compact",
|
|
1105
|
+
disabled,
|
|
1106
|
+
style: disabled ? { opacity: 0.5 } : void 0,
|
|
1107
|
+
onValueChange: (_e, d) => {
|
|
1108
|
+
if (d && !disabled) onChange(d);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1114
|
+
/* @__PURE__ */ jsx(
|
|
1115
|
+
Pressable,
|
|
1116
|
+
{
|
|
1117
|
+
testID: testID ?? `native-${mode}-picker`,
|
|
1118
|
+
accessibilityRole: "button",
|
|
1119
|
+
accessibilityLabel: `Pick a ${mode}`,
|
|
1120
|
+
accessibilityValue: { text: label },
|
|
1121
|
+
accessibilityState: { disabled },
|
|
1122
|
+
disabled,
|
|
1123
|
+
onPress: () => setShowAndroid(true),
|
|
1124
|
+
className: cn(
|
|
1125
|
+
"min-h-[44px] flex-row items-center rounded-md border border-input bg-background px-3",
|
|
1126
|
+
disabled && "opacity-50",
|
|
1127
|
+
className
|
|
1128
|
+
),
|
|
1129
|
+
children: /* @__PURE__ */ jsx(Text, { className: "flex-1 text-base text-foreground", children: label })
|
|
1130
|
+
}
|
|
1131
|
+
),
|
|
1132
|
+
showAndroid ? /* @__PURE__ */ jsx(
|
|
1133
|
+
Picker,
|
|
1134
|
+
{
|
|
1135
|
+
testID: testID ? `${testID}-picker` : void 0,
|
|
1136
|
+
value,
|
|
1137
|
+
mode,
|
|
1138
|
+
presentation: "dialog",
|
|
1139
|
+
onValueChange: (_e, d) => {
|
|
1140
|
+
setShowAndroid(false);
|
|
1141
|
+
if (d) onChange(d);
|
|
1142
|
+
},
|
|
1143
|
+
onDismiss: () => setShowAndroid(false)
|
|
1144
|
+
}
|
|
1145
|
+
) : null
|
|
1146
|
+
] });
|
|
1147
|
+
}
|
|
809
1148
|
function NativeDatePicker(props) {
|
|
810
1149
|
return /* @__PURE__ */ jsx(PickerButton, { ...props, mode: "date" });
|
|
811
1150
|
}
|
|
@@ -1156,6 +1495,8 @@ function NativeRangeSlider({
|
|
|
1156
1495
|
}
|
|
1157
1496
|
);
|
|
1158
1497
|
}
|
|
1498
|
+
var SELECTED_LIFT = { shadowColor: "black", shadowOpacity: 0.08, shadowRadius: 2, shadowOffset: { width: 0, height: 1 }, elevation: 1 };
|
|
1499
|
+
var UNSELECTED_LIFT = { shadowColor: "black", shadowOpacity: 0, shadowRadius: 0, shadowOffset: { width: 0, height: 0 }, elevation: 0 };
|
|
1159
1500
|
function NativeSegmentedControl({
|
|
1160
1501
|
options,
|
|
1161
1502
|
value,
|
|
@@ -1186,8 +1527,9 @@ function NativeSegmentedControl({
|
|
|
1186
1527
|
onPress: () => onChange(opt.value),
|
|
1187
1528
|
className: cn(
|
|
1188
1529
|
"min-h-[36px] flex-1 items-center justify-center rounded px-3 py-1",
|
|
1189
|
-
selected && "bg-background
|
|
1530
|
+
selected && "bg-background"
|
|
1190
1531
|
),
|
|
1532
|
+
style: selected ? SELECTED_LIFT : UNSELECTED_LIFT,
|
|
1191
1533
|
children: /* @__PURE__ */ jsx(
|
|
1192
1534
|
Text,
|
|
1193
1535
|
{
|
|
@@ -1377,7 +1719,7 @@ function Ellipsis() {
|
|
|
1377
1719
|
}
|
|
1378
1720
|
);
|
|
1379
1721
|
}
|
|
1380
|
-
var
|
|
1722
|
+
var variantClasses2 = {
|
|
1381
1723
|
info: "bg-secondary border-border",
|
|
1382
1724
|
success: "bg-primary/10 border-primary/30",
|
|
1383
1725
|
warning: "bg-warning/10 border-warning/30",
|
|
@@ -1405,7 +1747,7 @@ function NativeInlineAlert({
|
|
|
1405
1747
|
accessibilityRole: "alert",
|
|
1406
1748
|
className: cn(
|
|
1407
1749
|
"flex-row gap-3 rounded-md border p-3",
|
|
1408
|
-
|
|
1750
|
+
variantClasses2[variant],
|
|
1409
1751
|
className
|
|
1410
1752
|
),
|
|
1411
1753
|
children: [
|
|
@@ -1447,7 +1789,7 @@ function NativeBanner({
|
|
|
1447
1789
|
accessibilityLiveRegion: "polite",
|
|
1448
1790
|
className: cn(
|
|
1449
1791
|
"flex-row items-start gap-3 border-b px-4 py-3",
|
|
1450
|
-
|
|
1792
|
+
variantClasses2[variant],
|
|
1451
1793
|
className
|
|
1452
1794
|
),
|
|
1453
1795
|
children: [
|
|
@@ -1589,20 +1931,29 @@ function NativeRefreshControl(props) {
|
|
|
1589
1931
|
}
|
|
1590
1932
|
);
|
|
1591
1933
|
}
|
|
1934
|
+
var FILL = { position: "absolute", top: 0, right: 0, bottom: 0, left: 0 };
|
|
1592
1935
|
function NativeAvatar({
|
|
1593
1936
|
className,
|
|
1594
1937
|
src,
|
|
1595
1938
|
alt,
|
|
1596
1939
|
fallback,
|
|
1597
1940
|
size = 40,
|
|
1598
|
-
|
|
1941
|
+
placeholder,
|
|
1942
|
+
recyclingKey,
|
|
1943
|
+
testID
|
|
1599
1944
|
}) {
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
const showImage = src &&
|
|
1605
|
-
|
|
1945
|
+
const { image: ExpoImage } = useGenesisModules();
|
|
1946
|
+
const reducedMotion = useReducedMotion();
|
|
1947
|
+
const [failedSrc, setFailedSrc] = useState(null);
|
|
1948
|
+
const [loadedSrc, setLoadedSrc] = useState(null);
|
|
1949
|
+
const showImage = !!src && failedSrc !== src;
|
|
1950
|
+
const loaded = !!src && loadedSrc === src;
|
|
1951
|
+
const imageProps = {
|
|
1952
|
+
accessible: false,
|
|
1953
|
+
onError: () => setFailedSrc(src ?? null),
|
|
1954
|
+
onLoad: () => setLoadedSrc(src ?? null)
|
|
1955
|
+
};
|
|
1956
|
+
return /* @__PURE__ */ jsxs(
|
|
1606
1957
|
View,
|
|
1607
1958
|
{
|
|
1608
1959
|
className: cn(
|
|
@@ -1610,28 +1961,49 @@ function NativeAvatar({
|
|
|
1610
1961
|
className
|
|
1611
1962
|
),
|
|
1612
1963
|
style: [{ width: size, height: size }],
|
|
1964
|
+
accessible: true,
|
|
1965
|
+
accessibilityRole: "image",
|
|
1613
1966
|
accessibilityLabel: alt || fallback || "Avatar",
|
|
1614
|
-
|
|
1615
|
-
children:
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1967
|
+
testID,
|
|
1968
|
+
children: [
|
|
1969
|
+
!showImage || !loaded ? /* @__PURE__ */ jsx(
|
|
1970
|
+
Text,
|
|
1971
|
+
{
|
|
1972
|
+
className: "text-sm font-medium text-muted-foreground",
|
|
1973
|
+
accessibilityElementsHidden: true,
|
|
1974
|
+
importantForAccessibility: "no",
|
|
1975
|
+
style: {
|
|
1976
|
+
fontSize: Math.round(size * 0.4),
|
|
1977
|
+
lineHeight: Math.round(size * 0.5)
|
|
1978
|
+
},
|
|
1979
|
+
children: fallback || "?"
|
|
1980
|
+
}
|
|
1981
|
+
) : null,
|
|
1982
|
+
showImage ? ExpoImage ? /* @__PURE__ */ jsx(
|
|
1983
|
+
ExpoImage,
|
|
1984
|
+
{
|
|
1985
|
+
...imageProps,
|
|
1986
|
+
testID: testID ? `${testID}-image` : void 0,
|
|
1987
|
+
source: { uri: src },
|
|
1988
|
+
style: FILL,
|
|
1989
|
+
contentFit: "cover",
|
|
1990
|
+
cachePolicy: "memory-disk",
|
|
1991
|
+
placeholder,
|
|
1992
|
+
placeholderContentFit: "cover",
|
|
1993
|
+
transition: reducedMotion ? null : 150,
|
|
1994
|
+
recyclingKey: recyclingKey ?? src
|
|
1995
|
+
}
|
|
1996
|
+
) : /* @__PURE__ */ jsx(
|
|
1997
|
+
Image,
|
|
1998
|
+
{
|
|
1999
|
+
...imageProps,
|
|
2000
|
+
testID: testID ? `${testID}-image` : void 0,
|
|
2001
|
+
source: { uri: src },
|
|
2002
|
+
style: FILL,
|
|
2003
|
+
resizeMode: "cover"
|
|
2004
|
+
}
|
|
2005
|
+
) : null
|
|
2006
|
+
]
|
|
1635
2007
|
}
|
|
1636
2008
|
);
|
|
1637
2009
|
}
|
|
@@ -1753,12 +2125,11 @@ function NativeDropdownMenuContent({
|
|
|
1753
2125
|
if (!open) return null;
|
|
1754
2126
|
return /* @__PURE__ */ jsx(Modal, { transparent: true, animationType: "fade", onRequestClose: () => setOpen(false), children: /* @__PURE__ */ jsx(Pressable, { className: "flex-1", onPress: () => setOpen(false), children: /* @__PURE__ */ jsx(View, { className: "flex-1 items-center justify-center", children: /* @__PURE__ */ jsx(Pressable, { onPress: () => {
|
|
1755
2127
|
}, children: /* @__PURE__ */ jsx(
|
|
1756
|
-
|
|
2128
|
+
NativeGlassSurface,
|
|
1757
2129
|
{
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
),
|
|
2130
|
+
radius: 14,
|
|
2131
|
+
fallbackClassName: "rounded-md border border-border bg-popover shadow-md",
|
|
2132
|
+
className: cn("min-w-[8rem] p-1", className),
|
|
1762
2133
|
children
|
|
1763
2134
|
}
|
|
1764
2135
|
) }) }) }) });
|
|
@@ -2207,7 +2578,58 @@ function Grid({
|
|
|
2207
2578
|
Array.from({ length: cols - row.length }).map((_, padIndex) => /* @__PURE__ */ jsx(View, { className: "flex-1" }, `pad-${padIndex}`))
|
|
2208
2579
|
] }, `row-${rowIndex}`)) });
|
|
2209
2580
|
}
|
|
2581
|
+
var FILL2 = { position: "absolute", top: 0, right: 0, bottom: 0, left: 0 };
|
|
2582
|
+
function NativeImage({
|
|
2583
|
+
src,
|
|
2584
|
+
alt,
|
|
2585
|
+
className,
|
|
2586
|
+
width,
|
|
2587
|
+
height,
|
|
2588
|
+
contentFit = "cover",
|
|
2589
|
+
placeholder,
|
|
2590
|
+
recyclingKey,
|
|
2591
|
+
priority,
|
|
2592
|
+
testID
|
|
2593
|
+
}) {
|
|
2594
|
+
const { image: ExpoImage } = useGenesisModules();
|
|
2595
|
+
const reducedMotion = useReducedMotion();
|
|
2596
|
+
const a11y = alt ? { accessible: true, accessibilityRole: "image", accessibilityLabel: alt } : { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants" };
|
|
2597
|
+
return /* @__PURE__ */ jsx(
|
|
2598
|
+
View,
|
|
2599
|
+
{
|
|
2600
|
+
...a11y,
|
|
2601
|
+
testID,
|
|
2602
|
+
className: cn("overflow-hidden bg-muted", className),
|
|
2603
|
+
style: width !== void 0 || height !== void 0 ? { width, height } : void 0,
|
|
2604
|
+
children: ExpoImage ? /* @__PURE__ */ jsx(
|
|
2605
|
+
ExpoImage,
|
|
2606
|
+
{
|
|
2607
|
+
testID: testID ? `${testID}-image` : void 0,
|
|
2608
|
+
accessible: false,
|
|
2609
|
+
source: { uri: src },
|
|
2610
|
+
style: FILL2,
|
|
2611
|
+
contentFit,
|
|
2612
|
+
cachePolicy: "memory-disk",
|
|
2613
|
+
placeholder,
|
|
2614
|
+
placeholderContentFit: contentFit,
|
|
2615
|
+
transition: reducedMotion ? null : 150,
|
|
2616
|
+
recyclingKey: recyclingKey ?? src,
|
|
2617
|
+
priority
|
|
2618
|
+
}
|
|
2619
|
+
) : /* @__PURE__ */ jsx(
|
|
2620
|
+
Image,
|
|
2621
|
+
{
|
|
2622
|
+
testID: testID ? `${testID}-image` : void 0,
|
|
2623
|
+
accessible: false,
|
|
2624
|
+
source: { uri: src },
|
|
2625
|
+
style: FILL2,
|
|
2626
|
+
resizeMode: contentFit
|
|
2627
|
+
}
|
|
2628
|
+
)
|
|
2629
|
+
}
|
|
2630
|
+
);
|
|
2631
|
+
}
|
|
2210
2632
|
|
|
2211
|
-
export { Box, Grid, Inline, NativeAccordion, NativeAccordionContent, NativeAccordionItem, NativeAccordionTrigger, NativeAvatar, NativeBanner, NativeChip, NativeChipGroup, NativeCombobox, NativeDatePicker, NativeDialog, NativeDialogContent, NativeDialogDescription, NativeDialogFooter, NativeDialogHeader, NativeDialogTitle, NativeDrawer, NativeDropdownMenu, NativeDropdownMenuContent, NativeDropdownMenuItem, NativeDropdownMenuTrigger, NativeHeaderCard, NativeInlineAlert, NativeNumberInput, NativePagination, NativePopover, NativePopoverContent, NativePopoverTrigger, NativeProgress, NativeRadioGroup, NativeRadioGroupItem, NativeRangeSlider, NativeRefreshControl, NativeSearchBar, NativeSegmentedControl, NativeSheet, NativeSlider, NativeStepper, NativeTabs, NativeTabsContent, NativeTabsList, NativeTabsTrigger, NativeTimePicker, NativeToastProvider, NativeToggle, NativeTooltip, NativeTooltipContent, NativeTooltipTrigger, Stack, spaceScale, spacingClass, toggleVariants, useToast };
|
|
2212
|
-
//# sourceMappingURL=chunk-
|
|
2213
|
-
//# sourceMappingURL=chunk-
|
|
2633
|
+
export { Box, Grid, Inline, NativeAccordion, NativeAccordionContent, NativeAccordionItem, NativeAccordionTrigger, NativeAvatar, NativeBanner, NativeChip, NativeChipGroup, NativeCombobox, NativeDatePicker, NativeDialog, NativeDialogContent, NativeDialogDescription, NativeDialogFooter, NativeDialogHeader, NativeDialogTitle, NativeDrawer, NativeDropdownMenu, NativeDropdownMenuContent, NativeDropdownMenuItem, NativeDropdownMenuTrigger, NativeGlassSurface, NativeHeaderCard, NativeImage, NativeInlineAlert, NativeNumberInput, NativePagination, NativePopover, NativePopoverContent, NativePopoverTrigger, NativeProgress, NativeRadioGroup, NativeRadioGroupItem, NativeRangeSlider, NativeRefreshControl, NativeSearchBar, NativeSegmentedControl, NativeSheet, NativeSheetProvider, NativeSheetScrollView, NativeSlider, NativeStepper, NativeTabs, NativeTabsContent, NativeTabsList, NativeTabsTrigger, NativeTimePicker, NativeToastProvider, NativeToggle, NativeTooltip, NativeTooltipContent, NativeTooltipTrigger, Stack, spaceScale, spacingClass, toggleVariants, useLiquidGlass, useReduceTransparency, useToast };
|
|
2634
|
+
//# sourceMappingURL=chunk-W7BK3ARU.js.map
|
|
2635
|
+
//# sourceMappingURL=chunk-W7BK3ARU.js.map
|