@marktiderman/genesis-ui-native 2.0.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/dist/chunk-BAU4YQZV.js +760 -0
- package/dist/chunk-BAU4YQZV.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +10 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-HNIEFTEL.js +43 -0
- package/dist/chunk-HNIEFTEL.js.map +1 -0
- package/dist/chunk-N4WHTQIO.js +20 -0
- package/dist/chunk-N4WHTQIO.js.map +1 -0
- package/dist/chunk-OHZD7KRO.js +11 -0
- package/dist/chunk-OHZD7KRO.js.map +1 -0
- package/dist/chunk-PTJ2KCLM.js +160 -0
- package/dist/chunk-PTJ2KCLM.js.map +1 -0
- package/dist/chunk-TXJT55JC.js +2213 -0
- package/dist/chunk-TXJT55JC.js.map +1 -0
- package/dist/chunk-ULS7I6ZS.js +183 -0
- package/dist/chunk-ULS7I6ZS.js.map +1 -0
- package/dist/chunk-ZVF6PONU.js +522 -0
- package/dist/chunk-ZVF6PONU.js.map +1 -0
- package/dist/components/index.d.ts +908 -0
- package/dist/components/index.js +8 -0
- package/dist/components/index.js.map +1 -0
- package/dist/data/index.d.ts +117 -0
- package/dist/data/index.js +770 -0
- package/dist/data/index.js.map +1 -0
- package/dist/hooks/index.d.ts +31 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/index.d.ts +364 -0
- package/dist/layouts/index.js +8 -0
- package/dist/layouts/index.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +4 -0
- package/dist/utils.js.map +1 -0
- package/package.json +127 -0
- package/src/components/__tests__/accordion.test.tsx +122 -0
- package/src/components/__tests__/chip-group.test.tsx +45 -0
- package/src/components/__tests__/combobox.test.tsx +97 -0
- package/src/components/__tests__/drawer.test.tsx +98 -0
- package/src/components/__tests__/empty-state.test.tsx +66 -0
- package/src/components/__tests__/header-card.test.tsx +31 -0
- package/src/components/__tests__/layout.test.tsx +109 -0
- package/src/components/__tests__/list-item.test.tsx +31 -0
- package/src/components/__tests__/number-input.test.tsx +46 -0
- package/src/components/__tests__/pagination.test.tsx +43 -0
- package/src/components/__tests__/search-bar.test.tsx +41 -0
- package/src/components/__tests__/segmented-empty-alert.test.tsx +79 -0
- package/src/components/__tests__/slider.test.tsx +134 -0
- package/src/components/__tests__/stepper.test.tsx +25 -0
- package/src/components/__tests__/toast.test.tsx +63 -0
- package/src/components/accordion.tsx +223 -0
- package/src/components/alert.tsx +131 -0
- package/src/components/avatar.tsx +68 -0
- package/src/components/badge.tsx +80 -0
- package/src/components/button.tsx +118 -0
- package/src/components/card.tsx +120 -0
- package/src/components/checkbox.tsx +60 -0
- package/src/components/chip-group.tsx +127 -0
- package/src/components/combobox.tsx +137 -0
- package/src/components/date-time-picker.tsx +127 -0
- package/src/components/dialog.tsx +131 -0
- package/src/components/drawer.tsx +131 -0
- package/src/components/dropdown-menu.tsx +133 -0
- package/src/components/empty-state.tsx +161 -0
- package/src/components/header-card.tsx +116 -0
- package/src/components/index.ts +259 -0
- package/src/components/inline-alert.tsx +150 -0
- package/src/components/input.tsx +51 -0
- package/src/components/label.tsx +35 -0
- package/src/components/layout/box.tsx +115 -0
- package/src/components/layout/flex.ts +24 -0
- package/src/components/layout/grid.tsx +73 -0
- package/src/components/layout/index.ts +27 -0
- package/src/components/layout/inline.tsx +63 -0
- package/src/components/layout/spacing.ts +116 -0
- package/src/components/layout/stack.tsx +58 -0
- package/src/components/list-item.tsx +108 -0
- package/src/components/number-input.tsx +119 -0
- package/src/components/pagination.tsx +132 -0
- package/src/components/popover.tsx +198 -0
- package/src/components/progress.tsx +50 -0
- package/src/components/radio-group.tsx +92 -0
- package/src/components/refresh-control.tsx +73 -0
- package/src/components/search-bar.tsx +128 -0
- package/src/components/section-list.tsx +54 -0
- package/src/components/segmented-control.tsx +79 -0
- package/src/components/select.tsx +178 -0
- package/src/components/separator.tsx +31 -0
- package/src/components/sheet.tsx +192 -0
- package/src/components/skeleton.tsx +104 -0
- package/src/components/slider.tsx +223 -0
- package/src/components/stepper.tsx +96 -0
- package/src/components/switch.tsx +35 -0
- package/src/components/tabs.tsx +147 -0
- package/src/components/text.tsx +62 -0
- package/src/components/textarea.tsx +52 -0
- package/src/components/toast.tsx +228 -0
- package/src/components/toggle.tsx +85 -0
- package/src/components/tooltip.tsx +104 -0
- package/src/data/NativeDataFilters.tsx +100 -0
- package/src/data/NativeDataPageShell.tsx +111 -0
- package/src/data/NativeDetailPanel.tsx +130 -0
- package/src/data/NativeEmptyState.tsx +46 -0
- package/src/data/NativeResourceForm.tsx +157 -0
- package/src/data/NativeResourceFormField.tsx +280 -0
- package/src/data/NativeResourcePage.tsx +505 -0
- package/src/data/index.ts +9 -0
- package/src/hooks/index.ts +16 -0
- package/src/hooks/use-genesis-extension.ts +81 -0
- package/src/hooks/use-reduced-motion.ts +32 -0
- package/src/hooks/use-theme-mode.ts +31 -0
- package/src/index.ts +5 -0
- package/src/layouts/__tests__/auth.test.tsx +150 -0
- package/src/layouts/__tests__/nav-bar.test.tsx +86 -0
- package/src/layouts/__tests__/notifications-page.test.tsx +94 -0
- package/src/layouts/__tests__/screen-container.test.tsx +79 -0
- package/src/layouts/__tests__/settings-page.test.tsx +107 -0
- package/src/layouts/__tests__/settings-sub-page.test.tsx +53 -0
- package/src/layouts/auth.tsx +352 -0
- package/src/layouts/index.ts +61 -0
- package/src/layouts/nav-bar.tsx +200 -0
- package/src/layouts/notifications-page.tsx +274 -0
- package/src/layouts/screen-container.tsx +213 -0
- package/src/layouts/settings-page.tsx +195 -0
- package/src/layouts/settings-sub-page.tsx +183 -0
- package/src/nativewind.d.ts +40 -0
- package/src/utils.ts +6 -0
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
import { NativeSectionListHeader, NativeListItem, NativeListItemDivider, NativeEmptyState } from './chunk-ULS7I6ZS.js';
|
|
2
|
+
import { NativeText, NativeButton, NativeInput } from './chunk-PTJ2KCLM.js';
|
|
3
|
+
import { useThemeMode } from './chunk-N4WHTQIO.js';
|
|
4
|
+
import { cn } from './chunk-OHZD7KRO.js';
|
|
5
|
+
import { ScrollView, View, StatusBar, Pressable, Text, TextInput, Alert, KeyboardAvoidingView, Platform, SectionList, RefreshControl } from 'react-native';
|
|
6
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
import { Fragment, useCallback, useState } from 'react';
|
|
9
|
+
|
|
10
|
+
function composeHeaderOptions(props) {
|
|
11
|
+
const {
|
|
12
|
+
headerTitle,
|
|
13
|
+
headerLeft,
|
|
14
|
+
headerRight,
|
|
15
|
+
large,
|
|
16
|
+
scrollEdgeBehavior,
|
|
17
|
+
headerOptions
|
|
18
|
+
} = props;
|
|
19
|
+
const opts = {};
|
|
20
|
+
if (headerTitle !== void 0) opts.title = headerTitle;
|
|
21
|
+
if (headerLeft) opts.headerLeft = headerLeft;
|
|
22
|
+
if (headerRight) opts.headerRight = headerRight;
|
|
23
|
+
if (large) {
|
|
24
|
+
opts.headerLargeTitle = true;
|
|
25
|
+
if (scrollEdgeBehavior === "transparent") {
|
|
26
|
+
opts.headerTransparent = true;
|
|
27
|
+
} else if (scrollEdgeBehavior === "opaque") {
|
|
28
|
+
opts.headerLargeTitleShadowVisible = true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (headerOptions) {
|
|
32
|
+
Object.assign(opts, headerOptions);
|
|
33
|
+
}
|
|
34
|
+
return opts;
|
|
35
|
+
}
|
|
36
|
+
var DEFAULT_EDGES = ["left", "right"];
|
|
37
|
+
function resolveBarStyle(statusBar, resolvedMode) {
|
|
38
|
+
if (statusBar === "auto") {
|
|
39
|
+
return resolvedMode === "dark" ? "light-content" : "dark-content";
|
|
40
|
+
}
|
|
41
|
+
if (statusBar === "light") return "light-content";
|
|
42
|
+
if (statusBar === "dark") return "dark-content";
|
|
43
|
+
return "default";
|
|
44
|
+
}
|
|
45
|
+
function ScreenContainer({
|
|
46
|
+
children,
|
|
47
|
+
scroll = false,
|
|
48
|
+
safeAreaEdges = DEFAULT_EDGES,
|
|
49
|
+
statusBar = "auto",
|
|
50
|
+
themeMode = "system",
|
|
51
|
+
className,
|
|
52
|
+
contentClassName,
|
|
53
|
+
keyboardShouldPersistTaps = "handled",
|
|
54
|
+
testID
|
|
55
|
+
}) {
|
|
56
|
+
const osMode = useThemeMode();
|
|
57
|
+
const resolvedMode = themeMode === "system" ? osMode : themeMode;
|
|
58
|
+
const barStyle = resolveBarStyle(statusBar, resolvedMode);
|
|
59
|
+
const body = scroll ? /* @__PURE__ */ jsx(
|
|
60
|
+
ScrollView,
|
|
61
|
+
{
|
|
62
|
+
testID: testID ? `${testID}-scroll` : void 0,
|
|
63
|
+
keyboardShouldPersistTaps,
|
|
64
|
+
contentInsetAdjustmentBehavior: "automatic",
|
|
65
|
+
contentContainerClassName: cn("flex-grow", contentClassName),
|
|
66
|
+
children
|
|
67
|
+
}
|
|
68
|
+
) : /* @__PURE__ */ jsx(
|
|
69
|
+
View,
|
|
70
|
+
{
|
|
71
|
+
testID: testID ? `${testID}-body` : void 0,
|
|
72
|
+
className: cn("flex-1", contentClassName),
|
|
73
|
+
children
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
return /* @__PURE__ */ jsxs(
|
|
77
|
+
SafeAreaView,
|
|
78
|
+
{
|
|
79
|
+
testID: testID ?? "screen-container",
|
|
80
|
+
edges: safeAreaEdges,
|
|
81
|
+
className: cn("flex-1 bg-background", className),
|
|
82
|
+
children: [
|
|
83
|
+
statusBar !== "hidden" ? /* @__PURE__ */ jsx(
|
|
84
|
+
StatusBar,
|
|
85
|
+
{
|
|
86
|
+
barStyle,
|
|
87
|
+
translucent: true,
|
|
88
|
+
backgroundColor: "transparent"
|
|
89
|
+
}
|
|
90
|
+
) : /* @__PURE__ */ jsx(StatusBar, { hidden: true }),
|
|
91
|
+
body
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function NavBarSaveButton({
|
|
97
|
+
onPress,
|
|
98
|
+
label = "Save",
|
|
99
|
+
disabled,
|
|
100
|
+
loading,
|
|
101
|
+
destructive,
|
|
102
|
+
className,
|
|
103
|
+
testID
|
|
104
|
+
}) {
|
|
105
|
+
const isDisabled = !!disabled || !!loading || !onPress;
|
|
106
|
+
return /* @__PURE__ */ jsx(
|
|
107
|
+
Pressable,
|
|
108
|
+
{
|
|
109
|
+
testID: testID ?? "nav-bar-save-button",
|
|
110
|
+
accessibilityRole: "button",
|
|
111
|
+
accessibilityLabel: label,
|
|
112
|
+
accessibilityState: { disabled: isDisabled, busy: !!loading },
|
|
113
|
+
onPress: isDisabled ? void 0 : onPress,
|
|
114
|
+
disabled: isDisabled,
|
|
115
|
+
className: cn("min-h-[44px] justify-center px-3", className),
|
|
116
|
+
hitSlop: 8,
|
|
117
|
+
children: /* @__PURE__ */ jsx(
|
|
118
|
+
Text,
|
|
119
|
+
{
|
|
120
|
+
className: cn(
|
|
121
|
+
"text-base font-semibold",
|
|
122
|
+
destructive ? "text-destructive" : "text-primary",
|
|
123
|
+
isDisabled && "opacity-40"
|
|
124
|
+
),
|
|
125
|
+
children: loading ? "\u2026" : label
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
function NavBarTitle({
|
|
132
|
+
title,
|
|
133
|
+
subtitle,
|
|
134
|
+
onPress,
|
|
135
|
+
className,
|
|
136
|
+
testID
|
|
137
|
+
}) {
|
|
138
|
+
const inner = /* @__PURE__ */ jsxs(View, { className: cn("items-center justify-center", className), children: [
|
|
139
|
+
/* @__PURE__ */ jsx(
|
|
140
|
+
Text,
|
|
141
|
+
{
|
|
142
|
+
testID: testID ? `${testID}-title` : void 0,
|
|
143
|
+
className: "text-base font-semibold text-foreground",
|
|
144
|
+
numberOfLines: 1,
|
|
145
|
+
children: title
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
subtitle ? /* @__PURE__ */ jsx(
|
|
149
|
+
Text,
|
|
150
|
+
{
|
|
151
|
+
testID: testID ? `${testID}-subtitle` : void 0,
|
|
152
|
+
className: "text-xs text-muted-foreground",
|
|
153
|
+
numberOfLines: 1,
|
|
154
|
+
children: subtitle
|
|
155
|
+
}
|
|
156
|
+
) : null
|
|
157
|
+
] });
|
|
158
|
+
if (onPress) {
|
|
159
|
+
return /* @__PURE__ */ jsx(
|
|
160
|
+
Pressable,
|
|
161
|
+
{
|
|
162
|
+
testID: testID ?? "nav-bar-title",
|
|
163
|
+
accessibilityRole: "button",
|
|
164
|
+
accessibilityLabel: subtitle ? `${title}, ${subtitle}` : title,
|
|
165
|
+
onPress,
|
|
166
|
+
hitSlop: 8,
|
|
167
|
+
children: inner
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return /* @__PURE__ */ jsx(View, { testID: testID ?? "nav-bar-title", accessibilityRole: "header", children: inner });
|
|
172
|
+
}
|
|
173
|
+
function NavBarSearchBar({
|
|
174
|
+
value,
|
|
175
|
+
onChangeText,
|
|
176
|
+
placeholder = "Search",
|
|
177
|
+
onSubmit,
|
|
178
|
+
clearable = true,
|
|
179
|
+
className,
|
|
180
|
+
testID
|
|
181
|
+
}) {
|
|
182
|
+
return /* @__PURE__ */ jsxs(
|
|
183
|
+
View,
|
|
184
|
+
{
|
|
185
|
+
testID: testID ?? "nav-bar-search",
|
|
186
|
+
className: cn(
|
|
187
|
+
"min-h-[36px] flex-row items-center rounded-full bg-muted px-3",
|
|
188
|
+
className
|
|
189
|
+
),
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ jsx(
|
|
192
|
+
TextInput,
|
|
193
|
+
{
|
|
194
|
+
testID: testID ? `${testID}-input` : void 0,
|
|
195
|
+
accessibilityLabel: placeholder,
|
|
196
|
+
value,
|
|
197
|
+
onChangeText,
|
|
198
|
+
onSubmitEditing: onSubmit,
|
|
199
|
+
placeholder,
|
|
200
|
+
placeholderTextColor: "#9ca3af",
|
|
201
|
+
returnKeyType: "search",
|
|
202
|
+
autoCorrect: false,
|
|
203
|
+
autoCapitalize: "none",
|
|
204
|
+
clearButtonMode: clearable ? "while-editing" : "never",
|
|
205
|
+
className: "flex-1 text-base text-foreground"
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
clearable && value.length > 0 ? /* @__PURE__ */ jsx(
|
|
209
|
+
Pressable,
|
|
210
|
+
{
|
|
211
|
+
testID: testID ? `${testID}-clear` : void 0,
|
|
212
|
+
accessibilityRole: "button",
|
|
213
|
+
accessibilityLabel: "Clear search",
|
|
214
|
+
onPress: () => onChangeText(""),
|
|
215
|
+
hitSlop: 8,
|
|
216
|
+
className: "ml-2 px-1",
|
|
217
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-muted-foreground", children: "\xD7" })
|
|
218
|
+
}
|
|
219
|
+
) : null
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
function getSettingsPageStackOptions(props) {
|
|
225
|
+
return composeHeaderOptions({
|
|
226
|
+
headerTitle: props.headerTitle ?? "Settings",
|
|
227
|
+
large: props.large ?? true,
|
|
228
|
+
scrollEdgeBehavior: props.scrollEdgeBehavior ?? "match",
|
|
229
|
+
headerLeft: props.headerLeft,
|
|
230
|
+
headerRight: props.headerRight,
|
|
231
|
+
headerOptions: props.headerOptions
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
function SettingsPage({
|
|
235
|
+
sections,
|
|
236
|
+
dangerousActions,
|
|
237
|
+
className,
|
|
238
|
+
testID = "settings-page",
|
|
239
|
+
children
|
|
240
|
+
}) {
|
|
241
|
+
return /* @__PURE__ */ jsxs(
|
|
242
|
+
ScreenContainer,
|
|
243
|
+
{
|
|
244
|
+
scroll: true,
|
|
245
|
+
safeAreaEdges: ["left", "right", "bottom"],
|
|
246
|
+
testID,
|
|
247
|
+
contentClassName: "pb-8",
|
|
248
|
+
className,
|
|
249
|
+
children: [
|
|
250
|
+
children ? /* @__PURE__ */ jsx(View, { className: "px-4 pt-2", children }) : null,
|
|
251
|
+
sections.map((section) => /* @__PURE__ */ jsxs(
|
|
252
|
+
View,
|
|
253
|
+
{
|
|
254
|
+
testID: `${testID}-section-${section.id}`,
|
|
255
|
+
className: "mt-6",
|
|
256
|
+
children: [
|
|
257
|
+
section.title ? /* @__PURE__ */ jsx(
|
|
258
|
+
NativeSectionListHeader,
|
|
259
|
+
{
|
|
260
|
+
title: section.title,
|
|
261
|
+
testID: `${testID}-section-${section.id}-header`
|
|
262
|
+
}
|
|
263
|
+
) : null,
|
|
264
|
+
/* @__PURE__ */ jsx(View, { className: "border-y border-border bg-background", children: section.rows.map((row, rowIndex) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
265
|
+
/* @__PURE__ */ jsx(
|
|
266
|
+
NativeListItem,
|
|
267
|
+
{
|
|
268
|
+
testID: row.testID ?? `${testID}-row-${row.id}`,
|
|
269
|
+
title: row.title,
|
|
270
|
+
subtitle: row.subtitle,
|
|
271
|
+
leading: row.leading,
|
|
272
|
+
trailing: row.trailing,
|
|
273
|
+
showChevron: row.showChevron,
|
|
274
|
+
onPress: row.onPress,
|
|
275
|
+
disabled: row.disabled
|
|
276
|
+
}
|
|
277
|
+
),
|
|
278
|
+
rowIndex < section.rows.length - 1 ? /* @__PURE__ */ jsx(NativeListItemDivider, { className: "ml-4" }) : null
|
|
279
|
+
] }, row.id)) }),
|
|
280
|
+
section.footnote ? /* @__PURE__ */ jsx(
|
|
281
|
+
NativeText,
|
|
282
|
+
{
|
|
283
|
+
preset: "body-sm",
|
|
284
|
+
className: "px-4 pt-2 text-muted-foreground",
|
|
285
|
+
children: section.footnote
|
|
286
|
+
}
|
|
287
|
+
) : null
|
|
288
|
+
]
|
|
289
|
+
},
|
|
290
|
+
section.id
|
|
291
|
+
)),
|
|
292
|
+
dangerousActions && dangerousActions.length > 0 ? /* @__PURE__ */ jsx(
|
|
293
|
+
View,
|
|
294
|
+
{
|
|
295
|
+
testID: `${testID}-dangerous-actions`,
|
|
296
|
+
className: cn("mt-8 gap-2 px-4"),
|
|
297
|
+
children: dangerousActions.map((action) => /* @__PURE__ */ jsx(
|
|
298
|
+
NativeButton,
|
|
299
|
+
{
|
|
300
|
+
testID: action.testID ?? `${testID}-danger-${slug(action.label)}`,
|
|
301
|
+
variant: action.emphasized ? "destructive" : "outline",
|
|
302
|
+
onPress: action.onPress,
|
|
303
|
+
children: action.label
|
|
304
|
+
},
|
|
305
|
+
action.label
|
|
306
|
+
))
|
|
307
|
+
}
|
|
308
|
+
) : null
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
function slug(s) {
|
|
314
|
+
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
315
|
+
}
|
|
316
|
+
function confirmDiscardChanges(proceed) {
|
|
317
|
+
Alert.alert(
|
|
318
|
+
"Discard changes?",
|
|
319
|
+
"You have unsaved changes. Leave this screen and lose them?",
|
|
320
|
+
[
|
|
321
|
+
{ text: "Keep editing", style: "cancel" },
|
|
322
|
+
{
|
|
323
|
+
text: "Discard",
|
|
324
|
+
style: "destructive",
|
|
325
|
+
onPress: () => proceed()
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
function getSettingsSubPageStackOptions(props) {
|
|
331
|
+
const {
|
|
332
|
+
headerTitle,
|
|
333
|
+
dirty,
|
|
334
|
+
saving,
|
|
335
|
+
onSave,
|
|
336
|
+
saveLabel = "Save",
|
|
337
|
+
large = false,
|
|
338
|
+
scrollEdgeBehavior,
|
|
339
|
+
headerLeft,
|
|
340
|
+
headerRight,
|
|
341
|
+
headerOptions
|
|
342
|
+
} = props;
|
|
343
|
+
const resolvedHeaderRight = headerRight ?? (onSave ? () => /* @__PURE__ */ jsx(
|
|
344
|
+
NavBarSaveButton,
|
|
345
|
+
{
|
|
346
|
+
label: saveLabel,
|
|
347
|
+
onPress: () => {
|
|
348
|
+
void onSave();
|
|
349
|
+
},
|
|
350
|
+
disabled: !dirty,
|
|
351
|
+
loading: saving
|
|
352
|
+
}
|
|
353
|
+
) : void 0);
|
|
354
|
+
return composeHeaderOptions({
|
|
355
|
+
headerTitle,
|
|
356
|
+
headerLeft,
|
|
357
|
+
headerRight: resolvedHeaderRight,
|
|
358
|
+
large,
|
|
359
|
+
scrollEdgeBehavior,
|
|
360
|
+
headerOptions
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function SettingsSubPage({
|
|
364
|
+
children,
|
|
365
|
+
onConfirmLeave,
|
|
366
|
+
className,
|
|
367
|
+
testID = "settings-sub-page"
|
|
368
|
+
}) {
|
|
369
|
+
useCallback(
|
|
370
|
+
(proceed) => {
|
|
371
|
+
if (onConfirmLeave === null) {
|
|
372
|
+
proceed();
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const fn = onConfirmLeave ?? confirmDiscardChanges;
|
|
376
|
+
fn(proceed);
|
|
377
|
+
},
|
|
378
|
+
[onConfirmLeave]
|
|
379
|
+
);
|
|
380
|
+
return /* @__PURE__ */ jsx(
|
|
381
|
+
KeyboardAvoidingView,
|
|
382
|
+
{
|
|
383
|
+
testID: `${testID}-kav`,
|
|
384
|
+
style: { flex: 1 },
|
|
385
|
+
behavior: Platform.OS === "ios" ? "padding" : void 0,
|
|
386
|
+
children: /* @__PURE__ */ jsx(
|
|
387
|
+
ScreenContainer,
|
|
388
|
+
{
|
|
389
|
+
scroll: true,
|
|
390
|
+
safeAreaEdges: ["left", "right", "bottom"],
|
|
391
|
+
testID,
|
|
392
|
+
contentClassName: cn("p-4", className),
|
|
393
|
+
keyboardShouldPersistTaps: "handled",
|
|
394
|
+
children: /* @__PURE__ */ jsx(View, { testID: `${testID}-form`, className: "gap-4", children })
|
|
395
|
+
}
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
function getNotificationsPageStackOptions(props) {
|
|
401
|
+
const {
|
|
402
|
+
headerTitle,
|
|
403
|
+
onMarkAllRead,
|
|
404
|
+
large,
|
|
405
|
+
scrollEdgeBehavior,
|
|
406
|
+
headerLeft,
|
|
407
|
+
headerRight,
|
|
408
|
+
headerOptions
|
|
409
|
+
} = props;
|
|
410
|
+
const resolvedHeaderRight = headerRight ?? (onMarkAllRead ? () => /* @__PURE__ */ jsx(
|
|
411
|
+
Pressable,
|
|
412
|
+
{
|
|
413
|
+
testID: "notifications-mark-all-read",
|
|
414
|
+
accessibilityRole: "button",
|
|
415
|
+
accessibilityLabel: "Mark all read",
|
|
416
|
+
onPress: onMarkAllRead,
|
|
417
|
+
hitSlop: 8,
|
|
418
|
+
className: "min-h-[44px] justify-center px-3",
|
|
419
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-base text-primary", children: "Mark all read" })
|
|
420
|
+
}
|
|
421
|
+
) : void 0);
|
|
422
|
+
return composeHeaderOptions({
|
|
423
|
+
headerTitle: headerTitle ?? "Notifications",
|
|
424
|
+
headerLeft,
|
|
425
|
+
headerRight: resolvedHeaderRight,
|
|
426
|
+
large: large ?? true,
|
|
427
|
+
scrollEdgeBehavior: scrollEdgeBehavior ?? "match",
|
|
428
|
+
headerOptions
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function bucketFor(ts, now = /* @__PURE__ */ new Date()) {
|
|
432
|
+
const d = typeof ts === "string" ? new Date(ts) : ts;
|
|
433
|
+
const startOfDay = (date) => {
|
|
434
|
+
const x = new Date(date);
|
|
435
|
+
x.setHours(0, 0, 0, 0);
|
|
436
|
+
return x.getTime();
|
|
437
|
+
};
|
|
438
|
+
const today = startOfDay(now);
|
|
439
|
+
const yesterday = today - 24 * 60 * 60 * 1e3;
|
|
440
|
+
const day = startOfDay(d);
|
|
441
|
+
if (day === today) return "Today";
|
|
442
|
+
if (day === yesterday) return "Yesterday";
|
|
443
|
+
return "Earlier";
|
|
444
|
+
}
|
|
445
|
+
function groupByDate(items, now = /* @__PURE__ */ new Date()) {
|
|
446
|
+
const map = /* @__PURE__ */ new Map();
|
|
447
|
+
for (const item of items) {
|
|
448
|
+
const bucket = bucketFor(item.timestamp, now);
|
|
449
|
+
const arr = map.get(bucket) ?? [];
|
|
450
|
+
arr.push(item);
|
|
451
|
+
map.set(bucket, arr);
|
|
452
|
+
}
|
|
453
|
+
const order = ["Today", "Yesterday", "Earlier"];
|
|
454
|
+
return order.filter((title) => map.has(title)).map((title) => ({
|
|
455
|
+
title,
|
|
456
|
+
data: map.get(title) ?? []
|
|
457
|
+
}));
|
|
458
|
+
}
|
|
459
|
+
function NotificationsPage({
|
|
460
|
+
items,
|
|
461
|
+
refreshing,
|
|
462
|
+
onRefresh,
|
|
463
|
+
emptyState,
|
|
464
|
+
emptyTitle,
|
|
465
|
+
emptyBody,
|
|
466
|
+
className,
|
|
467
|
+
testID = "notifications-page"
|
|
468
|
+
}) {
|
|
469
|
+
const sections = groupByDate(items);
|
|
470
|
+
if (items.length === 0) {
|
|
471
|
+
return /* @__PURE__ */ jsx(
|
|
472
|
+
SafeAreaView,
|
|
473
|
+
{
|
|
474
|
+
testID,
|
|
475
|
+
edges: ["left", "right", "bottom"],
|
|
476
|
+
className: cn("flex-1 bg-background", className),
|
|
477
|
+
children: emptyState ?? /* @__PURE__ */ jsx(
|
|
478
|
+
NativeEmptyState,
|
|
479
|
+
{
|
|
480
|
+
variant: "first-run",
|
|
481
|
+
title: emptyTitle ?? "No notifications",
|
|
482
|
+
body: emptyBody ?? "When you get a notification, it'll show up here.",
|
|
483
|
+
testID: `${testID}-empty`
|
|
484
|
+
}
|
|
485
|
+
)
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
return /* @__PURE__ */ jsx(
|
|
490
|
+
SafeAreaView,
|
|
491
|
+
{
|
|
492
|
+
testID,
|
|
493
|
+
edges: ["left", "right", "bottom"],
|
|
494
|
+
className: cn("flex-1 bg-background", className),
|
|
495
|
+
children: /* @__PURE__ */ jsx(
|
|
496
|
+
SectionList,
|
|
497
|
+
{
|
|
498
|
+
testID: `${testID}-list`,
|
|
499
|
+
sections,
|
|
500
|
+
keyExtractor: (item) => item.id,
|
|
501
|
+
renderSectionHeader: ({ section }) => /* @__PURE__ */ jsx(NativeSectionListHeader, { title: section.title }),
|
|
502
|
+
renderItem: ({ item }) => /* @__PURE__ */ jsx(
|
|
503
|
+
NativeListItem,
|
|
504
|
+
{
|
|
505
|
+
testID: item.testID ?? `${testID}-row-${item.id}`,
|
|
506
|
+
title: item.title,
|
|
507
|
+
subtitle: item.body,
|
|
508
|
+
leading: item.leading ?? /* @__PURE__ */ jsx(
|
|
509
|
+
UnreadDot,
|
|
510
|
+
{
|
|
511
|
+
unread: !!item.unread,
|
|
512
|
+
testID: `${testID}-row-${item.id}-unread`
|
|
513
|
+
}
|
|
514
|
+
),
|
|
515
|
+
onPress: item.onPress
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
ItemSeparatorComponent: () => /* @__PURE__ */ jsx(View, { className: "h-px bg-border ml-4" }),
|
|
519
|
+
refreshControl: onRefresh ? /* @__PURE__ */ jsx(
|
|
520
|
+
RefreshControl,
|
|
521
|
+
{
|
|
522
|
+
testID: `${testID}-refresh`,
|
|
523
|
+
refreshing: !!refreshing,
|
|
524
|
+
onRefresh
|
|
525
|
+
}
|
|
526
|
+
) : void 0,
|
|
527
|
+
contentContainerClassName: "pb-8"
|
|
528
|
+
}
|
|
529
|
+
)
|
|
530
|
+
}
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
function UnreadDot({
|
|
534
|
+
unread,
|
|
535
|
+
testID
|
|
536
|
+
}) {
|
|
537
|
+
if (!unread) {
|
|
538
|
+
return /* @__PURE__ */ jsx(View, { className: "h-2 w-2", testID });
|
|
539
|
+
}
|
|
540
|
+
return /* @__PURE__ */ jsx(
|
|
541
|
+
View,
|
|
542
|
+
{
|
|
543
|
+
testID,
|
|
544
|
+
accessibilityLabel: "Unread",
|
|
545
|
+
className: "h-2 w-2 rounded-full bg-primary"
|
|
546
|
+
}
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
function AuthBranding({
|
|
550
|
+
logo,
|
|
551
|
+
headline,
|
|
552
|
+
subhead,
|
|
553
|
+
className,
|
|
554
|
+
testID = "auth-branding"
|
|
555
|
+
}) {
|
|
556
|
+
return /* @__PURE__ */ jsxs(
|
|
557
|
+
View,
|
|
558
|
+
{
|
|
559
|
+
testID,
|
|
560
|
+
accessibilityRole: "header",
|
|
561
|
+
className: cn("items-center gap-3 pb-8", className),
|
|
562
|
+
children: [
|
|
563
|
+
logo ? /* @__PURE__ */ jsx(View, { testID: `${testID}-logo`, className: "mb-2", children: logo }) : null,
|
|
564
|
+
headline ? /* @__PURE__ */ jsx(
|
|
565
|
+
NativeText,
|
|
566
|
+
{
|
|
567
|
+
preset: "h1",
|
|
568
|
+
testID: `${testID}-headline`,
|
|
569
|
+
className: "text-center",
|
|
570
|
+
children: headline
|
|
571
|
+
}
|
|
572
|
+
) : null,
|
|
573
|
+
subhead ? /* @__PURE__ */ jsx(
|
|
574
|
+
NativeText,
|
|
575
|
+
{
|
|
576
|
+
preset: "body",
|
|
577
|
+
testID: `${testID}-subhead`,
|
|
578
|
+
className: "text-center text-muted-foreground",
|
|
579
|
+
children: subhead
|
|
580
|
+
}
|
|
581
|
+
) : null
|
|
582
|
+
]
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
function SocialAuthRow({
|
|
587
|
+
providers,
|
|
588
|
+
separator = "or",
|
|
589
|
+
className,
|
|
590
|
+
testID = "social-auth-row"
|
|
591
|
+
}) {
|
|
592
|
+
if (providers.length === 0) return null;
|
|
593
|
+
return /* @__PURE__ */ jsxs(View, { testID, className: cn("gap-3", className), children: [
|
|
594
|
+
/* @__PURE__ */ jsx(View, { className: "gap-2", children: providers.map((p) => /* @__PURE__ */ jsx(
|
|
595
|
+
NativeButton,
|
|
596
|
+
{
|
|
597
|
+
testID: `${testID}-${p.id}`,
|
|
598
|
+
variant: "outline",
|
|
599
|
+
disabled: p.disabled,
|
|
600
|
+
onPress: () => {
|
|
601
|
+
void p.onPress();
|
|
602
|
+
},
|
|
603
|
+
children: /* @__PURE__ */ jsxs(View, { className: "flex-row items-center gap-2", children: [
|
|
604
|
+
p.icon,
|
|
605
|
+
/* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: p.label })
|
|
606
|
+
] })
|
|
607
|
+
},
|
|
608
|
+
p.id
|
|
609
|
+
)) }),
|
|
610
|
+
separator !== null && separator !== void 0 ? /* @__PURE__ */ jsxs(
|
|
611
|
+
View,
|
|
612
|
+
{
|
|
613
|
+
testID: `${testID}-separator`,
|
|
614
|
+
className: "my-2 flex-row items-center gap-3",
|
|
615
|
+
accessibilityElementsHidden: true,
|
|
616
|
+
children: [
|
|
617
|
+
/* @__PURE__ */ jsx(View, { className: "h-px flex-1 bg-border" }),
|
|
618
|
+
/* @__PURE__ */ jsx(Text, { className: "text-xs uppercase tracking-wider text-muted-foreground", children: separator }),
|
|
619
|
+
/* @__PURE__ */ jsx(View, { className: "h-px flex-1 bg-border" })
|
|
620
|
+
]
|
|
621
|
+
}
|
|
622
|
+
) : null
|
|
623
|
+
] });
|
|
624
|
+
}
|
|
625
|
+
function AuthForm({
|
|
626
|
+
mode = "password",
|
|
627
|
+
onSubmit,
|
|
628
|
+
validate,
|
|
629
|
+
submitLabel,
|
|
630
|
+
loading,
|
|
631
|
+
errorMessage,
|
|
632
|
+
initialEmail = "",
|
|
633
|
+
belowFields,
|
|
634
|
+
className,
|
|
635
|
+
testID = "auth-form"
|
|
636
|
+
}) {
|
|
637
|
+
const [email, setEmail] = useState(initialEmail);
|
|
638
|
+
const [password, setPassword] = useState("");
|
|
639
|
+
const [localError, setLocalError] = useState(null);
|
|
640
|
+
const [submitting, setSubmitting] = useState(false);
|
|
641
|
+
const isMagic = mode === "magic-link";
|
|
642
|
+
const resolvedSubmitLabel = submitLabel ?? (isMagic ? "Send magic link" : "Sign in");
|
|
643
|
+
const handleSubmit = useCallback(async () => {
|
|
644
|
+
if (submitting || loading) return;
|
|
645
|
+
setLocalError(null);
|
|
646
|
+
const values = {
|
|
647
|
+
email: email.trim(),
|
|
648
|
+
password: isMagic ? "" : password
|
|
649
|
+
};
|
|
650
|
+
if (validate) {
|
|
651
|
+
const err = validate(values);
|
|
652
|
+
if (err) {
|
|
653
|
+
setLocalError(err);
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (!values.email) {
|
|
658
|
+
setLocalError("Email is required");
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
if (!isMagic && !values.password) {
|
|
662
|
+
setLocalError("Password is required");
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
setSubmitting(true);
|
|
666
|
+
try {
|
|
667
|
+
await onSubmit(values);
|
|
668
|
+
} catch (err) {
|
|
669
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
670
|
+
setLocalError(message);
|
|
671
|
+
} finally {
|
|
672
|
+
setSubmitting(false);
|
|
673
|
+
}
|
|
674
|
+
}, [email, password, isMagic, validate, onSubmit, submitting, loading]);
|
|
675
|
+
const visibleError = errorMessage ?? localError ?? null;
|
|
676
|
+
return /* @__PURE__ */ jsxs(View, { testID, className: cn("gap-3", className), children: [
|
|
677
|
+
/* @__PURE__ */ jsxs(View, { className: "gap-1", children: [
|
|
678
|
+
/* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: "Email" }),
|
|
679
|
+
/* @__PURE__ */ jsx(
|
|
680
|
+
NativeInput,
|
|
681
|
+
{
|
|
682
|
+
testID: `${testID}-email`,
|
|
683
|
+
accessibilityLabel: "Email",
|
|
684
|
+
value: email,
|
|
685
|
+
onChangeText: setEmail,
|
|
686
|
+
placeholder: "you@example.com",
|
|
687
|
+
autoCapitalize: "none",
|
|
688
|
+
autoCorrect: false,
|
|
689
|
+
keyboardType: "email-address",
|
|
690
|
+
returnKeyType: isMagic ? "send" : "next",
|
|
691
|
+
editable: !loading && !submitting,
|
|
692
|
+
onSubmitEditing: isMagic ? handleSubmit : void 0
|
|
693
|
+
}
|
|
694
|
+
)
|
|
695
|
+
] }),
|
|
696
|
+
isMagic ? null : /* @__PURE__ */ jsxs(View, { className: "gap-1", children: [
|
|
697
|
+
/* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: "Password" }),
|
|
698
|
+
/* @__PURE__ */ jsx(
|
|
699
|
+
NativeInput,
|
|
700
|
+
{
|
|
701
|
+
testID: `${testID}-password`,
|
|
702
|
+
accessibilityLabel: "Password",
|
|
703
|
+
value: password,
|
|
704
|
+
onChangeText: setPassword,
|
|
705
|
+
placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
706
|
+
secureTextEntry: true,
|
|
707
|
+
autoCapitalize: "none",
|
|
708
|
+
autoCorrect: false,
|
|
709
|
+
returnKeyType: "send",
|
|
710
|
+
editable: !loading && !submitting,
|
|
711
|
+
onSubmitEditing: handleSubmit
|
|
712
|
+
}
|
|
713
|
+
)
|
|
714
|
+
] }),
|
|
715
|
+
belowFields,
|
|
716
|
+
visibleError ? /* @__PURE__ */ jsx(
|
|
717
|
+
Text,
|
|
718
|
+
{
|
|
719
|
+
testID: `${testID}-error`,
|
|
720
|
+
accessibilityRole: "alert",
|
|
721
|
+
className: "text-sm text-destructive",
|
|
722
|
+
children: visibleError
|
|
723
|
+
}
|
|
724
|
+
) : null,
|
|
725
|
+
/* @__PURE__ */ jsx(
|
|
726
|
+
NativeButton,
|
|
727
|
+
{
|
|
728
|
+
testID: `${testID}-submit`,
|
|
729
|
+
onPress: () => {
|
|
730
|
+
void handleSubmit();
|
|
731
|
+
},
|
|
732
|
+
loading: loading || submitting,
|
|
733
|
+
disabled: loading || submitting,
|
|
734
|
+
children: resolvedSubmitLabel
|
|
735
|
+
}
|
|
736
|
+
)
|
|
737
|
+
] });
|
|
738
|
+
}
|
|
739
|
+
function ForgotPasswordLink({
|
|
740
|
+
onPress,
|
|
741
|
+
label = "Forgot password?",
|
|
742
|
+
testID = "auth-forgot-password"
|
|
743
|
+
}) {
|
|
744
|
+
return /* @__PURE__ */ jsx(
|
|
745
|
+
Pressable,
|
|
746
|
+
{
|
|
747
|
+
testID,
|
|
748
|
+
accessibilityRole: "link",
|
|
749
|
+
accessibilityLabel: label,
|
|
750
|
+
onPress,
|
|
751
|
+
hitSlop: 8,
|
|
752
|
+
className: "self-end",
|
|
753
|
+
children: /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-primary", children: label })
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
export { AuthBranding, AuthForm, ForgotPasswordLink, NavBarSaveButton, NavBarSearchBar, NavBarTitle, NotificationsPage, ScreenContainer, SettingsPage, SettingsSubPage, SocialAuthRow, composeHeaderOptions, confirmDiscardChanges, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions };
|
|
759
|
+
//# sourceMappingURL=chunk-BAU4YQZV.js.map
|
|
760
|
+
//# sourceMappingURL=chunk-BAU4YQZV.js.map
|