import { JsonSkeleton, stringifyJsonNode, IO_TABLE_CHAR_LIMIT, JSONView, } from "@/src/components/ui/CodeJsonViewer"; import { cn } from "@/src/utils/tailwind"; import { memo } from "react"; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/src/components/ui/hover-card"; import { decodeUnicodeEscapesOnly } from "@/src/utils/unicode"; const IOTableCellContent = ({ data, singleLine, className, }: { data: unknown; singleLine: boolean; className?: string; }) => { 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 ? decodeUnicodeEscapesOnly(stringifiedJson, true) : stringifiedJson}
) : shouldTruncate ? (
Content was truncated.
) : ( ); }; export const IOTableCell = ({ data, isLoading = false, className, singleLine = false, enableExpandOnHover = false, }: { data: unknown; isLoading?: boolean; className?: string; singleLine?: boolean; enableExpandOnHover?: boolean; }) => { if (isLoading) { return ( ); } if (!enableExpandOnHover) { return ( ); } return (
); }; export const MemoizedIOTableCell = memo(IOTableCell);