import {
JsonSkeleton,
stringifyJsonNode,
IO_TABLE_CHAR_LIMIT,
JSONView,
} from "@/src/components/ui/CodeJsonViewer";
import { cn } from "@/src/utils/tailwind";
import { memo } from "react";
export const IOTableCell = ({
data,
isLoading = false,
className,
singleLine = false,
}: {
data: unknown;
isLoading?: boolean;
className?: string;
singleLine?: boolean;
}) => {
if (isLoading) {
return ;
}
const stringifiedJson =
data !== null && data !== undefined ? stringifyJsonNode(data) : undefined;
// perf: truncate to IO_TABLE_CHAR_LIMIT characters as table becomes unresponsive attempting to render large JSONs with high levels of nesting
const shouldTruncate =
stringifiedJson && stringifiedJson.length > IO_TABLE_CHAR_LIMIT;
return (
<>
{singleLine ? (
{stringifiedJson}
) : shouldTruncate ? (
) : (
)}
>
);
};
export const MemoizedIOTableCell = memo(IOTableCell);