Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2664082
clone original Table Comp
iamfaran Aug 5, 2025
9ff640d
register table lite comp
iamfaran Aug 5, 2025
491782f
remove expansion data layer
iamfaran Aug 5, 2025
b43d31e
remove expansion functionality from table
iamfaran Aug 6, 2025
13cdeff
fix imports for table lite comp
iamfaran Aug 6, 2025
966c4df
remove edit functionality
iamfaran Aug 6, 2025
4d75755
remove filter modal / table toolbar unnecessary code
iamfaran Aug 8, 2025
d03a02d
remove search filter and fix css issue
iamfaran Aug 11, 2025
5d6301e
remove edit / insert functions
iamfaran Aug 11, 2025
714e6cc
remove row context
iamfaran Aug 11, 2025
d4afdb4
split down tableComp.tsx
iamfaran Aug 12, 2025
8b492c2
refactor tableCompView
iamfaran Aug 13, 2025
a909c64
refactor / add virtualization
iamfaran Aug 15, 2025
18a93cf
remove edit functionality from columns
iamfaran Aug 18, 2025
6b34a8d
remove remaining edit functionality from the columns
iamfaran Aug 18, 2025
38c8653
remove change value props
iamfaran Aug 18, 2025
c82279e
refactor columnToAntd function
iamfaran Aug 18, 2025
29f29b3
remove more edit related code from columns
iamfaran Aug 18, 2025
c406bb5
add basic filters in headers
iamfaran Aug 19, 2025
f09e36f
add dynamic virtualization
iamfaran Aug 20, 2025
07abda7
remove unnecssory code for virtualization
iamfaran Aug 20, 2025
5a6ac32
fix x scrolling
iamfaran Aug 20, 2025
3af069a
scroll fixes
iamfaran Aug 20, 2025
1e1b61e
fix virtualization toolbar bottom
iamfaran Aug 20, 2025
e98b05c
hide horizontal scroll virtualization
iamfaran Aug 20, 2025
fed09b1
fix y scroll
iamfaran Aug 20, 2025
58f13b2
delete rc-virtual-list
iamfaran Aug 20, 2025
b8c7586
fix infinite re renders / unnecessary logic
iamfaran Aug 21, 2025
c84c902
add styling structure / refactor styles
iamfaran Aug 22, 2025
67f9952
add custom Hook to calculate table height / body
iamfaran Aug 25, 2025
26f6b10
Add Base Table component
iamfaran Aug 25, 2025
4fd3e12
Add auto / fixed tables
iamfaran Aug 25, 2025
37d494a
basic refactor complete
iamfaran Aug 25, 2025
d73a5ff
add styles
iamfaran Aug 26, 2025
3edaee4
fix header styles
iamfaran Aug 26, 2025
4590bfe
add remaining styles
iamfaran Aug 26, 2025
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
Prev Previous commit
Next Next commit
basic refactor complete
  • Loading branch information
iamfaran committed Aug 25, 2025
commit 37d494ad1091880c924347aad3296eda2e876b0b
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
// AutoModeTable.tsx
import React from "react";
import BaseTable, { BaseTableProps } from "./BaseTable";

export interface AutoModeTableProps<RecordType> extends BaseTableProps<RecordType> {
// No additional props needed - auto mode is simple!
}
export interface AutoModeTableProps<RecordType> extends BaseTableProps<RecordType> {}

function AutoModeTableComp<RecordType extends object>(props: AutoModeTableProps<RecordType>) {
const { ...baseProps } = props;

// Auto mode configuration: natural growth, no height constraints
return (
<BaseTable<RecordType>
{...baseProps}
// Override any height-related props for auto mode
containerHeight={undefined}
isFixedHeight={false}
/>
);
return <BaseTable<RecordType> {...props} />;
}

