@terreno/ui 57.11.0 → 57.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AiSuggestionBox.js +9 -9
- package/dist/AiSuggestionBox.js.map +1 -1
- package/dist/Banner.js +1 -1
- package/dist/Banner.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +36 -3
- package/dist/Box.js.map +1 -1
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +7 -0
- package/dist/Button.js.map +1 -1
- package/dist/Common.d.ts +34 -4
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +50 -3
- package/dist/DataTable.js.map +1 -1
- package/dist/Image.d.ts.map +1 -1
- package/dist/Image.js +1 -1
- package/dist/Image.js.map +1 -1
- package/dist/MarkdownView.d.ts.map +1 -1
- package/dist/MarkdownView.js +67 -5
- package/dist/MarkdownView.js.map +1 -1
- package/dist/Modal.js +1 -1
- package/dist/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl.js +15 -11
- package/dist/SegmentedControl.js.map +1 -1
- package/dist/SelectField.d.ts.map +1 -1
- package/dist/SelectField.js +4 -1
- package/dist/SelectField.js.map +1 -1
- package/dist/SplitPage.d.ts.map +1 -1
- package/dist/SplitPage.js +145 -55
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.js +1 -1
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/TerrenoProvider.d.ts +7 -3
- package/dist/TerrenoProvider.d.ts.map +1 -1
- package/dist/TerrenoProvider.js +2 -2
- package/dist/TerrenoProvider.js.map +1 -1
- package/dist/Theme.d.ts +19 -85
- package/dist/Theme.d.ts.map +1 -1
- package/dist/Theme.js +149 -33
- package/dist/Theme.js.map +1 -1
- package/dist/Toast.d.ts.map +1 -1
- package/dist/Toast.js +21 -12
- package/dist/Toast.js.map +1 -1
- package/dist/ToastNotifications.d.ts.map +1 -1
- package/dist/ToastNotifications.js +5 -2
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/Tooltip.d.ts +1 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js +84 -37
- package/dist/Tooltip.js.map +1 -1
- package/dist/blocks/BlocksView.d.ts.map +1 -1
- package/dist/blocks/BlocksView.js +5 -1
- package/dist/blocks/BlocksView.js.map +1 -1
- package/dist/blocks/blockRenderers.d.ts +10 -1
- package/dist/blocks/blockRenderers.d.ts.map +1 -1
- package/dist/blocks/blockRenderers.js +330 -9
- package/dist/blocks/blockRenderers.js.map +1 -1
- package/dist/blocks/useChecklistState.d.ts +18 -0
- package/dist/blocks/useChecklistState.d.ts.map +1 -0
- package/dist/blocks/useChecklistState.js +29 -0
- package/dist/blocks/useChecklistState.js.map +1 -0
- package/dist/blocks/useResolvedImages.d.ts.map +1 -1
- package/dist/blocks/useResolvedImages.js +16 -0
- package/dist/blocks/useResolvedImages.js.map +1 -1
- package/dist/colorContrast.d.ts +9 -0
- package/dist/colorContrast.d.ts.map +1 -0
- package/dist/colorContrast.js +47 -0
- package/dist/colorContrast.js.map +1 -0
- package/dist/icons/OfflineIcon.js +1 -1
- package/dist/table/TableDate.d.ts.map +1 -1
- package/dist/table/TableDate.js +3 -1
- package/dist/table/TableDate.js.map +1 -1
- package/package.json +2 -2
- package/src/AiSuggestionBox.tsx +10 -10
- package/src/Banner.tsx +1 -1
- package/src/Box.test.tsx +80 -0
- package/src/Box.tsx +52 -0
- package/src/Button.test.tsx +39 -1
- package/src/Button.tsx +9 -0
- package/src/Common.ts +35 -4
- package/src/DataTable.test.tsx +133 -1
- package/src/DataTable.tsx +78 -3
- package/src/Image.tsx +1 -0
- package/src/MarkdownView.test.tsx +165 -2
- package/src/MarkdownView.tsx +100 -5
- package/src/Modal.tsx +1 -1
- package/src/SegmentedControl.test.tsx +7 -0
- package/src/SegmentedControl.tsx +22 -11
- package/src/SelectField.tsx +4 -1
- package/src/SplitPage.native.tsx +1 -1
- package/src/SplitPage.test.tsx +473 -5
- package/src/SplitPage.tsx +266 -132
- package/src/TerrenoProvider.tsx +15 -5
- package/src/Theme.test.tsx +212 -3
- package/src/Theme.tsx +184 -39
- package/src/Toast.test.tsx +7 -0
- package/src/Toast.tsx +22 -12
- package/src/ToastNotifications.test.tsx +36 -0
- package/src/ToastNotifications.tsx +5 -2
- package/src/Tooltip.test.tsx +232 -1
- package/src/Tooltip.tsx +128 -67
- package/src/__snapshots__/AddressField.test.tsx.snap +7 -7
- package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +23 -23
- package/src/__snapshots__/Banner.test.tsx.snap +3 -0
- package/src/__snapshots__/BooleanField.test.tsx.snap +3 -3
- package/src/__snapshots__/Button.test.tsx.snap +16 -16
- package/src/__snapshots__/Card.test.tsx.snap +0 -1
- package/src/__snapshots__/CustomSelectField.test.tsx.snap +23 -23
- package/src/__snapshots__/DataTable.test.tsx.snap +30 -30
- package/src/__snapshots__/DecimalRangeActionSheet.test.tsx.snap +2 -2
- package/src/__snapshots__/DropdownPanel.test.tsx.snap +2 -2
- package/src/__snapshots__/EmailField.test.tsx.snap +2 -2
- package/src/__snapshots__/ErrorPage.test.tsx.snap +1 -1
- package/src/__snapshots__/Field.test.tsx.snap +37 -37
- package/src/__snapshots__/FilterSelectMenu.test.tsx.snap +2 -1
- package/src/__snapshots__/HeightActionSheet.test.tsx.snap +2 -2
- package/src/__snapshots__/HeightField.test.tsx.snap +8 -8
- package/src/__snapshots__/HeightFieldDesktop.test.tsx.snap +6 -6
- package/src/__snapshots__/InfoModalIcon.test.tsx.snap +2 -2
- package/src/__snapshots__/MarkdownView.test.tsx.snap +2 -2
- package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +1 -1
- package/src/__snapshots__/Modal.test.tsx.snap +10 -10
- package/src/__snapshots__/NumberField.test.tsx.snap +1 -1
- package/src/__snapshots__/NumberPickerActionSheet.test.tsx.snap +2 -2
- package/src/__snapshots__/Page.test.tsx.snap +1 -1
- package/src/__snapshots__/PhoneNumberField.test.tsx.snap +4 -4
- package/src/__snapshots__/PickerSelect.test.tsx.snap +8 -8
- package/src/__snapshots__/SectionDivider.test.tsx.snap +2 -2
- package/src/__snapshots__/SegmentedControl.test.tsx.snap +183 -0
- package/src/__snapshots__/SelectBadge.test.tsx.snap +9 -9
- package/src/__snapshots__/SelectField.test.tsx.snap +19 -19
- package/src/__snapshots__/Signature.test.tsx.snap +1 -1
- package/src/__snapshots__/SignatureCaptureField.test.tsx.snap +2 -2
- package/src/__snapshots__/SignatureField.test.tsx.snap +2 -2
- package/src/__snapshots__/SplitPage.test.tsx.snap +165 -67
- package/src/__snapshots__/TapToEdit.test.tsx.snap +1 -1
- package/src/__snapshots__/TerrenoProvider.test.tsx.snap +20 -4
- package/src/__snapshots__/TextArea.test.tsx.snap +4 -4
- package/src/__snapshots__/TextField.test.tsx.snap +3 -3
- package/src/__snapshots__/TimezonePicker.test.tsx.snap +18 -18
- package/src/__snapshots__/Toast.test.tsx.snap +224 -154
- package/src/__snapshots__/TypedSignatureField.test.tsx.snap +3 -3
- package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +6 -6
- package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +4 -4
- package/src/blocks/BlocksView.test.tsx +1101 -2
- package/src/blocks/BlocksView.tsx +5 -1
- package/src/blocks/blockRenderers.tsx +730 -22
- package/src/blocks/useChecklistState.ts +46 -0
- package/src/blocks/useResolvedImages.ts +16 -0
- package/src/bunSetup.ts +3 -0
- package/src/colorContrast.test.ts +27 -0
- package/src/colorContrast.ts +55 -0
- package/src/icons/OfflineIcon.tsx +2 -2
- package/src/icons/__snapshots__/OfflineIcon.test.tsx.snap +4 -4
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +7 -7
- package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +3 -3
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +7 -7
- package/src/table/TableDate.tsx +3 -1
- package/src/table/__snapshots__/Table.test.tsx.snap +5 -5
- package/src/table/__snapshots__/TableBadge.test.tsx.snap +3 -3
- package/src/table/__snapshots__/TableDate.test.tsx.snap +4 -0
- package/src/table/__snapshots__/TableHeader.test.tsx.snap +4 -4
- package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +7 -7
- package/src/table/__snapshots__/TableRow.test.tsx.snap +6 -6
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} from "react-native";
|
|
4
|
+
import {Platform, StyleSheet} from "react-native";
|
|
5
5
|
|
|
6
6
|
import type {DataTableCustomComponentMap, DataTableProps} from "./Common";
|
|
7
7
|
import {DataTable} from "./DataTable";
|
|
@@ -297,6 +297,27 @@ describe("DataTable", () => {
|
|
|
297
297
|
expect(toJSON()).toBeTruthy();
|
|
298
298
|
});
|
|
299
299
|
|
|
300
|
+
it("uses inverted text on low-contrast highlights for text, number, and date cells", () => {
|
|
301
|
+
const highlightColumns = [
|
|
302
|
+
{columnType: "text", title: "Name", width: 150},
|
|
303
|
+
{columnType: "number", title: "Count", width: 100},
|
|
304
|
+
{columnType: "date", title: "Due", width: 150},
|
|
305
|
+
];
|
|
306
|
+
const highlightData = [
|
|
307
|
+
[
|
|
308
|
+
{highlight: "error", value: "Overdue"},
|
|
309
|
+
{highlight: "error", value: 42},
|
|
310
|
+
{highlight: "error", value: "2024-01-15"},
|
|
311
|
+
],
|
|
312
|
+
];
|
|
313
|
+
const {getByText} = renderWithTheme(
|
|
314
|
+
<DataTable columns={highlightColumns} data={highlightData} />
|
|
315
|
+
);
|
|
316
|
+
for (const label of ["Overdue", "42", "Jan 15, 2024"]) {
|
|
317
|
+
expect(StyleSheet.flatten(getByText(label).props.style).color).toBe("#FFFFFF");
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
300
321
|
it("renders with moreContentExtraData", () => {
|
|
301
322
|
const MoreContent: MoreContentComponent = ({rowIndex, extraInfo}) => (
|
|
302
323
|
<Text>
|
|
@@ -813,4 +834,115 @@ describe("DataTable", () => {
|
|
|
813
834
|
});
|
|
814
835
|
}
|
|
815
836
|
});
|
|
837
|
+
|
|
838
|
+
describe("typed cells", () => {
|
|
839
|
+
const textAlignOf = (node: {props: {style?: unknown}}): unknown =>
|
|
840
|
+
(StyleSheet.flatten(node.props.style as never) as {textAlign?: string} | undefined)
|
|
841
|
+
?.textAlign;
|
|
842
|
+
|
|
843
|
+
it("right-aligns number cells whether the value is a number or a numeric string", () => {
|
|
844
|
+
const {getByText} = renderWithTheme(
|
|
845
|
+
<DataTable
|
|
846
|
+
columns={[
|
|
847
|
+
{columnType: "text", title: "Name", width: 150},
|
|
848
|
+
{columnType: "number", title: "Guests", width: 100},
|
|
849
|
+
]}
|
|
850
|
+
data={[
|
|
851
|
+
[{value: "Ada"}, {value: 42}],
|
|
852
|
+
[{value: "Bo"}, {value: "7.5"}],
|
|
853
|
+
]}
|
|
854
|
+
/>
|
|
855
|
+
);
|
|
856
|
+
expect(textAlignOf(getByText("42"))).toBe("right");
|
|
857
|
+
expect(textAlignOf(getByText("7.5"))).toBe("right");
|
|
858
|
+
expect(textAlignOf(getByText("Ada"))).not.toBe("right");
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
it("right-aligns the header of a number column so it lines up with its cells", () => {
|
|
862
|
+
const {getByText} = renderWithTheme(
|
|
863
|
+
<DataTable
|
|
864
|
+
columns={[
|
|
865
|
+
{columnType: "text", title: "Name", width: 150},
|
|
866
|
+
{columnType: "number", title: "Guests", width: 100},
|
|
867
|
+
]}
|
|
868
|
+
data={[[{value: "Ada"}, {value: 42}]]}
|
|
869
|
+
/>
|
|
870
|
+
);
|
|
871
|
+
expect(textAlignOf(getByText("Guests"))).toBe("right");
|
|
872
|
+
expect(textAlignOf(getByText("Name"))).toBe("left");
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
it("renders an empty number cell without crashing", () => {
|
|
876
|
+
const {getByTestId} = renderWithTheme(
|
|
877
|
+
<DataTable
|
|
878
|
+
columns={[{columnType: "number", title: "Guests", width: 100}]}
|
|
879
|
+
data={[[{value: null}]]}
|
|
880
|
+
testID="table"
|
|
881
|
+
/>
|
|
882
|
+
);
|
|
883
|
+
expect(getByTestId("table")).toBeTruthy();
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
it("formats ISO date cells as Luxon DATE_MED", () => {
|
|
887
|
+
const {getByText, queryByText} = renderWithTheme(
|
|
888
|
+
<DataTable
|
|
889
|
+
columns={[
|
|
890
|
+
{columnType: "date", title: "Day", width: 150},
|
|
891
|
+
{columnType: "date", title: "At", width: 150},
|
|
892
|
+
]}
|
|
893
|
+
data={[[{value: "2026-03-14"}, {value: "2026-10-08T15:30:00"}]]}
|
|
894
|
+
/>
|
|
895
|
+
);
|
|
896
|
+
expect(getByText("Mar 14, 2026")).toBeTruthy();
|
|
897
|
+
expect(getByText("Oct 8, 2026")).toBeTruthy();
|
|
898
|
+
expect(queryByText("2026-03-14")).toBeNull();
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
it("formats a Date value in a date cell", () => {
|
|
902
|
+
const {getByText} = renderWithTheme(
|
|
903
|
+
<DataTable
|
|
904
|
+
columns={[{columnType: "date", title: "Day", width: 150}]}
|
|
905
|
+
data={[[{value: new Date(2026, 2, 14, 12)}]]}
|
|
906
|
+
/>
|
|
907
|
+
);
|
|
908
|
+
expect(getByText("Mar 14, 2026")).toBeTruthy();
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
it("shows invalid date strings as written and empty dates as blank", () => {
|
|
912
|
+
const {getByText, getByTestId} = renderWithTheme(
|
|
913
|
+
<DataTable
|
|
914
|
+
columns={[
|
|
915
|
+
{columnType: "date", title: "Day", width: 150},
|
|
916
|
+
{columnType: "date", title: "Other", width: 150},
|
|
917
|
+
]}
|
|
918
|
+
data={[
|
|
919
|
+
[{value: "next Tuesday"}, {value: ""}],
|
|
920
|
+
[{value: undefined}, {value: "Oct 8, 2026, 3:00 PM"}],
|
|
921
|
+
]}
|
|
922
|
+
testID="table"
|
|
923
|
+
/>
|
|
924
|
+
);
|
|
925
|
+
expect(getByText("next Tuesday")).toBeTruthy();
|
|
926
|
+
expect(getByText("Oct 8, 2026, 3:00 PM")).toBeTruthy();
|
|
927
|
+
expect(getByTestId("table")).toBeTruthy();
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
it("lets customColumnComponentMap override number and date cells", () => {
|
|
931
|
+
const Custom: DataTableCustomComponentMap[string] = ({cellData}) => (
|
|
932
|
+
<Text>{`Custom ${String(cellData.value)}`}</Text>
|
|
933
|
+
);
|
|
934
|
+
const {getByText} = renderWithTheme(
|
|
935
|
+
<DataTable
|
|
936
|
+
columns={[
|
|
937
|
+
{columnType: "number", title: "Guests", width: 100},
|
|
938
|
+
{columnType: "date", title: "Day", width: 150},
|
|
939
|
+
]}
|
|
940
|
+
customColumnComponentMap={{date: Custom, number: Custom}}
|
|
941
|
+
data={[[{value: 6}, {value: "2026-03-14"}]]}
|
|
942
|
+
/>
|
|
943
|
+
);
|
|
944
|
+
expect(getByText("Custom 6")).toBeTruthy();
|
|
945
|
+
expect(getByText("Custom 2026-03-14")).toBeTruthy();
|
|
946
|
+
});
|
|
947
|
+
});
|
|
816
948
|
});
|
package/src/DataTable.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
|
|
2
|
+
import {DateTime} from "luxon";
|
|
2
3
|
import type React from "react";
|
|
3
4
|
import {
|
|
4
5
|
type FC,
|
|
@@ -30,6 +31,7 @@ import type {
|
|
|
30
31
|
DataTableProps,
|
|
31
32
|
SurfaceColor,
|
|
32
33
|
} from "./Common";
|
|
34
|
+
import {readableTextColor} from "./colorContrast";
|
|
33
35
|
import {DataTableHeaderInfoMarkdown} from "./DataTableHeaderInfoMarkdown";
|
|
34
36
|
import {
|
|
35
37
|
DataTableAdditionalFiltersWeb,
|
|
@@ -60,13 +62,76 @@ const DATA_TABLE_MAX_TO_RENDER_PER_BATCH = 10;
|
|
|
60
62
|
const DATA_TABLE_WINDOW_SIZE = 5;
|
|
61
63
|
const DATA_TABLE_VERTICAL_SCROLL_SYNC_RELEASE_MS = 50;
|
|
62
64
|
|
|
65
|
+
/** Inverted text when primary text falls below WCAG AA on the cell's highlight fill. */
|
|
66
|
+
const useHighlightTextColor = (cellData: DataTableCellData): "inverted" | undefined => {
|
|
67
|
+
const {theme} = useTheme();
|
|
68
|
+
const highlightColor = cellData.highlight ? theme.surface[cellData.highlight] : undefined;
|
|
69
|
+
if (!highlightColor) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return readableTextColor(theme.text.primary, theme.text.inverted, highlightColor) === "inverted"
|
|
73
|
+
? "inverted"
|
|
74
|
+
: undefined;
|
|
75
|
+
};
|
|
76
|
+
|
|
63
77
|
const TextCell: FC<{
|
|
64
78
|
cellData: DataTableCellData;
|
|
65
79
|
column: DataTableColumn;
|
|
66
80
|
}> = ({cellData}) => {
|
|
81
|
+
const textColor = useHighlightTextColor(cellData);
|
|
82
|
+
|
|
67
83
|
return (
|
|
68
84
|
<Box flex="grow" justifyContent="center">
|
|
69
|
-
<Text size={cellData.textSize || "md"}>
|
|
85
|
+
<Text color={textColor} size={cellData.textSize || "md"}>
|
|
86
|
+
{String(cellData.value ?? "")}
|
|
87
|
+
</Text>
|
|
88
|
+
</Box>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const NumberCell: FC<{
|
|
93
|
+
cellData: DataTableCellData;
|
|
94
|
+
column: DataTableColumn;
|
|
95
|
+
}> = ({cellData}) => {
|
|
96
|
+
const textColor = useHighlightTextColor(cellData);
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Box flex="grow" justifyContent="center" width="100%">
|
|
100
|
+
<Text align="right" color={textColor} size={cellData.textSize || "md"}>
|
|
101
|
+
{String(cellData.value ?? "")}
|
|
102
|
+
</Text>
|
|
103
|
+
</Box>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Formats ISO strings and Dates as Luxon DATE_MED; anything unparseable is shown as written. */
|
|
108
|
+
const formatDataTableDate = (value: unknown): string => {
|
|
109
|
+
if (value === null || value === undefined || value === "") {
|
|
110
|
+
return "";
|
|
111
|
+
}
|
|
112
|
+
let date: DateTime | undefined;
|
|
113
|
+
if (value instanceof Date) {
|
|
114
|
+
date = DateTime.fromJSDate(value);
|
|
115
|
+
} else if (typeof value === "string") {
|
|
116
|
+
date = DateTime.fromISO(value);
|
|
117
|
+
}
|
|
118
|
+
if (!date?.isValid) {
|
|
119
|
+
return String(value);
|
|
120
|
+
}
|
|
121
|
+
return date.toLocaleString(DateTime.DATE_MED);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const DateCell: FC<{
|
|
125
|
+
cellData: DataTableCellData;
|
|
126
|
+
column: DataTableColumn;
|
|
127
|
+
}> = ({cellData}) => {
|
|
128
|
+
const textColor = useHighlightTextColor(cellData);
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<Box flex="grow" justifyContent="center">
|
|
132
|
+
<Text color={textColor} size={cellData.textSize || "md"}>
|
|
133
|
+
{formatDataTableDate(cellData.value)}
|
|
134
|
+
</Text>
|
|
70
135
|
</Box>
|
|
71
136
|
);
|
|
72
137
|
};
|
|
@@ -111,6 +176,10 @@ const DataTableCellComponent: FC<InternalDataTableCellProps> = ({
|
|
|
111
176
|
Component = customColumnComponentMap[columnDef.columnType];
|
|
112
177
|
} else if (columnDef.columnType === "boolean") {
|
|
113
178
|
Component = CheckedCell;
|
|
179
|
+
} else if (columnDef.columnType === "number") {
|
|
180
|
+
Component = NumberCell;
|
|
181
|
+
} else if (columnDef.columnType === "date") {
|
|
182
|
+
Component = DateCell;
|
|
114
183
|
}
|
|
115
184
|
const cellData = value.textSize === textSize ? value : {...value, textSize};
|
|
116
185
|
|
|
@@ -303,6 +372,8 @@ const DataTableHeaderCell: FC<DataTableHeaderCellProps> = ({
|
|
|
303
372
|
}) => {
|
|
304
373
|
const {theme} = useTheme();
|
|
305
374
|
const sort = sortColumn?.column === index ? sortColumn.direction : undefined;
|
|
375
|
+
// Number cells are right-aligned, so their header sits on the same edge.
|
|
376
|
+
const isNumberColumn = column.columnType === "number";
|
|
306
377
|
|
|
307
378
|
return (
|
|
308
379
|
<View
|
|
@@ -313,7 +384,7 @@ const DataTableHeaderCell: FC<DataTableHeaderCellProps> = ({
|
|
|
313
384
|
borderBottomWidth: 1,
|
|
314
385
|
flexDirection: "row",
|
|
315
386
|
height: headerHeight ?? rowHeight,
|
|
316
|
-
justifyContent: "space-between",
|
|
387
|
+
justifyContent: isNumberColumn ? "flex-end" : "space-between",
|
|
317
388
|
padding: 16,
|
|
318
389
|
width: column.width,
|
|
319
390
|
...(isPinnedHorizontal && {
|
|
@@ -325,7 +396,11 @@ const DataTableHeaderCell: FC<DataTableHeaderCellProps> = ({
|
|
|
325
396
|
>
|
|
326
397
|
{[
|
|
327
398
|
column.title ? (
|
|
328
|
-
<TableTitle
|
|
399
|
+
<TableTitle
|
|
400
|
+
align={isNumberColumn ? "right" : "left"}
|
|
401
|
+
key="data-table-header-title"
|
|
402
|
+
title={column.title!}
|
|
403
|
+
/>
|
|
329
404
|
) : null,
|
|
330
405
|
<View key="data-table-header-tools" style={{alignItems: "center", flexDirection: "row"}}>
|
|
331
406
|
{column.filter && onFilterValuesChange && Platform.OS === "web" ? (
|
package/src/Image.tsx
CHANGED
|
@@ -35,6 +35,7 @@ export class Image extends React.Component<ImageProps, {}> {
|
|
|
35
35
|
return (
|
|
36
36
|
<Box color={this.props.color}>
|
|
37
37
|
<NativeImage
|
|
38
|
+
{...(this.props.alt ? {accessibilityLabel: this.props.alt, accessible: true} : {})}
|
|
38
39
|
resizeMode={this.resizeMode(this.props.fit)}
|
|
39
40
|
source={{cache: "force-cache", uri: this.props.src}}
|
|
40
41
|
style={{
|
|
@@ -1,11 +1,63 @@
|
|
|
1
1
|
import {describe, expect, it, mock, spyOn} from "bun:test";
|
|
2
2
|
import assert from "node:assert";
|
|
3
|
-
import {fireEvent, waitFor} from "@testing-library/react-native";
|
|
4
|
-
import
|
|
3
|
+
import {fireEvent, render, waitFor} from "@testing-library/react-native";
|
|
4
|
+
import type React from "react";
|
|
5
|
+
import {Image, Linking, StyleSheet} from "react-native";
|
|
5
6
|
|
|
7
|
+
import type {TerrenoTheme} from "./Common";
|
|
6
8
|
import {MarkdownView} from "./MarkdownView";
|
|
9
|
+
import {ThemeProvider, useTheme} from "./Theme";
|
|
7
10
|
import {renderWithTheme} from "./test-utils";
|
|
8
11
|
|
|
12
|
+
const LAMB_TABLE = [
|
|
13
|
+
"| Guests | Bone-in lamb | Potatoes |",
|
|
14
|
+
"| --- | --- | --- |",
|
|
15
|
+
"| 4 | 2 kg | 1 kg |",
|
|
16
|
+
"| 6 | 3 kg | 1.5 kg |",
|
|
17
|
+
"| 8 | 4 kg | 2 kg |",
|
|
18
|
+
"| 10 | 5 kg | 2.5 kg |",
|
|
19
|
+
].join("\n");
|
|
20
|
+
|
|
21
|
+
const DARK_PRIMITIVES = {
|
|
22
|
+
neutral300: "#3A3A3A",
|
|
23
|
+
neutral900: "#F5F5F5",
|
|
24
|
+
secondary100: "#1F3A44",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface ThemeCapture {
|
|
28
|
+
theme?: TerrenoTheme;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ThemeProbe: React.FC<{capture: ThemeCapture}> = ({capture}) => {
|
|
32
|
+
const {theme} = useTheme();
|
|
33
|
+
capture.theme = theme;
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const renderTable = async ({
|
|
38
|
+
initialPrimitives,
|
|
39
|
+
markdown = LAMB_TABLE,
|
|
40
|
+
}: {
|
|
41
|
+
initialPrimitives?: Record<string, string>;
|
|
42
|
+
markdown?: string;
|
|
43
|
+
}): Promise<{capture: ThemeCapture; result: ReturnType<typeof render>}> => {
|
|
44
|
+
const capture: ThemeCapture = {};
|
|
45
|
+
const result = render(
|
|
46
|
+
<ThemeProvider initialPrimitives={initialPrimitives}>
|
|
47
|
+
<ThemeProbe capture={capture} />
|
|
48
|
+
<MarkdownView>{markdown}</MarkdownView>
|
|
49
|
+
</ThemeProvider>
|
|
50
|
+
);
|
|
51
|
+
await waitFor(() => {
|
|
52
|
+
expect(result.getByText("Bone-in lamb")).toBeTruthy();
|
|
53
|
+
});
|
|
54
|
+
return {capture, result};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const flatStyle = (node: {props: {style?: unknown}}): Record<string, unknown> => {
|
|
58
|
+
return (StyleSheet.flatten(node.props.style as never) ?? {}) as Record<string, unknown>;
|
|
59
|
+
};
|
|
60
|
+
|
|
9
61
|
describe("MarkdownView", () => {
|
|
10
62
|
it("renders correctly with simple text", async () => {
|
|
11
63
|
const {toJSON} = renderWithTheme(<MarkdownView>Hello world</MarkdownView>);
|
|
@@ -41,6 +93,50 @@ describe("MarkdownView", () => {
|
|
|
41
93
|
expect(toJSON()).toMatchSnapshot();
|
|
42
94
|
});
|
|
43
95
|
|
|
96
|
+
it("keeps an inverted blockquote off the same color as its text", async () => {
|
|
97
|
+
const {toJSON} = renderWithTheme(<MarkdownView inverted>{"> Quoted line"}</MarkdownView>);
|
|
98
|
+
await waitFor(() => {
|
|
99
|
+
expect(JSON.stringify(toJSON())).toContain("Quoted line");
|
|
100
|
+
});
|
|
101
|
+
const serialized = JSON.stringify(toJSON());
|
|
102
|
+
assert.ok(serialized.includes('"backgroundColor":"#353535"'));
|
|
103
|
+
assert.ok(serialized.includes('"color":"#FFFFFF"'));
|
|
104
|
+
|
|
105
|
+
const dark = render(
|
|
106
|
+
<ThemeProvider colorScheme="dark">
|
|
107
|
+
<MarkdownView inverted>{"> Quoted line"}</MarkdownView>
|
|
108
|
+
</ThemeProvider>
|
|
109
|
+
);
|
|
110
|
+
await waitFor(() => {
|
|
111
|
+
expect(JSON.stringify(dark.toJSON())).toContain("Quoted line");
|
|
112
|
+
});
|
|
113
|
+
const darkSerialized = JSON.stringify(dark.toJSON());
|
|
114
|
+
assert.ok(darkSerialized.includes('"backgroundColor":"#F2F2F2"'));
|
|
115
|
+
assert.ok(darkSerialized.includes('"color":"#353535"'));
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("keeps inverted code off a fill below 4.5:1", async () => {
|
|
119
|
+
const light = renderWithTheme(<MarkdownView inverted>{"Use `inline code` here"}</MarkdownView>);
|
|
120
|
+
await waitFor(() => {
|
|
121
|
+
expect(JSON.stringify(light.toJSON())).toContain("inline code");
|
|
122
|
+
});
|
|
123
|
+
const lightSerialized = JSON.stringify(light.toJSON());
|
|
124
|
+
assert.ok(lightSerialized.includes('"backgroundColor":"#353535"'));
|
|
125
|
+
assert.ok(lightSerialized.includes('"color":"#FFFFFF"'));
|
|
126
|
+
|
|
127
|
+
const dark = render(
|
|
128
|
+
<ThemeProvider colorScheme="dark">
|
|
129
|
+
<MarkdownView inverted>{"```\ncode block\n```"}</MarkdownView>
|
|
130
|
+
</ThemeProvider>
|
|
131
|
+
);
|
|
132
|
+
await waitFor(() => {
|
|
133
|
+
expect(JSON.stringify(dark.toJSON())).toContain("code block");
|
|
134
|
+
});
|
|
135
|
+
const darkSerialized = JSON.stringify(dark.toJSON());
|
|
136
|
+
assert.ok(darkSerialized.includes('"backgroundColor":"#F2F2F2"'));
|
|
137
|
+
assert.ok(darkSerialized.includes('"color":"#353535"'));
|
|
138
|
+
});
|
|
139
|
+
|
|
44
140
|
it("renders with inverted colors", async () => {
|
|
45
141
|
const {toJSON} = renderWithTheme(<MarkdownView inverted>Inverted text colors</MarkdownView>);
|
|
46
142
|
await waitFor(() => {
|
|
@@ -176,4 +272,71 @@ describe("MarkdownView", () => {
|
|
|
176
272
|
consoleError.mockRestore();
|
|
177
273
|
}
|
|
178
274
|
});
|
|
275
|
+
|
|
276
|
+
describe("GFM tables", () => {
|
|
277
|
+
it("draws table cell borders in theme.border.default", async () => {
|
|
278
|
+
const {capture, result} = await renderTable({});
|
|
279
|
+
const cell = result.getByTestId("markdown-table-cell-1-1");
|
|
280
|
+
const header = result.getByTestId("markdown-table-header-0");
|
|
281
|
+
assert.ok(capture.theme);
|
|
282
|
+
expect(flatStyle(cell).borderColor).toBe(capture.theme.border.default);
|
|
283
|
+
expect(flatStyle(header).borderColor).toBe(capture.theme.border.default);
|
|
284
|
+
expect(flatStyle(cell).borderRightWidth).toBe(1);
|
|
285
|
+
expect(flatStyle(cell).borderBottomWidth).toBe(1);
|
|
286
|
+
expect(flatStyle(result.getByTestId("markdown-table")).borderColor).toBe(
|
|
287
|
+
capture.theme.border.default
|
|
288
|
+
);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it("renders a bold header row on theme.surface.secondaryLight", async () => {
|
|
292
|
+
const {capture, result} = await renderTable({});
|
|
293
|
+
assert.ok(capture.theme);
|
|
294
|
+
for (const index of [0, 1, 2]) {
|
|
295
|
+
expect(
|
|
296
|
+
flatStyle(result.getByTestId(`markdown-table-header-${index}`)).backgroundColor
|
|
297
|
+
).toBe(capture.theme.surface.secondaryLight);
|
|
298
|
+
}
|
|
299
|
+
expect(flatStyle(result.getByText("Bone-in lamb")).fontFamily).toBe("text-bold");
|
|
300
|
+
expect(flatStyle(result.getByText("1.5 kg")).fontFamily).toBe("text-regular");
|
|
301
|
+
expect(flatStyle(result.getByTestId("markdown-table-cell-1-1")).backgroundColor).toBe(
|
|
302
|
+
undefined
|
|
303
|
+
);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it("wraps the table in a horizontal scroll view that fills a narrow container", async () => {
|
|
307
|
+
const {result} = await renderTable({});
|
|
308
|
+
const scroll = result.getByTestId("markdown-table-scroll");
|
|
309
|
+
expect(scroll.props.horizontal).toBe(true);
|
|
310
|
+
expect(flatStyle({props: {style: scroll.props.contentContainerStyle}}).minWidth).toBe("100%");
|
|
311
|
+
const table = result.getByTestId("markdown-table");
|
|
312
|
+
expect(flatStyle(table).flexGrow).toBe(1);
|
|
313
|
+
const cellStyle = flatStyle(result.getByTestId("markdown-table-cell-0-0"));
|
|
314
|
+
expect(cellStyle.flexGrow).toBe(1);
|
|
315
|
+
expect(cellStyle.minWidth).toBe(96);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it("follows a swapped (dark) palette instead of fixed colors", async () => {
|
|
319
|
+
const {capture, result} = await renderTable({initialPrimitives: DARK_PRIMITIVES});
|
|
320
|
+
assert.ok(capture.theme);
|
|
321
|
+
expect(capture.theme.border.default).toBe(DARK_PRIMITIVES.neutral300);
|
|
322
|
+
expect(flatStyle(result.getByTestId("markdown-table-cell-0-0")).borderColor).toBe(
|
|
323
|
+
DARK_PRIMITIVES.neutral300
|
|
324
|
+
);
|
|
325
|
+
expect(flatStyle(result.getByTestId("markdown-table-header-0")).backgroundColor).toBe(
|
|
326
|
+
DARK_PRIMITIVES.secondary100
|
|
327
|
+
);
|
|
328
|
+
expect(flatStyle(result.getByText("Guests")).color).toBe(DARK_PRIMITIVES.neutral900);
|
|
329
|
+
expect(JSON.stringify(result.toJSON())).not.toContain("#000000");
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it("leaves markdown without a table free of table scroll views", async () => {
|
|
333
|
+
const {queryByTestId, getByText} = renderWithTheme(
|
|
334
|
+
<MarkdownView>{"Just a paragraph with **bold** text."}</MarkdownView>
|
|
335
|
+
);
|
|
336
|
+
await waitFor(() => {
|
|
337
|
+
expect(getByText("bold")).toBeTruthy();
|
|
338
|
+
});
|
|
339
|
+
expect(queryByTestId("markdown-table-scroll")).toBeNull();
|
|
340
|
+
});
|
|
341
|
+
});
|
|
179
342
|
});
|
package/src/MarkdownView.tsx
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, {lazy, Suspense, useCallback, useEffect, useMemo} from "react";
|
|
2
|
-
import {Linking, Platform} from "react-native";
|
|
2
|
+
import {Linking, Platform, ScrollView} from "react-native";
|
|
3
3
|
import type Markdown from "react-native-markdown-display";
|
|
4
4
|
import {FitImage, renderRules} from "react-native-markdown-display";
|
|
5
5
|
|
|
6
|
+
import {Box} from "./Box";
|
|
7
|
+
import {contrastRatio, WCAG_NORMAL_TEXT_CONTRAST} from "./colorContrast";
|
|
6
8
|
import {MarkdownEmbed} from "./MarkdownEmbed";
|
|
7
9
|
import {isEmbeddableMediaUrl, toMediaEmbedUrl} from "./markdownEmbeds";
|
|
8
10
|
import {Spinner} from "./Spinner";
|
|
@@ -25,6 +27,9 @@ const MARKDOWN_SIZES = {
|
|
|
25
27
|
const MONO_FONT = IS_WEB ? "monospace" : Platform.select({android: "monospace", ios: "Menlo"});
|
|
26
28
|
const TEXT_FONT_SIZE = IS_WEB ? 16 : 14;
|
|
27
29
|
const TEXT_LINE_HEIGHT = IS_WEB ? 24 : 20;
|
|
30
|
+
// Keeps columns readable; past this width per column the table scrolls sideways.
|
|
31
|
+
const TABLE_MIN_COLUMN_WIDTH = 96;
|
|
32
|
+
const TABLE_SCROLL_CONTENT_STYLE = {minWidth: "100%"} as const;
|
|
28
33
|
|
|
29
34
|
interface MarkdownViewProps {
|
|
30
35
|
children: React.ReactNode;
|
|
@@ -47,6 +52,18 @@ const MarkdownViewComponent: React.FC<MarkdownViewProps> = ({children, inverted,
|
|
|
47
52
|
const textColor = inverted ? theme.text.inverted : theme.text.primary;
|
|
48
53
|
const markdownStyle = useMemo<React.ComponentProps<typeof Markdown>["style"]>(() => {
|
|
49
54
|
const color = {color: textColor};
|
|
55
|
+
const tableCellStyle = {
|
|
56
|
+
borderBottomWidth: 1,
|
|
57
|
+
borderColor: theme.border.default,
|
|
58
|
+
borderRightWidth: 1,
|
|
59
|
+
// Replaces the library's `flex: 1` so cells keep a minimum width in the scroll view.
|
|
60
|
+
flex: undefined,
|
|
61
|
+
flexBasis: 0,
|
|
62
|
+
flexGrow: 1,
|
|
63
|
+
flexShrink: 0,
|
|
64
|
+
minWidth: TABLE_MIN_COLUMN_WIDTH,
|
|
65
|
+
padding: 8,
|
|
66
|
+
};
|
|
50
67
|
const markdownTextStyle = {
|
|
51
68
|
fontFamily: "text-regular",
|
|
52
69
|
fontSize: TEXT_FONT_SIZE,
|
|
@@ -54,7 +71,26 @@ const MarkdownViewComponent: React.FC<MarkdownViewProps> = ({children, inverted,
|
|
|
54
71
|
...color,
|
|
55
72
|
};
|
|
56
73
|
|
|
74
|
+
const blockquoteBackground =
|
|
75
|
+
contrastRatio(textColor, theme.surface.baseAlternate) >= WCAG_NORMAL_TEXT_CONTRAST
|
|
76
|
+
? theme.surface.baseAlternate
|
|
77
|
+
: theme.surface.neutralDark;
|
|
78
|
+
// Inverted text on neutralLight is about 2:1 in dark mode. Prefer that fill, then
|
|
79
|
+
// neutralDark, so code stays on the lighter chip when primary text already passes.
|
|
80
|
+
const codeBackground =
|
|
81
|
+
contrastRatio(textColor, theme.surface.neutralLight) >= WCAG_NORMAL_TEXT_CONTRAST
|
|
82
|
+
? theme.surface.neutralLight
|
|
83
|
+
: theme.surface.neutralDark;
|
|
84
|
+
|
|
57
85
|
return {
|
|
86
|
+
blockquote: {
|
|
87
|
+
backgroundColor: blockquoteBackground,
|
|
88
|
+
borderColor: theme.border.default,
|
|
89
|
+
borderLeftWidth: 4,
|
|
90
|
+
marginLeft: 0,
|
|
91
|
+
paddingHorizontal: 12,
|
|
92
|
+
paddingVertical: 4,
|
|
93
|
+
},
|
|
58
94
|
body: {width: "100%", ...markdownTextStyle},
|
|
59
95
|
bullet_list: {width: "100%"},
|
|
60
96
|
bullet_list_content: {flex: 1, flexShrink: 1, minWidth: 0},
|
|
@@ -67,7 +103,7 @@ const MarkdownViewComponent: React.FC<MarkdownViewProps> = ({children, inverted,
|
|
|
67
103
|
...markdownTextStyle,
|
|
68
104
|
},
|
|
69
105
|
code_block: {
|
|
70
|
-
backgroundColor:
|
|
106
|
+
backgroundColor: codeBackground,
|
|
71
107
|
borderColor: theme.border.default,
|
|
72
108
|
borderRadius: 4,
|
|
73
109
|
borderWidth: 1,
|
|
@@ -77,7 +113,7 @@ const MarkdownViewComponent: React.FC<MarkdownViewProps> = ({children, inverted,
|
|
|
77
113
|
...color,
|
|
78
114
|
},
|
|
79
115
|
code_inline: {
|
|
80
|
-
backgroundColor:
|
|
116
|
+
backgroundColor: codeBackground,
|
|
81
117
|
borderColor: theme.border.default,
|
|
82
118
|
borderRadius: 3,
|
|
83
119
|
borderWidth: 1,
|
|
@@ -88,7 +124,7 @@ const MarkdownViewComponent: React.FC<MarkdownViewProps> = ({children, inverted,
|
|
|
88
124
|
...color,
|
|
89
125
|
},
|
|
90
126
|
fence: {
|
|
91
|
-
backgroundColor:
|
|
127
|
+
backgroundColor: codeBackground,
|
|
92
128
|
borderColor: theme.border.default,
|
|
93
129
|
borderRadius: 4,
|
|
94
130
|
borderWidth: 1,
|
|
@@ -146,10 +182,33 @@ const MarkdownViewComponent: React.FC<MarkdownViewProps> = ({children, inverted,
|
|
|
146
182
|
...markdownTextStyle,
|
|
147
183
|
},
|
|
148
184
|
paragraph: {flexShrink: 1, width: "100%", ...markdownTextStyle},
|
|
185
|
+
// Grid borders: the table draws top/left, every cell draws right/bottom.
|
|
186
|
+
table: {
|
|
187
|
+
borderColor: theme.border.default,
|
|
188
|
+
borderLeftWidth: 1,
|
|
189
|
+
borderRadius: 0,
|
|
190
|
+
borderTopWidth: 1,
|
|
191
|
+
borderWidth: 0,
|
|
192
|
+
flexGrow: 1,
|
|
193
|
+
},
|
|
194
|
+
td: {...tableCellStyle, fontFamily: "text-regular"},
|
|
149
195
|
text: color,
|
|
150
196
|
textgroup: {flexShrink: 1, minWidth: 0},
|
|
197
|
+
th: {
|
|
198
|
+
...tableCellStyle,
|
|
199
|
+
backgroundColor: theme.surface.secondaryLight,
|
|
200
|
+
fontFamily: "text-bold",
|
|
201
|
+
},
|
|
202
|
+
tr: {borderBottomWidth: 0, borderColor: theme.border.default, flexDirection: "row"},
|
|
151
203
|
};
|
|
152
|
-
}, [
|
|
204
|
+
}, [
|
|
205
|
+
textColor,
|
|
206
|
+
theme.border.default,
|
|
207
|
+
theme.surface.baseAlternate,
|
|
208
|
+
theme.surface.neutralDark,
|
|
209
|
+
theme.surface.neutralLight,
|
|
210
|
+
theme.surface.secondaryLight,
|
|
211
|
+
]);
|
|
153
212
|
|
|
154
213
|
const handleLinkPress = useCallback((url: string): boolean => {
|
|
155
214
|
void Linking.openURL(url);
|
|
@@ -191,6 +250,42 @@ const MarkdownViewComponent: React.FC<MarkdownViewProps> = ({children, inverted,
|
|
|
191
250
|
}
|
|
192
251
|
return renderRules.link?.(node, children, parent, styles, onLinkPress);
|
|
193
252
|
},
|
|
253
|
+
// Tables wider than their container scroll sideways instead of squeezing columns. The
|
|
254
|
+
// wrapper stays a ScrollView: Box `scroll` fixes its contentContainerStyle and puts the
|
|
255
|
+
// testID on the inner view, so it cannot give the content `minWidth: 100%`.
|
|
256
|
+
table: (node, children, _parent, styles) => (
|
|
257
|
+
<ScrollView
|
|
258
|
+
contentContainerStyle={TABLE_SCROLL_CONTENT_STYLE}
|
|
259
|
+
horizontal
|
|
260
|
+
key={node.key}
|
|
261
|
+
testID="markdown-table-scroll"
|
|
262
|
+
>
|
|
263
|
+
<Box
|
|
264
|
+
dangerouslySetInlineStyle={{__style: styles._VIEW_SAFE_table}}
|
|
265
|
+
testID="markdown-table"
|
|
266
|
+
>
|
|
267
|
+
{children}
|
|
268
|
+
</Box>
|
|
269
|
+
</ScrollView>
|
|
270
|
+
),
|
|
271
|
+
td: (node, children, parent, styles) => (
|
|
272
|
+
<Box
|
|
273
|
+
dangerouslySetInlineStyle={{__style: styles._VIEW_SAFE_td}}
|
|
274
|
+
key={node.key}
|
|
275
|
+
testID={`markdown-table-cell-${parent[0]?.index ?? 0}-${node.index}`}
|
|
276
|
+
>
|
|
277
|
+
{children}
|
|
278
|
+
</Box>
|
|
279
|
+
),
|
|
280
|
+
th: (node, children, _parent, styles) => (
|
|
281
|
+
<Box
|
|
282
|
+
dangerouslySetInlineStyle={{__style: styles._VIEW_SAFE_th}}
|
|
283
|
+
key={node.key}
|
|
284
|
+
testID={`markdown-table-header-${node.index}`}
|
|
285
|
+
>
|
|
286
|
+
{children}
|
|
287
|
+
</Box>
|
|
288
|
+
),
|
|
194
289
|
};
|
|
195
290
|
}, []);
|
|
196
291
|
|
package/src/Modal.tsx
CHANGED
|
@@ -43,6 +43,13 @@ describe("SegmentedControl", () => {
|
|
|
43
43
|
expect(toJSON()).toMatchSnapshot();
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
it("renders a compact control that hugs its labels", () => {
|
|
47
|
+
const {toJSON} = renderWithTheme(
|
|
48
|
+
<SegmentedControl items={defaultItems} selectedIndex={0} size="sm" />
|
|
49
|
+
);
|
|
50
|
+
expect(toJSON()).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
|
|
46
53
|
it("renders with large size", () => {
|
|
47
54
|
const {toJSON} = renderWithTheme(
|
|
48
55
|
<SegmentedControl items={defaultItems} selectedIndex={0} size="lg" />
|