Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

DelimitedFilePreview.tsx

44 lines1.7 KB

1/* oxlint-disable react/no-array-index-key -- Captured table cells have stable positions and may contain identical values. */
2import { useGT } from "gt-react-native";
3import { ScrollView, View } from "react-native";
4import type { parseDelimitedPreview } from "@t3tools/shared/delimitedPreview";
5import { AppText as Text } from "../../components/ui/AppText";
6import { NativeScrollView } from "../../native/NativeScrollViewMarker";
7import { FilePreviewNotice } from "./FilePreviewFeedback";
8​
9export function DelimitedFilePreview(props: {
10 readonly table: ReturnType<typeof parseDelimitedPreview>;
11}) {
12 const gt = useGT();
13 return (
14 <NativeScrollView className="flex-1" contentInsetAdjustmentBehavior="automatic">
15 {props.table.truncated ? (
16 <FilePreviewNotice>
17 {gt("Table limited to the first 100 rows and 30 columns. Source shows the rest.")}
18 </FilePreviewNotice>
19 ) : null}
20 <ScrollView horizontal>
21 <View>
22 {props.table.rows.map((row, rowIndex) => (
23 <View key={rowIndex} className={rowIndex === 0 ? "flex-row bg-subtle" : "flex-row"}>
24 {row.map((cell, columnIndex) => (
25 <View key={columnIndex} className="w-48 border-r border-b border-border px-3 py-2">
26 <Text
27 selectable
28 className={
29 rowIndex === 0
30 ? "text-sm font-t3-semibold text-foreground"
31 : "text-sm text-foreground"
32 }
33 >
34 {cell}
35 </Text>
36 </View>
37 ))}
38 </View>
39 ))}
40 </View>
41 </ScrollView>
42 </NativeScrollView>
43 );