@marktiderman/genesis-ui-native 2.2.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 +82 -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-2WCXMJL6.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 +142 -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 +320 -4
- 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/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__/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/auth-screen.tsx +6 -3
- package/src/layouts/google-sign-in.tsx +42 -0
- package/src/layouts/inbox-page.tsx +408 -0
- package/src/layouts/index.ts +37 -2
- package/src/layouts/keyboard.tsx +61 -9
- package/src/layouts/notifications-page.tsx +133 -16
- 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-2WCXMJL6.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-FZTUSM56.js +0 -935
- package/dist/chunk-FZTUSM56.js.map +0 -1
- package/dist/chunk-TXJT55JC.js.map +0 -1
- package/dist/chunk-ULS7I6ZS.js.map +0 -1
package/dist/chunk-FZTUSM56.js
DELETED
|
@@ -1,935 +0,0 @@
|
|
|
1
|
-
import { NativeSectionListHeader, NativeListItem, NativeListItemDivider, NativeEmptyState } from './chunk-ULS7I6ZS.js';
|
|
2
|
-
import { NativeText, NativeButton, NativeInput } from './chunk-5HRGIA6F.js';
|
|
3
|
-
import { useThemeMode, useThemeRoles } from './chunk-Z3AQYVUA.js';
|
|
4
|
-
import { cn } from './chunk-OHZD7KRO.js';
|
|
5
|
-
import { ScrollView, View, StatusBar, Pressable, Text, TextInput, Platform, Alert, KeyboardAvoidingView, SectionList, RefreshControl } from 'react-native';
|
|
6
|
-
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
7
|
-
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
8
|
-
import { nativeColors } from '@marktiderman/genesis-design-system/tokens/native';
|
|
9
|
-
import { createContext, Fragment, createElement, useContext, useCallback, useMemo, useState, useRef } from 'react';
|
|
10
|
-
import { renderSlot } from '@marktiderman/genesis-core/slots';
|
|
11
|
-
|
|
12
|
-
function composeHeaderOptions(props) {
|
|
13
|
-
const {
|
|
14
|
-
headerTitle,
|
|
15
|
-
headerLeft,
|
|
16
|
-
headerRight,
|
|
17
|
-
large,
|
|
18
|
-
scrollEdgeBehavior,
|
|
19
|
-
headerOptions
|
|
20
|
-
} = props;
|
|
21
|
-
const opts = {};
|
|
22
|
-
if (headerTitle !== void 0) opts.title = headerTitle;
|
|
23
|
-
if (headerLeft) opts.headerLeft = headerLeft;
|
|
24
|
-
if (headerRight) opts.headerRight = headerRight;
|
|
25
|
-
if (large) {
|
|
26
|
-
opts.headerLargeTitle = true;
|
|
27
|
-
if (scrollEdgeBehavior === "transparent") {
|
|
28
|
-
opts.headerTransparent = true;
|
|
29
|
-
} else if (scrollEdgeBehavior === "opaque") {
|
|
30
|
-
opts.headerLargeTitleShadowVisible = true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (headerOptions) {
|
|
34
|
-
Object.assign(opts, headerOptions);
|
|
35
|
-
}
|
|
36
|
-
return opts;
|
|
37
|
-
}
|
|
38
|
-
var DEFAULT_EDGES = ["left", "right"];
|
|
39
|
-
var TRANSLUCENT_ANDROID_BAR = { translucent: true, backgroundColor: "transparent" };
|
|
40
|
-
function resolveBarStyle(statusBar, resolvedMode) {
|
|
41
|
-
if (statusBar === "auto") {
|
|
42
|
-
return resolvedMode === "dark" ? "light-content" : "dark-content";
|
|
43
|
-
}
|
|
44
|
-
if (statusBar === "light") return "light-content";
|
|
45
|
-
if (statusBar === "dark") return "dark-content";
|
|
46
|
-
return "default";
|
|
47
|
-
}
|
|
48
|
-
function ScreenContainer({
|
|
49
|
-
children,
|
|
50
|
-
scroll = false,
|
|
51
|
-
safeAreaEdges = DEFAULT_EDGES,
|
|
52
|
-
statusBar = "auto",
|
|
53
|
-
themeMode = "system",
|
|
54
|
-
className,
|
|
55
|
-
contentClassName,
|
|
56
|
-
keyboardShouldPersistTaps = "handled",
|
|
57
|
-
style,
|
|
58
|
-
testID
|
|
59
|
-
}) {
|
|
60
|
-
const osMode = useThemeMode();
|
|
61
|
-
const resolvedMode = themeMode === "system" ? osMode : themeMode;
|
|
62
|
-
const barStyle = resolveBarStyle(statusBar, resolvedMode);
|
|
63
|
-
const body = scroll ? /* @__PURE__ */ jsx(
|
|
64
|
-
ScrollView,
|
|
65
|
-
{
|
|
66
|
-
testID: testID ? `${testID}-scroll` : void 0,
|
|
67
|
-
keyboardShouldPersistTaps,
|
|
68
|
-
contentInsetAdjustmentBehavior: "automatic",
|
|
69
|
-
contentContainerClassName: cn("flex-grow", contentClassName),
|
|
70
|
-
children
|
|
71
|
-
}
|
|
72
|
-
) : /* @__PURE__ */ jsx(
|
|
73
|
-
View,
|
|
74
|
-
{
|
|
75
|
-
testID: testID ? `${testID}-body` : void 0,
|
|
76
|
-
className: cn("flex-1", contentClassName),
|
|
77
|
-
children
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
return /* @__PURE__ */ jsxs(
|
|
81
|
-
SafeAreaView,
|
|
82
|
-
{
|
|
83
|
-
testID: testID ?? "screen-container",
|
|
84
|
-
edges: safeAreaEdges,
|
|
85
|
-
className: cn("flex-1 bg-background", className),
|
|
86
|
-
style,
|
|
87
|
-
children: [
|
|
88
|
-
statusBar !== "hidden" ? /* @__PURE__ */ jsx(
|
|
89
|
-
StatusBar,
|
|
90
|
-
{
|
|
91
|
-
barStyle,
|
|
92
|
-
...TRANSLUCENT_ANDROID_BAR
|
|
93
|
-
}
|
|
94
|
-
) : /* @__PURE__ */ jsx(StatusBar, { hidden: true }),
|
|
95
|
-
body
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
function NavBarSaveButton({
|
|
101
|
-
onPress,
|
|
102
|
-
label = "Save",
|
|
103
|
-
disabled,
|
|
104
|
-
loading,
|
|
105
|
-
destructive,
|
|
106
|
-
className,
|
|
107
|
-
testID
|
|
108
|
-
}) {
|
|
109
|
-
const isDisabled = !!disabled || !!loading || !onPress;
|
|
110
|
-
return /* @__PURE__ */ jsx(
|
|
111
|
-
Pressable,
|
|
112
|
-
{
|
|
113
|
-
testID: testID ?? "nav-bar-save-button",
|
|
114
|
-
accessibilityRole: "button",
|
|
115
|
-
accessibilityLabel: label,
|
|
116
|
-
accessibilityState: { disabled: isDisabled, busy: !!loading },
|
|
117
|
-
onPress: isDisabled ? void 0 : onPress,
|
|
118
|
-
disabled: isDisabled,
|
|
119
|
-
className: cn("min-h-[44px] justify-center px-3", className),
|
|
120
|
-
hitSlop: 8,
|
|
121
|
-
children: /* @__PURE__ */ jsx(
|
|
122
|
-
Text,
|
|
123
|
-
{
|
|
124
|
-
className: cn(
|
|
125
|
-
"text-base font-semibold",
|
|
126
|
-
destructive ? "text-destructive" : "text-primary",
|
|
127
|
-
isDisabled && "opacity-40"
|
|
128
|
-
),
|
|
129
|
-
children: loading ? "\u2026" : label
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
function NavBarTitle({
|
|
136
|
-
title,
|
|
137
|
-
subtitle,
|
|
138
|
-
onPress,
|
|
139
|
-
className,
|
|
140
|
-
testID
|
|
141
|
-
}) {
|
|
142
|
-
const inner = /* @__PURE__ */ jsxs(View, { className: cn("items-center justify-center", className), children: [
|
|
143
|
-
/* @__PURE__ */ jsx(
|
|
144
|
-
Text,
|
|
145
|
-
{
|
|
146
|
-
testID: testID ? `${testID}-title` : void 0,
|
|
147
|
-
className: "text-base font-semibold text-foreground",
|
|
148
|
-
numberOfLines: 1,
|
|
149
|
-
children: title
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
subtitle ? /* @__PURE__ */ jsx(
|
|
153
|
-
Text,
|
|
154
|
-
{
|
|
155
|
-
testID: testID ? `${testID}-subtitle` : void 0,
|
|
156
|
-
className: "text-xs text-muted-foreground",
|
|
157
|
-
numberOfLines: 1,
|
|
158
|
-
children: subtitle
|
|
159
|
-
}
|
|
160
|
-
) : null
|
|
161
|
-
] });
|
|
162
|
-
if (onPress) {
|
|
163
|
-
return /* @__PURE__ */ jsx(
|
|
164
|
-
Pressable,
|
|
165
|
-
{
|
|
166
|
-
testID: testID ?? "nav-bar-title",
|
|
167
|
-
accessibilityRole: "button",
|
|
168
|
-
accessibilityLabel: subtitle ? `${title}, ${subtitle}` : title,
|
|
169
|
-
onPress,
|
|
170
|
-
hitSlop: 8,
|
|
171
|
-
children: inner
|
|
172
|
-
}
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
return /* @__PURE__ */ jsx(View, { testID: testID ?? "nav-bar-title", accessibilityRole: "header", children: inner });
|
|
176
|
-
}
|
|
177
|
-
function NavBarSearchBar({
|
|
178
|
-
value,
|
|
179
|
-
onChangeText,
|
|
180
|
-
placeholder = "Search",
|
|
181
|
-
onSubmit,
|
|
182
|
-
clearable = true,
|
|
183
|
-
className,
|
|
184
|
-
testID
|
|
185
|
-
}) {
|
|
186
|
-
return /* @__PURE__ */ jsxs(
|
|
187
|
-
View,
|
|
188
|
-
{
|
|
189
|
-
testID: testID ?? "nav-bar-search",
|
|
190
|
-
className: cn(
|
|
191
|
-
"min-h-[36px] flex-row items-center rounded-full bg-muted px-3",
|
|
192
|
-
className
|
|
193
|
-
),
|
|
194
|
-
children: [
|
|
195
|
-
/* @__PURE__ */ jsx(
|
|
196
|
-
TextInput,
|
|
197
|
-
{
|
|
198
|
-
testID: testID ? `${testID}-input` : void 0,
|
|
199
|
-
accessibilityLabel: placeholder,
|
|
200
|
-
value,
|
|
201
|
-
onChangeText,
|
|
202
|
-
onSubmitEditing: onSubmit,
|
|
203
|
-
placeholder,
|
|
204
|
-
placeholderTextColor: nativeColors.neutral[400],
|
|
205
|
-
returnKeyType: "search",
|
|
206
|
-
autoCorrect: false,
|
|
207
|
-
autoCapitalize: "none",
|
|
208
|
-
clearButtonMode: clearable ? "while-editing" : "never",
|
|
209
|
-
className: "flex-1 text-base text-foreground"
|
|
210
|
-
}
|
|
211
|
-
),
|
|
212
|
-
clearable && value.length > 0 ? /* @__PURE__ */ jsx(
|
|
213
|
-
Pressable,
|
|
214
|
-
{
|
|
215
|
-
testID: testID ? `${testID}-clear` : void 0,
|
|
216
|
-
accessibilityRole: "button",
|
|
217
|
-
accessibilityLabel: "Clear search",
|
|
218
|
-
onPress: () => onChangeText(""),
|
|
219
|
-
hitSlop: 8,
|
|
220
|
-
className: "ml-2 px-1",
|
|
221
|
-
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-muted-foreground", children: "\xD7" })
|
|
222
|
-
}
|
|
223
|
-
) : null
|
|
224
|
-
]
|
|
225
|
-
}
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
function getSettingsPageStackOptions(props) {
|
|
229
|
-
return composeHeaderOptions({
|
|
230
|
-
headerTitle: props.headerTitle ?? "Settings",
|
|
231
|
-
large: props.large ?? true,
|
|
232
|
-
scrollEdgeBehavior: props.scrollEdgeBehavior ?? "match",
|
|
233
|
-
headerLeft: props.headerLeft,
|
|
234
|
-
headerRight: props.headerRight,
|
|
235
|
-
headerOptions: props.headerOptions
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
function SettingsPage({
|
|
239
|
-
sections,
|
|
240
|
-
dangerousActions,
|
|
241
|
-
className,
|
|
242
|
-
testID = "settings-page",
|
|
243
|
-
children,
|
|
244
|
-
slots = {},
|
|
245
|
-
slotProps = {}
|
|
246
|
-
}) {
|
|
247
|
-
const colors = useThemeRoles();
|
|
248
|
-
const inset = Platform.OS === "ios";
|
|
249
|
-
return /* @__PURE__ */ jsxs(
|
|
250
|
-
ScreenContainer,
|
|
251
|
-
{
|
|
252
|
-
scroll: true,
|
|
253
|
-
safeAreaEdges: ["left", "right", "bottom"],
|
|
254
|
-
testID,
|
|
255
|
-
contentClassName: "pb-8",
|
|
256
|
-
className,
|
|
257
|
-
style: { backgroundColor: colors.groupedBackground },
|
|
258
|
-
children: [
|
|
259
|
-
children ? /* @__PURE__ */ jsx(View, { className: "px-4 pt-2", children }) : null,
|
|
260
|
-
sections.map((section) => /* @__PURE__ */ jsxs(
|
|
261
|
-
View,
|
|
262
|
-
{
|
|
263
|
-
testID: `${testID}-section-${section.id}`,
|
|
264
|
-
className: "mt-6",
|
|
265
|
-
children: [
|
|
266
|
-
section.title ? renderSlot(
|
|
267
|
-
DefaultSectionHeader,
|
|
268
|
-
slots.sectionHeader,
|
|
269
|
-
{ title: section.title, testID: `${testID}-section-${section.id}-header` },
|
|
270
|
-
slotProps.sectionHeader
|
|
271
|
-
) : null,
|
|
272
|
-
/* @__PURE__ */ jsx(
|
|
273
|
-
View,
|
|
274
|
-
{
|
|
275
|
-
className: inset ? "mx-4 overflow-hidden rounded-xl" : "border-y",
|
|
276
|
-
style: { backgroundColor: colors.surface, borderColor: colors.separator },
|
|
277
|
-
children: section.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(Fragment, { children: renderSlot(
|
|
278
|
-
DefaultRow,
|
|
279
|
-
slots.row,
|
|
280
|
-
{ ...row, testID: row.testID ?? `${testID}-row-${row.id}`, isLast: rowIndex === section.rows.length - 1 },
|
|
281
|
-
slotProps.row
|
|
282
|
-
) }, row.id))
|
|
283
|
-
}
|
|
284
|
-
),
|
|
285
|
-
section.footnote ? renderSlot(DefaultFootnote, slots.footnote, { text: section.footnote }, slotProps.footnote) : null
|
|
286
|
-
]
|
|
287
|
-
},
|
|
288
|
-
section.id
|
|
289
|
-
)),
|
|
290
|
-
dangerousActions && dangerousActions.length > 0 ? renderSlot(
|
|
291
|
-
DefaultDangerousActions,
|
|
292
|
-
slots.dangerousActions,
|
|
293
|
-
{
|
|
294
|
-
actions: dangerousActions.map((action) => ({ ...action, testID: action.testID ?? `${testID}-danger-${slug(action.label)}` })),
|
|
295
|
-
testID: `${testID}-dangerous-actions`
|
|
296
|
-
},
|
|
297
|
-
slotProps.dangerousActions
|
|
298
|
-
) : null
|
|
299
|
-
]
|
|
300
|
-
}
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
function DefaultSectionHeader({ title, testID }) {
|
|
304
|
-
return /* @__PURE__ */ jsx(NativeSectionListHeader, { title, testID });
|
|
305
|
-
}
|
|
306
|
-
function DefaultRow({ isLast, id: _id, ...row }) {
|
|
307
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
308
|
-
/* @__PURE__ */ jsx(
|
|
309
|
-
NativeListItem,
|
|
310
|
-
{
|
|
311
|
-
testID: row.testID,
|
|
312
|
-
className: "bg-transparent",
|
|
313
|
-
title: row.title,
|
|
314
|
-
subtitle: row.subtitle,
|
|
315
|
-
leading: row.leading,
|
|
316
|
-
trailing: row.trailing,
|
|
317
|
-
showChevron: row.showChevron,
|
|
318
|
-
onPress: row.onPress,
|
|
319
|
-
disabled: row.disabled
|
|
320
|
-
}
|
|
321
|
-
),
|
|
322
|
-
isLast ? null : /* @__PURE__ */ jsx(NativeListItemDivider, { className: "ml-4" })
|
|
323
|
-
] });
|
|
324
|
-
}
|
|
325
|
-
function DefaultFootnote({ text }) {
|
|
326
|
-
return /* @__PURE__ */ jsx(NativeText, { preset: "body-sm", className: "px-4 pt-2 text-muted-foreground", children: text });
|
|
327
|
-
}
|
|
328
|
-
function DefaultDangerousActions({ actions, testID }) {
|
|
329
|
-
return /* @__PURE__ */ jsx(View, { testID, className: cn("mt-8 gap-2 px-4"), children: actions.map((action) => /* @__PURE__ */ jsx(
|
|
330
|
-
NativeButton,
|
|
331
|
-
{
|
|
332
|
-
testID: action.testID,
|
|
333
|
-
variant: action.emphasized ? "destructive" : "outline",
|
|
334
|
-
onPress: action.onPress,
|
|
335
|
-
children: action.label
|
|
336
|
-
},
|
|
337
|
-
action.label
|
|
338
|
-
)) });
|
|
339
|
-
}
|
|
340
|
-
function slug(s) {
|
|
341
|
-
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
342
|
-
}
|
|
343
|
-
var KeyboardScrollContext = createContext(null);
|
|
344
|
-
function KeyboardScrollProvider({ component, children }) {
|
|
345
|
-
return createElement(KeyboardScrollContext.Provider, { value: component }, children);
|
|
346
|
-
}
|
|
347
|
-
function useKeyboardScroll() {
|
|
348
|
-
return useContext(KeyboardScrollContext);
|
|
349
|
-
}
|
|
350
|
-
function confirmDiscardChanges(proceed) {
|
|
351
|
-
Alert.alert(
|
|
352
|
-
"Discard changes?",
|
|
353
|
-
"You have unsaved changes. Leave this screen and lose them?",
|
|
354
|
-
[
|
|
355
|
-
{ text: "Keep editing", style: "cancel" },
|
|
356
|
-
{
|
|
357
|
-
text: "Discard",
|
|
358
|
-
style: "destructive",
|
|
359
|
-
onPress: () => proceed()
|
|
360
|
-
}
|
|
361
|
-
]
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
function getSettingsSubPageStackOptions(props) {
|
|
365
|
-
const {
|
|
366
|
-
headerTitle,
|
|
367
|
-
dirty,
|
|
368
|
-
saving,
|
|
369
|
-
onSave,
|
|
370
|
-
saveLabel = "Save",
|
|
371
|
-
large = false,
|
|
372
|
-
scrollEdgeBehavior,
|
|
373
|
-
headerLeft,
|
|
374
|
-
headerRight,
|
|
375
|
-
headerOptions
|
|
376
|
-
} = props;
|
|
377
|
-
const resolvedHeaderRight = headerRight ?? (onSave ? () => /* @__PURE__ */ jsx(
|
|
378
|
-
NavBarSaveButton,
|
|
379
|
-
{
|
|
380
|
-
label: saveLabel,
|
|
381
|
-
onPress: () => {
|
|
382
|
-
void onSave();
|
|
383
|
-
},
|
|
384
|
-
disabled: !dirty,
|
|
385
|
-
loading: saving
|
|
386
|
-
}
|
|
387
|
-
) : void 0);
|
|
388
|
-
return composeHeaderOptions({
|
|
389
|
-
headerTitle,
|
|
390
|
-
headerLeft,
|
|
391
|
-
headerRight: resolvedHeaderRight,
|
|
392
|
-
large,
|
|
393
|
-
scrollEdgeBehavior,
|
|
394
|
-
headerOptions
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
function SettingsSubPage({
|
|
398
|
-
children,
|
|
399
|
-
onConfirmLeave,
|
|
400
|
-
className,
|
|
401
|
-
testID = "settings-sub-page"
|
|
402
|
-
}) {
|
|
403
|
-
useCallback(
|
|
404
|
-
(proceed) => {
|
|
405
|
-
if (onConfirmLeave === null) {
|
|
406
|
-
proceed();
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
const fn = onConfirmLeave ?? confirmDiscardChanges;
|
|
410
|
-
fn(proceed);
|
|
411
|
-
},
|
|
412
|
-
[onConfirmLeave]
|
|
413
|
-
);
|
|
414
|
-
const KeyboardScroll = useKeyboardScroll();
|
|
415
|
-
if (KeyboardScroll) {
|
|
416
|
-
return /* @__PURE__ */ jsx(ScreenContainer, { safeAreaEdges: ["left", "right", "bottom"], testID, children: /* @__PURE__ */ jsx(
|
|
417
|
-
KeyboardScroll,
|
|
418
|
-
{
|
|
419
|
-
testID: `${testID}-keyboard`,
|
|
420
|
-
keyboardShouldPersistTaps: "handled",
|
|
421
|
-
contentInsetAdjustmentBehavior: "automatic",
|
|
422
|
-
bottomOffset: 24,
|
|
423
|
-
children: /* @__PURE__ */ jsx(View, { className: cn("p-4", className), children: /* @__PURE__ */ jsx(View, { testID: `${testID}-form`, className: "gap-4", children }) })
|
|
424
|
-
}
|
|
425
|
-
) });
|
|
426
|
-
}
|
|
427
|
-
return /* @__PURE__ */ jsx(
|
|
428
|
-
KeyboardAvoidingView,
|
|
429
|
-
{
|
|
430
|
-
testID: `${testID}-kav`,
|
|
431
|
-
style: { flex: 1 },
|
|
432
|
-
behavior: Platform.OS === "ios" ? "padding" : void 0,
|
|
433
|
-
children: /* @__PURE__ */ jsx(
|
|
434
|
-
ScreenContainer,
|
|
435
|
-
{
|
|
436
|
-
scroll: true,
|
|
437
|
-
safeAreaEdges: ["left", "right", "bottom"],
|
|
438
|
-
testID,
|
|
439
|
-
contentClassName: cn("p-4", className),
|
|
440
|
-
keyboardShouldPersistTaps: "handled",
|
|
441
|
-
children: /* @__PURE__ */ jsx(View, { testID: `${testID}-form`, className: "gap-4", children })
|
|
442
|
-
}
|
|
443
|
-
)
|
|
444
|
-
}
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
function getNotificationsPageStackOptions(props) {
|
|
448
|
-
const {
|
|
449
|
-
headerTitle,
|
|
450
|
-
onMarkAllRead,
|
|
451
|
-
large,
|
|
452
|
-
scrollEdgeBehavior,
|
|
453
|
-
headerLeft,
|
|
454
|
-
headerRight,
|
|
455
|
-
headerOptions
|
|
456
|
-
} = props;
|
|
457
|
-
const resolvedHeaderRight = headerRight ?? (onMarkAllRead ? () => /* @__PURE__ */ jsx(
|
|
458
|
-
Pressable,
|
|
459
|
-
{
|
|
460
|
-
testID: "notifications-mark-all-read",
|
|
461
|
-
accessibilityRole: "button",
|
|
462
|
-
accessibilityLabel: "Mark all read",
|
|
463
|
-
onPress: onMarkAllRead,
|
|
464
|
-
hitSlop: 8,
|
|
465
|
-
className: "min-h-[44px] justify-center px-3",
|
|
466
|
-
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-primary", children: "Mark all read" })
|
|
467
|
-
}
|
|
468
|
-
) : void 0);
|
|
469
|
-
return composeHeaderOptions({
|
|
470
|
-
headerTitle: headerTitle ?? "Notifications",
|
|
471
|
-
headerLeft,
|
|
472
|
-
headerRight: resolvedHeaderRight,
|
|
473
|
-
large: large ?? true,
|
|
474
|
-
scrollEdgeBehavior: scrollEdgeBehavior ?? "match",
|
|
475
|
-
headerOptions
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
function bucketFor(ts, now = /* @__PURE__ */ new Date()) {
|
|
479
|
-
const d = typeof ts === "string" ? new Date(ts) : ts;
|
|
480
|
-
const startOfDay = (date) => {
|
|
481
|
-
const x = new Date(date);
|
|
482
|
-
x.setHours(0, 0, 0, 0);
|
|
483
|
-
return x.getTime();
|
|
484
|
-
};
|
|
485
|
-
const today = startOfDay(now);
|
|
486
|
-
const yesterday = today - 24 * 60 * 60 * 1e3;
|
|
487
|
-
const day = startOfDay(d);
|
|
488
|
-
if (day === today) return "Today";
|
|
489
|
-
if (day === yesterday) return "Yesterday";
|
|
490
|
-
return "Earlier";
|
|
491
|
-
}
|
|
492
|
-
function groupByDate(items, now = /* @__PURE__ */ new Date()) {
|
|
493
|
-
const map = /* @__PURE__ */ new Map();
|
|
494
|
-
for (const item of items) {
|
|
495
|
-
const bucket = bucketFor(item.timestamp, now);
|
|
496
|
-
const arr = map.get(bucket) ?? [];
|
|
497
|
-
arr.push(item);
|
|
498
|
-
map.set(bucket, arr);
|
|
499
|
-
}
|
|
500
|
-
const order = ["Today", "Yesterday", "Earlier"];
|
|
501
|
-
return order.filter((title) => map.has(title)).map((title) => ({
|
|
502
|
-
title,
|
|
503
|
-
data: map.get(title) ?? []
|
|
504
|
-
}));
|
|
505
|
-
}
|
|
506
|
-
function NotificationsPage({
|
|
507
|
-
items,
|
|
508
|
-
refreshing,
|
|
509
|
-
onRefresh,
|
|
510
|
-
emptyState,
|
|
511
|
-
emptyTitle,
|
|
512
|
-
emptyBody,
|
|
513
|
-
className,
|
|
514
|
-
testID = "notifications-page",
|
|
515
|
-
slots = {},
|
|
516
|
-
slotProps = {}
|
|
517
|
-
}) {
|
|
518
|
-
const sections = useMemo(() => groupByDate(items), [items]);
|
|
519
|
-
if (items.length === 0) {
|
|
520
|
-
return /* @__PURE__ */ jsx(
|
|
521
|
-
SafeAreaView,
|
|
522
|
-
{
|
|
523
|
-
testID,
|
|
524
|
-
edges: ["left", "right", "bottom"],
|
|
525
|
-
className: cn("flex-1 bg-background", className),
|
|
526
|
-
children: emptyState ?? renderSlot(
|
|
527
|
-
DefaultEmpty,
|
|
528
|
-
slots.empty,
|
|
529
|
-
{
|
|
530
|
-
title: emptyTitle ?? "No notifications",
|
|
531
|
-
body: emptyBody ?? "When you get a notification, it'll show up here.",
|
|
532
|
-
testID: `${testID}-empty`
|
|
533
|
-
},
|
|
534
|
-
slotProps.empty
|
|
535
|
-
)
|
|
536
|
-
}
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
return /* @__PURE__ */ jsx(
|
|
540
|
-
SafeAreaView,
|
|
541
|
-
{
|
|
542
|
-
testID,
|
|
543
|
-
edges: ["left", "right", "bottom"],
|
|
544
|
-
className: cn("flex-1 bg-background", className),
|
|
545
|
-
children: /* @__PURE__ */ jsx(
|
|
546
|
-
SectionList,
|
|
547
|
-
{
|
|
548
|
-
testID: `${testID}-list`,
|
|
549
|
-
sections,
|
|
550
|
-
keyExtractor: (item) => item.id,
|
|
551
|
-
renderSectionHeader: ({ section }) => renderSlot(DefaultSectionHeader2, slots.sectionHeader, { title: section.title }, slotProps.sectionHeader),
|
|
552
|
-
renderItem: ({ item }) => renderSlot(DefaultRow2, slots.row, { ...item, testID: item.testID ?? `${testID}-row-${item.id}` }, slotProps.row),
|
|
553
|
-
ItemSeparatorComponent: RowSeparator,
|
|
554
|
-
refreshControl: onRefresh ? /* @__PURE__ */ jsx(
|
|
555
|
-
RefreshControl,
|
|
556
|
-
{
|
|
557
|
-
testID: `${testID}-refresh`,
|
|
558
|
-
refreshing: !!refreshing,
|
|
559
|
-
onRefresh
|
|
560
|
-
}
|
|
561
|
-
) : void 0,
|
|
562
|
-
contentContainerClassName: "pb-8"
|
|
563
|
-
}
|
|
564
|
-
)
|
|
565
|
-
}
|
|
566
|
-
);
|
|
567
|
-
}
|
|
568
|
-
function RowSeparator() {
|
|
569
|
-
return /* @__PURE__ */ jsx(View, { className: "h-px bg-border ml-4" });
|
|
570
|
-
}
|
|
571
|
-
function DefaultSectionHeader2({ title }) {
|
|
572
|
-
return /* @__PURE__ */ jsx(NativeSectionListHeader, { title });
|
|
573
|
-
}
|
|
574
|
-
function DefaultRow2(item) {
|
|
575
|
-
return /* @__PURE__ */ jsx(
|
|
576
|
-
NativeListItem,
|
|
577
|
-
{
|
|
578
|
-
testID: item.testID,
|
|
579
|
-
title: item.title,
|
|
580
|
-
subtitle: item.body,
|
|
581
|
-
leading: item.leading ?? /* @__PURE__ */ jsx(UnreadDot, { unread: !!item.unread, testID: `${item.testID}-unread` }),
|
|
582
|
-
onPress: item.onPress
|
|
583
|
-
}
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
function DefaultEmpty({ title, body, testID }) {
|
|
587
|
-
return /* @__PURE__ */ jsx(NativeEmptyState, { variant: "first-run", title, body, testID });
|
|
588
|
-
}
|
|
589
|
-
function UnreadDot({
|
|
590
|
-
unread,
|
|
591
|
-
testID
|
|
592
|
-
}) {
|
|
593
|
-
if (!unread) {
|
|
594
|
-
return /* @__PURE__ */ jsx(View, { className: "h-2 w-2", testID });
|
|
595
|
-
}
|
|
596
|
-
return /* @__PURE__ */ jsx(
|
|
597
|
-
View,
|
|
598
|
-
{
|
|
599
|
-
testID,
|
|
600
|
-
accessibilityLabel: "Unread",
|
|
601
|
-
className: "h-2 w-2 rounded-full bg-primary"
|
|
602
|
-
}
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
function AuthBranding({
|
|
606
|
-
logo,
|
|
607
|
-
headline,
|
|
608
|
-
subhead,
|
|
609
|
-
className,
|
|
610
|
-
testID = "auth-branding"
|
|
611
|
-
}) {
|
|
612
|
-
return /* @__PURE__ */ jsxs(
|
|
613
|
-
View,
|
|
614
|
-
{
|
|
615
|
-
testID,
|
|
616
|
-
accessibilityRole: "header",
|
|
617
|
-
className: cn("items-center gap-3 pb-8", className),
|
|
618
|
-
children: [
|
|
619
|
-
logo ? /* @__PURE__ */ jsx(View, { testID: `${testID}-logo`, className: "mb-2", children: logo }) : null,
|
|
620
|
-
headline ? /* @__PURE__ */ jsx(
|
|
621
|
-
NativeText,
|
|
622
|
-
{
|
|
623
|
-
preset: "h1",
|
|
624
|
-
testID: `${testID}-headline`,
|
|
625
|
-
className: "text-center",
|
|
626
|
-
children: headline
|
|
627
|
-
}
|
|
628
|
-
) : null,
|
|
629
|
-
subhead ? /* @__PURE__ */ jsx(
|
|
630
|
-
NativeText,
|
|
631
|
-
{
|
|
632
|
-
preset: "body",
|
|
633
|
-
testID: `${testID}-subhead`,
|
|
634
|
-
className: "text-center text-muted-foreground",
|
|
635
|
-
children: subhead
|
|
636
|
-
}
|
|
637
|
-
) : null
|
|
638
|
-
]
|
|
639
|
-
}
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
function SocialAuthRow({
|
|
643
|
-
providers,
|
|
644
|
-
separator = "or",
|
|
645
|
-
className,
|
|
646
|
-
testID = "social-auth-row"
|
|
647
|
-
}) {
|
|
648
|
-
if (providers.length === 0) return null;
|
|
649
|
-
return /* @__PURE__ */ jsxs(View, { testID, className: cn("gap-3", className), children: [
|
|
650
|
-
/* @__PURE__ */ jsx(View, { className: "gap-2", children: providers.map(
|
|
651
|
-
(p) => p.render ? /* @__PURE__ */ jsx(Fragment, { children: p.render({ testID: `${testID}-${p.id}`, disabled: p.disabled }) }, p.id) : /* @__PURE__ */ jsx(
|
|
652
|
-
NativeButton,
|
|
653
|
-
{
|
|
654
|
-
testID: `${testID}-${p.id}`,
|
|
655
|
-
variant: "outline",
|
|
656
|
-
disabled: p.disabled,
|
|
657
|
-
onPress: () => {
|
|
658
|
-
void p.onPress();
|
|
659
|
-
},
|
|
660
|
-
children: /* @__PURE__ */ jsxs(View, { className: "flex-row items-center gap-2", children: [
|
|
661
|
-
p.icon,
|
|
662
|
-
/* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: p.label })
|
|
663
|
-
] })
|
|
664
|
-
},
|
|
665
|
-
p.id
|
|
666
|
-
)
|
|
667
|
-
) }),
|
|
668
|
-
separator !== null && separator !== void 0 ? /* @__PURE__ */ jsxs(
|
|
669
|
-
View,
|
|
670
|
-
{
|
|
671
|
-
testID: `${testID}-separator`,
|
|
672
|
-
className: "my-2 flex-row items-center gap-3",
|
|
673
|
-
accessibilityElementsHidden: true,
|
|
674
|
-
children: [
|
|
675
|
-
/* @__PURE__ */ jsx(View, { className: "h-px flex-1 bg-border" }),
|
|
676
|
-
/* @__PURE__ */ jsx(Text, { className: "text-xs uppercase tracking-wider text-muted-foreground", children: separator }),
|
|
677
|
-
/* @__PURE__ */ jsx(View, { className: "h-px flex-1 bg-border" })
|
|
678
|
-
]
|
|
679
|
-
}
|
|
680
|
-
) : null
|
|
681
|
-
] });
|
|
682
|
-
}
|
|
683
|
-
function AuthForm({
|
|
684
|
-
mode = "password",
|
|
685
|
-
onSubmit,
|
|
686
|
-
validate,
|
|
687
|
-
submitLabel,
|
|
688
|
-
loading,
|
|
689
|
-
errorMessage,
|
|
690
|
-
initialEmail = "",
|
|
691
|
-
belowFields,
|
|
692
|
-
className,
|
|
693
|
-
testID = "auth-form"
|
|
694
|
-
}) {
|
|
695
|
-
const [email, setEmail] = useState(initialEmail);
|
|
696
|
-
const [password, setPassword] = useState("");
|
|
697
|
-
const [localError, setLocalError] = useState(null);
|
|
698
|
-
const [submitting, setSubmitting] = useState(false);
|
|
699
|
-
const passwordRef = useRef(null);
|
|
700
|
-
const isMagic = mode === "magic-link";
|
|
701
|
-
const resolvedSubmitLabel = submitLabel ?? (isMagic ? "Send magic link" : "Sign in");
|
|
702
|
-
const handleSubmit = useCallback(async () => {
|
|
703
|
-
if (submitting || loading) return;
|
|
704
|
-
setLocalError(null);
|
|
705
|
-
const values = {
|
|
706
|
-
email: email.trim(),
|
|
707
|
-
password: isMagic ? "" : password
|
|
708
|
-
};
|
|
709
|
-
if (validate) {
|
|
710
|
-
const err = validate(values);
|
|
711
|
-
if (err) {
|
|
712
|
-
setLocalError(err);
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
if (!values.email) {
|
|
717
|
-
setLocalError("Email is required");
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
if (!isMagic && !values.password) {
|
|
721
|
-
setLocalError("Password is required");
|
|
722
|
-
return;
|
|
723
|
-
}
|
|
724
|
-
setSubmitting(true);
|
|
725
|
-
try {
|
|
726
|
-
await onSubmit(values);
|
|
727
|
-
} catch (err) {
|
|
728
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
729
|
-
setLocalError(message);
|
|
730
|
-
} finally {
|
|
731
|
-
setSubmitting(false);
|
|
732
|
-
}
|
|
733
|
-
}, [email, password, isMagic, validate, onSubmit, submitting, loading]);
|
|
734
|
-
const visibleError = errorMessage ?? localError ?? null;
|
|
735
|
-
return /* @__PURE__ */ jsxs(View, { testID, className: cn("gap-3", className), children: [
|
|
736
|
-
/* @__PURE__ */ jsxs(View, { className: "gap-1", children: [
|
|
737
|
-
/* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: "Email" }),
|
|
738
|
-
/* @__PURE__ */ jsx(
|
|
739
|
-
NativeInput,
|
|
740
|
-
{
|
|
741
|
-
testID: `${testID}-email`,
|
|
742
|
-
accessibilityLabel: "Email",
|
|
743
|
-
value: email,
|
|
744
|
-
onChangeText: setEmail,
|
|
745
|
-
placeholder: "you@example.com",
|
|
746
|
-
autoCapitalize: "none",
|
|
747
|
-
autoCorrect: false,
|
|
748
|
-
keyboardType: "email-address",
|
|
749
|
-
textContentType: "emailAddress",
|
|
750
|
-
autoComplete: "email",
|
|
751
|
-
returnKeyType: isMagic ? "send" : "next",
|
|
752
|
-
editable: !loading && !submitting,
|
|
753
|
-
submitBehavior: isMagic ? "blurAndSubmit" : "submit",
|
|
754
|
-
onSubmitEditing: isMagic ? handleSubmit : () => passwordRef.current?.focus()
|
|
755
|
-
}
|
|
756
|
-
)
|
|
757
|
-
] }),
|
|
758
|
-
isMagic ? null : /* @__PURE__ */ jsxs(View, { className: "gap-1", children: [
|
|
759
|
-
/* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: "Password" }),
|
|
760
|
-
/* @__PURE__ */ jsx(
|
|
761
|
-
NativeInput,
|
|
762
|
-
{
|
|
763
|
-
ref: passwordRef,
|
|
764
|
-
testID: `${testID}-password`,
|
|
765
|
-
accessibilityLabel: "Password",
|
|
766
|
-
value: password,
|
|
767
|
-
onChangeText: setPassword,
|
|
768
|
-
placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
769
|
-
secureTextEntry: true,
|
|
770
|
-
textContentType: "password",
|
|
771
|
-
autoComplete: "current-password",
|
|
772
|
-
autoCapitalize: "none",
|
|
773
|
-
autoCorrect: false,
|
|
774
|
-
returnKeyType: "send",
|
|
775
|
-
editable: !loading && !submitting,
|
|
776
|
-
onSubmitEditing: handleSubmit
|
|
777
|
-
}
|
|
778
|
-
)
|
|
779
|
-
] }),
|
|
780
|
-
belowFields,
|
|
781
|
-
visibleError ? /* @__PURE__ */ jsx(
|
|
782
|
-
Text,
|
|
783
|
-
{
|
|
784
|
-
testID: `${testID}-error`,
|
|
785
|
-
accessibilityRole: "alert",
|
|
786
|
-
className: "text-sm text-destructive",
|
|
787
|
-
children: visibleError
|
|
788
|
-
}
|
|
789
|
-
) : null,
|
|
790
|
-
/* @__PURE__ */ jsx(
|
|
791
|
-
NativeButton,
|
|
792
|
-
{
|
|
793
|
-
testID: `${testID}-submit`,
|
|
794
|
-
onPress: () => {
|
|
795
|
-
void handleSubmit();
|
|
796
|
-
},
|
|
797
|
-
loading: loading || submitting,
|
|
798
|
-
disabled: loading || submitting,
|
|
799
|
-
children: resolvedSubmitLabel
|
|
800
|
-
}
|
|
801
|
-
)
|
|
802
|
-
] });
|
|
803
|
-
}
|
|
804
|
-
function ForgotPasswordLink({
|
|
805
|
-
onPress,
|
|
806
|
-
label = "Forgot password?",
|
|
807
|
-
testID = "auth-forgot-password"
|
|
808
|
-
}) {
|
|
809
|
-
return /* @__PURE__ */ jsx(
|
|
810
|
-
Pressable,
|
|
811
|
-
{
|
|
812
|
-
testID,
|
|
813
|
-
accessibilityRole: "link",
|
|
814
|
-
accessibilityLabel: label,
|
|
815
|
-
onPress,
|
|
816
|
-
hitSlop: 8,
|
|
817
|
-
className: "self-end",
|
|
818
|
-
children: /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-primary", children: label })
|
|
819
|
-
}
|
|
820
|
-
);
|
|
821
|
-
}
|
|
822
|
-
function AuthScreen({
|
|
823
|
-
branding,
|
|
824
|
-
providers: givenProviders,
|
|
825
|
-
form,
|
|
826
|
-
onForgotPassword,
|
|
827
|
-
footer,
|
|
828
|
-
slots = {},
|
|
829
|
-
slotProps = {},
|
|
830
|
-
testID = "auth-screen"
|
|
831
|
-
}) {
|
|
832
|
-
const providers = givenProviders?.filter((p) => !!p);
|
|
833
|
-
warnIfNoAppleSignIn(providers);
|
|
834
|
-
const forgot = onForgotPassword && (form.mode ?? "password") === "password" ? /* @__PURE__ */ jsx(ForgotPasswordLink, { onPress: onForgotPassword }) : null;
|
|
835
|
-
const formProps = { ...form, belowFields: form.belowFields ?? forgot, testID: form.testID ?? `${testID}-form` };
|
|
836
|
-
const KeyboardScroll = useKeyboardScroll();
|
|
837
|
-
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
838
|
-
branding ? renderSlot(AuthBranding, slots.branding, { ...branding, testID: branding.testID ?? `${testID}-branding` }, slotProps.branding) : null,
|
|
839
|
-
providers?.length ? renderSlot(DefaultSocial, slots.social, { providers, testID: `${testID}-social` }, slotProps.social) : null,
|
|
840
|
-
renderSlot(AuthForm, slots.form, formProps, slotProps.form),
|
|
841
|
-
footer ? renderSlot(DefaultFooter, slots.footer, { children: footer, testID: `${testID}-footer` }, slotProps.footer) : null
|
|
842
|
-
] });
|
|
843
|
-
if (KeyboardScroll) {
|
|
844
|
-
return /* @__PURE__ */ jsx(ScreenContainer, { testID, children: /* @__PURE__ */ jsx(
|
|
845
|
-
KeyboardScroll,
|
|
846
|
-
{
|
|
847
|
-
testID: `${testID}-keyboard`,
|
|
848
|
-
keyboardShouldPersistTaps: "handled",
|
|
849
|
-
contentInsetAdjustmentBehavior: "automatic",
|
|
850
|
-
bottomOffset: 24,
|
|
851
|
-
contentContainerStyle: { flexGrow: 1, justifyContent: "center", gap: 24, paddingHorizontal: 24, paddingVertical: 32 },
|
|
852
|
-
children: content
|
|
853
|
-
}
|
|
854
|
-
) });
|
|
855
|
-
}
|
|
856
|
-
return /* @__PURE__ */ jsx(KeyboardAvoidingView, { testID: `${testID}-kav`, style: { flex: 1 }, behavior: Platform.OS === "ios" ? "padding" : void 0, children: /* @__PURE__ */ jsx(ScreenContainer, { scroll: true, keyboardShouldPersistTaps: "handled", testID, contentClassName: "flex-grow justify-center gap-6 px-6 py-8", children: content }) });
|
|
857
|
-
}
|
|
858
|
-
var warnedNoApple = /* @__PURE__ */ new Set();
|
|
859
|
-
function warnIfNoAppleSignIn(providers) {
|
|
860
|
-
const dev = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process !== "undefined" && process.env.NODE_ENV !== "production";
|
|
861
|
-
if (!dev || Platform.OS !== "ios" || !providers?.length) return;
|
|
862
|
-
if (providers.some((p) => p.id === "apple")) return;
|
|
863
|
-
const ids = providers.map((p) => p.id).join(",");
|
|
864
|
-
if (warnedNoApple.has(ids)) return;
|
|
865
|
-
warnedNoApple.add(ids);
|
|
866
|
-
console.warn(
|
|
867
|
-
`[genesis] AuthScreen offers ${providers.map((p) => p.label).join(", ")} on iOS without Sign in with Apple. App Store Review Guideline 4.8 requires it; add appleProvider({ apple: AppleAuthentication, onPress }) (or any provider with id "apple"). If you did, expo-apple-authentication wasn't passed in.`
|
|
868
|
-
);
|
|
869
|
-
}
|
|
870
|
-
function DefaultSocial({ providers, testID }) {
|
|
871
|
-
return /* @__PURE__ */ jsx(SocialAuthRow, { providers, testID });
|
|
872
|
-
}
|
|
873
|
-
function DefaultFooter({ children, testID }) {
|
|
874
|
-
return /* @__PURE__ */ jsx(View, { testID, className: "items-center", children });
|
|
875
|
-
}
|
|
876
|
-
function AppleSignInButton({
|
|
877
|
-
apple,
|
|
878
|
-
onPress,
|
|
879
|
-
type = "continue",
|
|
880
|
-
appearance = "auto",
|
|
881
|
-
cornerRadius = 10,
|
|
882
|
-
height = 44,
|
|
883
|
-
disabled,
|
|
884
|
-
testID = "apple-sign-in"
|
|
885
|
-
}) {
|
|
886
|
-
const mode = useThemeMode();
|
|
887
|
-
const pending = useRef(false);
|
|
888
|
-
const [busy, setBusy] = useState(false);
|
|
889
|
-
if (Platform.OS !== "ios") return null;
|
|
890
|
-
const press = async () => {
|
|
891
|
-
if (disabled || pending.current) return;
|
|
892
|
-
pending.current = true;
|
|
893
|
-
setBusy(true);
|
|
894
|
-
try {
|
|
895
|
-
await onPress();
|
|
896
|
-
} finally {
|
|
897
|
-
pending.current = false;
|
|
898
|
-
setBusy(false);
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
const inactive = !!disabled || busy;
|
|
902
|
-
const { AppleAuthenticationButton, AppleAuthenticationButtonType: Type, AppleAuthenticationButtonStyle: Style } = apple;
|
|
903
|
-
const buttonType = type === "sign-in" ? Type.SIGN_IN : type === "sign-up" ? Type.SIGN_UP : Type.CONTINUE;
|
|
904
|
-
const resolved = appearance === "auto" ? mode === "dark" ? "white" : "black" : appearance;
|
|
905
|
-
const buttonStyle = resolved === "white" ? Style.WHITE : resolved === "white-outline" ? Style.WHITE_OUTLINE : Style.BLACK;
|
|
906
|
-
return /* @__PURE__ */ jsx(View, { testID: `${testID}-container`, pointerEvents: inactive ? "none" : "auto", style: disabled ? { opacity: 0.5 } : void 0, children: /* @__PURE__ */ jsx(
|
|
907
|
-
AppleAuthenticationButton,
|
|
908
|
-
{
|
|
909
|
-
testID,
|
|
910
|
-
buttonType,
|
|
911
|
-
buttonStyle,
|
|
912
|
-
cornerRadius,
|
|
913
|
-
style: { width: "100%", height },
|
|
914
|
-
accessibilityState: { disabled: inactive, busy },
|
|
915
|
-
onPress: () => {
|
|
916
|
-
void press();
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
) });
|
|
920
|
-
}
|
|
921
|
-
var APPLE_LABELS = { continue: "Continue with Apple", "sign-in": "Sign in with Apple", "sign-up": "Sign up with Apple" };
|
|
922
|
-
function appleProvider({ apple, label, ...button }) {
|
|
923
|
-
if (Platform.OS !== "ios" || !apple) return null;
|
|
924
|
-
return {
|
|
925
|
-
id: "apple",
|
|
926
|
-
label: label ?? APPLE_LABELS[button.type ?? "continue"],
|
|
927
|
-
onPress: button.onPress,
|
|
928
|
-
disabled: button.disabled,
|
|
929
|
-
render: ({ testID, disabled }) => /* @__PURE__ */ jsx(AppleSignInButton, { apple, ...button, disabled, testID })
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
export { AppleSignInButton, AuthBranding, AuthForm, AuthScreen, ForgotPasswordLink, KeyboardScrollProvider, NavBarSaveButton, NavBarSearchBar, NavBarTitle, NotificationsPage, ScreenContainer, SettingsPage, SettingsSubPage, SocialAuthRow, appleProvider, composeHeaderOptions, confirmDiscardChanges, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, useKeyboardScroll };
|
|
934
|
-
//# sourceMappingURL=chunk-FZTUSM56.js.map
|
|
935
|
-
//# sourceMappingURL=chunk-FZTUSM56.js.map
|