@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.
Files changed (129) hide show
  1. package/dist/chunk-BAU4YQZV.js +760 -0
  2. package/dist/chunk-BAU4YQZV.js.map +1 -0
  3. package/dist/chunk-DGUM43GV.js +10 -0
  4. package/dist/chunk-DGUM43GV.js.map +1 -0
  5. package/dist/chunk-HNIEFTEL.js +43 -0
  6. package/dist/chunk-HNIEFTEL.js.map +1 -0
  7. package/dist/chunk-N4WHTQIO.js +20 -0
  8. package/dist/chunk-N4WHTQIO.js.map +1 -0
  9. package/dist/chunk-OHZD7KRO.js +11 -0
  10. package/dist/chunk-OHZD7KRO.js.map +1 -0
  11. package/dist/chunk-PTJ2KCLM.js +160 -0
  12. package/dist/chunk-PTJ2KCLM.js.map +1 -0
  13. package/dist/chunk-TXJT55JC.js +2213 -0
  14. package/dist/chunk-TXJT55JC.js.map +1 -0
  15. package/dist/chunk-ULS7I6ZS.js +183 -0
  16. package/dist/chunk-ULS7I6ZS.js.map +1 -0
  17. package/dist/chunk-ZVF6PONU.js +522 -0
  18. package/dist/chunk-ZVF6PONU.js.map +1 -0
  19. package/dist/components/index.d.ts +908 -0
  20. package/dist/components/index.js +8 -0
  21. package/dist/components/index.js.map +1 -0
  22. package/dist/data/index.d.ts +117 -0
  23. package/dist/data/index.js +770 -0
  24. package/dist/data/index.js.map +1 -0
  25. package/dist/hooks/index.d.ts +31 -0
  26. package/dist/hooks/index.js +5 -0
  27. package/dist/hooks/index.js.map +1 -0
  28. package/dist/index.d.ts +11 -0
  29. package/dist/index.js +11 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/layouts/index.d.ts +364 -0
  32. package/dist/layouts/index.js +8 -0
  33. package/dist/layouts/index.js.map +1 -0
  34. package/dist/utils.d.ts +5 -0
  35. package/dist/utils.js +4 -0
  36. package/dist/utils.js.map +1 -0
  37. package/package.json +127 -0
  38. package/src/components/__tests__/accordion.test.tsx +122 -0
  39. package/src/components/__tests__/chip-group.test.tsx +45 -0
  40. package/src/components/__tests__/combobox.test.tsx +97 -0
  41. package/src/components/__tests__/drawer.test.tsx +98 -0
  42. package/src/components/__tests__/empty-state.test.tsx +66 -0
  43. package/src/components/__tests__/header-card.test.tsx +31 -0
  44. package/src/components/__tests__/layout.test.tsx +109 -0
  45. package/src/components/__tests__/list-item.test.tsx +31 -0
  46. package/src/components/__tests__/number-input.test.tsx +46 -0
  47. package/src/components/__tests__/pagination.test.tsx +43 -0
  48. package/src/components/__tests__/search-bar.test.tsx +41 -0
  49. package/src/components/__tests__/segmented-empty-alert.test.tsx +79 -0
  50. package/src/components/__tests__/slider.test.tsx +134 -0
  51. package/src/components/__tests__/stepper.test.tsx +25 -0
  52. package/src/components/__tests__/toast.test.tsx +63 -0
  53. package/src/components/accordion.tsx +223 -0
  54. package/src/components/alert.tsx +131 -0
  55. package/src/components/avatar.tsx +68 -0
  56. package/src/components/badge.tsx +80 -0
  57. package/src/components/button.tsx +118 -0
  58. package/src/components/card.tsx +120 -0
  59. package/src/components/checkbox.tsx +60 -0
  60. package/src/components/chip-group.tsx +127 -0
  61. package/src/components/combobox.tsx +137 -0
  62. package/src/components/date-time-picker.tsx +127 -0
  63. package/src/components/dialog.tsx +131 -0
  64. package/src/components/drawer.tsx +131 -0
  65. package/src/components/dropdown-menu.tsx +133 -0
  66. package/src/components/empty-state.tsx +161 -0
  67. package/src/components/header-card.tsx +116 -0
  68. package/src/components/index.ts +259 -0
  69. package/src/components/inline-alert.tsx +150 -0
  70. package/src/components/input.tsx +51 -0
  71. package/src/components/label.tsx +35 -0
  72. package/src/components/layout/box.tsx +115 -0
  73. package/src/components/layout/flex.ts +24 -0
  74. package/src/components/layout/grid.tsx +73 -0
  75. package/src/components/layout/index.ts +27 -0
  76. package/src/components/layout/inline.tsx +63 -0
  77. package/src/components/layout/spacing.ts +116 -0
  78. package/src/components/layout/stack.tsx +58 -0
  79. package/src/components/list-item.tsx +108 -0
  80. package/src/components/number-input.tsx +119 -0
  81. package/src/components/pagination.tsx +132 -0
  82. package/src/components/popover.tsx +198 -0
  83. package/src/components/progress.tsx +50 -0
  84. package/src/components/radio-group.tsx +92 -0
  85. package/src/components/refresh-control.tsx +73 -0
  86. package/src/components/search-bar.tsx +128 -0
  87. package/src/components/section-list.tsx +54 -0
  88. package/src/components/segmented-control.tsx +79 -0
  89. package/src/components/select.tsx +178 -0
  90. package/src/components/separator.tsx +31 -0
  91. package/src/components/sheet.tsx +192 -0
  92. package/src/components/skeleton.tsx +104 -0
  93. package/src/components/slider.tsx +223 -0
  94. package/src/components/stepper.tsx +96 -0
  95. package/src/components/switch.tsx +35 -0
  96. package/src/components/tabs.tsx +147 -0
  97. package/src/components/text.tsx +62 -0
  98. package/src/components/textarea.tsx +52 -0
  99. package/src/components/toast.tsx +228 -0
  100. package/src/components/toggle.tsx +85 -0
  101. package/src/components/tooltip.tsx +104 -0
  102. package/src/data/NativeDataFilters.tsx +100 -0
  103. package/src/data/NativeDataPageShell.tsx +111 -0
  104. package/src/data/NativeDetailPanel.tsx +130 -0
  105. package/src/data/NativeEmptyState.tsx +46 -0
  106. package/src/data/NativeResourceForm.tsx +157 -0
  107. package/src/data/NativeResourceFormField.tsx +280 -0
  108. package/src/data/NativeResourcePage.tsx +505 -0
  109. package/src/data/index.ts +9 -0
  110. package/src/hooks/index.ts +16 -0
  111. package/src/hooks/use-genesis-extension.ts +81 -0
  112. package/src/hooks/use-reduced-motion.ts +32 -0
  113. package/src/hooks/use-theme-mode.ts +31 -0
  114. package/src/index.ts +5 -0
  115. package/src/layouts/__tests__/auth.test.tsx +150 -0
  116. package/src/layouts/__tests__/nav-bar.test.tsx +86 -0
  117. package/src/layouts/__tests__/notifications-page.test.tsx +94 -0
  118. package/src/layouts/__tests__/screen-container.test.tsx +79 -0
  119. package/src/layouts/__tests__/settings-page.test.tsx +107 -0
  120. package/src/layouts/__tests__/settings-sub-page.test.tsx +53 -0
  121. package/src/layouts/auth.tsx +352 -0
  122. package/src/layouts/index.ts +61 -0
  123. package/src/layouts/nav-bar.tsx +200 -0
  124. package/src/layouts/notifications-page.tsx +274 -0
  125. package/src/layouts/screen-container.tsx +213 -0
  126. package/src/layouts/settings-page.tsx +195 -0
  127. package/src/layouts/settings-sub-page.tsx +183 -0
  128. package/src/nativewind.d.ts +40 -0
  129. package/src/utils.ts +6 -0
