@terreno/ui 57.21.0 → 58.0.0-beta.2
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/.ai/guidelines/core.md +1 -1
- package/CHANGELOG.md +89 -0
- package/dist/ActionSheet.d.ts +9 -9
- package/dist/ActionSheet.d.ts.map +1 -1
- package/dist/ActionSheet.js +11 -4
- package/dist/ActionSheet.js.map +1 -1
- package/dist/AnnouncementNavigator.d.ts +7 -1
- package/dist/AnnouncementNavigator.d.ts.map +1 -1
- package/dist/AnnouncementNavigator.js +15 -16
- package/dist/AnnouncementNavigator.js.map +1 -1
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/Avatar.js +1 -1
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +3 -1
- package/dist/Box.js.map +1 -1
- package/dist/Common.d.ts +16 -12
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/ConsentFormScreen.d.ts.map +1 -1
- package/dist/ConsentFormScreen.js.map +1 -1
- package/dist/ConsentNavigator.d.ts +5 -3
- package/dist/ConsentNavigator.d.ts.map +1 -1
- package/dist/ConsentNavigator.js +4 -4
- package/dist/ConsentNavigator.js.map +1 -1
- package/dist/CustomSelectField.js.map +1 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +37 -12
- package/dist/DataTable.js.map +1 -1
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DropdownPanel.d.ts +0 -5
- package/dist/DropdownPanel.d.ts.map +1 -1
- package/dist/DropdownPanel.js +0 -5
- package/dist/DropdownPanel.js.map +1 -1
- package/dist/FilterAccordion.d.ts.map +1 -1
- package/dist/FilterAccordion.js.map +1 -1
- package/dist/FilterBoolean.d.ts.map +1 -1
- package/dist/FilterBoolean.js.map +1 -1
- package/dist/FilterSelectMenu.js +1 -1
- package/dist/FilterSelectMenu.js.map +1 -1
- package/dist/GPTChat.d.ts.map +1 -1
- package/dist/GPTChat.js.map +1 -1
- package/dist/Heading.d.ts.map +1 -1
- package/dist/Heading.js +6 -12
- package/dist/Heading.js.map +1 -1
- package/dist/HeightField.d.ts.map +1 -1
- package/dist/HeightField.js +1 -1
- package/dist/HeightField.js.map +1 -1
- package/dist/Hyperlink.d.ts.map +1 -1
- package/dist/Hyperlink.js +6 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Image.d.ts +1 -1
- package/dist/MarkdownEditorField.d.ts.map +1 -1
- package/dist/MarkdownEditorField.js +1 -1
- package/dist/MarkdownEditorField.js.map +1 -1
- package/dist/OfflineBanner.d.ts +3 -2
- package/dist/OfflineBanner.d.ts.map +1 -1
- package/dist/OfflineBanner.js +3 -2
- package/dist/OfflineBanner.js.map +1 -1
- package/dist/OtpField.d.ts.map +1 -1
- package/dist/OtpField.js +6 -3
- package/dist/OtpField.js.map +1 -1
- package/dist/PickerSelect.d.ts +4 -4
- package/dist/PickerSelect.d.ts.map +1 -1
- package/dist/PickerSelect.js.map +1 -1
- package/dist/ProvisionalConsentSigner.d.ts +3 -2
- package/dist/ProvisionalConsentSigner.d.ts.map +1 -1
- package/dist/ProvisionalConsentSigner.js +2 -2
- package/dist/ProvisionalConsentSigner.js.map +1 -1
- package/dist/SidebarNavigation.js +2 -2
- package/dist/SidebarNavigation.js.map +1 -1
- package/dist/SidebarNavigation.native.js +2 -2
- package/dist/SidebarNavigation.native.js.map +1 -1
- package/dist/Skeleton.js.map +1 -1
- package/dist/Text.d.ts.map +1 -1
- package/dist/Text.js +27 -50
- package/dist/Text.js.map +1 -1
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js.map +1 -1
- package/dist/ThumbsUpDownFeedback.d.ts.map +1 -1
- package/dist/ThumbsUpDownFeedback.js.map +1 -1
- package/dist/ToastNotifications.d.ts.map +1 -1
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js.map +1 -1
- package/dist/Unifier.d.ts +1 -1
- package/dist/WebAddressAutocomplete.js.map +1 -1
- package/dist/WebDropdownMenu.d.ts +3 -3
- package/dist/WebDropdownMenu.d.ts.map +1 -1
- package/dist/WebDropdownMenu.js +1 -1
- package/dist/WebDropdownMenu.js.map +1 -1
- package/dist/announcementPlatform.d.ts +5 -0
- package/dist/announcementPlatform.d.ts.map +1 -1
- package/dist/announcementPlatform.js +9 -0
- package/dist/announcementPlatform.js.map +1 -1
- package/dist/asks/AskCard.d.ts +2 -2
- package/dist/asks/AskCard.d.ts.map +1 -1
- package/dist/dataTableColumnWidths.d.ts +76 -0
- package/dist/dataTableColumnWidths.d.ts.map +1 -0
- package/dist/dataTableColumnWidths.js +181 -0
- package/dist/dataTableColumnWidths.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/login/LoginScreen.js.map +1 -1
- package/dist/requestClient.d.ts +71 -0
- package/dist/requestClient.d.ts.map +1 -0
- package/dist/requestClient.js +139 -0
- package/dist/requestClient.js.map +1 -0
- package/dist/security/PasswordCard.d.ts.map +1 -1
- package/dist/security/PasswordCard.js.map +1 -1
- package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -1
- package/dist/security/TwoFactorSettingsCard.js +1 -1
- package/dist/security/TwoFactorSettingsCard.js.map +1 -1
- package/dist/signUp/SignUpScreen.js.map +1 -1
- package/dist/table/Table.d.ts.map +1 -1
- package/dist/table/Table.js.map +1 -1
- package/dist/table/TableTitle.d.ts.map +1 -1
- package/dist/table/TableTitle.js +2 -1
- package/dist/table/TableTitle.js.map +1 -1
- package/dist/textFontSizes.d.ts +12 -0
- package/dist/textFontSizes.d.ts.map +1 -0
- package/dist/textFontSizes.js +21 -0
- package/dist/textFontSizes.js.map +1 -0
- package/dist/useAcknowledgeAnnouncement.d.ts +8 -63
- package/dist/useAcknowledgeAnnouncement.d.ts.map +1 -1
- package/dist/useAcknowledgeAnnouncement.js +31 -80
- package/dist/useAcknowledgeAnnouncement.js.map +1 -1
- package/dist/useAnnouncements.d.ts +14 -47
- package/dist/useAnnouncements.d.ts.map +1 -1
- package/dist/useAnnouncements.js +30 -57
- package/dist/useAnnouncements.js.map +1 -1
- package/dist/useConsentForms.d.ts +6 -38
- package/dist/useConsentForms.d.ts.map +1 -1
- package/dist/useConsentForms.js +25 -48
- package/dist/useConsentForms.js.map +1 -1
- package/dist/useProvisionalConsent.d.ts +7 -58
- package/dist/useProvisionalConsent.d.ts.map +1 -1
- package/dist/useProvisionalConsent.js +57 -67
- package/dist/useProvisionalConsent.js.map +1 -1
- package/dist/useSubmitConsent.d.ts +9 -39
- package/dist/useSubmitConsent.d.ts.map +1 -1
- package/dist/useSubmitConsent.js +10 -39
- package/dist/useSubmitConsent.js.map +1 -1
- package/package.json +38 -38
- package/src/ActionSheet.test.tsx +4 -4
- package/src/ActionSheet.tsx +18 -5
- package/src/AnnouncementNavigator.test.tsx +215 -315
- package/src/AnnouncementNavigator.tsx +25 -20
- package/src/Avatar.tsx +2 -9
- package/src/Box.test.tsx +3 -3
- package/src/Box.tsx +4 -2
- package/src/Common.ts +19 -15
- package/src/ConsentFormScreen.tsx +2 -1
- package/src/ConsentNavigator.test.tsx +166 -242
- package/src/ConsentNavigator.tsx +9 -13
- package/src/CustomSelectField.tsx +3 -3
- package/src/DataTable.test.tsx +69 -1
- package/src/DataTable.tsx +72 -19
- package/src/DateTimeField.tsx +4 -4
- package/src/DropdownPanel.tsx +0 -6
- package/src/FilterAccordion.tsx +3 -3
- package/src/FilterBoolean.tsx +3 -3
- package/src/FilterSelectMenu.tsx +1 -1
- package/src/GPTChat.tsx +10 -9
- package/src/Heading.tsx +7 -14
- package/src/HeightField.tsx +9 -2
- package/src/Hyperlink.tsx +6 -3
- package/src/Link.test.tsx +2 -2
- package/src/MarkdownEditorField.tsx +10 -2
- package/src/MarkdownView.test.tsx +10 -6
- package/src/Modal.test.tsx +3 -1
- package/src/ModalSheet.test.tsx +6 -6
- package/src/OfflineBanner.tsx +3 -2
- package/src/OtpField.test.tsx +44 -0
- package/src/OtpField.tsx +8 -4
- package/src/PickerSelect.tsx +3 -2
- package/src/ProvisionalConsentSigner.test.tsx +140 -113
- package/src/ProvisionalConsentSigner.tsx +5 -4
- package/src/SidebarNavigation.native.tsx +2 -2
- package/src/SidebarNavigation.tsx +2 -2
- package/src/Skeleton.tsx +1 -1
- package/src/TapToEdit.test.tsx +2 -2
- package/src/Text.test.tsx +1 -1
- package/src/Text.tsx +25 -51
- package/src/TextField.tsx +2 -1
- package/src/ThumbsUpDownFeedback.tsx +3 -3
- package/src/ToastNotifications.tsx +3 -2
- package/src/ToastNotifications.webModal.test.tsx +4 -1
- package/src/Tooltip.tsx +2 -1
- package/src/UserInactivity.test.tsx +2 -3
- package/src/WebAddressAutocomplete.tsx +3 -3
- package/src/WebDropdownMenu.tsx +16 -5
- package/src/__snapshots__/DataTable.test.tsx.snap +13 -0
- package/src/announcementPlatform.ts +10 -0
- package/src/asks/AskCard.test.tsx +14 -12
- package/src/asks/AskCard.tsx +2 -2
- package/src/bunSetup.ts +42 -0
- package/src/dataTableColumnWidths.test.ts +266 -0
- package/src/dataTableColumnWidths.ts +272 -0
- package/src/index.tsx +9 -2
- package/src/login/LoginScreen.tsx +2 -2
- package/src/requestClient.test.ts +288 -0
- package/src/requestClient.ts +228 -0
- package/src/security/PasswordCard.tsx +7 -5
- package/src/security/TwoFactorSettingsCard.tsx +10 -3
- package/src/signUp/SignUpScreen.tsx +2 -2
- package/src/table/Table.tsx +1 -2
- package/src/table/TableTitle.tsx +2 -1
- package/src/test-utils.tsx +76 -0
- package/src/textFontSizes.ts +31 -0
- package/src/useAcknowledgeAnnouncement.test.ts +101 -193
- package/src/useAcknowledgeAnnouncement.ts +69 -147
- package/src/useAnnouncements.test.ts +122 -186
- package/src/useAnnouncements.ts +49 -105
- package/src/useConsentForms.test.ts +59 -112
- package/src/useConsentForms.ts +37 -87
- package/src/useProvisionalConsent.test.ts +74 -150
- package/src/useProvisionalConsent.ts +79 -125
- package/src/useSubmitConsent.test.ts +59 -85
- package/src/useSubmitConsent.ts +22 -77
package/src/DataTable.test.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {describe, expect, it, mock} from "bun:test";
|
|
2
2
|
import {act, fireEvent, waitFor} from "@testing-library/react-native";
|
|
3
3
|
import {type FC, useState} from "react";
|
|
4
|
-
import {Platform, StyleSheet} from "react-native";
|
|
4
|
+
import {Platform, type StyleProp, StyleSheet, type ViewStyle} from "react-native";
|
|
5
5
|
|
|
6
6
|
import type {DataTableCellData, DataTableCustomComponentMap, DataTableProps} from "./Common";
|
|
7
7
|
import {DataTable} from "./DataTable";
|
|
@@ -945,4 +945,72 @@ describe("DataTable", () => {
|
|
|
945
945
|
expect(getByText("Custom 2026-03-14")).toBeTruthy();
|
|
946
946
|
});
|
|
947
947
|
});
|
|
948
|
+
|
|
949
|
+
describe("auto column widths", () => {
|
|
950
|
+
interface HostNode {
|
|
951
|
+
props?: {style?: unknown};
|
|
952
|
+
parent: HostNode | null;
|
|
953
|
+
}
|
|
954
|
+
const headerCellWidth = (titleNode: HostNode): number | undefined => {
|
|
955
|
+
let node: HostNode | null = titleNode;
|
|
956
|
+
while (node) {
|
|
957
|
+
const width = StyleSheet.flatten(node.props?.style as StyleProp<ViewStyle>)?.width;
|
|
958
|
+
if (typeof width === "number") {
|
|
959
|
+
return width;
|
|
960
|
+
}
|
|
961
|
+
node = node.parent;
|
|
962
|
+
}
|
|
963
|
+
return undefined;
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
const autoColumns = [
|
|
967
|
+
{columnType: "text", title: "Name"},
|
|
968
|
+
{columnType: "text", title: "Notes"},
|
|
969
|
+
{columnType: "number", title: "Fixed", width: 90},
|
|
970
|
+
];
|
|
971
|
+
const autoData = [
|
|
972
|
+
[
|
|
973
|
+
{value: "Ada"},
|
|
974
|
+
{value: "A much longer note that should make this column wider"},
|
|
975
|
+
{value: 1},
|
|
976
|
+
],
|
|
977
|
+
];
|
|
978
|
+
|
|
979
|
+
it("sizes columns without a width from their content and keeps explicit widths", () => {
|
|
980
|
+
const {getByText} = renderWithTheme(<DataTable columns={autoColumns} data={autoData} />);
|
|
981
|
+
const nameWidth = headerCellWidth(getByText("Name"));
|
|
982
|
+
const notesWidth = headerCellWidth(getByText("Notes"));
|
|
983
|
+
expect(nameWidth).toBeGreaterThan(0);
|
|
984
|
+
expect(notesWidth).toBeGreaterThan(nameWidth!);
|
|
985
|
+
expect(headerCellWidth(getByText("Fixed"))).toBe(90);
|
|
986
|
+
});
|
|
987
|
+
|
|
988
|
+
it("grows auto-sized columns to fill the measured container", async () => {
|
|
989
|
+
const {getByTestId, getByText} = renderWithTheme(
|
|
990
|
+
<DataTable columns={autoColumns} data={autoData} testID="auto-table" />
|
|
991
|
+
);
|
|
992
|
+
await act(async () => {
|
|
993
|
+
fireEvent(getByTestId("auto-table.body"), "layout", {
|
|
994
|
+
nativeEvent: {layout: {height: 400, width: 1602, x: 0, y: 0}},
|
|
995
|
+
});
|
|
996
|
+
});
|
|
997
|
+
const widths = ["Name", "Notes", "Fixed"].map((title) => headerCellWidth(getByText(title)));
|
|
998
|
+
expect(widths[2]).toBe(90);
|
|
999
|
+
// The container is 1602 wide with a 1px border on each side.
|
|
1000
|
+
expect(widths.reduce((sum: number, width) => sum + (width ?? 0), 0)).toBe(1600);
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
it("leaves explicit widths alone when the container is wider", async () => {
|
|
1004
|
+
const {getByTestId, getByText} = renderWithTheme(
|
|
1005
|
+
<DataTable columns={sampleColumns} data={sampleData} testID="fixed-table" />
|
|
1006
|
+
);
|
|
1007
|
+
await act(async () => {
|
|
1008
|
+
fireEvent(getByTestId("fixed-table.body"), "layout", {
|
|
1009
|
+
nativeEvent: {layout: {height: 400, width: 1200, x: 0, y: 0}},
|
|
1010
|
+
});
|
|
1011
|
+
});
|
|
1012
|
+
expect(headerCellWidth(getByText("Name"))).toBe(150);
|
|
1013
|
+
expect(headerCellWidth(getByText("Age"))).toBe(100);
|
|
1014
|
+
});
|
|
1015
|
+
});
|
|
948
1016
|
});
|
package/src/DataTable.tsx
CHANGED
|
@@ -12,12 +12,14 @@ import {
|
|
|
12
12
|
useState,
|
|
13
13
|
} from "react";
|
|
14
14
|
import {
|
|
15
|
+
type LayoutChangeEvent,
|
|
15
16
|
type NativeScrollEvent,
|
|
16
17
|
type NativeSyntheticEvent,
|
|
17
18
|
Platform,
|
|
18
19
|
Pressable,
|
|
19
20
|
type FlatList as RNFlatList,
|
|
20
21
|
ScrollView,
|
|
22
|
+
type ScrollViewInstance,
|
|
21
23
|
View,
|
|
22
24
|
} from "react-native";
|
|
23
25
|
import {Box} from "./Box";
|
|
@@ -33,6 +35,15 @@ import type {
|
|
|
33
35
|
} from "./Common";
|
|
34
36
|
import {readableTextColor} from "./colorContrast";
|
|
35
37
|
import {DataTableHeaderInfoMarkdown} from "./DataTableHeaderInfoMarkdown";
|
|
38
|
+
import {
|
|
39
|
+
DATA_TABLE_BORDER_WIDTH,
|
|
40
|
+
DATA_TABLE_CELL_PADDING,
|
|
41
|
+
DATA_TABLE_MORE_COLUMN_WIDTH,
|
|
42
|
+
DATA_TABLE_SORT_BUTTON_MARGIN,
|
|
43
|
+
DATA_TABLE_SORT_BUTTON_SIZE,
|
|
44
|
+
fitDataTableColumnWidths,
|
|
45
|
+
getDataTableNaturalWidths,
|
|
46
|
+
} from "./dataTableColumnWidths";
|
|
36
47
|
import {
|
|
37
48
|
DataTableAdditionalFiltersWeb,
|
|
38
49
|
DataTableColumnFilterWeb,
|
|
@@ -62,6 +73,9 @@ const DATA_TABLE_MAX_TO_RENDER_PER_BATCH = 10;
|
|
|
62
73
|
const DATA_TABLE_WINDOW_SIZE = 5;
|
|
63
74
|
const DATA_TABLE_VERTICAL_SCROLL_SYNC_RELEASE_MS = 50;
|
|
64
75
|
|
|
76
|
+
/** A column after auto-sizing: every column has a resolved pixel width. */
|
|
77
|
+
type SizedDataTableColumn = DataTableColumn & {width: number};
|
|
78
|
+
|
|
65
79
|
/** Inverted text when primary text falls below WCAG AA on the cell's highlight fill. */
|
|
66
80
|
// Dark neutralLight (#686868) is too light for a stripe: ghost and link text drop near 2:1 on it.
|
|
67
81
|
const useStripeColor = (): string => {
|
|
@@ -198,7 +212,7 @@ const DataTableCellComponent: FC<InternalDataTableCellProps> = ({
|
|
|
198
212
|
height,
|
|
199
213
|
justifyContent: "center",
|
|
200
214
|
overflow: "hidden",
|
|
201
|
-
padding:
|
|
215
|
+
padding: DATA_TABLE_CELL_PADDING,
|
|
202
216
|
position: "relative",
|
|
203
217
|
width: columnDef.width,
|
|
204
218
|
zIndex: 1,
|
|
@@ -226,7 +240,7 @@ const DataTableCell = memo(DataTableCellComponent);
|
|
|
226
240
|
interface DataTableRowProps {
|
|
227
241
|
rowData: DataTableCellData[];
|
|
228
242
|
rowIndex: number;
|
|
229
|
-
columns:
|
|
243
|
+
columns: SizedDataTableColumn[];
|
|
230
244
|
columnEnd: number;
|
|
231
245
|
columnStart: number;
|
|
232
246
|
pinnedColumns: number;
|
|
@@ -322,7 +336,7 @@ const MoreButtonCellComponent: FC<MoreButtonCellProps> = ({
|
|
|
322
336
|
borderBottomWidth: 1,
|
|
323
337
|
height: rowHeight ?? 54,
|
|
324
338
|
justifyContent: "center",
|
|
325
|
-
width:
|
|
339
|
+
width: DATA_TABLE_MORE_COLUMN_WIDTH,
|
|
326
340
|
}}
|
|
327
341
|
>
|
|
328
342
|
<Pressable
|
|
@@ -389,7 +403,7 @@ const DataTableHeaderCell: FC<DataTableHeaderCellProps> = ({
|
|
|
389
403
|
flexDirection: "row",
|
|
390
404
|
height: headerHeight ?? rowHeight,
|
|
391
405
|
justifyContent: isNumberColumn ? "flex-end" : "space-between",
|
|
392
|
-
padding:
|
|
406
|
+
padding: DATA_TABLE_CELL_PADDING,
|
|
393
407
|
width: column.width,
|
|
394
408
|
...(isPinnedHorizontal && {
|
|
395
409
|
left: pinnedLeft,
|
|
@@ -430,10 +444,10 @@ const DataTableHeaderCell: FC<DataTableHeaderCellProps> = ({
|
|
|
430
444
|
alignItems: "center",
|
|
431
445
|
backgroundColor: sort ? theme.surface.primary : theme.surface.neutralLight,
|
|
432
446
|
borderRadius: theme.radius.rounded,
|
|
433
|
-
height:
|
|
447
|
+
height: DATA_TABLE_SORT_BUTTON_SIZE,
|
|
434
448
|
justifyContent: "center",
|
|
435
|
-
marginLeft:
|
|
436
|
-
width:
|
|
449
|
+
marginLeft: DATA_TABLE_SORT_BUTTON_MARGIN,
|
|
450
|
+
width: DATA_TABLE_SORT_BUTTON_SIZE,
|
|
437
451
|
}}
|
|
438
452
|
>
|
|
439
453
|
<FontAwesome6
|
|
@@ -455,12 +469,12 @@ const DataTableHeaderCell: FC<DataTableHeaderCellProps> = ({
|
|
|
455
469
|
};
|
|
456
470
|
|
|
457
471
|
interface DataTableHeaderProps {
|
|
458
|
-
columns:
|
|
472
|
+
columns: SizedDataTableColumn[];
|
|
459
473
|
hasMoreContent: boolean;
|
|
460
474
|
pinnedColumns: number;
|
|
461
475
|
pinnedLeftOffsets: number[];
|
|
462
476
|
pinnedWidth: number;
|
|
463
|
-
headerScrollRef: React.RefObject<
|
|
477
|
+
headerScrollRef: React.RefObject<ScrollViewInstance | null>;
|
|
464
478
|
sortColumn?: ColumnSortInterface;
|
|
465
479
|
onSort: (index: number) => void;
|
|
466
480
|
onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>, isHeader: boolean) => void;
|
|
@@ -499,7 +513,7 @@ const DataTableHeader: FC<DataTableHeaderProps> = ({
|
|
|
499
513
|
borderBottomColor: theme.border.default,
|
|
500
514
|
borderBottomWidth: 1,
|
|
501
515
|
height: headerHeight ?? rowHeight,
|
|
502
|
-
width:
|
|
516
|
+
width: DATA_TABLE_MORE_COLUMN_WIDTH,
|
|
503
517
|
zIndex: 11,
|
|
504
518
|
}}
|
|
505
519
|
/>
|
|
@@ -568,12 +582,12 @@ const DataTableHeader: FC<DataTableHeaderProps> = ({
|
|
|
568
582
|
|
|
569
583
|
interface DataTableContentProps {
|
|
570
584
|
data: DataTableCellData[][];
|
|
571
|
-
columns:
|
|
585
|
+
columns: SizedDataTableColumn[];
|
|
572
586
|
pinnedColumns: number;
|
|
573
587
|
alternateRowBackground: boolean;
|
|
574
588
|
pinnedLeftOffsets: number[];
|
|
575
589
|
pinnedWidth: number;
|
|
576
|
-
bodyScrollRef: React.RefObject<
|
|
590
|
+
bodyScrollRef: React.RefObject<ScrollViewInstance | null>;
|
|
577
591
|
onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>, isHeader: boolean) => void;
|
|
578
592
|
moreContentComponent?: React.ComponentType<
|
|
579
593
|
{
|
|
@@ -851,7 +865,7 @@ const DataTableContentComponent: FC<DataTableContentProps> = ({
|
|
|
851
865
|
left: 0,
|
|
852
866
|
position: "absolute",
|
|
853
867
|
top: 0,
|
|
854
|
-
width:
|
|
868
|
+
width: DATA_TABLE_MORE_COLUMN_WIDTH,
|
|
855
869
|
zIndex: 1,
|
|
856
870
|
}}
|
|
857
871
|
>
|
|
@@ -982,8 +996,8 @@ const DataTableComponent: FC<DataTableProps> = ({
|
|
|
982
996
|
}) => {
|
|
983
997
|
const {theme} = useTheme();
|
|
984
998
|
const tableTestIDs = resolveDataTableTestIDsFromProps({testID, testIDs});
|
|
985
|
-
const headerScrollRef = useRef<
|
|
986
|
-
const bodyScrollRef = useRef<
|
|
999
|
+
const headerScrollRef = useRef<ScrollViewInstance>(null);
|
|
1000
|
+
const bodyScrollRef = useRef<ScrollViewInstance>(null);
|
|
987
1001
|
const lastEmittedQueryRef = useRef<string | undefined>(undefined);
|
|
988
1002
|
const [debouncedSearch, setDebouncedSearch] = useState(search);
|
|
989
1003
|
const [isNativeFiltersOpen, setIsNativeFiltersOpen] = useState(false);
|
|
@@ -1060,7 +1074,45 @@ const DataTableComponent: FC<DataTableProps> = ({
|
|
|
1060
1074
|
setNativeSearchDraft("");
|
|
1061
1075
|
}, [columnFilters]);
|
|
1062
1076
|
|
|
1063
|
-
const
|
|
1077
|
+
const [availableWidth, setAvailableWidth] = useState(0);
|
|
1078
|
+
const moreColumnWidth = moreContentComponent ? DATA_TABLE_MORE_COLUMN_WIDTH : 0;
|
|
1079
|
+
// Measure text only when columns or data change; a resize only re-runs the cheap fit below.
|
|
1080
|
+
const naturalWidths = useMemo(
|
|
1081
|
+
() =>
|
|
1082
|
+
getDataTableNaturalWidths({
|
|
1083
|
+
columns,
|
|
1084
|
+
customColumnTypes: customColumnComponentMap
|
|
1085
|
+
? new Set(Object.keys(customColumnComponentMap))
|
|
1086
|
+
: undefined,
|
|
1087
|
+
data,
|
|
1088
|
+
defaultTextSize,
|
|
1089
|
+
formatDate: formatDataTableDate,
|
|
1090
|
+
hasFilters: Boolean(onFilterValuesChange),
|
|
1091
|
+
}),
|
|
1092
|
+
[columns, customColumnComponentMap, data, defaultTextSize, onFilterValuesChange]
|
|
1093
|
+
);
|
|
1094
|
+
const columnWidths = useMemo(
|
|
1095
|
+
() =>
|
|
1096
|
+
fitDataTableColumnWidths({
|
|
1097
|
+
availableWidth: availableWidth > 0 ? availableWidth - moreColumnWidth : 0,
|
|
1098
|
+
columns,
|
|
1099
|
+
naturalWidths,
|
|
1100
|
+
}),
|
|
1101
|
+
[availableWidth, columns, moreColumnWidth, naturalWidths]
|
|
1102
|
+
);
|
|
1103
|
+
const sizedColumns = useMemo(
|
|
1104
|
+
(): SizedDataTableColumn[] =>
|
|
1105
|
+
columns.map((column, index) =>
|
|
1106
|
+
column.width === columnWidths[index]
|
|
1107
|
+
? (column as SizedDataTableColumn)
|
|
1108
|
+
: {...column, width: columnWidths[index]}
|
|
1109
|
+
),
|
|
1110
|
+
[columns, columnWidths]
|
|
1111
|
+
);
|
|
1112
|
+
const handleBodyLayout = useCallback((event: LayoutChangeEvent): void => {
|
|
1113
|
+
const width = Math.floor(event.nativeEvent.layout.width - DATA_TABLE_BORDER_WIDTH * 2);
|
|
1114
|
+
setAvailableWidth((previous) => (previous === width ? previous : width));
|
|
1115
|
+
}, []);
|
|
1064
1116
|
const pinnedLeftOffsets = useMemo(() => {
|
|
1065
1117
|
let currentOffset = 0;
|
|
1066
1118
|
return columnWidths.map((width) => {
|
|
@@ -1156,9 +1208,10 @@ const DataTableComponent: FC<DataTableProps> = ({
|
|
|
1156
1208
|
</Box>
|
|
1157
1209
|
) : null}
|
|
1158
1210
|
<View
|
|
1211
|
+
onLayout={handleBodyLayout}
|
|
1159
1212
|
style={{
|
|
1160
1213
|
borderColor: theme.border.default,
|
|
1161
|
-
borderWidth:
|
|
1214
|
+
borderWidth: DATA_TABLE_BORDER_WIDTH,
|
|
1162
1215
|
flex: 1,
|
|
1163
1216
|
height: "100%",
|
|
1164
1217
|
minHeight: 0,
|
|
@@ -1166,7 +1219,7 @@ const DataTableComponent: FC<DataTableProps> = ({
|
|
|
1166
1219
|
testID={tableTestIDs.body}
|
|
1167
1220
|
>
|
|
1168
1221
|
<DataTableHeader
|
|
1169
|
-
columns={
|
|
1222
|
+
columns={sizedColumns}
|
|
1170
1223
|
filterValues={filterValues}
|
|
1171
1224
|
hasMoreContent={Boolean(moreContentComponent)}
|
|
1172
1225
|
headerHeight={headerHeight}
|
|
@@ -1189,7 +1242,7 @@ const DataTableComponent: FC<DataTableProps> = ({
|
|
|
1189
1242
|
<DataTableContent
|
|
1190
1243
|
alternateRowBackground={alternateRowBackground}
|
|
1191
1244
|
bodyScrollRef={bodyScrollRef}
|
|
1192
|
-
columns={
|
|
1245
|
+
columns={sizedColumns}
|
|
1193
1246
|
customColumnComponentMap={customColumnComponentMap}
|
|
1194
1247
|
data={data}
|
|
1195
1248
|
defaultTextSize={defaultTextSize}
|
package/src/DateTimeField.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
2
2
|
import {DateTime} from "luxon";
|
|
3
3
|
import React, {type FC, useCallback, useEffect, useMemo, useRef, useState} from "react";
|
|
4
|
-
import {Pressable, TextInput, View} from "react-native";
|
|
4
|
+
import {Pressable, TextInput, type TextInputInstance, View} from "react-native";
|
|
5
5
|
|
|
6
6
|
import type {ActionSheet} from "./ActionSheet";
|
|
7
7
|
import {Box} from "./Box";
|
|
@@ -47,7 +47,7 @@ interface DateTimeSegmentProps {
|
|
|
47
47
|
getFieldValue: (index: number) => string;
|
|
48
48
|
handleFieldChange: (index: number, text: string, config: FieldConfig) => void;
|
|
49
49
|
onBlur: (override?: {amPm?: "am" | "pm"; timezone?: string}) => void;
|
|
50
|
-
onRef: (ref:
|
|
50
|
+
onRef: (ref: TextInputInstance | null, index: number) => void;
|
|
51
51
|
index: number;
|
|
52
52
|
error?: string;
|
|
53
53
|
}
|
|
@@ -495,7 +495,7 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
|
|
|
495
495
|
|
|
496
496
|
// Use provided timezone if available, otherwise use local
|
|
497
497
|
const timezone = providedTimezone ?? localTimezone;
|
|
498
|
-
const inputRefs = useRef<(
|
|
498
|
+
const inputRefs = useRef<(TextInputInstance | null)[]>([]);
|
|
499
499
|
|
|
500
500
|
let borderColor = theme.field.border;
|
|
501
501
|
if (disabled) {
|
|
@@ -993,7 +993,7 @@ export const DateTimeField: FC<DateTimeFieldProps> = ({
|
|
|
993
993
|
getFieldValue,
|
|
994
994
|
handleFieldChange,
|
|
995
995
|
onBlur,
|
|
996
|
-
onRef: (el:
|
|
996
|
+
onRef: (el: TextInputInstance | null, i: number) => (inputRefs.current[i] = el),
|
|
997
997
|
};
|
|
998
998
|
|
|
999
999
|
const isMobile = isNarrowViewport();
|
package/src/DropdownPanel.tsx
CHANGED
|
@@ -360,9 +360,3 @@ export const DropdownPanel: FC<DropdownPanelProps> = ({
|
|
|
360
360
|
</View>
|
|
361
361
|
);
|
|
362
362
|
};
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* @deprecated Renamed to {@link DropdownPanel} — the component is a general
|
|
366
|
-
* compositional dropdown, not filter-specific. Removed in Terreno 58.
|
|
367
|
-
*/
|
|
368
|
-
export const Filter = DropdownPanel;
|
package/src/FilterAccordion.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {type FC, useState} from "react";
|
|
1
|
+
import {type ComponentProps, type FC, useState} from "react";
|
|
2
2
|
import {Pressable, View} from "react-native";
|
|
3
3
|
|
|
4
4
|
import type {FilterAccordionProps} from "./Common";
|
|
@@ -12,7 +12,7 @@ import {resolveTestID} from "./testing/resolveTestId";
|
|
|
12
12
|
// Native Web forwards it. A disclosure button needs its own spacebar handler
|
|
13
13
|
// (per ARIA, Space activates it) since role="button" only activates on Enter.
|
|
14
14
|
interface WebKeyDownEvent {
|
|
15
|
-
key
|
|
15
|
+
key?: string;
|
|
16
16
|
preventDefault: () => void;
|
|
17
17
|
repeat?: boolean;
|
|
18
18
|
}
|
|
@@ -83,7 +83,7 @@ export const FilterAccordion: FC<FilterAccordionProps> = ({
|
|
|
83
83
|
testID={testID}
|
|
84
84
|
>
|
|
85
85
|
<Pressable
|
|
86
|
-
{...webKeyDownProps}
|
|
86
|
+
{...(webKeyDownProps as Pick<ComponentProps<typeof Pressable>, "onKeyDown">)}
|
|
87
87
|
accessibilityRole="button"
|
|
88
88
|
accessibilityState={{expanded: isExpanded}}
|
|
89
89
|
aria-expanded={isExpanded}
|
package/src/FilterBoolean.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {type FC, useState} from "react";
|
|
1
|
+
import {type ComponentProps, type FC, useState} from "react";
|
|
2
2
|
import {Pressable, View} from "react-native";
|
|
3
3
|
|
|
4
4
|
import type {FilterBooleanProps} from "./Common";
|
|
@@ -11,7 +11,7 @@ import {resolveTestID} from "./testing/resolveTestId";
|
|
|
11
11
|
// Native Web forwards it. A switch needs its own spacebar handler (per ARIA,
|
|
12
12
|
// Space toggles it) since role="switch" only activates on Enter on the web.
|
|
13
13
|
interface WebKeyDownEvent {
|
|
14
|
-
key
|
|
14
|
+
key?: string;
|
|
15
15
|
preventDefault: () => void;
|
|
16
16
|
repeat?: boolean;
|
|
17
17
|
}
|
|
@@ -74,7 +74,7 @@ export const FilterBoolean: FC<FilterBooleanProps> = ({
|
|
|
74
74
|
|
|
75
75
|
return (
|
|
76
76
|
<Pressable
|
|
77
|
-
{...webKeyDownProps}
|
|
77
|
+
{...(webKeyDownProps as Pick<ComponentProps<typeof Pressable>, "onKeyDown">)}
|
|
78
78
|
accessibilityRole="switch"
|
|
79
79
|
accessibilityState={{checked: value, disabled}}
|
|
80
80
|
aria-checked={value}
|
package/src/FilterSelectMenu.tsx
CHANGED
|
@@ -63,7 +63,7 @@ export const FilterSelectMenu: FC<FilterSelectMenuProps> = ({
|
|
|
63
63
|
onChange={onChange}
|
|
64
64
|
options={options}
|
|
65
65
|
placeholder={placeholder}
|
|
66
|
-
// The
|
|
66
|
+
// The DropdownPanel is a fixed portal on document.body (zIndex 9999).
|
|
67
67
|
// Render the menu in a matching body portal so it floats above the
|
|
68
68
|
// panel instead of a React Native Modal that would stack behind it.
|
|
69
69
|
renderMenuInBodyPortal
|
package/src/GPTChat.tsx
CHANGED
|
@@ -11,12 +11,13 @@ import React, {useCallback, useEffect, useRef, useState} from "react";
|
|
|
11
11
|
import {
|
|
12
12
|
AccessibilityInfo,
|
|
13
13
|
findNodeHandle,
|
|
14
|
-
type Text as NativeText,
|
|
15
14
|
Platform,
|
|
16
15
|
Image as RNImage,
|
|
17
|
-
type
|
|
18
|
-
type
|
|
16
|
+
type ScrollViewInstance,
|
|
17
|
+
type TextInputInstance,
|
|
18
|
+
type TextInstance,
|
|
19
19
|
View,
|
|
20
|
+
type ViewInstance,
|
|
20
21
|
} from "react-native";
|
|
21
22
|
|
|
22
23
|
import {AttachmentPreview} from "./AttachmentPreview";
|
|
@@ -1020,10 +1021,10 @@ const AskFocusTarget = ({
|
|
|
1020
1021
|
renderCard,
|
|
1021
1022
|
}: {
|
|
1022
1023
|
label: string;
|
|
1023
|
-
renderCard: (promptRef: React.RefObject<
|
|
1024
|
+
renderCard: (promptRef: React.RefObject<TextInstance | null>) => React.ReactElement;
|
|
1024
1025
|
}): React.ReactElement => {
|
|
1025
|
-
const viewRef = useRef<
|
|
1026
|
-
const promptRef = useRef<
|
|
1026
|
+
const viewRef = useRef<ViewInstance>(null);
|
|
1027
|
+
const promptRef = useRef<TextInstance>(null);
|
|
1027
1028
|
|
|
1028
1029
|
// Focus the ask once, when it mounts; later renders of the same ask leave focus alone.
|
|
1029
1030
|
useEffect(() => {
|
|
@@ -1064,7 +1065,7 @@ const AskTranscriptItem = ({
|
|
|
1064
1065
|
onAskSubmit?: AskSubmitHandler;
|
|
1065
1066
|
resolveAskFiles?: AskFilesResolver;
|
|
1066
1067
|
}): React.ReactElement => {
|
|
1067
|
-
const renderCard = (promptRef?: React.Ref<
|
|
1068
|
+
const renderCard = (promptRef?: React.Ref<TextInstance>): React.ReactElement => (
|
|
1068
1069
|
<AskCard
|
|
1069
1070
|
ask={ask}
|
|
1070
1071
|
errors={errors}
|
|
@@ -1453,7 +1454,7 @@ export const GPTChat = ({
|
|
|
1453
1454
|
const [inputValue, setInputValue] = useState("");
|
|
1454
1455
|
const [editingHistoryId, setEditingHistoryId] = useState<string | null>(null);
|
|
1455
1456
|
const [editingTitle, setEditingTitle] = useState("");
|
|
1456
|
-
const scrollViewRef = useRef<
|
|
1457
|
+
const scrollViewRef = useRef<ScrollViewInstance>(null);
|
|
1457
1458
|
const [isScrolledUp, setIsScrolledUp] = useState(false);
|
|
1458
1459
|
const contentHeightRef = useRef(0);
|
|
1459
1460
|
const scrollOffsetRef = useRef(0);
|
|
@@ -1558,7 +1559,7 @@ export const GPTChat = ({
|
|
|
1558
1559
|
const [inputElement, setInputElement] = useState<HTMLElement | null>(null);
|
|
1559
1560
|
|
|
1560
1561
|
// On React Native Web the TextInput ref is the underlying DOM element.
|
|
1561
|
-
const handleInputRef = useCallback((ref:
|
|
1562
|
+
const handleInputRef = useCallback((ref: TextInputInstance | null) => {
|
|
1562
1563
|
setInputElement(ref as unknown as HTMLElement | null);
|
|
1563
1564
|
}, []);
|
|
1564
1565
|
|
package/src/Heading.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {Text as NativeText, Platform, type
|
|
2
|
+
import {Text as NativeText, Platform, type TextStyle} from "react-native";
|
|
3
3
|
|
|
4
4
|
import type {HeadingProps} from "./Common";
|
|
5
5
|
import {useTerrenoFontsLoaded} from "./TerrenoFontProvider";
|
|
@@ -34,19 +34,12 @@ const HeadingComponent = ({
|
|
|
34
34
|
const {theme} = useTheme();
|
|
35
35
|
useTerrenoFontsLoaded();
|
|
36
36
|
|
|
37
|
-
const style:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
style.fontSize = fontSizes[size || "md"].size;
|
|
46
|
-
if (align) {
|
|
47
|
-
style.textAlign = align;
|
|
48
|
-
}
|
|
49
|
-
style.color = theme.text[color];
|
|
37
|
+
const style: TextStyle = {
|
|
38
|
+
color: theme.text[color],
|
|
39
|
+
fontFamily: size === "sm" ? "heading-semibold" : "heading-bold",
|
|
40
|
+
fontSize: fontSizes[size || "md"].size,
|
|
41
|
+
...(align ? {textAlign: align} : {}),
|
|
42
|
+
};
|
|
50
43
|
|
|
51
44
|
// react-native-web turns role="heading" plus aria-level into <h1>-<h6>; native maps the role
|
|
52
45
|
// to the header accessibility role. RN's TextProps don't declare aria-level, hence the spread.
|
package/src/HeightField.tsx
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import {type FC, useCallback, useEffect, useMemo, useRef, useState} from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Platform,
|
|
4
|
+
Pressable,
|
|
5
|
+
type StyleProp,
|
|
6
|
+
TextInput,
|
|
7
|
+
type TextInputInstance,
|
|
8
|
+
View,
|
|
9
|
+
} from "react-native";
|
|
3
10
|
|
|
4
11
|
import type {ActionSheet} from "./ActionSheet";
|
|
5
12
|
import {Box} from "./Box";
|
|
@@ -57,7 +64,7 @@ interface HeightSegmentProps {
|
|
|
57
64
|
label: string;
|
|
58
65
|
disabled?: boolean;
|
|
59
66
|
maxValue: number;
|
|
60
|
-
inputRef?: (ref:
|
|
67
|
+
inputRef?: (ref: TextInputInstance | null) => void;
|
|
61
68
|
error?: boolean;
|
|
62
69
|
focused?: boolean;
|
|
63
70
|
}
|
package/src/Hyperlink.tsx
CHANGED
|
@@ -178,9 +178,12 @@ export const Hyperlink = (props: HyperlinkProps) => {
|
|
|
178
178
|
urlObject.protocol = urlObject.protocol?.toLowerCase() ?? "";
|
|
179
179
|
const normalizedURL = mdurl.format(urlObject);
|
|
180
180
|
|
|
181
|
-
void Linking.canOpenURL(normalizedURL).then(
|
|
182
|
-
(supported)
|
|
183
|
-
|
|
181
|
+
void Linking.canOpenURL(normalizedURL).then((supported) => {
|
|
182
|
+
if (supported) {
|
|
183
|
+
return Linking.openURL(normalizedURL);
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
});
|
|
184
187
|
};
|
|
185
188
|
|
|
186
189
|
const onPress = handleLink || props.onPress;
|
package/src/Link.test.tsx
CHANGED
|
@@ -26,7 +26,7 @@ describe("Link", () => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it("opens URL when href is provided and pressed", () => {
|
|
29
|
-
const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve(
|
|
29
|
+
const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve());
|
|
30
30
|
|
|
31
31
|
const {getByText} = renderWithTheme(<Link href="https://example.com" text="External Link" />);
|
|
32
32
|
|
|
@@ -38,7 +38,7 @@ describe("Link", () => {
|
|
|
38
38
|
|
|
39
39
|
it("prefers onClick over href when both are provided", () => {
|
|
40
40
|
const handleClick = mock(() => {});
|
|
41
|
-
const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve(
|
|
41
|
+
const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve());
|
|
42
42
|
|
|
43
43
|
// LinkProps forbids href with onClick; untyped callers can still pass both.
|
|
44
44
|
const bothActionProps = {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import {useMemo, useRef} from "react";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Platform,
|
|
5
|
+
Pressable,
|
|
6
|
+
Text as RNText,
|
|
7
|
+
ScrollView,
|
|
8
|
+
TextInput,
|
|
9
|
+
type TextInputInstance,
|
|
10
|
+
View,
|
|
11
|
+
} from "react-native";
|
|
4
12
|
|
|
5
13
|
import {Box} from "./Box";
|
|
6
14
|
import type {ErrorTextProps, HelperTextProps} from "./Common";
|
|
@@ -55,7 +63,7 @@ export const MarkdownEditorField: React.FC<MarkdownEditorFieldProps> = ({
|
|
|
55
63
|
}) => {
|
|
56
64
|
const {theme} = useTheme();
|
|
57
65
|
const isWeb = Platform.OS === "web";
|
|
58
|
-
const inputRef = useRef<
|
|
66
|
+
const inputRef = useRef<TextInputInstance>(null);
|
|
59
67
|
|
|
60
68
|
const monoFont = useMemo(
|
|
61
69
|
() => (isWeb ? "monospace" : Platform.select({android: "monospace", ios: "Menlo"})),
|
|
@@ -218,7 +218,7 @@ describe("MarkdownView", () => {
|
|
|
218
218
|
});
|
|
219
219
|
|
|
220
220
|
it("opens ordinary markdown links", async () => {
|
|
221
|
-
const openURL = mock(() => Promise.resolve(
|
|
221
|
+
const openURL = mock((_url: string): Promise<void> => Promise.resolve());
|
|
222
222
|
Linking.openURL = openURL;
|
|
223
223
|
const {getByText} = renderWithTheme(
|
|
224
224
|
<MarkdownView>[Docs](https://example.com/docs)</MarkdownView>
|
|
@@ -248,10 +248,14 @@ describe("MarkdownView", () => {
|
|
|
248
248
|
|
|
249
249
|
it("passes ordinary image keys directly instead of spreading them through props", async () => {
|
|
250
250
|
const consoleError = spyOn(console, "error").mockImplementation(() => {});
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
// Image.getSize is typed read-only; the test swaps it for a synchronous stub.
|
|
252
|
+
const mutableImage = Image as unknown as {getSize: typeof Image.getSize};
|
|
253
|
+
const originalGetSize = mutableImage.getSize;
|
|
254
|
+
mutableImage.getSize = mock(
|
|
255
|
+
(_uri: string, success: (width: number, height: number) => void): void => {
|
|
256
|
+
success(1200, 800);
|
|
257
|
+
}
|
|
258
|
+
) as unknown as typeof Image.getSize;
|
|
255
259
|
try {
|
|
256
260
|
const {toJSON} = renderWithTheme(
|
|
257
261
|
<MarkdownView>
|
|
@@ -268,7 +272,7 @@ describe("MarkdownView", () => {
|
|
|
268
272
|
);
|
|
269
273
|
assert.equal(keySpreadWarnings.length, 0);
|
|
270
274
|
} finally {
|
|
271
|
-
|
|
275
|
+
mutableImage.getSize = originalGetSize;
|
|
272
276
|
consoleError.mockRestore();
|
|
273
277
|
}
|
|
274
278
|
});
|
package/src/Modal.test.tsx
CHANGED
|
@@ -141,9 +141,11 @@ const setWindowWidth = (width: number): (() => void) => {
|
|
|
141
141
|
windowDimensions.mockImplementation(
|
|
142
142
|
(): ScaledSize => ({fontScale: 1, height: 924, scale: 1, width})
|
|
143
143
|
);
|
|
144
|
+
// Back to bunSetup's phone-sized default (375x812), so later suites in the process do not
|
|
145
|
+
// inherit a desktop width.
|
|
144
146
|
return (): void => {
|
|
145
147
|
windowDimensions.mockImplementation?.(
|
|
146
|
-
(): ScaledSize => ({fontScale: 1, height:
|
|
148
|
+
(): ScaledSize => ({fontScale: 1, height: 812, scale: 2, width: 375})
|
|
147
149
|
);
|
|
148
150
|
};
|
|
149
151
|
};
|
package/src/ModalSheet.test.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import {afterEach, beforeEach, describe, expect, it, mock, spyOn} from "bun:test
|
|
|
2
2
|
import {act} from "@testing-library/react-native";
|
|
3
3
|
import {assert} from "chai";
|
|
4
4
|
import {createRef, forwardRef, useImperativeHandle, useRef} from "react";
|
|
5
|
-
import {Platform, Modal as RNModal, Text, View} from "react-native";
|
|
5
|
+
import {Platform, Modal as RNModal, Text, View, type ViewInstance} from "react-native";
|
|
6
6
|
|
|
7
7
|
import {SimpleContent, useCombinedRefs} from "./ModalSheet";
|
|
8
8
|
import {renderWithTheme} from "./test-utils";
|
|
@@ -49,8 +49,8 @@ describe("ModalSheet", () => {
|
|
|
49
49
|
|
|
50
50
|
it("useCombinedRefs combines multiple refs", () => {
|
|
51
51
|
const TestComponent = () => {
|
|
52
|
-
const ref1 = useRef<
|
|
53
|
-
const ref2 = useRef<
|
|
52
|
+
const ref1 = useRef<ViewInstance>(null);
|
|
53
|
+
const ref2 = useRef<ViewInstance>(null);
|
|
54
54
|
const combinedRef = useCombinedRefs(ref1, ref2);
|
|
55
55
|
return <View ref={combinedRef} testID="combined-ref-view" />;
|
|
56
56
|
};
|
|
@@ -73,10 +73,10 @@ describe("ModalSheet", () => {
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
it("useCombinedRefs forwards the node to callback refs, object refs, and skips undefined", () => {
|
|
76
|
-
const callbackRef = mock((_node:
|
|
77
|
-
const objectRef: {current:
|
|
76
|
+
const callbackRef = mock((_node: ViewInstance | null) => {});
|
|
77
|
+
const objectRef: {current: ViewInstance | null} = {current: null};
|
|
78
78
|
const TestComponent = () => {
|
|
79
|
-
const combinedRef = useCombinedRefs<
|
|
79
|
+
const combinedRef = useCombinedRefs<ViewInstance>(callbackRef, undefined, objectRef);
|
|
80
80
|
return <View ref={combinedRef} testID="combined-ref-view" />;
|
|
81
81
|
};
|
|
82
82
|
|