@terreno/ui 0.30.0 → 56.0.0-beta.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 (118) hide show
  1. package/dist/ActionSheet.d.ts +1 -1
  2. package/dist/Avatar.js +1 -4
  3. package/dist/Avatar.js.map +1 -1
  4. package/dist/Box.js +45 -9
  5. package/dist/Box.js.map +1 -1
  6. package/dist/Common.d.ts +21 -0
  7. package/dist/Common.js.map +1 -1
  8. package/dist/ConflictSheet.d.ts +53 -0
  9. package/dist/ConflictSheet.js +132 -0
  10. package/dist/ConflictSheet.js.map +1 -0
  11. package/dist/DateTimeActionSheet.d.ts +2 -1
  12. package/dist/DecimalRangeActionSheet.d.ts +1 -1
  13. package/dist/EmojiSelector.d.ts +1 -1
  14. package/dist/ErrorPage.d.ts +1 -1
  15. package/dist/HeightActionSheet.d.ts +1 -1
  16. package/dist/Hyperlink.d.ts +2 -1
  17. package/dist/Hyperlink.js +2 -1
  18. package/dist/Hyperlink.js.map +1 -1
  19. package/dist/Image.d.ts +1 -1
  20. package/dist/ImageBackground.d.ts +1 -1
  21. package/dist/MobileAddressAutoComplete.d.ts +1 -1
  22. package/dist/NumberPickerActionSheet.d.ts +1 -1
  23. package/dist/Page.d.ts +3 -3
  24. package/dist/PickerSelect.d.ts +1 -1
  25. package/dist/SidebarNavigation.js +1 -1
  26. package/dist/SidebarNavigation.js.map +1 -1
  27. package/dist/SidebarNavigation.native.js +1 -1
  28. package/dist/SidebarNavigation.native.js.map +1 -1
  29. package/dist/SplitPage.d.ts +1 -1
  30. package/dist/SplitPage.js +1 -4
  31. package/dist/SplitPage.js.map +1 -1
  32. package/dist/SplitPage.native.d.ts +1 -1
  33. package/dist/SyncStatusBanner.d.ts +46 -0
  34. package/dist/SyncStatusBanner.js +29 -0
  35. package/dist/SyncStatusBanner.js.map +1 -0
  36. package/dist/Theme.d.ts +1 -1
  37. package/dist/Toast.d.ts +9 -1
  38. package/dist/Toast.js +20 -7
  39. package/dist/Toast.js.map +1 -1
  40. package/dist/ToastNotifications.js +23 -1
  41. package/dist/ToastNotifications.js.map +1 -1
  42. package/dist/UnifiedAddressAutoComplete.d.ts +1 -1
  43. package/dist/Unifier.js +1 -1
  44. package/dist/Unifier.js.map +1 -1
  45. package/dist/conflictFieldDiff.d.ts +14 -0
  46. package/dist/conflictFieldDiff.js +62 -0
  47. package/dist/conflictFieldDiff.js.map +1 -0
  48. package/dist/icons/OfflineIcon.d.ts +1 -1
  49. package/dist/icons/OnlineIcon.d.ts +1 -1
  50. package/dist/icons/OutOfficeIcon.d.ts +1 -1
  51. package/dist/index.d.ts +5 -2
  52. package/dist/index.js +5 -2
  53. package/dist/index.js.map +1 -1
  54. package/dist/pdfHtmlTemplate.d.ts +30 -0
  55. package/dist/pdfHtmlTemplate.js +170 -0
  56. package/dist/pdfHtmlTemplate.js.map +1 -0
  57. package/dist/table/TableTitle.js +1 -3
  58. package/dist/table/TableTitle.js.map +1 -1
  59. package/dist/useAppLaunchOrForeground.d.ts +9 -0
  60. package/dist/useAppLaunchOrForeground.js +27 -0
  61. package/dist/useAppLaunchOrForeground.js.map +1 -0
  62. package/package.json +44 -37
  63. package/src/Box.test.tsx +39 -9
  64. package/src/Box.tsx +46 -7
  65. package/src/Common.ts +21 -3
  66. package/src/ConflictSheet.test.tsx +461 -0
  67. package/src/ConflictSheet.tsx +399 -0
  68. package/src/DataTable.test.tsx +15 -21
  69. package/src/Hyperlink.tsx +1 -1
  70. package/src/SidebarNavigation.native.tsx +1 -1
  71. package/src/SidebarNavigation.tsx +1 -1
  72. package/src/SyncStatusBanner.test.tsx +204 -0
  73. package/src/SyncStatusBanner.tsx +148 -0
  74. package/src/TapToEdit.test.tsx +8 -14
  75. package/src/TerrenoProvider.test.tsx +3 -4
  76. package/src/Toast.test.tsx +60 -0
  77. package/src/Toast.tsx +46 -1
  78. package/src/ToastNotifications.test.tsx +82 -0
  79. package/src/ToastNotifications.tsx +25 -1
  80. package/src/Tooltip.test.tsx +1 -0
  81. package/src/Unifier.ts +1 -1
  82. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +0 -3
  83. package/src/__snapshots__/Body.test.tsx.snap +0 -16
  84. package/src/__snapshots__/Box.test.tsx.snap +4 -13
  85. package/src/__snapshots__/Page.test.tsx.snap +0 -84
  86. package/src/__snapshots__/SplitPage.test.tsx.snap +24 -120
  87. package/src/__snapshots__/TapToEdit.test.tsx.snap +5 -16
  88. package/src/__snapshots__/Toast.test.tsx.snap +4 -2
  89. package/src/bunSetup.ts +19 -0
  90. package/src/conflictFieldDiff.test.ts +26 -0
  91. package/src/conflictFieldDiff.ts +78 -0
  92. package/src/index.tsx +5 -2
  93. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +0 -9
  94. package/src/pdfHtmlTemplate.ts +219 -0
  95. package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +0 -1
  96. package/src/signUp/__snapshots__/PasswordRequirements.test.tsx.snap +2 -16
  97. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +1 -17
  98. package/src/signUp/__snapshots__/Swiper.test.tsx.snap +0 -1
  99. package/src/table/__snapshots__/Table.test.tsx.snap +22 -87
  100. package/src/table/__snapshots__/TableHeader.test.tsx.snap +10 -50
  101. package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +10 -84
  102. package/src/table/__snapshots__/TableRow.test.tsx.snap +12 -77
  103. package/src/useAppLaunchOrForeground.test.tsx +54 -0
  104. package/src/useAppLaunchOrForeground.ts +30 -0
  105. package/dist/ConsentHistory.d.ts +0 -9
  106. package/dist/ConsentHistory.js +0 -70
  107. package/dist/ConsentHistory.js.map +0 -1
  108. package/dist/generateConsentHistoryPdf.d.ts +0 -2
  109. package/dist/generateConsentHistoryPdf.js +0 -185
  110. package/dist/generateConsentHistoryPdf.js.map +0 -1
  111. package/dist/useConsentHistory.d.ts +0 -63
  112. package/dist/useConsentHistory.js +0 -40
  113. package/dist/useConsentHistory.js.map +0 -1
  114. package/src/ConsentHistory.test.tsx +0 -161
  115. package/src/ConsentHistory.tsx +0 -249
  116. package/src/generateConsentHistoryPdf.ts +0 -211
  117. package/src/useConsentHistory.test.ts +0 -106
  118. package/src/useConsentHistory.ts +0 -94
