@marktiderman/genesis-ui-native 2.4.1 → 2.6.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 +30 -0
- package/dist/{chunk-BPD5DCFP.js → chunk-3S5XVER4.js} +271 -6
- package/dist/chunk-3S5XVER4.js.map +1 -0
- package/dist/chunk-56QLEHHV.js +1231 -0
- package/dist/chunk-56QLEHHV.js.map +1 -0
- package/dist/chunk-6JBNSW4D.js +479 -0
- package/dist/chunk-6JBNSW4D.js.map +1 -0
- package/dist/{chunk-RARJGZA3.js → chunk-KZEIF4YI.js} +7 -741
- package/dist/chunk-KZEIF4YI.js.map +1 -0
- package/dist/{chunk-6TLBCRS6.js → chunk-VMSIKSU2.js} +13 -477
- package/dist/chunk-VMSIKSU2.js.map +1 -0
- package/dist/components/index.d.ts +29 -3
- package/dist/components/index.js +3 -4
- package/dist/data/index.d.ts +382 -4
- package/dist/data/index.js +1067 -19
- package/dist/data/index.js.map +1 -1
- package/dist/inbox-page-DZUR-PJ1.d.ts +199 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -5
- package/dist/layouts/index.d.ts +4 -186
- package/dist/layouts/index.js +3 -3
- package/package.json +2 -2
- package/src/components/__tests__/loading-state.test.tsx +41 -0
- package/src/components/image.tsx +5 -0
- package/src/components/index.ts +3 -0
- package/src/components/loading-state.tsx +92 -0
- package/src/data/NativeDetailPanel.tsx +8 -1
- package/src/data/index.ts +1 -0
- package/src/data/resource-view/NativeResourceFormSheet.tsx +305 -0
- package/src/data/resource-view/NativeResourceView.tsx +528 -0
- package/src/data/resource-view/__tests__/native-resource-view.test.tsx +870 -0
- package/src/data/resource-view/display.tsx +256 -0
- package/src/data/resource-view/index.ts +50 -0
- package/src/data/resource-view/mapping.ts +326 -0
- package/src/data/resource-view/messages.ts +121 -0
- package/src/data/resource-view/use-native-resource-view.ts +307 -0
- package/src/layouts/__tests__/inbox-page.test.tsx +2 -1
- package/src/layouts/__tests__/screen-container.test.tsx +27 -0
- package/src/layouts/inbox-page.tsx +4 -7
- package/src/layouts/screen-container.tsx +18 -1
- package/dist/chunk-6TLBCRS6.js.map +0 -1
- package/dist/chunk-BPD5DCFP.js.map +0 -1
- package/dist/chunk-EFXCJ5AN.js +0 -234
- package/dist/chunk-EFXCJ5AN.js.map +0 -1
- package/dist/chunk-FIITITXO.js +0 -492
- package/dist/chunk-FIITITXO.js.map +0 -1
- package/dist/chunk-RARJGZA3.js.map +0 -1
|
@@ -0,0 +1,1231 @@
|
|
|
1
|
+
import { useReducedMotion } from './chunk-7PCWEY6R.js';
|
|
2
|
+
import { useGenesisModules } from './chunk-3S5XVER4.js';
|
|
3
|
+
import { useThemeRoles } from './chunk-Z3AQYVUA.js';
|
|
4
|
+
import { cn } from './chunk-OHZD7KRO.js';
|
|
5
|
+
import { __require } from './chunk-DGUM43GV.js';
|
|
6
|
+
import { View, Text, ScrollView, Dimensions, Platform, Modal, Pressable, KeyboardAvoidingView, TextInput, Animated, Easing, Image, Switch, AccessibilityInfo } from 'react-native';
|
|
7
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
import { createContext, useState, useEffect, useContext, useRef, useCallback, useMemo } from 'react';
|
|
9
|
+
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
10
|
+
import { cva } from 'class-variance-authority';
|
|
11
|
+
import { nativeColors } from '@marktiderman/genesis-design-system/tokens/native';
|
|
12
|
+
|
|
13
|
+
function NativeCard({ className, children, ...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
View,
|
|
16
|
+
{
|
|
17
|
+
className: cn(
|
|
18
|
+
"rounded-xl border border-border bg-card p-0 shadow-sm",
|
|
19
|
+
className
|
|
20
|
+
),
|
|
21
|
+
...props,
|
|
22
|
+
children
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
function NativeCardHeader({
|
|
27
|
+
className,
|
|
28
|
+
children,
|
|
29
|
+
...props
|
|
30
|
+
}) {
|
|
31
|
+
return /* @__PURE__ */ jsx(View, { className: cn("flex-col gap-1.5 p-6", className), ...props, children });
|
|
32
|
+
}
|
|
33
|
+
function NativeCardTitle({
|
|
34
|
+
className,
|
|
35
|
+
children,
|
|
36
|
+
...props
|
|
37
|
+
}) {
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
Text,
|
|
40
|
+
{
|
|
41
|
+
className: cn(
|
|
42
|
+
"text-2xl font-semibold leading-none tracking-tight text-card-foreground",
|
|
43
|
+
className
|
|
44
|
+
),
|
|
45
|
+
...props,
|
|
46
|
+
children
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
function NativeCardDescription({
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
...props
|
|
54
|
+
}) {
|
|
55
|
+
return /* @__PURE__ */ jsx(
|
|
56
|
+
Text,
|
|
57
|
+
{
|
|
58
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
59
|
+
...props,
|
|
60
|
+
children
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function NativeCardContent({
|
|
65
|
+
className,
|
|
66
|
+
children,
|
|
67
|
+
...props
|
|
68
|
+
}) {
|
|
69
|
+
return /* @__PURE__ */ jsx(View, { className: cn("p-6 pt-0", className), ...props, children });
|
|
70
|
+
}
|
|
71
|
+
function NativeCardFooter({
|
|
72
|
+
className,
|
|
73
|
+
children,
|
|
74
|
+
...props
|
|
75
|
+
}) {
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
View,
|
|
78
|
+
{
|
|
79
|
+
className: cn("flex-row items-center p-6 pt-0", className),
|
|
80
|
+
...props,
|
|
81
|
+
children
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
var REQUIRED_EXPORTS = ["BottomSheetModal", "BottomSheetView", "BottomSheetBackdrop", "BottomSheetModalProvider"];
|
|
86
|
+
var SheetLibraryContext = createContext(null);
|
|
87
|
+
function NativeSheetProvider({ bottomSheet, children }) {
|
|
88
|
+
const [library] = useState(() => isSheetLibrary(bottomSheet) ? bottomSheet : null);
|
|
89
|
+
const [problem] = useState(() => library ? null : invalidLibraryMessage(bottomSheet));
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (problem) console.error(problem);
|
|
92
|
+
}, [problem]);
|
|
93
|
+
if (!library) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
94
|
+
const Provider = library.BottomSheetModalProvider;
|
|
95
|
+
return /* @__PURE__ */ jsx(SheetLibraryContext.Provider, { value: library, children: /* @__PURE__ */ jsx(Provider, { children }) });
|
|
96
|
+
}
|
|
97
|
+
function isSheetLibrary(value) {
|
|
98
|
+
if (!value || typeof value !== "object") return false;
|
|
99
|
+
const mod = value;
|
|
100
|
+
return REQUIRED_EXPORTS.every((name) => mod[name] != null);
|
|
101
|
+
}
|
|
102
|
+
function invalidLibraryMessage(value) {
|
|
103
|
+
const mod = value && typeof value === "object" ? value : {};
|
|
104
|
+
const missing = REQUIRED_EXPORTS.filter((name) => mod[name] == null);
|
|
105
|
+
return `NativeSheetProvider: \`bottomSheet\` is missing ${missing.join(", ")}, so sheets use the native modal. Pass the whole module: \`import * as BottomSheet from "@gorhom/bottom-sheet"\`.`;
|
|
106
|
+
}
|
|
107
|
+
function NativeSheet(props) {
|
|
108
|
+
const library = useContext(SheetLibraryContext);
|
|
109
|
+
if (library) return /* @__PURE__ */ jsx(LibrarySheet, { library, ...props });
|
|
110
|
+
return /* @__PURE__ */ jsx(ModalSheet, { ...props });
|
|
111
|
+
}
|
|
112
|
+
function NativeSheetScrollView({ style, ...props }) {
|
|
113
|
+
const library = useContext(SheetLibraryContext);
|
|
114
|
+
const Scroll = library?.BottomSheetScrollView ?? ScrollView;
|
|
115
|
+
const own = { flexGrow: 0 };
|
|
116
|
+
return /* @__PURE__ */ jsx(Scroll, { style: [own, ...Array.isArray(style) ? style : style ? [style] : []], ...props });
|
|
117
|
+
}
|
|
118
|
+
function LibrarySheet({
|
|
119
|
+
library,
|
|
120
|
+
open,
|
|
121
|
+
onOpenChange,
|
|
122
|
+
snapPoints = ["50%", "90%"],
|
|
123
|
+
initialSnapIndex = 0,
|
|
124
|
+
disableBackdropDismiss = false,
|
|
125
|
+
fitContent = false,
|
|
126
|
+
testID,
|
|
127
|
+
children
|
|
128
|
+
}) {
|
|
129
|
+
const sheet = useRef(null);
|
|
130
|
+
const wanted = useRef(open);
|
|
131
|
+
const onOpenChangeRef = useRef(onOpenChange);
|
|
132
|
+
onOpenChangeRef.current = onOpenChange;
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
wanted.current = open;
|
|
135
|
+
if (open) sheet.current?.present();
|
|
136
|
+
else sheet.current?.dismiss();
|
|
137
|
+
}, [open]);
|
|
138
|
+
const BottomSheetModal = library.BottomSheetModal;
|
|
139
|
+
const BottomSheetView = library.BottomSheetView;
|
|
140
|
+
const BottomSheetBackdrop = library.BottomSheetBackdrop;
|
|
141
|
+
const onDismiss = useCallback(() => {
|
|
142
|
+
if (wanted.current) {
|
|
143
|
+
wanted.current = false;
|
|
144
|
+
onOpenChangeRef.current(false);
|
|
145
|
+
}
|
|
146
|
+
}, []);
|
|
147
|
+
const backdrop = useCallback(
|
|
148
|
+
(p) => /* @__PURE__ */ jsx(
|
|
149
|
+
BottomSheetBackdrop,
|
|
150
|
+
{
|
|
151
|
+
...p,
|
|
152
|
+
appearsOnIndex: 0,
|
|
153
|
+
disappearsOnIndex: -1,
|
|
154
|
+
pressBehavior: disableBackdropDismiss ? "none" : "close"
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
[BottomSheetBackdrop, disableBackdropDismiss]
|
|
158
|
+
);
|
|
159
|
+
return /* @__PURE__ */ jsx(
|
|
160
|
+
BottomSheetModal,
|
|
161
|
+
{
|
|
162
|
+
ref: sheet,
|
|
163
|
+
snapPoints: fitContent ? void 0 : snapPoints,
|
|
164
|
+
index: fitContent ? 0 : initialSnapIndex,
|
|
165
|
+
enableDynamicSizing: fitContent,
|
|
166
|
+
...fitContent ? { maxDynamicContentSize: Math.round(Dimensions.get("window").height * 0.9) } : {},
|
|
167
|
+
onDismiss,
|
|
168
|
+
enablePanDownToClose: !disableBackdropDismiss,
|
|
169
|
+
backdropComponent: backdrop,
|
|
170
|
+
children: /* @__PURE__ */ jsx(BottomSheetView, { testID: testID ?? "native-sheet", children })
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
function useReduceMotionAnswer() {
|
|
175
|
+
const [reduced, setReduced] = useState(null);
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
let mounted = true;
|
|
178
|
+
AccessibilityInfo.isReduceMotionEnabled().then(
|
|
179
|
+
(value) => mounted && setReduced(value),
|
|
180
|
+
() => mounted && setReduced(false)
|
|
181
|
+
);
|
|
182
|
+
const sub = AccessibilityInfo.addEventListener("reduceMotionChanged", (value) => setReduced(value));
|
|
183
|
+
return () => {
|
|
184
|
+
mounted = false;
|
|
185
|
+
sub?.remove?.();
|
|
186
|
+
};
|
|
187
|
+
}, []);
|
|
188
|
+
return reduced;
|
|
189
|
+
}
|
|
190
|
+
function ModalSheet({ open, onOpenChange, disableBackdropDismiss = false, fitContent = false, testID, children }) {
|
|
191
|
+
const reducedMotion = useReduceMotionAnswer();
|
|
192
|
+
const roles = useThemeRoles();
|
|
193
|
+
const requestClose = () => {
|
|
194
|
+
if (!disableBackdropDismiss) onOpenChange(false);
|
|
195
|
+
};
|
|
196
|
+
const visible = open && reducedMotion !== null;
|
|
197
|
+
const animationType = reducedMotion ? "none" : "slide";
|
|
198
|
+
const id = testID ?? "native-sheet";
|
|
199
|
+
const ios = Platform.OS === "ios";
|
|
200
|
+
if (ios && !fitContent) {
|
|
201
|
+
return /* @__PURE__ */ jsx(
|
|
202
|
+
Modal,
|
|
203
|
+
{
|
|
204
|
+
visible,
|
|
205
|
+
animationType,
|
|
206
|
+
presentationStyle: "pageSheet",
|
|
207
|
+
allowSwipeDismissal: !disableBackdropDismiss,
|
|
208
|
+
backdropColor: roles.background,
|
|
209
|
+
onRequestClose: requestClose,
|
|
210
|
+
children: /* @__PURE__ */ jsx(SafeAreaProvider, { children: /* @__PURE__ */ jsx(
|
|
211
|
+
SheetBody,
|
|
212
|
+
{
|
|
213
|
+
testID: id,
|
|
214
|
+
onAccessibilityEscape: disableBackdropDismiss ? void 0 : requestClose,
|
|
215
|
+
style: { flex: 1, backgroundColor: roles.background },
|
|
216
|
+
children
|
|
217
|
+
}
|
|
218
|
+
) })
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return /* @__PURE__ */ jsx(
|
|
223
|
+
Modal,
|
|
224
|
+
{
|
|
225
|
+
visible,
|
|
226
|
+
transparent: true,
|
|
227
|
+
animationType,
|
|
228
|
+
statusBarTranslucent: true,
|
|
229
|
+
navigationBarTranslucent: true,
|
|
230
|
+
onRequestClose: requestClose,
|
|
231
|
+
children: /* @__PURE__ */ jsx(SafeAreaProvider, { children: /* @__PURE__ */ jsxs(KeyboardPanel, { ios, children: [
|
|
232
|
+
/* @__PURE__ */ jsx(
|
|
233
|
+
Pressable,
|
|
234
|
+
{
|
|
235
|
+
testID: `${id}-backdrop`,
|
|
236
|
+
accessibilityRole: "button",
|
|
237
|
+
accessibilityLabel: "Close",
|
|
238
|
+
disabled: disableBackdropDismiss,
|
|
239
|
+
importantForAccessibility: disableBackdropDismiss ? "no-hide-descendants" : "auto",
|
|
240
|
+
onPress: requestClose,
|
|
241
|
+
style: { position: "absolute", top: 0, right: 0, bottom: 0, left: 0, backgroundColor: "rgba(0,0,0,0.4)" }
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
/* @__PURE__ */ jsxs(
|
|
245
|
+
SheetBody,
|
|
246
|
+
{
|
|
247
|
+
testID: id,
|
|
248
|
+
onAccessibilityEscape: disableBackdropDismiss ? void 0 : requestClose,
|
|
249
|
+
style: {
|
|
250
|
+
maxHeight: "90%",
|
|
251
|
+
borderTopLeftRadius: 28,
|
|
252
|
+
borderTopRightRadius: 28,
|
|
253
|
+
backgroundColor: roles.surface,
|
|
254
|
+
paddingTop: 12
|
|
255
|
+
},
|
|
256
|
+
children: [
|
|
257
|
+
/* @__PURE__ */ jsx(
|
|
258
|
+
View,
|
|
259
|
+
{
|
|
260
|
+
style: { alignSelf: "center", width: 32, height: 4, borderRadius: 2, marginBottom: 8, backgroundColor: roles.tertiaryLabel }
|
|
261
|
+
}
|
|
262
|
+
),
|
|
263
|
+
children
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
] }) })
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
function KeyboardPanel({ ios, children }) {
|
|
272
|
+
const insets = useSafeAreaInsets();
|
|
273
|
+
return /* @__PURE__ */ jsx(KeyboardAvoidingView, { behavior: ios ? "padding" : void 0, keyboardVerticalOffset: ios ? -insets.bottom : 0, style: { flex: 1, justifyContent: "flex-end" }, children });
|
|
274
|
+
}
|
|
275
|
+
function SheetBody({
|
|
276
|
+
testID,
|
|
277
|
+
style,
|
|
278
|
+
onAccessibilityEscape,
|
|
279
|
+
children
|
|
280
|
+
}) {
|
|
281
|
+
const insets = useSafeAreaInsets();
|
|
282
|
+
return /* @__PURE__ */ jsx(View, { testID, accessibilityViewIsModal: true, onAccessibilityEscape, style: { ...style, paddingBottom: insets.bottom }, children });
|
|
283
|
+
}
|
|
284
|
+
function resolveDateTimePicker() {
|
|
285
|
+
try {
|
|
286
|
+
return __require("@react-native-community/datetimepicker").default;
|
|
287
|
+
} catch {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function PickerButton({
|
|
292
|
+
value,
|
|
293
|
+
onChange,
|
|
294
|
+
mode,
|
|
295
|
+
formatLabel,
|
|
296
|
+
disabled,
|
|
297
|
+
className,
|
|
298
|
+
testID
|
|
299
|
+
}) {
|
|
300
|
+
const { datePicker: ExpoUiPicker } = useGenesisModules();
|
|
301
|
+
const Picker = ExpoUiPicker ? null : resolveDateTimePicker();
|
|
302
|
+
const [showAndroid, setShowAndroid] = useState(false);
|
|
303
|
+
const isIOS = Platform.OS === "ios";
|
|
304
|
+
const label = useMemo(() => {
|
|
305
|
+
if (formatLabel) return formatLabel(value);
|
|
306
|
+
if (mode === "date") return value.toDateString();
|
|
307
|
+
return value.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
308
|
+
}, [formatLabel, mode, value]);
|
|
309
|
+
if (ExpoUiPicker) {
|
|
310
|
+
return /* @__PURE__ */ jsx(
|
|
311
|
+
ExpoUiPickerButton,
|
|
312
|
+
{
|
|
313
|
+
Picker: ExpoUiPicker,
|
|
314
|
+
value,
|
|
315
|
+
onChange,
|
|
316
|
+
mode,
|
|
317
|
+
label,
|
|
318
|
+
disabled,
|
|
319
|
+
className,
|
|
320
|
+
testID
|
|
321
|
+
}
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
if (!Picker) {
|
|
325
|
+
return /* @__PURE__ */ jsxs(
|
|
326
|
+
Text,
|
|
327
|
+
{
|
|
328
|
+
testID,
|
|
329
|
+
className: cn(
|
|
330
|
+
"min-h-[44px] rounded-md border border-input bg-background px-3 py-3 text-base text-muted-foreground",
|
|
331
|
+
className
|
|
332
|
+
),
|
|
333
|
+
children: [
|
|
334
|
+
label,
|
|
335
|
+
" (picker module not installed)"
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
if (isIOS) {
|
|
341
|
+
return /* @__PURE__ */ jsx(
|
|
342
|
+
Picker,
|
|
343
|
+
{
|
|
344
|
+
testID: testID ?? `native-${mode}-picker`,
|
|
345
|
+
value,
|
|
346
|
+
mode,
|
|
347
|
+
display: "compact",
|
|
348
|
+
disabled,
|
|
349
|
+
style: disabled ? { opacity: 0.5 } : void 0,
|
|
350
|
+
onChange: (_e, d) => {
|
|
351
|
+
if (d && !disabled) onChange(d);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
357
|
+
/* @__PURE__ */ jsx(
|
|
358
|
+
Pressable,
|
|
359
|
+
{
|
|
360
|
+
testID: testID ?? `native-${mode}-picker`,
|
|
361
|
+
accessibilityRole: "button",
|
|
362
|
+
accessibilityLabel: `Pick a ${mode}`,
|
|
363
|
+
accessibilityValue: { text: label },
|
|
364
|
+
accessibilityState: { disabled },
|
|
365
|
+
disabled,
|
|
366
|
+
onPress: () => setShowAndroid(true),
|
|
367
|
+
className: cn(
|
|
368
|
+
"min-h-[44px] flex-row items-center rounded-md border border-input bg-background px-3",
|
|
369
|
+
disabled && "opacity-50",
|
|
370
|
+
className
|
|
371
|
+
),
|
|
372
|
+
children: /* @__PURE__ */ jsx(Text, { className: "flex-1 text-base text-foreground", children: label })
|
|
373
|
+
}
|
|
374
|
+
),
|
|
375
|
+
showAndroid ? /* @__PURE__ */ jsx(
|
|
376
|
+
Picker,
|
|
377
|
+
{
|
|
378
|
+
testID: testID ? `${testID}-picker` : void 0,
|
|
379
|
+
value,
|
|
380
|
+
mode,
|
|
381
|
+
display: "default",
|
|
382
|
+
onChange: (_e, d) => {
|
|
383
|
+
setShowAndroid(false);
|
|
384
|
+
if (d) onChange(d);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
) : null
|
|
388
|
+
] });
|
|
389
|
+
}
|
|
390
|
+
function ExpoUiPickerButton({
|
|
391
|
+
Picker,
|
|
392
|
+
value,
|
|
393
|
+
onChange,
|
|
394
|
+
mode,
|
|
395
|
+
label,
|
|
396
|
+
disabled,
|
|
397
|
+
className,
|
|
398
|
+
testID
|
|
399
|
+
}) {
|
|
400
|
+
const [showAndroid, setShowAndroid] = useState(false);
|
|
401
|
+
if (Platform.OS === "ios") {
|
|
402
|
+
return /* @__PURE__ */ jsx(
|
|
403
|
+
Picker,
|
|
404
|
+
{
|
|
405
|
+
testID: testID ?? `native-${mode}-picker`,
|
|
406
|
+
value,
|
|
407
|
+
mode,
|
|
408
|
+
display: "compact",
|
|
409
|
+
disabled,
|
|
410
|
+
style: disabled ? { opacity: 0.5 } : void 0,
|
|
411
|
+
onValueChange: (_e, d) => {
|
|
412
|
+
if (d && !disabled) onChange(d);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
418
|
+
/* @__PURE__ */ jsx(
|
|
419
|
+
Pressable,
|
|
420
|
+
{
|
|
421
|
+
testID: testID ?? `native-${mode}-picker`,
|
|
422
|
+
accessibilityRole: "button",
|
|
423
|
+
accessibilityLabel: `Pick a ${mode}`,
|
|
424
|
+
accessibilityValue: { text: label },
|
|
425
|
+
accessibilityState: { disabled },
|
|
426
|
+
disabled,
|
|
427
|
+
onPress: () => setShowAndroid(true),
|
|
428
|
+
className: cn(
|
|
429
|
+
"min-h-[44px] flex-row items-center rounded-md border border-input bg-background px-3",
|
|
430
|
+
disabled && "opacity-50",
|
|
431
|
+
className
|
|
432
|
+
),
|
|
433
|
+
children: /* @__PURE__ */ jsx(Text, { className: "flex-1 text-base text-foreground", children: label })
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
showAndroid ? /* @__PURE__ */ jsx(
|
|
437
|
+
Picker,
|
|
438
|
+
{
|
|
439
|
+
testID: testID ? `${testID}-picker` : void 0,
|
|
440
|
+
value,
|
|
441
|
+
mode,
|
|
442
|
+
presentation: "dialog",
|
|
443
|
+
onValueChange: (_e, d) => {
|
|
444
|
+
setShowAndroid(false);
|
|
445
|
+
if (d) onChange(d);
|
|
446
|
+
},
|
|
447
|
+
onDismiss: () => setShowAndroid(false)
|
|
448
|
+
}
|
|
449
|
+
) : null
|
|
450
|
+
] });
|
|
451
|
+
}
|
|
452
|
+
function NativeDatePicker(props) {
|
|
453
|
+
return /* @__PURE__ */ jsx(PickerButton, { ...props, mode: "date" });
|
|
454
|
+
}
|
|
455
|
+
function NativeTimePicker(props) {
|
|
456
|
+
return /* @__PURE__ */ jsx(PickerButton, { ...props, mode: "time" });
|
|
457
|
+
}
|
|
458
|
+
var SELECTED_LIFT = { shadowColor: "black", shadowOpacity: 0.08, shadowRadius: 2, shadowOffset: { width: 0, height: 1 }, elevation: 1 };
|
|
459
|
+
var UNSELECTED_LIFT = { shadowColor: "black", shadowOpacity: 0, shadowRadius: 0, shadowOffset: { width: 0, height: 0 }, elevation: 0 };
|
|
460
|
+
function NativeSegmentedControl({
|
|
461
|
+
options,
|
|
462
|
+
value,
|
|
463
|
+
onChange,
|
|
464
|
+
disabled,
|
|
465
|
+
className,
|
|
466
|
+
testID
|
|
467
|
+
}) {
|
|
468
|
+
return /* @__PURE__ */ jsx(
|
|
469
|
+
View,
|
|
470
|
+
{
|
|
471
|
+
testID: testID ?? "native-segmented",
|
|
472
|
+
accessibilityRole: "radiogroup",
|
|
473
|
+
className: cn(
|
|
474
|
+
"flex-row rounded-md border border-border bg-muted p-0.5",
|
|
475
|
+
disabled && "opacity-50",
|
|
476
|
+
className
|
|
477
|
+
),
|
|
478
|
+
children: options.map((opt) => {
|
|
479
|
+
const selected = opt.value === value;
|
|
480
|
+
return /* @__PURE__ */ jsx(
|
|
481
|
+
Pressable,
|
|
482
|
+
{
|
|
483
|
+
testID: testID ? `${testID}-option-${String(opt.value)}` : `segmented-option-${String(opt.value)}`,
|
|
484
|
+
disabled,
|
|
485
|
+
accessibilityRole: "radio",
|
|
486
|
+
accessibilityState: { selected, disabled },
|
|
487
|
+
onPress: () => onChange(opt.value),
|
|
488
|
+
className: cn(
|
|
489
|
+
"min-h-[36px] flex-1 items-center justify-center rounded px-3 py-1",
|
|
490
|
+
selected && "bg-background"
|
|
491
|
+
),
|
|
492
|
+
style: selected ? SELECTED_LIFT : UNSELECTED_LIFT,
|
|
493
|
+
children: /* @__PURE__ */ jsx(
|
|
494
|
+
Text,
|
|
495
|
+
{
|
|
496
|
+
className: cn(
|
|
497
|
+
"text-sm",
|
|
498
|
+
selected ? "font-semibold text-foreground" : "text-muted-foreground"
|
|
499
|
+
),
|
|
500
|
+
children: opt.label
|
|
501
|
+
}
|
|
502
|
+
)
|
|
503
|
+
},
|
|
504
|
+
String(opt.value)
|
|
505
|
+
);
|
|
506
|
+
})
|
|
507
|
+
}
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
var variantClasses = {
|
|
511
|
+
info: "bg-secondary border-border",
|
|
512
|
+
success: "bg-primary/10 border-primary/30",
|
|
513
|
+
warning: "bg-warning/10 border-warning/30",
|
|
514
|
+
destructive: "bg-destructive/10 border-destructive/30"
|
|
515
|
+
};
|
|
516
|
+
var titleClasses = {
|
|
517
|
+
info: "text-foreground",
|
|
518
|
+
success: "text-primary",
|
|
519
|
+
warning: "text-warning",
|
|
520
|
+
destructive: "text-destructive"
|
|
521
|
+
};
|
|
522
|
+
function NativeInlineAlert({
|
|
523
|
+
variant = "info",
|
|
524
|
+
title,
|
|
525
|
+
description,
|
|
526
|
+
icon,
|
|
527
|
+
onDismiss,
|
|
528
|
+
className,
|
|
529
|
+
testID
|
|
530
|
+
}) {
|
|
531
|
+
return /* @__PURE__ */ jsxs(
|
|
532
|
+
View,
|
|
533
|
+
{
|
|
534
|
+
testID: testID ?? `inline-alert-${variant}`,
|
|
535
|
+
accessibilityRole: "alert",
|
|
536
|
+
className: cn(
|
|
537
|
+
"flex-row gap-3 rounded-md border p-3",
|
|
538
|
+
variantClasses[variant],
|
|
539
|
+
className
|
|
540
|
+
),
|
|
541
|
+
children: [
|
|
542
|
+
icon ? /* @__PURE__ */ jsx(View, { className: "pt-0.5", children: icon }) : null,
|
|
543
|
+
/* @__PURE__ */ jsxs(View, { className: "flex-1", children: [
|
|
544
|
+
title ? /* @__PURE__ */ jsx(Text, { className: cn("text-sm font-semibold", titleClasses[variant]), children: title }) : null,
|
|
545
|
+
description ? /* @__PURE__ */ jsx(Text, { className: "mt-0.5 text-sm text-foreground/80", children: description }) : null
|
|
546
|
+
] }),
|
|
547
|
+
onDismiss ? /* @__PURE__ */ jsx(
|
|
548
|
+
Pressable,
|
|
549
|
+
{
|
|
550
|
+
testID: testID ? `${testID}-dismiss` : void 0,
|
|
551
|
+
accessibilityRole: "button",
|
|
552
|
+
accessibilityLabel: "Dismiss",
|
|
553
|
+
onPress: onDismiss,
|
|
554
|
+
hitSlop: 8,
|
|
555
|
+
className: "min-h-[24px] min-w-[24px] items-center justify-center",
|
|
556
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-muted-foreground", children: "\u2715" })
|
|
557
|
+
}
|
|
558
|
+
) : null
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
function NativeBanner({
|
|
564
|
+
variant = "info",
|
|
565
|
+
title,
|
|
566
|
+
description,
|
|
567
|
+
icon,
|
|
568
|
+
onDismiss,
|
|
569
|
+
className,
|
|
570
|
+
testID
|
|
571
|
+
}) {
|
|
572
|
+
return /* @__PURE__ */ jsxs(
|
|
573
|
+
View,
|
|
574
|
+
{
|
|
575
|
+
testID: testID ?? `banner-${variant}`,
|
|
576
|
+
accessibilityRole: "alert",
|
|
577
|
+
accessibilityLiveRegion: "polite",
|
|
578
|
+
className: cn(
|
|
579
|
+
"flex-row items-start gap-3 border-b px-4 py-3",
|
|
580
|
+
variantClasses[variant],
|
|
581
|
+
className
|
|
582
|
+
),
|
|
583
|
+
children: [
|
|
584
|
+
icon ? /* @__PURE__ */ jsx(View, { className: "pt-0.5", children: icon }) : null,
|
|
585
|
+
/* @__PURE__ */ jsxs(View, { className: "flex-1", children: [
|
|
586
|
+
title ? /* @__PURE__ */ jsx(Text, { className: cn("text-sm font-semibold", titleClasses[variant]), children: title }) : null,
|
|
587
|
+
description ? /* @__PURE__ */ jsx(Text, { className: "mt-0.5 text-sm text-foreground/80", children: description }) : null
|
|
588
|
+
] }),
|
|
589
|
+
onDismiss ? /* @__PURE__ */ jsx(
|
|
590
|
+
Pressable,
|
|
591
|
+
{
|
|
592
|
+
testID: testID ? `${testID}-dismiss` : void 0,
|
|
593
|
+
accessibilityRole: "button",
|
|
594
|
+
accessibilityLabel: "Dismiss",
|
|
595
|
+
onPress: onDismiss,
|
|
596
|
+
hitSlop: 8,
|
|
597
|
+
className: "min-h-[24px] min-w-[24px] items-center justify-center",
|
|
598
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-muted-foreground", children: "\u2715" })
|
|
599
|
+
}
|
|
600
|
+
) : null
|
|
601
|
+
]
|
|
602
|
+
}
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
function NativeSearchBar({
|
|
606
|
+
value,
|
|
607
|
+
onChange,
|
|
608
|
+
onSubmit,
|
|
609
|
+
placeholder = "Search",
|
|
610
|
+
placeholderTextColor,
|
|
611
|
+
onVoicePress,
|
|
612
|
+
showCancel = true,
|
|
613
|
+
cancelLabel = "Cancel",
|
|
614
|
+
className,
|
|
615
|
+
testID
|
|
616
|
+
}) {
|
|
617
|
+
const [focused, setFocused] = useState(false);
|
|
618
|
+
const inputRef = useRef(null);
|
|
619
|
+
return /* @__PURE__ */ jsxs(
|
|
620
|
+
View,
|
|
621
|
+
{
|
|
622
|
+
testID: testID ?? "native-search-bar",
|
|
623
|
+
className: cn("flex-row items-center gap-2", className),
|
|
624
|
+
children: [
|
|
625
|
+
/* @__PURE__ */ jsxs(View, { className: "flex-1 flex-row items-center rounded-md border border-input bg-background px-3", children: [
|
|
626
|
+
/* @__PURE__ */ jsx(Text, { accessibilityElementsHidden: true, className: "text-sm text-muted-foreground", children: "\u{1F50D}" }),
|
|
627
|
+
/* @__PURE__ */ jsx(
|
|
628
|
+
TextInput,
|
|
629
|
+
{
|
|
630
|
+
ref: inputRef,
|
|
631
|
+
testID: testID ? `${testID}-input` : "search-input",
|
|
632
|
+
value,
|
|
633
|
+
onChangeText: onChange,
|
|
634
|
+
onFocus: () => setFocused(true),
|
|
635
|
+
onBlur: () => setFocused(false),
|
|
636
|
+
onSubmitEditing: () => onSubmit?.(value),
|
|
637
|
+
placeholder,
|
|
638
|
+
placeholderTextColor,
|
|
639
|
+
accessibilityLabel: placeholder,
|
|
640
|
+
returnKeyType: "search",
|
|
641
|
+
autoCorrect: false,
|
|
642
|
+
autoCapitalize: "none",
|
|
643
|
+
clearButtonMode: "never",
|
|
644
|
+
className: "ml-2 min-h-[44px] flex-1 text-base text-foreground"
|
|
645
|
+
}
|
|
646
|
+
),
|
|
647
|
+
value.length > 0 ? /* @__PURE__ */ jsx(
|
|
648
|
+
Pressable,
|
|
649
|
+
{
|
|
650
|
+
testID: testID ? `${testID}-clear` : "search-clear",
|
|
651
|
+
accessibilityRole: "button",
|
|
652
|
+
accessibilityLabel: "Clear search",
|
|
653
|
+
hitSlop: 8,
|
|
654
|
+
onPress: () => onChange(""),
|
|
655
|
+
className: "ml-1 min-h-[24px] min-w-[24px] items-center justify-center",
|
|
656
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-sm text-muted-foreground", children: "\u2715" })
|
|
657
|
+
}
|
|
658
|
+
) : null,
|
|
659
|
+
onVoicePress ? /* @__PURE__ */ jsx(
|
|
660
|
+
Pressable,
|
|
661
|
+
{
|
|
662
|
+
testID: testID ? `${testID}-voice` : "search-voice",
|
|
663
|
+
accessibilityRole: "button",
|
|
664
|
+
accessibilityLabel: "Voice search",
|
|
665
|
+
hitSlop: 8,
|
|
666
|
+
onPress: onVoicePress,
|
|
667
|
+
className: "ml-2 min-h-[24px] min-w-[24px] items-center justify-center",
|
|
668
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-sm text-muted-foreground", children: "\u{1F3A4}" })
|
|
669
|
+
}
|
|
670
|
+
) : null
|
|
671
|
+
] }),
|
|
672
|
+
showCancel && focused ? /* @__PURE__ */ jsx(
|
|
673
|
+
Pressable,
|
|
674
|
+
{
|
|
675
|
+
testID: testID ? `${testID}-cancel` : "search-cancel",
|
|
676
|
+
accessibilityRole: "button",
|
|
677
|
+
accessibilityLabel: cancelLabel,
|
|
678
|
+
onPress: () => {
|
|
679
|
+
onChange("");
|
|
680
|
+
inputRef.current?.blur();
|
|
681
|
+
setFocused(false);
|
|
682
|
+
},
|
|
683
|
+
className: "min-h-[44px] items-center justify-center px-2",
|
|
684
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-primary", children: cancelLabel })
|
|
685
|
+
}
|
|
686
|
+
) : null
|
|
687
|
+
]
|
|
688
|
+
}
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
function NativeSeparator({
|
|
692
|
+
className,
|
|
693
|
+
orientation = "horizontal",
|
|
694
|
+
...props
|
|
695
|
+
}) {
|
|
696
|
+
return /* @__PURE__ */ jsx(
|
|
697
|
+
View,
|
|
698
|
+
{
|
|
699
|
+
className: cn(
|
|
700
|
+
"bg-border",
|
|
701
|
+
orientation === "horizontal" ? "h-px w-full" : "h-full w-px",
|
|
702
|
+
className
|
|
703
|
+
),
|
|
704
|
+
accessibilityRole: "none",
|
|
705
|
+
...props
|
|
706
|
+
}
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
var PULSE_MS = 1e3;
|
|
710
|
+
var LOW = 0.3;
|
|
711
|
+
var HIGH = 1;
|
|
712
|
+
var STILL = 0.6;
|
|
713
|
+
function sizeStyles({ width, height, size }) {
|
|
714
|
+
const w = width ?? size;
|
|
715
|
+
const h = height ?? size;
|
|
716
|
+
const styles = [];
|
|
717
|
+
if (w !== void 0) styles.push({ width: w });
|
|
718
|
+
if (h !== void 0) styles.push({ height: h });
|
|
719
|
+
return styles;
|
|
720
|
+
}
|
|
721
|
+
function skeletonClass({ className, circle }) {
|
|
722
|
+
return cn("rounded-md bg-muted", circle && "rounded-full", className);
|
|
723
|
+
}
|
|
724
|
+
function NativeSkeleton(props) {
|
|
725
|
+
const { reanimated } = useGenesisModules();
|
|
726
|
+
return reanimated ? /* @__PURE__ */ jsx(ReanimatedSkeleton, { ...props, reanimated }) : /* @__PURE__ */ jsx(AnimatedSkeleton, { ...props });
|
|
727
|
+
}
|
|
728
|
+
function ReanimatedSkeleton({ reanimated: R, ...props }) {
|
|
729
|
+
const reduceMotion = useReducedMotion();
|
|
730
|
+
const opacity = R.useSharedValue(LOW);
|
|
731
|
+
useEffect(() => {
|
|
732
|
+
R.cancelAnimation(opacity);
|
|
733
|
+
if (reduceMotion) {
|
|
734
|
+
opacity.value = STILL;
|
|
735
|
+
return void 0;
|
|
736
|
+
}
|
|
737
|
+
opacity.value = LOW;
|
|
738
|
+
opacity.value = R.withRepeat(R.withTiming(HIGH, { duration: PULSE_MS, easing: R.Easing.inOut(R.Easing.ease) }), -1, true);
|
|
739
|
+
return () => R.cancelAnimation(opacity);
|
|
740
|
+
}, [reduceMotion]);
|
|
741
|
+
const animatedStyle = R.useAnimatedStyle(() => {
|
|
742
|
+
"worklet";
|
|
743
|
+
return { opacity: opacity.value };
|
|
744
|
+
});
|
|
745
|
+
const AnimatedView = R.default.View;
|
|
746
|
+
return /* @__PURE__ */ jsx(
|
|
747
|
+
AnimatedView,
|
|
748
|
+
{
|
|
749
|
+
className: skeletonClass(props),
|
|
750
|
+
style: [animatedStyle, ...sizeStyles(props)],
|
|
751
|
+
testID: props.testID,
|
|
752
|
+
accessibilityElementsHidden: true,
|
|
753
|
+
importantForAccessibility: "no-hide-descendants"
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
function AnimatedSkeleton(props) {
|
|
758
|
+
const opacity = useRef(new Animated.Value(LOW)).current;
|
|
759
|
+
const reduceMotion = useReducedMotion();
|
|
760
|
+
useEffect(() => {
|
|
761
|
+
if (reduceMotion) {
|
|
762
|
+
opacity.setValue(STILL);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
const animation = Animated.loop(
|
|
766
|
+
Animated.sequence([
|
|
767
|
+
Animated.timing(opacity, {
|
|
768
|
+
toValue: HIGH,
|
|
769
|
+
duration: PULSE_MS,
|
|
770
|
+
easing: Easing.inOut(Easing.ease),
|
|
771
|
+
useNativeDriver: true
|
|
772
|
+
}),
|
|
773
|
+
Animated.timing(opacity, {
|
|
774
|
+
toValue: LOW,
|
|
775
|
+
duration: PULSE_MS,
|
|
776
|
+
easing: Easing.inOut(Easing.ease),
|
|
777
|
+
useNativeDriver: true
|
|
778
|
+
})
|
|
779
|
+
])
|
|
780
|
+
);
|
|
781
|
+
animation.start();
|
|
782
|
+
return () => animation.stop();
|
|
783
|
+
}, [opacity, reduceMotion]);
|
|
784
|
+
return /* @__PURE__ */ jsx(
|
|
785
|
+
Animated.View,
|
|
786
|
+
{
|
|
787
|
+
className: skeletonClass(props),
|
|
788
|
+
style: [{ opacity }, ...sizeStyles(props)],
|
|
789
|
+
testID: props.testID,
|
|
790
|
+
accessibilityElementsHidden: true,
|
|
791
|
+
importantForAccessibility: "no-hide-descendants"
|
|
792
|
+
}
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
var alertVariants = cva(
|
|
796
|
+
"rounded-lg border p-4",
|
|
797
|
+
{
|
|
798
|
+
variants: {
|
|
799
|
+
variant: {
|
|
800
|
+
default: "border-border bg-background",
|
|
801
|
+
destructive: "border-destructive/50 bg-destructive/10",
|
|
802
|
+
success: "border-success/50 bg-success/10",
|
|
803
|
+
warning: "border-warning/50 bg-warning/10",
|
|
804
|
+
info: "border-info/50 bg-info/10"
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
defaultVariants: {
|
|
808
|
+
variant: "default"
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
);
|
|
812
|
+
var alertTitleTextVariants = cva("text-base font-semibold leading-6", {
|
|
813
|
+
variants: {
|
|
814
|
+
variant: {
|
|
815
|
+
default: "text-foreground",
|
|
816
|
+
destructive: "text-destructive",
|
|
817
|
+
success: "text-success",
|
|
818
|
+
warning: "text-warning",
|
|
819
|
+
info: "text-info"
|
|
820
|
+
}
|
|
821
|
+
},
|
|
822
|
+
defaultVariants: {
|
|
823
|
+
variant: "default"
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
var alertDescriptionTextVariants = cva("text-sm leading-5", {
|
|
827
|
+
variants: {
|
|
828
|
+
variant: {
|
|
829
|
+
default: "text-muted-foreground",
|
|
830
|
+
destructive: "text-destructive",
|
|
831
|
+
success: "text-success",
|
|
832
|
+
warning: "text-warning",
|
|
833
|
+
info: "text-info"
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
defaultVariants: {
|
|
837
|
+
variant: "default"
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
function NativeAlert({
|
|
841
|
+
className,
|
|
842
|
+
variant,
|
|
843
|
+
children,
|
|
844
|
+
...props
|
|
845
|
+
}) {
|
|
846
|
+
return /* @__PURE__ */ jsx(
|
|
847
|
+
View,
|
|
848
|
+
{
|
|
849
|
+
className: cn(alertVariants({ variant }), className),
|
|
850
|
+
accessibilityRole: "alert",
|
|
851
|
+
...props,
|
|
852
|
+
children
|
|
853
|
+
}
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
function NativeAlertTitle({
|
|
857
|
+
className,
|
|
858
|
+
variant,
|
|
859
|
+
children
|
|
860
|
+
}) {
|
|
861
|
+
return /* @__PURE__ */ jsx(
|
|
862
|
+
Text,
|
|
863
|
+
{
|
|
864
|
+
className: cn(alertTitleTextVariants({ variant }), className),
|
|
865
|
+
children
|
|
866
|
+
}
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
function NativeAlertDescription({
|
|
870
|
+
className,
|
|
871
|
+
variant,
|
|
872
|
+
children
|
|
873
|
+
}) {
|
|
874
|
+
return /* @__PURE__ */ jsx(
|
|
875
|
+
Text,
|
|
876
|
+
{
|
|
877
|
+
className: cn(
|
|
878
|
+
alertDescriptionTextVariants({ variant }),
|
|
879
|
+
"mt-1",
|
|
880
|
+
className
|
|
881
|
+
),
|
|
882
|
+
children
|
|
883
|
+
}
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
var FILL = { position: "absolute", top: 0, right: 0, bottom: 0, left: 0 };
|
|
887
|
+
function NativeAvatar({
|
|
888
|
+
className,
|
|
889
|
+
src,
|
|
890
|
+
alt,
|
|
891
|
+
fallback,
|
|
892
|
+
size = 40,
|
|
893
|
+
placeholder,
|
|
894
|
+
recyclingKey,
|
|
895
|
+
testID
|
|
896
|
+
}) {
|
|
897
|
+
const { image: ExpoImage } = useGenesisModules();
|
|
898
|
+
const reducedMotion = useReducedMotion();
|
|
899
|
+
const [failedSrc, setFailedSrc] = useState(null);
|
|
900
|
+
const [loadedSrc, setLoadedSrc] = useState(null);
|
|
901
|
+
const showImage = !!src && failedSrc !== src;
|
|
902
|
+
const loaded = !!src && loadedSrc === src;
|
|
903
|
+
const imageProps = {
|
|
904
|
+
accessible: false,
|
|
905
|
+
onError: () => setFailedSrc(src ?? null),
|
|
906
|
+
onLoad: () => setLoadedSrc(src ?? null)
|
|
907
|
+
};
|
|
908
|
+
return /* @__PURE__ */ jsxs(
|
|
909
|
+
View,
|
|
910
|
+
{
|
|
911
|
+
className: cn(
|
|
912
|
+
"items-center justify-center overflow-hidden rounded-full bg-muted",
|
|
913
|
+
className
|
|
914
|
+
),
|
|
915
|
+
style: [{ width: size, height: size }],
|
|
916
|
+
accessible: true,
|
|
917
|
+
accessibilityRole: "image",
|
|
918
|
+
accessibilityLabel: alt || fallback || "Avatar",
|
|
919
|
+
testID,
|
|
920
|
+
children: [
|
|
921
|
+
!showImage || !loaded ? /* @__PURE__ */ jsx(
|
|
922
|
+
Text,
|
|
923
|
+
{
|
|
924
|
+
className: "text-sm font-medium text-muted-foreground",
|
|
925
|
+
accessibilityElementsHidden: true,
|
|
926
|
+
importantForAccessibility: "no",
|
|
927
|
+
style: {
|
|
928
|
+
fontSize: Math.round(size * 0.4),
|
|
929
|
+
lineHeight: Math.round(size * 0.5)
|
|
930
|
+
},
|
|
931
|
+
children: fallback || "?"
|
|
932
|
+
}
|
|
933
|
+
) : null,
|
|
934
|
+
showImage ? ExpoImage ? /* @__PURE__ */ jsx(
|
|
935
|
+
ExpoImage,
|
|
936
|
+
{
|
|
937
|
+
...imageProps,
|
|
938
|
+
testID: testID ? `${testID}-image` : void 0,
|
|
939
|
+
source: { uri: src },
|
|
940
|
+
style: FILL,
|
|
941
|
+
contentFit: "cover",
|
|
942
|
+
cachePolicy: "memory-disk",
|
|
943
|
+
placeholder,
|
|
944
|
+
placeholderContentFit: "cover",
|
|
945
|
+
transition: reducedMotion ? null : 150,
|
|
946
|
+
recyclingKey: recyclingKey ?? src
|
|
947
|
+
}
|
|
948
|
+
) : /* @__PURE__ */ jsx(
|
|
949
|
+
Image,
|
|
950
|
+
{
|
|
951
|
+
...imageProps,
|
|
952
|
+
testID: testID ? `${testID}-image` : void 0,
|
|
953
|
+
source: { uri: src },
|
|
954
|
+
style: FILL,
|
|
955
|
+
resizeMode: "cover"
|
|
956
|
+
}
|
|
957
|
+
) : null
|
|
958
|
+
]
|
|
959
|
+
}
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
function NativeCheckbox({
|
|
963
|
+
className,
|
|
964
|
+
checked: controlledChecked,
|
|
965
|
+
defaultChecked = false,
|
|
966
|
+
onCheckedChange,
|
|
967
|
+
disabled,
|
|
968
|
+
...props
|
|
969
|
+
}) {
|
|
970
|
+
const [uncontrolledChecked, setUncontrolledChecked] = useState(defaultChecked);
|
|
971
|
+
const isChecked = controlledChecked ?? uncontrolledChecked;
|
|
972
|
+
function handlePress() {
|
|
973
|
+
const next = !isChecked;
|
|
974
|
+
if (controlledChecked === void 0) {
|
|
975
|
+
setUncontrolledChecked(next);
|
|
976
|
+
}
|
|
977
|
+
onCheckedChange?.(next);
|
|
978
|
+
}
|
|
979
|
+
return /* @__PURE__ */ jsx(
|
|
980
|
+
Pressable,
|
|
981
|
+
{
|
|
982
|
+
className: cn(
|
|
983
|
+
"h-5 w-5 items-center justify-center rounded border border-border",
|
|
984
|
+
isChecked && "border-primary bg-primary",
|
|
985
|
+
disabled && "opacity-50",
|
|
986
|
+
className
|
|
987
|
+
),
|
|
988
|
+
onPress: handlePress,
|
|
989
|
+
disabled,
|
|
990
|
+
accessibilityRole: "checkbox",
|
|
991
|
+
accessibilityState: { checked: isChecked },
|
|
992
|
+
...props,
|
|
993
|
+
children: isChecked ? /* @__PURE__ */ jsx(View, { className: "h-2.5 w-2.5 rounded-sm bg-primary-foreground" }) : null
|
|
994
|
+
}
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
function NativeLabel({
|
|
998
|
+
className,
|
|
999
|
+
children,
|
|
1000
|
+
disabled,
|
|
1001
|
+
...props
|
|
1002
|
+
}) {
|
|
1003
|
+
return /* @__PURE__ */ jsx(
|
|
1004
|
+
Text,
|
|
1005
|
+
{
|
|
1006
|
+
className: cn(
|
|
1007
|
+
"text-sm font-medium text-foreground",
|
|
1008
|
+
disabled && "opacity-70",
|
|
1009
|
+
className
|
|
1010
|
+
),
|
|
1011
|
+
accessibilityState: disabled ? { disabled } : void 0,
|
|
1012
|
+
...props,
|
|
1013
|
+
children
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
var SelectContext = createContext(null);
|
|
1018
|
+
function useSelect() {
|
|
1019
|
+
const context = useContext(SelectContext);
|
|
1020
|
+
if (!context)
|
|
1021
|
+
throw new Error("Select components must be used within <NativeSelect>");
|
|
1022
|
+
return context;
|
|
1023
|
+
}
|
|
1024
|
+
function NativeSelect({
|
|
1025
|
+
value: controlledValue,
|
|
1026
|
+
defaultValue = "",
|
|
1027
|
+
onValueChange: controlledOnValueChange,
|
|
1028
|
+
children
|
|
1029
|
+
}) {
|
|
1030
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
1031
|
+
const [open, setOpen] = useState(false);
|
|
1032
|
+
const value = controlledValue ?? uncontrolledValue;
|
|
1033
|
+
const onValueChange = controlledOnValueChange ?? setUncontrolledValue;
|
|
1034
|
+
return /* @__PURE__ */ jsx(SelectContext.Provider, { value: { value, onValueChange, open, setOpen }, children });
|
|
1035
|
+
}
|
|
1036
|
+
function NativeSelectTrigger({
|
|
1037
|
+
className,
|
|
1038
|
+
children,
|
|
1039
|
+
placeholder,
|
|
1040
|
+
disabled,
|
|
1041
|
+
...props
|
|
1042
|
+
}) {
|
|
1043
|
+
const { value, open, setOpen } = useSelect();
|
|
1044
|
+
return /* @__PURE__ */ jsxs(
|
|
1045
|
+
Pressable,
|
|
1046
|
+
{
|
|
1047
|
+
className: cn(
|
|
1048
|
+
"h-10 flex-row items-center justify-between rounded-md border border-input bg-background px-3",
|
|
1049
|
+
disabled && "opacity-50",
|
|
1050
|
+
className
|
|
1051
|
+
),
|
|
1052
|
+
onPress: () => setOpen(true),
|
|
1053
|
+
disabled,
|
|
1054
|
+
accessibilityRole: "button",
|
|
1055
|
+
accessibilityState: { expanded: open, disabled },
|
|
1056
|
+
...props,
|
|
1057
|
+
children: [
|
|
1058
|
+
children ?? /* @__PURE__ */ jsx(
|
|
1059
|
+
Text,
|
|
1060
|
+
{
|
|
1061
|
+
className: cn(
|
|
1062
|
+
"text-sm",
|
|
1063
|
+
value ? "text-foreground" : "text-muted-foreground"
|
|
1064
|
+
),
|
|
1065
|
+
children: value || placeholder || "Select..."
|
|
1066
|
+
}
|
|
1067
|
+
),
|
|
1068
|
+
/* @__PURE__ */ jsx(Text, { className: "text-sm text-muted-foreground", children: "\u25BE" })
|
|
1069
|
+
]
|
|
1070
|
+
}
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
function NativeSelectContent({
|
|
1074
|
+
className,
|
|
1075
|
+
children
|
|
1076
|
+
}) {
|
|
1077
|
+
const { open, setOpen } = useSelect();
|
|
1078
|
+
if (!open) return null;
|
|
1079
|
+
return /* @__PURE__ */ jsx(Modal, { transparent: true, animationType: "fade", onRequestClose: () => setOpen(false), children: /* @__PURE__ */ jsx(Pressable, { className: "flex-1 items-center justify-center bg-black/50", onPress: () => setOpen(false), children: /* @__PURE__ */ jsx(Pressable, { onPress: () => {
|
|
1080
|
+
}, children: /* @__PURE__ */ jsx(
|
|
1081
|
+
View,
|
|
1082
|
+
{
|
|
1083
|
+
className: cn(
|
|
1084
|
+
"min-w-[10rem] rounded-md border border-border bg-popover p-1 shadow-md",
|
|
1085
|
+
className
|
|
1086
|
+
),
|
|
1087
|
+
children
|
|
1088
|
+
}
|
|
1089
|
+
) }) }) });
|
|
1090
|
+
}
|
|
1091
|
+
function NativeSelectItem({
|
|
1092
|
+
className,
|
|
1093
|
+
value,
|
|
1094
|
+
children,
|
|
1095
|
+
...props
|
|
1096
|
+
}) {
|
|
1097
|
+
const { value: selectedValue, onValueChange, setOpen } = useSelect();
|
|
1098
|
+
const isSelected = selectedValue === value;
|
|
1099
|
+
return /* @__PURE__ */ jsx(
|
|
1100
|
+
Pressable,
|
|
1101
|
+
{
|
|
1102
|
+
className: cn(
|
|
1103
|
+
"flex-row items-center rounded-sm px-2 py-1.5",
|
|
1104
|
+
isSelected && "bg-accent",
|
|
1105
|
+
className
|
|
1106
|
+
),
|
|
1107
|
+
onPress: () => {
|
|
1108
|
+
onValueChange(value);
|
|
1109
|
+
setOpen(false);
|
|
1110
|
+
},
|
|
1111
|
+
...props,
|
|
1112
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx(
|
|
1113
|
+
Text,
|
|
1114
|
+
{
|
|
1115
|
+
className: cn(
|
|
1116
|
+
"text-sm",
|
|
1117
|
+
isSelected ? "text-accent-foreground" : "text-popover-foreground"
|
|
1118
|
+
),
|
|
1119
|
+
children
|
|
1120
|
+
}
|
|
1121
|
+
) : children
|
|
1122
|
+
}
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
function NativeSwitch({
|
|
1126
|
+
className,
|
|
1127
|
+
checked,
|
|
1128
|
+
onCheckedChange,
|
|
1129
|
+
disabled,
|
|
1130
|
+
...props
|
|
1131
|
+
}) {
|
|
1132
|
+
return /* @__PURE__ */ jsx(View, { className: cn(disabled && "opacity-50", className), children: /* @__PURE__ */ jsx(
|
|
1133
|
+
Switch,
|
|
1134
|
+
{
|
|
1135
|
+
value: checked,
|
|
1136
|
+
onValueChange: onCheckedChange,
|
|
1137
|
+
disabled,
|
|
1138
|
+
accessibilityState: { checked, disabled },
|
|
1139
|
+
...props
|
|
1140
|
+
}
|
|
1141
|
+
) });
|
|
1142
|
+
}
|
|
1143
|
+
function NativeTextarea({
|
|
1144
|
+
className,
|
|
1145
|
+
inputClassName,
|
|
1146
|
+
label,
|
|
1147
|
+
error,
|
|
1148
|
+
editable = true,
|
|
1149
|
+
rows = 4,
|
|
1150
|
+
placeholderTextColor,
|
|
1151
|
+
...props
|
|
1152
|
+
}) {
|
|
1153
|
+
return /* @__PURE__ */ jsxs(View, { className: cn("gap-1.5", className), children: [
|
|
1154
|
+
label ? /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: label }) : null,
|
|
1155
|
+
/* @__PURE__ */ jsx(
|
|
1156
|
+
TextInput,
|
|
1157
|
+
{
|
|
1158
|
+
className: cn(
|
|
1159
|
+
"rounded-md border border-input bg-background px-3 py-2 text-base text-foreground",
|
|
1160
|
+
!editable && "opacity-50",
|
|
1161
|
+
error && "border-destructive",
|
|
1162
|
+
inputClassName
|
|
1163
|
+
),
|
|
1164
|
+
multiline: true,
|
|
1165
|
+
numberOfLines: rows,
|
|
1166
|
+
editable,
|
|
1167
|
+
placeholderTextColor: placeholderTextColor ?? nativeColors.neutral[400],
|
|
1168
|
+
...props
|
|
1169
|
+
}
|
|
1170
|
+
),
|
|
1171
|
+
error ? /* @__PURE__ */ jsx(Text, { className: "text-sm text-destructive", children: error }) : null
|
|
1172
|
+
] });
|
|
1173
|
+
}
|
|
1174
|
+
var FILL2 = { position: "absolute", top: 0, right: 0, bottom: 0, left: 0 };
|
|
1175
|
+
function NativeImage({
|
|
1176
|
+
src,
|
|
1177
|
+
alt,
|
|
1178
|
+
className,
|
|
1179
|
+
width,
|
|
1180
|
+
height,
|
|
1181
|
+
contentFit = "cover",
|
|
1182
|
+
placeholder,
|
|
1183
|
+
recyclingKey,
|
|
1184
|
+
priority,
|
|
1185
|
+
onError,
|
|
1186
|
+
testID
|
|
1187
|
+
}) {
|
|
1188
|
+
const { image: ExpoImage } = useGenesisModules();
|
|
1189
|
+
const reducedMotion = useReducedMotion();
|
|
1190
|
+
const a11y = alt ? { accessible: true, accessibilityRole: "image", accessibilityLabel: alt } : { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants" };
|
|
1191
|
+
return /* @__PURE__ */ jsx(
|
|
1192
|
+
View,
|
|
1193
|
+
{
|
|
1194
|
+
...a11y,
|
|
1195
|
+
testID,
|
|
1196
|
+
className: cn("overflow-hidden bg-muted", className),
|
|
1197
|
+
style: width !== void 0 || height !== void 0 ? { width, height } : void 0,
|
|
1198
|
+
children: ExpoImage ? /* @__PURE__ */ jsx(
|
|
1199
|
+
ExpoImage,
|
|
1200
|
+
{
|
|
1201
|
+
testID: testID ? `${testID}-image` : void 0,
|
|
1202
|
+
accessible: false,
|
|
1203
|
+
source: { uri: src },
|
|
1204
|
+
style: FILL2,
|
|
1205
|
+
contentFit,
|
|
1206
|
+
cachePolicy: "memory-disk",
|
|
1207
|
+
placeholder,
|
|
1208
|
+
placeholderContentFit: contentFit,
|
|
1209
|
+
transition: reducedMotion ? null : 150,
|
|
1210
|
+
recyclingKey: recyclingKey ?? src,
|
|
1211
|
+
priority,
|
|
1212
|
+
onError
|
|
1213
|
+
}
|
|
1214
|
+
) : /* @__PURE__ */ jsx(
|
|
1215
|
+
Image,
|
|
1216
|
+
{
|
|
1217
|
+
testID: testID ? `${testID}-image` : void 0,
|
|
1218
|
+
accessible: false,
|
|
1219
|
+
source: { uri: src },
|
|
1220
|
+
style: FILL2,
|
|
1221
|
+
resizeMode: contentFit,
|
|
1222
|
+
onError
|
|
1223
|
+
}
|
|
1224
|
+
)
|
|
1225
|
+
}
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
export { NativeAlert, NativeAlertDescription, NativeAlertTitle, NativeAvatar, NativeBanner, NativeCard, NativeCardContent, NativeCardDescription, NativeCardFooter, NativeCardHeader, NativeCardTitle, NativeCheckbox, NativeDatePicker, NativeImage, NativeInlineAlert, NativeLabel, NativeSearchBar, NativeSegmentedControl, NativeSelect, NativeSelectContent, NativeSelectItem, NativeSelectTrigger, NativeSeparator, NativeSheet, NativeSheetProvider, NativeSheetScrollView, NativeSkeleton, NativeSwitch, NativeTextarea, NativeTimePicker, alertVariants };
|
|
1230
|
+
//# sourceMappingURL=chunk-56QLEHHV.js.map
|
|
1231
|
+
//# sourceMappingURL=chunk-56QLEHHV.js.map
|