@@ -0,0 +1,505 @@
1
+ import * as React from "react";
2
+ import { useCallback, useEffect, useMemo, useState, type ReactNode } from "react";
3
+ import {
4
+ FlatList,
5
+ Pressable,
6
+ View,
7
+ } from "react-native";
8
+ import { SafeAreaView } from "react-native-safe-area-context";
9
+ import { useResource, type UseResourceOptions } from "@marktiderman/genesis-core/hooks";
10
+ import type { BaseRecord } from "@marktiderman/genesis-core";
11
+ import { NativeText } from "../components/text";
12
+ import {
13
+ NativeCard,
14
+ NativeCardHeader,
15
+ NativeCardTitle,
16
+ NativeCardContent,
17
+ } from "../components/card";
18
+ import { NativeButton } from "../components/button";
19
+ import { NativeSkeleton } from "../components/skeleton";
20
+ import { NativeDataFilters } from "./NativeDataFilters";
21
+ import { NativeEmptyState } from "./NativeEmptyState";
22
+
23
+ // ---------------------------------------------------------------------------
24
+ // Types
25
+ // ---------------------------------------------------------------------------
26
+
27
+ export interface NativeCardFieldDef<T> {
28
+ key: Extract<keyof T, string>;
29
+ label?: string;
30
+ render?: (value: unknown, item: T) => ReactNode;
31
+ position?: "title" | "badge" | "subtitle" | "meta";
32
+ }
33
+
34
+ export interface NativeResourcePageProps<T extends BaseRecord = BaseRecord> {
35
+ // Data source
36
+ resource: string;
37
+ resourceOptions?: UseResourceOptions<T>;
38
+
39
+ // Page chrome
40
+ title: string;
41
+ subtitle?: string;
42
+
43
+ // List rendering
44
+ cardFields?: Array<string | NativeCardFieldDef<T>>;
45
+ renderItem?: (item: T) => ReactNode;
46
+
47
+ // Search & filters
48
+ searchFields?: string[];
49
+ searchPlaceholder?: string;
50
+ statusFilter?: string | { field: string; options?: string[] };
51
+
52
+ // Detail
53
+ onItemPress?: (item: T) => void;
54
+ titleField?: Extract<keyof T, string>;
55
+
56
+ // CRUD — presence of onCreatePress enables the create button
57
+ onCreatePress?: () => void;
58
+ createLabel?: string;
59
+
60
+ // Slots
61
+ headerRight?: ReactNode;
62
+ emptyState?: ReactNode;
63
+ }
64
+
65
+ // ---------------------------------------------------------------------------
66
+ // Helpers
67
+ // ---------------------------------------------------------------------------
68
+
69
+ function resolveField<T>(
70
+ f: string | NativeCardFieldDef<T>,
71
+ index: number
72
+ ): NativeCardFieldDef<T> {
73
+ if (typeof f === "string") {
74
+ return {
75
+ key: f as Extract<keyof T, string>,
76
+ position: index === 0 ? "title" : "meta",
77
+ };
78
+ }
79
+ return f;
80
+ }
81
+
82
+ function autoDetectFields<T extends BaseRecord>(
83
+ item: T
84
+ ): Array<NativeCardFieldDef<T>> {
85
+ const keys = Object.keys(item).filter((k) => k !== "id");
86
+ return keys.map((key, i) => ({
87
+ key: key as Extract<keyof T, string>,
88
+ position: i === 0 ? ("title" as const) : ("meta" as const),
89
+ }));
90
+ }
91
+
92
+ // ---------------------------------------------------------------------------
93
+ // DefaultCardRenderer
94
+ // ---------------------------------------------------------------------------
95
+
96
+ interface DefaultCardRendererProps<T extends BaseRecord> {
97
+ item: T;
98
+ fields: Array<NativeCardFieldDef<T>>;
99
+ onPress?: (item: T) => void;
100
+ }
101
+
102
+ function DefaultCardRenderer<T extends BaseRecord>({
103
+ item,
104
+ fields,
105
+ onPress,
106
+ }: DefaultCardRendererProps<T>) {
107
+ const titleField = fields.find((f) => f.position === "title");
108
+ const badgeField = fields.find((f) => f.position === "badge");
109
+ const subtitleField = fields.find((f) => f.position === "subtitle");
110
+ const metaFields = fields.filter((f) => f.position === "meta");
111
+
112
+ const renderValue = (field: NativeCardFieldDef<T>): ReactNode => {
113
+ const value = item[field.key];
114
+ if (field.render) {
115
+ return field.render(value, item);
116
+ }
117
+ if (value === null || value === undefined) return null;
118
+ return String(value);
119
+ };
120
+
121
+ const titleContent = titleField ? renderValue(titleField) : null;
122
+ const badgeContent = badgeField ? renderValue(badgeField) : null;
123
+ const subtitleContent = subtitleField ? renderValue(subtitleField) : null;
124
+
125
+ return (
126
+ <Pressable
127
+ onPress={onPress ? () => onPress(item) : undefined}
128
+ style={({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })}
129
+ >
130
+ <NativeCard className="mx-4 mb-3">
131
+ <NativeCardHeader className="pb-2">
132
+ <View style={{ flexDirection: "row", alignItems: "center", justifyContent: "space-between" }}>
133
+ {titleContent !== null ? (
134
+ <NativeCardTitle className="flex-1 text-base">
135
+ {titleContent}
136
+ </NativeCardTitle>
137
+ ) : null}
138
+ {badgeContent !== null ? (
139
+ <NativeText preset="body-sm" className="text-muted-foreground ml-2">
140
+ {badgeContent}
141
+ </NativeText>
142
+ ) : null}
143
+ </View>
144
+ {subtitleContent !== null ? (
145
+ <NativeText preset="body-sm" className="text-muted-foreground mt-0.5">
146
+ {subtitleContent}
147
+ </NativeText>
148
+ ) : null}
149
+ </NativeCardHeader>
150
+ {metaFields.length > 0 ? (
151
+ <NativeCardContent className="pt-0">
152
+ <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
153
+ {metaFields.map((field) => {
154
+ const val = renderValue(field);
155
+ if (val === null) return null;
156
+ return (
157
+ <NativeText key={field.key} preset="caption" className="text-muted-foreground">
158
+ {field.label ? `${field.label}: ` : ""}
159
+ {val}
160
+ </NativeText>
161
+ );
162
+ })}
163
+ </View>
164
+ </NativeCardContent>
165
+ ) : null}
166
+ </NativeCard>
167
+ </Pressable>
168
+ );
169
+ }
170
+
171
+ // ---------------------------------------------------------------------------
172
+ // NativeResourcePage
173
+ // ---------------------------------------------------------------------------
174
+
175
+ function NativeResourcePage<T extends BaseRecord = BaseRecord>({
176
+ resource,
177
+ resourceOptions,
178
+ title,
179
+ subtitle,
180
+ cardFields,
181
+ renderItem,
182
+ searchFields,
183
+ searchPlaceholder,
184
+ statusFilter,
185
+ onItemPress,
186
+ titleField,
187
+ onCreatePress,
188
+ createLabel = "New",
189
+ headerRight,
190
+ emptyState,
191
+ }: NativeResourcePageProps<T>) {
192
+ // -------------------------------------------------------------------------
193
+ // State
194
+ // -------------------------------------------------------------------------
195
+
196
+ const [search, setSearchLocal] = useState("");
197
+ const [selectedStatuses, setSelectedStatuses] = useState<string[]>([]);
198
+
199
+ // -------------------------------------------------------------------------
200
+ // Resolve status filter config
201
+ // -------------------------------------------------------------------------
202
+
203
+ const statusFilterConfig = useMemo(() => {
204
+ if (!statusFilter) return null;
205
+ if (typeof statusFilter === "string") {
206
+ return { field: statusFilter, options: undefined };
207
+ }
208
+ return { field: statusFilter.field, options: statusFilter.options };
209
+ }, [statusFilter]);
210
+
211
+ // -------------------------------------------------------------------------
212
+ // Resource hook — pass searchFields so server-side search works
213
+ // -------------------------------------------------------------------------
214
+
215
+ const mergedOptions: UseResourceOptions<T> = useMemo(
216
+ () => ({
217
+ ...resourceOptions,
218
+ searchFields: searchFields ?? resourceOptions?.searchFields,
219
+ }),
220
+ // eslint-disable-next-line react-hooks/exhaustive-deps
221
+ [resourceOptions, searchFields]
222
+ );
223
+
224
+ const { list, setSearch, setFilters } = useResource<T>(resource, mergedOptions);
225
+
226
+ // -------------------------------------------------------------------------
227
+ // Sync search state → hook
228
+ // -------------------------------------------------------------------------
229
+
230
+ useEffect(() => {
231
+ setSearch(search);
232
+ }, [search, setSearch]);
233
+
234
+ // -------------------------------------------------------------------------
235
+ // Sync status filter → hook
236
+ // -------------------------------------------------------------------------
237
+
238
+ useEffect(() => {
239
+ if (!statusFilterConfig) return;
240
+
241
+ if (selectedStatuses.length === 0) {
242
+ setFilters([]);
243
+ } else if (selectedStatuses.length === 1) {
244
+ setFilters([
245
+ {
246
+ field: statusFilterConfig.field,
247
+ operator: "eq" as const,
248
+ value: selectedStatuses[0],
249
+ },
250
+ ]);
251
+ } else {
252
+ setFilters([
253
+ {
254
+ field: statusFilterConfig.field,
255
+ operator: "in" as const,
256
+ value: selectedStatuses,
257
+ },
258
+ ]);
259
+ }
260
+ }, [selectedStatuses, statusFilterConfig, setFilters]);
261
+
262
+ // -------------------------------------------------------------------------
263
+ // Derived data
264
+ // -------------------------------------------------------------------------
265
+
266
+ const items: T[] = list.data?.data ?? [];
267
+ const isLoading = list.isLoading;
268
+ const hasError = list.isError;
269
+
270
+ // -------------------------------------------------------------------------
271
+ // Resolve card fields
272
+ // -------------------------------------------------------------------------
273
+
274
+ const resolvedFields = useMemo<Array<NativeCardFieldDef<T>>>(() => {
275
+ // If titleField provided, inject it as an explicit title override
276
+ if (titleField && cardFields) {
277
+ const resolved = cardFields.map((f, i) => resolveField<T>(f, i));
278
+ // ensure titleField has position=title
279
+ return resolved.map((f) =>
280
+ f.key === titleField ? { ...f, position: "title" as const } : f
281
+ );
282
+ }
283
+ if (cardFields && cardFields.length > 0) {
284
+ return cardFields.map((f, i) => resolveField<T>(f, i));
285
+ }
286
+ // Auto-detect from first item
287
+ if (items.length > 0) {
288
+ const detected = autoDetectFields(items[0]);
289
+ if (titleField) {
290
+ return detected.map((f) =>
291
+ f.key === titleField ? { ...f, position: "title" as const } : f
292
+ );
293
+ }
294
+ return detected;
295
+ }
296
+ return [];
297
+ }, [cardFields, titleField, items]);
298
+
299
+ // -------------------------------------------------------------------------
300
+ // Status chip options
301
+ // -------------------------------------------------------------------------
302
+
303
+ const statusOptions = useMemo<string[]>(() => {
304
+ if (!statusFilterConfig) return [];
305
+ if (statusFilterConfig.options) return statusFilterConfig.options;
306
+ // Auto-detect from data
307
+ const values = new Set<string>();
308
+ for (const item of items) {
309
+ const v = item[statusFilterConfig.field];
310
+ if (typeof v === "string") values.add(v);
311
+ }
312
+ return Array.from(values).sort();
313
+ }, [statusFilterConfig, items]);
314
+
315
+ // -------------------------------------------------------------------------
316
+ // Header right — create button or custom
317
+ // -------------------------------------------------------------------------
318
+
319
+ const effectiveHeaderRight = useMemo<ReactNode>(() => {
320
+ if (onCreatePress) {
321
+ return (
322
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
323
+ {headerRight}
324
+ <NativeButton size="sm" onPress={onCreatePress}>
325
+ {createLabel}
326
+ </NativeButton>
327
+ </View>
328
+ );
329
+ }
330
+ return headerRight ?? null;
331
+ }, [onCreatePress, createLabel, headerRight]);
332
+
333
+ // -------------------------------------------------------------------------
334
+ // Pull-to-refresh
335
+ // -------------------------------------------------------------------------
336
+
337
+ const [refreshing, setRefreshing] = useState(false);
338
+
339
+ const refetch = list.refetch;
340
+
341
+ const handleRefresh = useCallback(async () => {
342
+ setRefreshing(true);
343
+ try {
344
+ await refetch();
345
+ } catch (err) {
346
+ console.error(`[NativeResourcePage] Pull-to-refresh failed:`, err);
347
+ } finally {
348
+ setRefreshing(false);
349
+ }
350
+ }, [refetch]);
351
+
352
+ // -------------------------------------------------------------------------
353
+ // Filter awareness for empty state
354
+ // -------------------------------------------------------------------------
355
+
356
+ const hasActiveFilters = search.length > 0 || selectedStatuses.length > 0;
357
+
358
+ const handleClearFilters = useCallback(() => {
359
+ setSearchLocal("");
360
+ setSelectedStatuses([]);
361
+ }, []);
362
+
363
+ // -------------------------------------------------------------------------
364
+ // FlatList helpers
365
+ // -------------------------------------------------------------------------
366
+
367
+ const keyExtractor = useCallback(
368
+ (item: T) => String(item.id),
369
+ []
370
+ );
371
+
372
+ const renderFlatListItem = useCallback(
373
+ ({ item }: { item: T }) => {
374
+ if (renderItem) {
375
+ return <>{renderItem(item)}</>;
376
+ }
377
+ return (
378
+ <DefaultCardRenderer
379
+ item={item}
380
+ fields={resolvedFields}
381
+ onPress={onItemPress}
382
+ />
383
+ );
384
+ },
385
+ [renderItem, resolvedFields, onItemPress]
386
+ );
387
+
388
+ // Filters rendered as FlatList header to avoid ScrollView nesting
389
+ const ListHeaderComponent = useMemo(
390
+ () => (
391
+ <View className="px-4 pb-3">
392
+ <NativeDataFilters
393
+ search={search}
394
+ onSearchChange={setSearchLocal}
395
+ searchPlaceholder={searchPlaceholder}
396
+ statusChips={
397
+ statusOptions.length > 0
398
+ ? {
399
+ options: statusOptions,
400
+ selected: selectedStatuses,
401
+ onChange: setSelectedStatuses,
402
+ }
403
+ : undefined
404
+ }
405
+ />
406
+ </View>
407
+ ),
408
+ [search, searchPlaceholder, statusOptions, selectedStatuses]
409
+ );
410
+
411
+ const ListEmptyComponent = useMemo(
412
+ () =>
413
+ isLoading ? null : (
414
+ <>
415
+ {emptyState ?? (
416
+ <NativeEmptyState
417
+ hasFilters={hasActiveFilters}
418
+ onClearFilters={hasActiveFilters ? handleClearFilters : undefined}
419
+ />
420
+ )}
421
+ </>
422
+ ),
423
+ [isLoading, emptyState, hasActiveFilters, handleClearFilters]
424
+ );
425
+
426
+ // -------------------------------------------------------------------------
427
+ // Render — loading/error use shell-style layout; list uses FlatList directly
428
+ // NOTE: NativeDataPageShell wraps children in ScrollView which conflicts with
429
+ // FlatList — so we replicate the shell's header + SafeAreaView manually.
430
+ // -------------------------------------------------------------------------
431
+
432
+ const renderPageContent = () => {
433
+ if (isLoading) {
434
+ return (
435
+ <View className="px-4 pt-4 gap-3">
436
+ <NativeSkeleton className="w-full h-10 rounded-lg" />
437
+ <NativeSkeleton className="w-full h-20 rounded-lg" />
438
+ <NativeSkeleton className="w-full h-20 rounded-lg" />
439
+ <NativeSkeleton className="w-full h-20 rounded-lg" />
440
+ </View>
441
+ );
442
+ }
443
+
444
+ if (hasError) {
445
+ return (
446
+ <View className="flex-1 items-center justify-center px-4 py-12 gap-4">
447
+ <NativeText preset="body" className="text-destructive text-center">
448
+ {list.error?.message ?? "Something went wrong."}
449
+ </NativeText>
450
+ <NativeButton variant="outline" size="sm" onPress={() => list.refetch()}>
451
+ Try Again
452
+ </NativeButton>
453
+ </View>
454
+ );
455
+ }
456
+
457
+ return (
458
+ <FlatList<T>
459
+ data={items}
460
+ keyExtractor={keyExtractor}
461
+ renderItem={renderFlatListItem}
462
+ ListHeaderComponent={ListHeaderComponent}
463
+ ListEmptyComponent={ListEmptyComponent}
464
+ contentContainerStyle={{ flexGrow: 1, paddingBottom: 24 }}
465
+ refreshing={refreshing}
466
+ onRefresh={handleRefresh}
467
+ />
468
+ );
469
+ };
470
+
471
+ return (
472
+ <SafeAreaView edges={["left", "right"]} className="flex-1 bg-background">
473
+ {/* Page header */}
474
+ <View className="px-4 pt-4 pb-2">
475
+ <View
476
+ style={{
477
+ flexDirection: "row",
478
+ alignItems: "center",
479
+ justifyContent: "space-between",
480
+ }}
481
+ >
482
+ <View className="flex-1">
483
+ <NativeText preset="h2">{title}</NativeText>
484
+ {subtitle ? (
485
+ <NativeText
486
+ preset="body-sm"
487
+ className="text-muted-foreground mt-0.5"
488
+ >
489
+ {subtitle}
490
+ </NativeText>
491
+ ) : null}
492
+ </View>
493
+ {effectiveHeaderRight ? (
494
+ <View className="ml-3">{effectiveHeaderRight}</View>
495
+ ) : null}
496
+ </View>
497
+ </View>
498
+
499
+ {/* Content */}
500
+ <View className="flex-1">{renderPageContent()}</View>
501
+ </SafeAreaView>
502
+ );
503
+ }
504
+
505
+ export { NativeResourcePage };
@@ -0,0 +1,9 @@
1
+ // Data components — high-level config-driven components mirroring @marktiderman/genesis-ui/data
2
+ // Components are added as they are implemented in subsequent tasks.
3
+ export { NativeEmptyState, type NativeEmptyStateProps } from "./NativeEmptyState";
4
+ export { NativeDataFilters, type NativeDataFiltersProps } from "./NativeDataFilters";
5
+ export { NativeDataPageShell, type NativeDataPageShellProps } from "./NativeDataPageShell";
6
+ export { NativeDetailPanel, type NativeDetailPanelProps, type NativeDetailField } from "./NativeDetailPanel";
7
+ export { NativeResourceFormFieldRenderer, type NativeResourceFormFieldRendererProps } from "./NativeResourceFormField";
8
+ export { NativeResourceForm, type NativeResourceFormProps } from "./NativeResourceForm";
9
+ export { NativeResourcePage, type NativeResourcePageProps, type NativeCardFieldDef } from "./NativeResourcePage";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Genesis UI-native hooks — Layer-3/4 helpers.
3
+ *
4
+ * Hooks here are meant for consumer code AND internal Genesis primitives.
5
+ * Group conventions mirror genesis-core/src/hooks (category folders for
6
+ * future growth; flat exports today since the surface is small).
7
+ */
8
+
9
+ export { useReducedMotion } from "./use-reduced-motion";
10
+ export { useThemeMode, type ThemeMode } from "./use-theme-mode";
11
+ export {
12
+ BrandExtensionsProvider,
13
+ useGenesisExtension,
14
+ type BrandExtensionsValue,
15
+ type BrandExtensionsProviderProps,
16
+ } from "./use-genesis-extension";
@@ -0,0 +1,81 @@
1
+ /**
2
+ * useGenesisExtension — read a brand-package `extensions[<key>]` token scale.
3
+ *
4
+ * Brand packages declare domain-specific token categories under the
5
+ * `extensions` slot of the canonical schema (PRD-07 D8 design decision).
6
+ * Genesis primitives don't read these — only consumer composites do — so
7
+ * this hook is the canonical accessor.
8
+ *
9
+ * Resolution order:
10
+ * 1. `BrandExtensionsContext` value (set via <BrandExtensionsProvider>)
11
+ * 2. `undefined` — the extension key isn't declared
12
+ *
13
+ * Consumers wire the provider once at app root; calls anywhere downstream
14
+ * read by key.
15
+ *
16
+ * <BrandExtensionsProvider value={brand.extensions}>
17
+ * <App />
18
+ * </BrandExtensionsProvider>
19
+ *
20
+ * const moodTokens = useGenesisExtension("mood");
21
+ * // moodTokens?.[500] etc. — shape is consumer-defined
22
+ *
23
+ * Type contract: the canonical `BrandExtensions` interface lives in
24
+ * `@marktiderman/genesis-design-system` (declaration-merging surface). At
25
+ * runtime, consumers may pass a partially-populated object whose keys
26
+ * match their own augmented `BrandExtensions`. We intentionally accept
27
+ * `Partial<BrandExtensions>` here so the provider works with brand
28
+ * packages that haven't declared extensions yet (a common case in newly
29
+ * scaffolded apps).
30
+ *
31
+ * @stability Beta
32
+ */
33
+ import {
34
+ createContext,
35
+ createElement,
36
+ useContext,
37
+ type ReactNode,
38
+ } from "react";
39
+ import type { BrandExtensions } from "@marktiderman/genesis-design-system";
40
+
41
+ /**
42
+ * Runtime shape passed to `<BrandExtensionsProvider>`. Consumers augment
43
+ * the canonical `BrandExtensions` interface (in design-system) via TS
44
+ * declaration merging; the provider accepts the resulting record.
45
+ *
46
+ * `Partial<>` so brand packages that have no extensions can still wrap
47
+ * their app in the provider without TS errors.
48
+ */
49
+ export type BrandExtensionsValue = Partial<BrandExtensions>;
50
+
51
+ const BrandExtensionsContext = createContext<BrandExtensionsValue | undefined>(
52
+ undefined,
53
+ );
54
+
55
+ export interface BrandExtensionsProviderProps {
56
+ value?: BrandExtensionsValue;
57
+ children: ReactNode;
58
+ }
59
+
60
+ export function BrandExtensionsProvider({
61
+ value,
62
+ children,
63
+ }: BrandExtensionsProviderProps) {
64
+ return createElement(
65
+ BrandExtensionsContext.Provider,
66
+ { value },
67
+ children,
68
+ );
69
+ }
70
+
71
+ /**
72
+ * Read an extension scale by key. Returns `undefined` when the provider
73
+ * isn't mounted OR when the key isn't declared on the brand. The return
74
+ * type follows the consumer's augmented `BrandExtensions[K]`.
75
+ */
76
+ export function useGenesisExtension<K extends keyof BrandExtensions>(
77
+ key: K,
78
+ ): BrandExtensions[K] | undefined {
79
+ const ctx = useContext(BrandExtensionsContext);
80
+ return ctx?.[key];
81
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * useReducedMotion — subscribe to the OS reduce-motion preference.
3
+ *
4
+ * Returns `true` when the user has enabled reduce-motion at the OS level.
5
+ * Components that animate (Sheet, Drawer, Toast, etc.) honor this hook by
6
+ * skipping non-essential transitions and snapping into final state.
7
+ *
8
+ * @stability Beta
9
+ */
10
+ import { useEffect, useState } from "react";
11
+ import { AccessibilityInfo } from "react-native";
12
+
13
+ export function useReducedMotion(): boolean {
14
+ const [reduced, setReduced] = useState(false);
15
+
16
+ useEffect(() => {
17
+ let mounted = true;
18
+ AccessibilityInfo.isReduceMotionEnabled().then((v) => {
19
+ if (mounted) setReduced(v);
20
+ });
21
+ const sub = AccessibilityInfo.addEventListener(
22
+ "reduceMotionChanged",
23
+ (v: boolean) => setReduced(v),
24
+ );
25
+ return () => {
26
+ mounted = false;
27
+ sub?.remove?.();
28
+ };
29
+ }, []);
30
+
31
+ return reduced;
32
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * useThemeMode — read the active color scheme (light / dark / unset).
3
+ *
4
+ * Wraps RN's `Appearance.getColorScheme()` + `Appearance.addChangeListener`
5
+ * with a stable React hook so consumers don't have to wire it themselves.
6
+ *
7
+ * Use this in tokens-aware components when you need to choose between
8
+ * light/dark variants OUTSIDE of Tailwind's `dark:` modifier (e.g., to pick
9
+ * an asset, run an extra-color computation, or set StatusBar style).
10
+ *
11
+ * @stability Beta
12
+ */
13
+ import { useEffect, useState } from "react";
14
+ import { Appearance, type ColorSchemeName } from "react-native";
15
+
16
+ export type ThemeMode = "light" | "dark";
17
+
18
+ export function useThemeMode(): ThemeMode {
19
+ const [scheme, setScheme] = useState<ColorSchemeName>(
20
+ Appearance.getColorScheme(),
21
+ );
22
+
23
+ useEffect(() => {
24
+ const sub = Appearance.addChangeListener(({ colorScheme }) => {
25
+ setScheme(colorScheme);
26
+ });
27
+ return () => sub.remove();
28
+ }, []);
29
+
30
+ return scheme === "dark" ? "dark" : "light";
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ /// <reference path="./nativewind.d.ts" />
2
+ export * from "./components";
3
+ export * from "./hooks";
4
+ export * from "./layouts";
5
+ export { cn } from "./utils";