@@ -0,0 +1,399 @@
1
+ import {DateTime} from "luxon";
2
+ import type React from "react";
3
+ import {useCallback, useEffect, useRef, useState} from "react";
4
+ import {ScrollView, useWindowDimensions} from "react-native";
5
+
6
+ import {Badge} from "./Badge";
7
+ import {Box} from "./Box";
8
+ import {Button} from "./Button";
9
+ import {
10
+ formatConflictFieldLabel,
11
+ formatConflictFieldValue,
12
+ getChangedConflictFields,
13
+ NO_CONFLICT_DIFF_FIELDS,
14
+ parseConflictPayload,
15
+ summarizeConflictSide,
16
+ } from "./conflictFieldDiff";
17
+ import {Modal} from "./Modal";
18
+ import {Text} from "./Text";
19
+
20
+ /** Resolution strategy for a sync conflict. */
21
+ export type SyncConflictResolutionStrategy = "useServer" | "keepMine";
22
+
23
+ /**
24
+ * Minimal shape of a sync conflict rendered by {@link ConflictSheet}. Mirrors the fields exposed by
25
+ * @terreno/syncdb's `SyncConflict` (local/server payloads are JSON strings) without importing the
26
+ * data layer, so the sheet stays a pure presentational component.
27
+ */
28
+ export interface SyncConflictItem {
29
+ mutationId: string;
30
+ collection: string;
31
+ entityId: string;
32
+ /** Local (optimistic) payload as a JSON string. */
33
+ localData: string;
34
+ /** Server payload as a JSON string. */
35
+ serverData: string;
36
+ }
37
+
38
+ export interface ConflictSheetProps {
39
+ visible: boolean;
40
+ onDismiss: () => void;
41
+ /** Unresolved conflicts to display. */
42
+ conflicts: SyncConflictItem[];
43
+ /** Called when the user picks a resolution for a conflict. */
44
+ onResolve: (args: {mutationId: string; strategy: SyncConflictResolutionStrategy}) => void;
45
+ /**
46
+ * Modal title. Default avoids sync jargon so non-technical users understand
47
+ * they need to pick between two versions of the same item.
48
+ */
49
+ title?: string;
50
+ /**
51
+ * Plain-language explanation shown above the conflict list. Pass an empty
52
+ * string to hide it.
53
+ */
54
+ description?: string;
55
+ testID?: string;
56
+ }
57
+
58
+ const DEFAULT_TITLE = "These changes don't match";
59
+
60
+ const DEFAULT_DESCRIPTION =
61
+ "The same item was changed in two places at once — for example on this device and on another phone, computer, or by someone else. Choose which version to keep. The other one will be discarded.";
62
+
63
+ const LOCAL_COLUMN_TITLE = "Your change";
64
+ const REMOTE_COLUMN_TITLE = "Other version";
65
+
66
+ const KEEP_MINE_BUTTON = "Keep my change";
67
+ const USE_OTHER_BUTTON = "Use the other version";
68
+ const KEEP_MINE_ALL_BUTTON = "Keep all of my changes";
69
+ const USE_OTHER_ALL_BUTTON = "Use all other versions";
70
+
71
+ const KEEP_MINE_ALL_CONFIRM_TITLE = "Keep all of your changes?";
72
+ const KEEP_MINE_ALL_CONFIRM_TEXT =
73
+ "Your edits on this device will be kept and sent again. The other versions will be discarded.";
74
+ const USE_OTHER_ALL_CONFIRM_TITLE = "Use the other versions for everything?";
75
+ const USE_OTHER_ALL_CONFIRM_TEXT =
76
+ "Your edits on this device will be discarded. What's saved elsewhere will be kept instead.";
77
+
78
+ const EMPTY_STATE = "Nothing left to choose — you're all set.";
79
+
80
+ const TIME_UNAVAILABLE = "Time unavailable";
81
+
82
+ /**
83
+ * Best-effort "when was this last touched" for a conflict side. Payload shapes
84
+ * vary by collection, so try the usual timestamp fields in order of specificity.
85
+ */
86
+ const parseConflictTime = (data: Record<string, unknown>): DateTime | null => {
87
+ const value = data.updated ?? data.updatedAt ?? data.created ?? data.createdAt;
88
+ if (typeof value !== "string") {
89
+ return null;
90
+ }
91
+ const dateTime = DateTime.fromISO(value);
92
+ return dateTime.isValid ? dateTime : null;
93
+ };
94
+
95
+ const formatConflictTime = (dateTime: DateTime | null): string =>
96
+ dateTime ? dateTime.toLocaleString(DateTime.DATETIME_MED_WITH_SECONDS) : TIME_UNAVAILABLE;
97
+
98
+ /** Badge label for each side, or null where there is nothing meaningful to say. */
99
+ type RecencyLabel = "Newer" | "Same time" | null;
100
+
101
+ /**
102
+ * Which side is more recent, so the user can tell at a glance which version they
103
+ * would be discarding. Both sides need a usable timestamp for a comparison to
104
+ * mean anything; without that we stay silent rather than guess.
105
+ */
106
+ const compareRecency = ({
107
+ local,
108
+ server,
109
+ }: {
110
+ local: DateTime | null;
111
+ server: DateTime | null;
112
+ }): {local: RecencyLabel; server: RecencyLabel} => {
113
+ if (!local || !server) {
114
+ return {local: null, server: null};
115
+ }
116
+ const localMillis = local.toMillis();
117
+ const serverMillis = server.toMillis();
118
+ if (localMillis === serverMillis) {
119
+ return {local: "Same time", server: "Same time"};
120
+ }
121
+ if (localMillis > serverMillis) {
122
+ return {local: "Newer", server: null};
123
+ }
124
+ return {local: null, server: "Newer"};
125
+ };
126
+
127
+ const RecencyBadge: React.FC<{label: RecencyLabel; testID: string}> = ({label, testID}) => {
128
+ if (!label) {
129
+ return null;
130
+ }
131
+ return (
132
+ <Badge
133
+ secondary
134
+ status={label === "Newer" ? "info" : "neutral"}
135
+ testID={testID}
136
+ value={label}
137
+ />
138
+ );
139
+ };
140
+
141
+ interface VersionColumnProps {
142
+ action: React.ReactNode;
143
+ changedFields: string[];
144
+ data: Record<string, unknown>;
145
+ entityId: string;
146
+ recency: RecencyLabel;
147
+ showDiff: boolean;
148
+ side: "local" | "server";
149
+ time: DateTime | null;
150
+ title: string;
151
+ }
152
+
153
+ const VersionColumn: React.FC<VersionColumnProps> = ({
154
+ action,
155
+ changedFields,
156
+ data,
157
+ entityId,
158
+ recency,
159
+ showDiff,
160
+ side,
161
+ time,
162
+ title,
163
+ }) => (
164
+ <Box
165
+ flex="grow"
166
+ gap={3}
167
+ justifyContent="between"
168
+ minWidth={240}
169
+ testID={`conflict-${side}-column-${entityId}`}
170
+ width={240}
171
+ >
172
+ <Box gap={2}>
173
+ <Box alignItems="center" direction="row" gap={1}>
174
+ <Text bold color="secondaryDark" size="sm">
175
+ {title}
176
+ </Text>
177
+ <RecencyBadge label={recency} testID={`conflict-${side}-recency-${entityId}`} />
178
+ </Box>
179
+ <Text color="secondaryLight" size="sm" testID={`conflict-${side}-time-${entityId}`}>
180
+ {formatConflictTime(time)}
181
+ </Text>
182
+ {showDiff ? (
183
+ changedFields.length === 0 ? (
184
+ <Text color="secondaryLight" size="sm">
185
+ {NO_CONFLICT_DIFF_FIELDS}
186
+ </Text>
187
+ ) : (
188
+ changedFields.map((field) => (
189
+ <Box gap={1} key={field} testID={`conflict-${side}-field-${field}-${entityId}`}>
190
+ <Text bold color="secondaryDark" size="sm">
191
+ {formatConflictFieldLabel(field)}
192
+ </Text>
193
+ <Text size="sm">{formatConflictFieldValue(data[field])}</Text>
194
+ </Box>
195
+ ))
196
+ )
197
+ ) : (
198
+ <Text size="sm">{summarizeConflictSide({changedFields, data})}</Text>
199
+ )}
200
+ </Box>
201
+ {action}
202
+ </Box>
203
+ );
204
+
205
+ const ConflictItem: React.FC<{
206
+ conflict: SyncConflictItem;
207
+ onResolve: (args: {mutationId: string; strategy: SyncConflictResolutionStrategy}) => void;
208
+ }> = ({conflict, onResolve}) => {
209
+ const [showDiff, setShowDiff] = useState<boolean>(false);
210
+ const local = parseConflictPayload(conflict.localData);
211
+ const server = parseConflictPayload(conflict.serverData);
212
+ const localTime = parseConflictTime(local);
213
+ const serverTime = parseConflictTime(server);
214
+ const recency = compareRecency({local: localTime, server: serverTime});
215
+ const changedFields = getChangedConflictFields({local, server});
216
+
217
+ const handleToggleDiff = useCallback((): void => {
218
+ setShowDiff((prev) => !prev);
219
+ }, []);
220
+
221
+ const handleKeepMine = useCallback((): void => {
222
+ onResolve({mutationId: conflict.mutationId, strategy: "keepMine"});
223
+ }, [conflict.mutationId, onResolve]);
224
+
225
+ const handleUseServer = useCallback((): void => {
226
+ onResolve({mutationId: conflict.mutationId, strategy: "useServer"});
227
+ }, [conflict.mutationId, onResolve]);
228
+
229
+ return (
230
+ <Box
231
+ border="default"
232
+ gap={3}
233
+ padding={3}
234
+ rounding="md"
235
+ testID={`conflict-item-${conflict.entityId}`}
236
+ >
237
+ <Box direction="row" gap={2} justifyContent="between" wrap>
238
+ <Box flex="grow">
239
+ <Text bold size="sm">
240
+ {conflict.collection} · {conflict.entityId}
241
+ </Text>
242
+ </Box>
243
+ <Button
244
+ onClick={handleToggleDiff}
245
+ size="sm"
246
+ testID={`conflict-diff-toggle-${conflict.entityId}`}
247
+ text={showDiff ? "Hide diff" : "Diff"}
248
+ variant="outline"
249
+ />
250
+ </Box>
251
+ <Box direction="row" gap={3} wrap>
252
+ <VersionColumn
253
+ action={
254
+ <Button
255
+ fullWidth
256
+ onClick={handleKeepMine}
257
+ testID={`conflict-keep-mine-button-${conflict.mutationId}`}
258
+ text={KEEP_MINE_BUTTON}
259
+ variant="outline"
260
+ />
261
+ }
262
+ changedFields={changedFields}
263
+ data={local}
264
+ entityId={conflict.entityId}
265
+ recency={recency.local}
266
+ showDiff={showDiff}
267
+ side="local"
268
+ time={localTime}
269
+ title={LOCAL_COLUMN_TITLE}
270
+ />
271
+ <VersionColumn
272
+ action={
273
+ <Button
274
+ fullWidth
275
+ onClick={handleUseServer}
276
+ testID={`conflict-use-server-button-${conflict.mutationId}`}
277
+ text={USE_OTHER_BUTTON}
278
+ variant="primary"
279
+ />
280
+ }
281
+ changedFields={changedFields}
282
+ data={server}
283
+ entityId={conflict.entityId}
284
+ recency={recency.server}
285
+ showDiff={showDiff}
286
+ side="server"
287
+ time={serverTime}
288
+ title={REMOTE_COLUMN_TITLE}
289
+ />
290
+ </Box>
291
+ </Box>
292
+ );
293
+ };
294
+
295
+ /**
296
+ * Presentational modal listing unresolved sync conflicts. Copy is written for
297
+ * non-technical users: "Your change" (this device) vs "Other version" (elsewhere
298
+ * or out of sync), with a short explanation of why they must pick one. Whichever
299
+ * side is more recent is badged. Users can resolve conflicts individually — each
300
+ * button lives inside the version column it keeps — or apply a choice to every
301
+ * conflict after confirmation. Data-layer agnostic: pass `conflicts` and an `onResolve`
302
+ * callback (e.g. from @terreno/syncdb's `useConflicts`).
303
+ *
304
+ * The sheet never closes itself on a button press. It calls `onDismiss` once `conflicts`
305
+ * becomes empty while open, so the caller's resolutions get to settle (or fail, keeping
306
+ * the sheet open) before the UI goes away.
307
+ */
308
+ export const ConflictSheet: React.FC<ConflictSheetProps> = ({
309
+ visible,
310
+ onDismiss,
311
+ conflicts,
312
+ onResolve,
313
+ title = DEFAULT_TITLE,
314
+ description = DEFAULT_DESCRIPTION,
315
+ testID = "conflict-sheet",
316
+ }) => {
317
+ const {height: windowHeight} = useWindowDimensions();
318
+ // Whether this open episode ever had conflicts, so a sheet opened deliberately
319
+ // with none (to show the empty state) is not closed out from under the caller.
320
+ const hadConflictsRef = useRef<boolean>(false);
321
+
322
+ // Dismissal is driven purely by the conflict list emptying, never by a button
323
+ // press: `onResolve` resolutions settle asynchronously in the data layer, and the
324
+ // parent drops a row from `conflicts` only once its resolution actually landed.
325
+ // Closing at press time would hide a resolution that then failed, leaving the
326
+ // conflict unresolved with no visible way back to it.
327
+ useEffect(() => {
328
+ if (!visible) {
329
+ hadConflictsRef.current = false;
330
+ return;
331
+ }
332
+ if (conflicts.length > 0) {
333
+ hadConflictsRef.current = true;
334
+ return;
335
+ }
336
+ if (hadConflictsRef.current) {
337
+ onDismiss();
338
+ }
339
+ }, [conflicts.length, onDismiss, visible]);
340
+
341
+ const handleUseServerForAll = useCallback((): void => {
342
+ for (const conflict of conflicts) {
343
+ onResolve({mutationId: conflict.mutationId, strategy: "useServer"});
344
+ }
345
+ }, [conflicts, onResolve]);
346
+
347
+ const handleUseMineForAll = useCallback((): void => {
348
+ for (const conflict of conflicts) {
349
+ onResolve({mutationId: conflict.mutationId, strategy: "keepMine"});
350
+ }
351
+ }, [conflicts, onResolve]);
352
+
353
+ return (
354
+ <Modal onDismiss={onDismiss} size="md" title={title} visible={visible}>
355
+ <ScrollView
356
+ contentContainerStyle={{paddingBottom: 4}}
357
+ style={{maxHeight: Math.max(windowHeight * 0.65, 240), width: "100%"}}
358
+ testID="conflict-sheet-scroll"
359
+ >
360
+ <Box gap={3} testID={testID}>
361
+ {conflicts.length === 0 ? (
362
+ <Text color="secondaryLight">{EMPTY_STATE}</Text>
363
+ ) : (
364
+ <>
365
+ {description ? (
366
+ <Text color="secondaryDark" size="sm" testID="conflict-sheet-description">
367
+ {description}
368
+ </Text>
369
+ ) : null}
370
+ <Box direction="row" gap={2} wrap>
371
+ <Button
372
+ confirmationText={KEEP_MINE_ALL_CONFIRM_TEXT}
373
+ modalTitle={KEEP_MINE_ALL_CONFIRM_TITLE}
374
+ onClick={handleUseMineForAll}
375
+ testID="conflict-use-mine-all-button"
376
+ text={KEEP_MINE_ALL_BUTTON}
377
+ variant="outline"
378
+ withConfirmation
379
+ />
380
+ <Button
381
+ confirmationText={USE_OTHER_ALL_CONFIRM_TEXT}
382
+ modalTitle={USE_OTHER_ALL_CONFIRM_TITLE}
383
+ onClick={handleUseServerForAll}
384
+ testID="conflict-use-server-all-button"
385
+ text={USE_OTHER_ALL_BUTTON}
386
+ variant="destructive"
387
+ withConfirmation
388
+ />
389
+ </Box>
390
+ {conflicts.map((conflict) => (
391
+ <ConflictItem conflict={conflict} key={conflict.mutationId} onResolve={onResolve} />
392
+ ))}
393
+ </>
394
+ )}
395
+ </Box>
396
+ </ScrollView>
397
+ </Modal>
398
+ );
399
+ };
@@ -1,5 +1,3 @@
1
- // noExplicitAny: test mock typing
2
- // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
1
  import {describe, expect, it, mock} from "bun:test";