const AutoModeTable = React.memo(AutoModeTableComp) as typeof AutoModeTableComp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, {
useMemo,
useState,
useRef,
useEffect,
} from "react";
import { default as Table, TableProps, ColumnType } from "antd/es/table";
import ResizeableTitle from "./ResizeableTitle";
Expand Down Expand Up @@ -32,7 +31,6 @@ import React, {
height: 0 !important;
}
`;

export interface BaseTableProps<RecordType> extends Omit<TableProps<RecordType>, "components" | "columns"> {
columns: CustomColumnType<RecordType>[];
viewModeResizable: boolean;
Expand All @@ -43,9 +41,9 @@ import React, {
customLoading?: boolean;
onCellClick: (columnName: string, dataIndex: string) => void;

// Simplified props (remove the old virtualization logic for now)
containerHeight?: number;
isFixedHeight?: boolean;
// NEW: Accept explicit configuration from parent
scroll?: { x?: number | string; y?: number };
virtual?: boolean;
}

/**
Expand All @@ -63,8 +61,8 @@ import React, {
rowAutoHeight,
customLoading,
onCellClick,
containerHeight,
isFixedHeight,
scroll,
virtual,
dataSource,
...restProps
} = props;
Expand Down Expand Up @@ -168,38 +166,6 @@ import React, {
});
}, [columns, resizeData, createCellHandler, createHeaderCellHandler]);



// Sum widths (including resized values) to keep horizontal scroll baseline accurate
function getTotalTableWidth(
cols: CustomColumnType<RecordType>[],
rData: { index: number; width: number }
) {
return cols.reduce((sum, col, i) => {
const liveWidth =
(rData.index === i ? rData.width : (col.width as number | undefined)) ??
undefined;
const w =
typeof liveWidth === "number" && liveWidth > 0
? liveWidth
: COL_MIN_WIDTH;
return sum + w;
}, 0);
}

const scrollAndVirtualizationSettings = useMemo(() => {
const totalWidth = getTotalTableWidth(memoizedColumns as any, resizeData);
const shouldVirtualize = isFixedHeight && (dataSource?.length ?? 0) >= 50;

return {
virtual: shouldVirtualize,
scroll: {
x: totalWidth,
// FIX: Set y for ANY fixed height mode, not just virtualization
y: isFixedHeight && containerHeight ? containerHeight : undefined
}
};
}, [isFixedHeight, containerHeight, dataSource?.length, memoizedColumns, resizeData]);

return (
<StyledTableWrapper ref={tableRef}>
Expand All @@ -216,8 +182,8 @@ import React, {
dataSource={dataSource}
pagination={false}
columns={memoizedColumns}
virtual={scrollAndVirtualizationSettings.virtual}
scroll={scrollAndVirtualizationSettings.scroll}
virtual={virtual || false}
scroll={scroll || { x: 'max-content' }}
/>
</StyledTableWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FixedModeTable.tsx
import React from "react";
import BaseTable, { BaseTableProps } from "./BaseTable";

Expand All @@ -6,16 +7,7 @@ export interface FixedModeTableProps<RecordType> extends BaseTableProps<RecordTy
}

function FixedModeTableComp<RecordType extends object>(props: FixedModeTableProps<RecordType>) {
const { bodyHeight, ...baseProps } = props;

// Fixed mode configuration: height constraints and internal scrolling
return (
<BaseTable<RecordType>
{...baseProps}
containerHeight={bodyHeight}
isFixedHeight={true}
/>
);
return <BaseTable<RecordType> {...props} />;
}

const FixedModeTable = React.memo(FixedModeTableComp) as typeof FixedModeTableComp;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React, { useMemo } from "react";
import AutoModeTable from "./AutoModeTable";
import FixedModeTable from "./FixedModeTable";
import VirtualizedTable from "./VirtualizedTable";
import { BaseTableProps } from "./BaseTable";
import { COL_MIN_WIDTH } from "../tableUtils";

export interface TableRendererProps<RecordType> extends BaseTableProps<RecordType> {
mode: 'AUTO' | 'FIXED';
heights: {
bodyHeight?: number;
canVirtualize: boolean;
[key: string]: any;
};
virtualizationConfig: {
enabled: boolean;
itemHeight: number;
threshold: number;
reason?: string;
};
}

function TableRendererComp<RecordType extends object>(props: TableRendererProps<RecordType>) {
const {
mode,
heights,
virtualizationConfig,
columns,
...baseTableProps
} = props;

// Calculate total width for X scroll
const totalWidth = useMemo(() => {
return columns.reduce((sum, col) => {
const width = typeof col.width === "number" && col.width > 0 ? col.width : COL_MIN_WIDTH;
return sum + width;
}, 0);
}, [columns]);

// AUTO MODE: Natural growth
if (mode === 'AUTO') {
console.log('AutoModeTable');
return (
<AutoModeTable
{...baseTableProps}
columns={columns}
scroll={{ x: totalWidth }}
virtual={false}
/>
);
}

// FIXED MODE: Height-constrained with optional virtualization
if (mode === 'FIXED') {
console.log('FixedModeTable');
const bodyHeight = heights.bodyHeight ?? 0;

if (bodyHeight <= 0) {
console.warn('TableRenderer: Invalid bodyHeight, falling back to auto mode');
return (
<AutoModeTable
{...baseTableProps}
columns={columns}
scroll={{ x: totalWidth }}
virtual={false}
/>
);
}

const scrollConfig = { x: totalWidth, y: bodyHeight };

// VIRTUALIZED: High performance for large datasets
if (virtualizationConfig.enabled && heights.canVirtualize) {
console.log('VirtualizedTable');
return (
<VirtualizedTable
{...baseTableProps}
columns={columns}
bodyHeight={bodyHeight}
virtualizationConfig={virtualizationConfig}
scroll={scrollConfig}
virtual={true}
/>
);
}

// FIXED: Regular height-constrained mode
return (
<FixedModeTable
{...baseTableProps}
columns={columns}
bodyHeight={bodyHeight}
scroll={scrollConfig}
virtual={false}
/>
);
}

// Fallback
return (
<AutoModeTable
{...baseTableProps}
columns={columns}
scroll={{ x: totalWidth }}
virtual={false}
/>
);
}

const TableRenderer = React.memo(TableRendererComp) as typeof TableRendererComp;
export default TableRenderer;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import BaseTable, { BaseTableProps } from "./BaseTable";

export interface VirtualizedTableProps<RecordType> extends BaseTableProps<RecordType> {
bodyHeight: number;
virtualizationConfig: {
enabled: boolean;
itemHeight: number;
threshold: number;
reason?: string;
};
}

function VirtualizedTableComp<RecordType extends object>(props: VirtualizedTableProps<RecordType>) {
const { bodyHeight, virtualizationConfig, ...baseProps } = props;

// Virtualized mode: explicit scroll config for performance
return (
<BaseTable<RecordType>
{...baseProps}
// Props are set by TableRenderer
/>
);
}

const VirtualizedTable = React.memo(VirtualizedTableComp) as typeof VirtualizedTableComp;
export default VirtualizedTable;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TableImplComp } from "./tableComp";
import { EmptyContent } from "pages/common/styledComponent";
import { TableSummary } from "./tableSummaryComp";
import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
import BaseTable from "./parts/BaseTable";
import TableRenderer from "./parts/TableRenderer";
import { TableWrapper } from "./styles/TableWrapper";
import { useContainerHeight, useTableMode, useTableHeights, useVirtualization } from "./hooks/useTableConfiguration";

Expand Down Expand Up @@ -193,7 +193,7 @@ export const TableCompView = React.memo((props: {
$visibleResizables={visibleResizables}
$showHRowGridBorder={showHRowGridBorder}
>
<BaseTable<any>
<TableRenderer<any>
{...compChildren.selection.getView()(onEvent)}
bordered={compChildren.showRowGridBorder.getView()}
onChange={(pagination: any, filters: any, sorter: any, extra: any) => {
Expand All @@ -218,8 +218,9 @@ export const TableCompView = React.memo((props: {
dataIndex: dataIndex,
});
}}
containerHeight={containerHeight}
isFixedHeight={isFixedMode}
mode={mode as 'AUTO' | 'FIXED'}
heights={heights}
virtualizationConfig={virtualization}
/>
</TableWrapper>
</div>
Expand Down
Loading