diff --git a/packages/apsara-ui/src/Listing/Listing.types.tsx b/packages/apsara-ui/src/Listing/Listing.types.tsx index a00d9c58..5cd47cba 100644 --- a/packages/apsara-ui/src/Listing/Listing.types.tsx +++ b/packages/apsara-ui/src/Listing/Listing.types.tsx @@ -1,5 +1,8 @@ import { IVirtualTable } from "../Table/VirtualisedTable"; import { Column } from "../TableV2/VirtualisedTable"; + +export type ColumnRenderFunc = (path: string, x: any) => Column[]; + export interface ListingProps { list?: T[]; loading?: boolean; @@ -8,7 +11,7 @@ export interface ListingProps { rowKey?: string; className?: string; tableProps?: { - getColumnList?: (path: string, sortedInfo: any) => Column[]; + getColumnList?: ColumnRenderFunc | undefined; selectedRowId?: number; scroll?: any; } & Omit; @@ -18,9 +21,11 @@ export interface ListingProps { searchFields?: string[]; disabled?: boolean; }; - renderExtraFilters?: React.ReactNode | null; - renderHeader?: React.ReactNode | null; - renderBody?: React.ReactNode | null; + calculateRowHeight?: (index: number, defaultRowHeight: number) => number; + calculateColumnWidth?: (index: number, defaultColumnWidth: number) => number; + renderExtraFilters?: React.ReactNode; + renderHeader?: React.ReactNode; + renderBody?: React.ReactNode; rowClick?: (props: any) => any; sortable?: boolean; defaultSearchTerm?: string; diff --git a/packages/apsara-ui/src/Table/VirtualisedTable.tsx b/packages/apsara-ui/src/Table/VirtualisedTable.tsx index 8530e394..c243031a 100644 --- a/packages/apsara-ui/src/Table/VirtualisedTable.tsx +++ b/packages/apsara-ui/src/Table/VirtualisedTable.tsx @@ -57,8 +57,8 @@ export interface IVirtualTable extends TableProps { }; loadMore?: () => Promise | null; onRowClick?: (event: any, rowIndexData: any) => void; - calculateRowHeight?: any; - calculateColumnWidth?: any; + calculateRowHeight?: (index: number, defaultRowHeight: number) => number; + calculateColumnWidth?: (index: number, defaultRowHeight: number) => number; alternate?: boolean; alternateHover?: boolean; className?: string; diff --git a/packages/apsara-ui/src/TableV2/VirtualisedTable.tsx b/packages/apsara-ui/src/TableV2/VirtualisedTable.tsx index c53d7ebd..87e9b995 100644 --- a/packages/apsara-ui/src/TableV2/VirtualisedTable.tsx +++ b/packages/apsara-ui/src/TableV2/VirtualisedTable.tsx @@ -28,15 +28,17 @@ interface ITableProps { loading?: boolean; } +type RenderFunction = (props: { row: { original: U } }) => any; + export type Column = { - key: string; - title: string; - dataIndex: string; - sorter?: (a: T, b: T) => number; + key?: string | undefined; + title?: string; + dataIndex?: string; + sorter?: (a: any, b: any) => number; sortOrder?: any; ellipsis?: boolean; width?: number; - render?: React.ReactNode | null; + render?: RenderFunction; }; function VirtualisedTable({