4
2
  import {act} from "@testing-library/react-native";
5
3
 
@@ -8,6 +6,8 @@ import {DataTable} from "./DataTable";
8
6
  import {Text} from "./Text";
9
7
  import {renderWithTheme} from "./test-utils";
10
8
 
9
+ type MoreContentComponent = NonNullable<DataTableProps["moreContentComponent"]>;
10
+
11
11
  describe("DataTable", () => {
12
12
  const sampleColumns = [
13
13
  {columnType: "text", title: "Name", width: 150},
@@ -112,13 +112,9 @@ describe("DataTable", () => {
112
112
  });
113
113
 
114
114
  it("renders with more content component", () => {
115
- const MoreContent = ({rowIndex}: {rowIndex: number}) => <Text>Row {rowIndex} details</Text>;
115
+ const MoreContent: MoreContentComponent = ({rowIndex}) => <Text>Row {rowIndex} details</Text>;
116
116
  const {toJSON} = renderWithTheme(
117
- <DataTable
118
- columns={sampleColumns}
119
- data={sampleData}
120
- moreContentComponent={MoreContent as unknown as DataTableProps["moreContentComponent"]}
121
- />
117
+ <DataTable columns={sampleColumns} data={sampleData} moreContentComponent={MoreContent} />
122
118
  );
123
119
  expect(toJSON()).toMatchSnapshot();
124
120
  });
@@ -266,7 +262,7 @@ describe("DataTable", () => {
266
262
  });
267
263
 
268
264
  it("renders with custom column component map", () => {
269
- const CustomComponent = ({cellData}: {cellData: {value: unknown}}) => (
265
+ const CustomComponent: DataTableCustomComponentMap[string] = ({cellData}) => (
270
266
  <Text>Custom: {String(cellData.value)}</Text>
271
267
  );
272
268
  const customColumns = [{columnType: "custom", title: "Custom Col", width: 150}];
@@ -274,7 +270,7 @@ describe("DataTable", () => {
274
270
  const {getByText} = renderWithTheme(
275
271
  <DataTable
276
272
  columns={customColumns}
277
- customColumnComponentMap={{custom: CustomComponent as any}}
273
+ customColumnComponentMap={{custom: CustomComponent}}
278
274
  data={customData}
279
275
  />
280
276
  );
@@ -300,16 +296,16 @@ describe("DataTable", () => {
300
296
  });
301
297
 
302
298
  it("renders with moreContentExtraData", () => {
303
- const MoreContent = ({rowIndex, extraInfo}: {rowIndex: number; extraInfo?: string}) => (
299
+ const MoreContent: MoreContentComponent = ({rowIndex, extraInfo}) => (
304
300
  <Text>
305
- Row {rowIndex}: {extraInfo}
301
+ Row {rowIndex}: {String(extraInfo)}
306
302
  </Text>
307
303
  );
308
304
  const {toJSON} = renderWithTheme(
309
305
  <DataTable
310
306
  columns={sampleColumns}
311
307
  data={sampleData}
312
- moreContentComponent={MoreContent as any}
308
+ moreContentComponent={MoreContent}
313
309
  moreContentExtraData={[{extraInfo: "info1"}, {extraInfo: "info2"}, {extraInfo: "info3"}]}
314
310
  />
315
311
  );
@@ -317,13 +313,11 @@ describe("DataTable", () => {
317
313
  });
318
314
 
319
315
  it("opens and dismisses more content modal via MoreButtonCell press", async () => {
320
- const MoreContent = ({rowIndex}: {rowIndex: number}) => <Text>Detail for row {rowIndex}</Text>;
316
+ const MoreContent: MoreContentComponent = ({rowIndex}) => (
317
+ <Text>Detail for row {rowIndex}</Text>
318
+ );
321
319
  const {UNSAFE_getAllByType} = renderWithTheme(
322
- <DataTable
323
- columns={sampleColumns}
324
- data={sampleData}
325
- moreContentComponent={MoreContent as any}
326
- />
320
+ <DataTable columns={sampleColumns} data={sampleData} moreContentComponent={MoreContent} />
327
321
  );
328
322
 
329
323
  const {Pressable: PressableComp} = require("react-native");
@@ -352,7 +346,7 @@ describe("DataTable", () => {
352
346
  });
353
347
 
354
348
  it("renders with customColumnComponentMap", () => {
355
- const CustomCell = ({cellData}: {cellData: {value: unknown}; column: unknown}) => (
349
+ const CustomCell: DataTableCustomComponentMap[string] = ({cellData}) => (
356
350
  <Text>Custom: {String(cellData.value)}</Text>
357
351
  );
358
352
  const customColumns = [
@@ -363,7 +357,7 @@ describe("DataTable", () => {
363
357
  const {getByText} = renderWithTheme(
364
358
  <DataTable
365
359
  columns={customColumns}
366
- customColumnComponentMap={{custom: CustomCell} as DataTableCustomComponentMap}
360
+ customColumnComponentMap={{custom: CustomCell}}
367
361
  data={customData}
368
362
  />
369
363
  );
package/src/Hyperlink.tsx CHANGED
@@ -188,7 +188,7 @@ class HyperlinkComponent extends React.Component<HyperlinkProps> {
188
188
  export const Hyperlink = (props: HyperlinkProps) => {
189
189
  const handleLink = (url: string) => {
190
190
  const urlObject = mdurl.parse(url);
191
- urlObject.protocol = urlObject.protocol.toLowerCase();
191
+ urlObject.protocol = urlObject.protocol?.toLowerCase() ?? "";
192
192
  const normalizedURL = mdurl.format(urlObject);
193
193
 
194
194
  void Linking.canOpenURL(normalizedURL).then(
@@ -1,10 +1,10 @@
1
- import {TabRouter} from "@react-navigation/native";
2
1
  import {Navigator, Slot} from "expo-router";
3
2
  // Screen is not exported from expo-router's public API (exports.d.ts only exposes ScreenProps).
4
3
  // Stack.Screen and Tabs.Screen use this same internal path. If expo-router upgrades break this,
5
4
  // update the import path here — this is the only place in the codebase that references it.
6
5
  // eslint-disable-next-line import/no-internal-modules
7
6
  import {Screen} from "expo-router/build/views/Screen";
7
+ import {TabRouter} from "expo-router/react-navigation";
8
8
  import {type FC, type ReactNode, useCallback, useEffect, useMemo, useRef, useState} from "react";
9
9
  import {
10
10
  Animated,
@@ -1,10 +1,10 @@
1
- import {TabRouter} from "@react-navigation/native";
2
1
  import {Navigator, Slot} from "expo-router";
3
2
  // Screen is not exported from expo-router's public API (exports.d.ts only exposes ScreenProps).
4
3
  // Stack.Screen and Tabs.Screen use this same internal path. If expo-router upgrades break this,
5
4
  // update the import path here — this is the only place in the codebase that references it.
6
5
  // eslint-disable-next-line import/no-internal-modules
7
6
  import {Screen} from "expo-router/build/views/Screen";
7
+ import {TabRouter} from "expo-router/react-navigation";
8
8
  import {type FC, type ReactNode, useCallback, useMemo, useState} from "react";
9
9
  import {Pressable, type StyleProp, View, type ViewProps, type ViewStyle} from "react-native";
10
10