@marktiderman/genesis-ui-native 2.0.3 → 2.2.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 +52 -0
- package/dist/{chunk-3LK5ZJ4M.js → chunk-2WCXMJL6.js} +2 -2
- package/dist/{chunk-3LK5ZJ4M.js.map → chunk-2WCXMJL6.js.map} +1 -1
- package/dist/{chunk-HNIEFTEL.js → chunk-F2TGDKOO.js} +2 -2
- package/dist/{chunk-HNIEFTEL.js.map → chunk-F2TGDKOO.js.map} +1 -1
- package/dist/{chunk-OMTXD7ND.js → chunk-FZTUSM56.js} +267 -93
- package/dist/chunk-FZTUSM56.js.map +1 -0
- package/dist/chunk-Z3AQYVUA.js +36 -0
- package/dist/chunk-Z3AQYVUA.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -1
- package/dist/data/index.js +1 -1
- package/dist/hooks/index.d.ts +12 -2
- package/dist/hooks/index.js +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -4
- package/dist/layouts/index.d.ts +186 -13
- package/dist/layouts/index.js +2 -2
- package/package.json +6 -6
- package/src/components/__tests__/badge.test.tsx +1 -0
- package/src/components/textarea.tsx +1 -0
- package/src/hooks/__tests__/use-theme-roles.test.tsx +30 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-theme-roles.ts +45 -0
- package/src/layouts/__tests__/apple-sign-in.test.tsx +97 -0
- package/src/layouts/__tests__/auth-screen.test.tsx +72 -0
- package/src/layouts/__tests__/auth.test.tsx +1 -0
- package/src/layouts/__tests__/keyboard-scroll.test.tsx +34 -0
- package/src/layouts/__tests__/nav-bar.test.tsx +1 -0
- package/src/layouts/__tests__/notifications-page-slots.test.tsx +23 -0
- package/src/layouts/__tests__/notifications-page.test.tsx +1 -0
- package/src/layouts/__tests__/screen-container.test.tsx +1 -0
- package/src/layouts/__tests__/settings-page-slots.test.tsx +41 -0
- package/src/layouts/__tests__/settings-page.test.tsx +1 -0
- package/src/layouts/__tests__/settings-sub-page.test.tsx +1 -0
- package/src/layouts/apple-sign-in.tsx +136 -0
- package/src/layouts/auth-screen.tsx +144 -0
- package/src/layouts/auth.tsx +41 -24
- package/src/layouts/index.ts +15 -1
- package/src/layouts/keyboard.tsx +39 -0
- package/src/layouts/notifications-page.tsx +63 -35
- package/src/layouts/screen-container.tsx +11 -3
- package/src/layouts/settings-page.tsx +122 -55
- package/src/layouts/settings-sub-page.tsx +21 -0
- package/dist/chunk-N4WHTQIO.js +0 -20
- package/dist/chunk-N4WHTQIO.js.map +0 -1
- package/dist/chunk-OMTXD7ND.js.map +0 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { NativeSectionListHeader, NativeListItem, NativeListItemDivider, NativeEmptyState } from './chunk-ULS7I6ZS.js';
|
|
2
2
|
import { NativeText, NativeButton, NativeInput } from './chunk-5HRGIA6F.js';
|
|
3
|
-
import { useThemeMode } from './chunk-
|
|
3
|
+
import { useThemeMode, useThemeRoles } from './chunk-Z3AQYVUA.js';
|
|
4
4
|
import { cn } from './chunk-OHZD7KRO.js';
|
|
5
|
-
import { ScrollView, View, StatusBar, Pressable, Text, TextInput, Alert, KeyboardAvoidingView,
|
|
5
|
+
import { ScrollView, View, StatusBar, Pressable, Text, TextInput, Platform, Alert, KeyboardAvoidingView, SectionList, RefreshControl } from 'react-native';
|
|
6
6
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
7
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
8
8
|
import { nativeColors } from '@marktiderman/genesis-design-system/tokens/native';
|
|
9
|
-
import { Fragment, useCallback, useState } from 'react';
|
|
9
|
+
import { createContext, Fragment, createElement, useContext, useCallback, useMemo, useState, useRef } from 'react';
|
|
10
|
+
import { renderSlot } from '@marktiderman/genesis-core/slots';
|
|
10
11
|
|
|
11
12
|
function composeHeaderOptions(props) {
|
|
12
13
|
const {
|
|
@@ -35,6 +36,7 @@ function composeHeaderOptions(props) {
|
|
|
35
36
|
return opts;
|
|
36
37
|
}
|
|
37
38
|
var DEFAULT_EDGES = ["left", "right"];
|
|
39
|
+
var TRANSLUCENT_ANDROID_BAR = { translucent: true, backgroundColor: "transparent" };
|
|
38
40
|
function resolveBarStyle(statusBar, resolvedMode) {
|
|
39
41
|
if (statusBar === "auto") {
|
|
40
42
|
return resolvedMode === "dark" ? "light-content" : "dark-content";
|
|
@@ -52,6 +54,7 @@ function ScreenContainer({
|
|
|
52
54
|
className,
|
|
53
55
|
contentClassName,
|
|
54
56
|
keyboardShouldPersistTaps = "handled",
|
|
57
|
+
style,
|
|
55
58
|
testID
|
|
56
59
|
}) {
|
|
57
60
|
const osMode = useThemeMode();
|
|
@@ -80,13 +83,13 @@ function ScreenContainer({
|
|
|
80
83
|
testID: testID ?? "screen-container",
|
|
81
84
|
edges: safeAreaEdges,
|
|
82
85
|
className: cn("flex-1 bg-background", className),
|
|
86
|
+
style,
|
|
83
87
|
children: [
|
|
84
88
|
statusBar !== "hidden" ? /* @__PURE__ */ jsx(
|
|
85
89
|
StatusBar,
|
|
86
90
|
{
|
|
87
91
|
barStyle,
|
|
88
|
-
|
|
89
|
-
backgroundColor: "transparent"
|
|
92
|
+
...TRANSLUCENT_ANDROID_BAR
|
|
90
93
|
}
|
|
91
94
|
) : /* @__PURE__ */ jsx(StatusBar, { hidden: true }),
|
|
92
95
|
body
|
|
@@ -237,8 +240,12 @@ function SettingsPage({
|
|
|
237
240
|
dangerousActions,
|
|
238
241
|
className,
|
|
239
242
|
testID = "settings-page",
|
|
240
|
-
children
|
|
243
|
+
children,
|
|
244
|
+
slots = {},
|
|
245
|
+
slotProps = {}
|
|
241
246
|
}) {
|
|
247
|
+
const colors = useThemeRoles();
|
|
248
|
+
const inset = Platform.OS === "ios";
|
|
242
249
|
return /* @__PURE__ */ jsxs(
|
|
243
250
|
ScreenContainer,
|
|
244
251
|
{
|
|
@@ -247,6 +254,7 @@ function SettingsPage({
|
|
|
247
254
|
testID,
|
|
248
255
|
contentClassName: "pb-8",
|
|
249
256
|
className,
|
|
257
|
+
style: { backgroundColor: colors.groupedBackground },
|
|
250
258
|
children: [
|
|
251
259
|
children ? /* @__PURE__ */ jsx(View, { className: "px-4 pt-2", children }) : null,
|
|
252
260
|
sections.map((section) => /* @__PURE__ */ jsxs(
|
|
@@ -255,65 +263,90 @@ function SettingsPage({
|
|
|
255
263
|
testID: `${testID}-section-${section.id}`,
|
|
256
264
|
className: "mt-6",
|
|
257
265
|
children: [
|
|
258
|
-
section.title ?
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
266
|
+
section.title ? renderSlot(
|
|
267
|
+
DefaultSectionHeader,
|
|
268
|
+
slots.sectionHeader,
|
|
269
|
+
{ title: section.title, testID: `${testID}-section-${section.id}-header` },
|
|
270
|
+
slotProps.sectionHeader
|
|
264
271
|
) : null,
|
|
265
|
-
/* @__PURE__ */ jsx(
|
|
266
|
-
|
|
267
|
-
NativeListItem,
|
|
268
|
-
{
|
|
269
|
-
testID: row.testID ?? `${testID}-row-${row.id}`,
|
|
270
|
-
title: row.title,
|
|
271
|
-
subtitle: row.subtitle,
|
|
272
|
-
leading: row.leading,
|
|
273
|
-
trailing: row.trailing,
|
|
274
|
-
showChevron: row.showChevron,
|
|
275
|
-
onPress: row.onPress,
|
|
276
|
-
disabled: row.disabled
|
|
277
|
-
}
|
|
278
|
-
),
|
|
279
|
-
rowIndex < section.rows.length - 1 ? /* @__PURE__ */ jsx(NativeListItemDivider, { className: "ml-4" }) : null
|
|
280
|
-
] }, row.id)) }),
|
|
281
|
-
section.footnote ? /* @__PURE__ */ jsx(
|
|
282
|
-
NativeText,
|
|
272
|
+
/* @__PURE__ */ jsx(
|
|
273
|
+
View,
|
|
283
274
|
{
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
children: section.
|
|
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))
|
|
287
283
|
}
|
|
288
|
-
)
|
|
284
|
+
),
|
|
285
|
+
section.footnote ? renderSlot(DefaultFootnote, slots.footnote, { text: section.footnote }, slotProps.footnote) : null
|
|
289
286
|
]
|
|
290
287
|
},
|
|
291
288
|
section.id
|
|
292
289
|
)),
|
|
293
|
-
dangerousActions && dangerousActions.length > 0 ?
|
|
294
|
-
|
|
290
|
+
dangerousActions && dangerousActions.length > 0 ? renderSlot(
|
|
291
|
+
DefaultDangerousActions,
|
|
292
|
+
slots.dangerousActions,
|
|
295
293
|
{
|
|
296
|
-
testID: `${testID}-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
{
|
|
301
|
-
testID: action.testID ?? `${testID}-danger-${slug(action.label)}`,
|
|
302
|
-
variant: action.emphasized ? "destructive" : "outline",
|
|
303
|
-
onPress: action.onPress,
|
|
304
|
-
children: action.label
|
|
305
|
-
},
|
|
306
|
-
action.label
|
|
307
|
-
))
|
|
308
|
-
}
|
|
294
|
+
actions: dangerousActions.map((action) => ({ ...action, testID: action.testID ?? `${testID}-danger-${slug(action.label)}` })),
|
|
295
|
+
testID: `${testID}-dangerous-actions`
|
|
296
|
+
},
|
|
297
|
+
slotProps.dangerousActions
|
|
309
298
|
) : null
|
|
310
299
|
]
|
|
311
300
|
}
|
|
312
301
|
);
|
|
313
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
|
+
}
|
|
314
340
|
function slug(s) {
|
|
315
341
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
316
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
|
+
}
|
|
317
350
|
function confirmDiscardChanges(proceed) {
|
|
318
351
|
Alert.alert(
|
|
319
352
|
"Discard changes?",
|
|
@@ -378,6 +411,19 @@ function SettingsSubPage({
|
|
|
378
411
|
},
|
|
379
412
|
[onConfirmLeave]
|
|
380
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
|
+
}
|
|
381
427
|
return /* @__PURE__ */ jsx(
|
|
382
428
|
KeyboardAvoidingView,
|
|
383
429
|
{
|
|
@@ -465,9 +511,11 @@ function NotificationsPage({
|
|
|
465
511
|
emptyTitle,
|
|
466
512
|
emptyBody,
|
|
467
513
|
className,
|
|
468
|
-
testID = "notifications-page"
|
|
514
|
+
testID = "notifications-page",
|
|
515
|
+
slots = {},
|
|
516
|
+
slotProps = {}
|
|
469
517
|
}) {
|
|
470
|
-
const sections = groupByDate(items);
|
|
518
|
+
const sections = useMemo(() => groupByDate(items), [items]);
|
|
471
519
|
if (items.length === 0) {
|
|
472
520
|
return /* @__PURE__ */ jsx(
|
|
473
521
|
SafeAreaView,
|
|
@@ -475,14 +523,15 @@ function NotificationsPage({
|
|
|
475
523
|
testID,
|
|
476
524
|
edges: ["left", "right", "bottom"],
|
|
477
525
|
className: cn("flex-1 bg-background", className),
|
|
478
|
-
children: emptyState ??
|
|
479
|
-
|
|
526
|
+
children: emptyState ?? renderSlot(
|
|
527
|
+
DefaultEmpty,
|
|
528
|
+
slots.empty,
|
|
480
529
|
{
|
|
481
|
-
variant: "first-run",
|
|
482
530
|
title: emptyTitle ?? "No notifications",
|
|
483
531
|
body: emptyBody ?? "When you get a notification, it'll show up here.",
|
|
484
532
|
testID: `${testID}-empty`
|
|
485
|
-
}
|
|
533
|
+
},
|
|
534
|
+
slotProps.empty
|
|
486
535
|
)
|
|
487
536
|
}
|
|
488
537
|
);
|
|
@@ -499,24 +548,9 @@ function NotificationsPage({
|
|
|
499
548
|
testID: `${testID}-list`,
|
|
500
549
|
sections,
|
|
501
550
|
keyExtractor: (item) => item.id,
|
|
502
|
-
renderSectionHeader: ({ section }) =>
|
|
503
|
-
renderItem: ({ item }) =>
|
|
504
|
-
|
|
505
|
-
{
|
|
506
|
-
testID: item.testID ?? `${testID}-row-${item.id}`,
|
|
507
|
-
title: item.title,
|
|
508
|
-
subtitle: item.body,
|
|
509
|
-
leading: item.leading ?? /* @__PURE__ */ jsx(
|
|
510
|
-
UnreadDot,
|
|
511
|
-
{
|
|
512
|
-
unread: !!item.unread,
|
|
513
|
-
testID: `${testID}-row-${item.id}-unread`
|
|
514
|
-
}
|
|
515
|
-
),
|
|
516
|
-
onPress: item.onPress
|
|
517
|
-
}
|
|
518
|
-
),
|
|
519
|
-
ItemSeparatorComponent: () => /* @__PURE__ */ jsx(View, { className: "h-px bg-border ml-4" }),
|
|
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,
|
|
520
554
|
refreshControl: onRefresh ? /* @__PURE__ */ jsx(
|
|
521
555
|
RefreshControl,
|
|
522
556
|
{
|
|
@@ -531,6 +565,27 @@ function NotificationsPage({
|
|
|
531
565
|
}
|
|
532
566
|
);
|
|
533
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
|
+
}
|
|
534
589
|
function UnreadDot({
|
|
535
590
|
unread,
|
|
536
591
|
testID
|
|
@@ -592,22 +647,24 @@ function SocialAuthRow({
|
|
|
592
647
|
}) {
|
|
593
648
|
if (providers.length === 0) return null;
|
|
594
649
|
return /* @__PURE__ */ jsxs(View, { testID, className: cn("gap-3", className), children: [
|
|
595
|
-
/* @__PURE__ */ jsx(View, { className: "gap-2", children: providers.map(
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
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
|
+
] })
|
|
603
664
|
},
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
] })
|
|
608
|
-
},
|
|
609
|
-
p.id
|
|
610
|
-
)) }),
|
|
665
|
+
p.id
|
|
666
|
+
)
|
|
667
|
+
) }),
|
|
611
668
|
separator !== null && separator !== void 0 ? /* @__PURE__ */ jsxs(
|
|
612
669
|
View,
|
|
613
670
|
{
|
|
@@ -639,6 +696,7 @@ function AuthForm({
|
|
|
639
696
|
const [password, setPassword] = useState("");
|
|
640
697
|
const [localError, setLocalError] = useState(null);
|
|
641
698
|
const [submitting, setSubmitting] = useState(false);
|
|
699
|
+
const passwordRef = useRef(null);
|
|
642
700
|
const isMagic = mode === "magic-link";
|
|
643
701
|
const resolvedSubmitLabel = submitLabel ?? (isMagic ? "Send magic link" : "Sign in");
|
|
644
702
|
const handleSubmit = useCallback(async () => {
|
|
@@ -688,9 +746,12 @@ function AuthForm({
|
|
|
688
746
|
autoCapitalize: "none",
|
|
689
747
|
autoCorrect: false,
|
|
690
748
|
keyboardType: "email-address",
|
|
749
|
+
textContentType: "emailAddress",
|
|
750
|
+
autoComplete: "email",
|
|
691
751
|
returnKeyType: isMagic ? "send" : "next",
|
|
692
752
|
editable: !loading && !submitting,
|
|
693
|
-
|
|
753
|
+
submitBehavior: isMagic ? "blurAndSubmit" : "submit",
|
|
754
|
+
onSubmitEditing: isMagic ? handleSubmit : () => passwordRef.current?.focus()
|
|
694
755
|
}
|
|
695
756
|
)
|
|
696
757
|
] }),
|
|
@@ -699,12 +760,15 @@ function AuthForm({
|
|
|
699
760
|
/* @__PURE__ */ jsx(
|
|
700
761
|
NativeInput,
|
|
701
762
|
{
|
|
763
|
+
ref: passwordRef,
|
|
702
764
|
testID: `${testID}-password`,
|
|
703
765
|
accessibilityLabel: "Password",
|
|
704
766
|
value: password,
|
|
705
767
|
onChangeText: setPassword,
|
|
706
768
|
placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
707
769
|
secureTextEntry: true,
|
|
770
|
+
textContentType: "password",
|
|
771
|
+
autoComplete: "current-password",
|
|
708
772
|
autoCapitalize: "none",
|
|
709
773
|
autoCorrect: false,
|
|
710
774
|
returnKeyType: "send",
|
|
@@ -755,7 +819,117 @@ function ForgotPasswordLink({
|
|
|
755
819
|
}
|
|
756
820
|
);
|
|
757
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
|
+
}
|
|
758
932
|
|
|
759
|
-
export { AuthBranding, AuthForm, ForgotPasswordLink, NavBarSaveButton, NavBarSearchBar, NavBarTitle, NotificationsPage, ScreenContainer, SettingsPage, SettingsSubPage, SocialAuthRow, composeHeaderOptions, confirmDiscardChanges, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions };
|
|
760
|
-
//# sourceMappingURL=chunk-
|
|
761
|
-
//# sourceMappingURL=chunk-
|
|
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
|