Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import type {
ColumnWrappingTableState,
} from "./types";

export const COLUMN_WRAPPING_STYLES = "whitespace-pre-wrap min-w-[200px]";

export const ColumnWrappingFeature: TableFeature = {
getInitialState: (state): ColumnWrappingTableState => {
return {
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/components/data-table/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Tooltip } from "../ui/tooltip";
import { DataTableColumnHeader } from "./column-header";
import type { ColumnChartSpecModel } from "./column-summary/chart-spec-model";
import { TableColumnSummary } from "./column-summary/column-summary";
import { COLUMN_WRAPPING_STYLES } from "./column-wrapping/feature";
import { DatePopover } from "./date-popover";
import type { FilterType } from "./filters";
import { getMimeValues, MimeCell } from "./mime-cell";
Expand Down Expand Up @@ -315,13 +316,15 @@ const PopoutColumn = ({
rawStringValue,
contentClassName,
buttonText,
wrapped,
children,
}: {
cellStyles?: string;
selectCell?: () => void;
rawStringValue: string;
contentClassName?: string;
buttonText?: string;
wrapped?: boolean;
children: React.ReactNode;
}) => {
return (
Expand All @@ -336,7 +339,10 @@ const PopoutColumn = ({
}}
>
<span
className="cursor-pointer hover:text-link"
className={cn(
"cursor-pointer hover:text-link",
wrapped && COLUMN_WRAPPING_STYLES,
)}
title={rawStringValue}
>
{rawStringValue}
Expand Down Expand Up @@ -408,7 +414,7 @@ function getCellStyleClass(
"truncate",
justify === "center" && "text-center",
justify === "right" && "text-right",
wrapped && "whitespace-pre-wrap min-w-[200px] break-words",
wrapped && `${COLUMN_WRAPPING_STYLES} break-words`,
);
}

Expand Down Expand Up @@ -517,6 +523,7 @@ export function renderCellValue<TData, TValue>({
rawStringValue={stringValue}
contentClassName="max-h-64 overflow-auto whitespace-pre-wrap break-words text-sm"
buttonText="X"
wrapped={column.getColumnWrapping?.() === "wrap"}
>
<UrlDetector parts={parts} />
</PopoutColumn>
Expand Down Expand Up @@ -558,6 +565,7 @@ export function renderCellValue<TData, TValue>({
cellStyles={cellStyles}
selectCell={selectCell}
rawStringValue={rawStringValue}
wrapped={column.getColumnWrapping?.() === "wrap"}
>
<JsonOutput data={value} format="tree" className="max-h-64" />
</PopoutColumn>
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/data-table/renderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
TableRow,
} from "@/components/ui/table";
import { cn } from "@/utils/cn";
import { COLUMN_WRAPPING_STYLES } from "./column-wrapping/feature";
import { CellRangeSelectionIndicator } from "./range-focus/cell-selection-indicator";
import { useCellRangeSelection } from "./range-focus/use-cell-range-selection";
import { useScrollIntoViewOnFocus } from "./range-focus/use-scroll-into-view";
Expand Down Expand Up @@ -130,8 +131,8 @@ export const DataTableBody = <TData,>({
className={cn(
"whitespace-pre truncate max-w-[300px] outline-hidden",
cell.column.getColumnWrapping &&
cell.column.getColumnWrapping() === "wrap" &&
"whitespace-pre-wrap min-w-[200px]",
cell.column.getColumnWrapping?.() === "wrap" &&
COLUMN_WRAPPING_STYLES,
"px-1.5 py-[0.18rem]",
className,
)}
Expand Down
Loading