From c60980667499d562859474fefa9bf8d59ef3e647 Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Wed, 3 Jan 2024 14:41:42 -0500 Subject: [PATCH] Use any --- src/components/Table/BaseTable.tsx | 190 ++++++++++++++--------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/src/components/Table/BaseTable.tsx b/src/components/Table/BaseTable.tsx index 30eeb33a68..d1f42f8964 100644 --- a/src/components/Table/BaseTable.tsx +++ b/src/components/Table/BaseTable.tsx @@ -58,98 +58,101 @@ type SpruceTableProps = { className?: string; }; -const BaseTable = ( - { - className, - "data-cy-row": dataCyRow, - "data-cy-table": dataCyTable, - emptyComponent, - loading, - loadingRows = 5, - table, - ...args - }: SpruceTableProps & TableProps, - ref: ForwardedRef -) => { - const { virtualRows } = table; - const { rows } = table.getRowModel(); - return ( - <> - - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => { - const { columnDef } = header.column ?? {}; - const { meta } = columnDef; - return ( - - {flexRender(columnDef.header, header.getContext())} - {header.column.getCanFilter() && - (meta?.treeSelect ? ( - - header.column.setFilterValue(value) - } - options={ - meta.treeSelect?.filterOptions - ? meta.treeSelect.options.filter( - ({ value }) => - !!header.column - .getFacetedUniqueValues() - .get(value) - ) - : meta.treeSelect.options - } - value={ - (header?.column?.getFilterValue() as string[]) ?? [] - } - /> - ) : ( - - header.column.setFilterValue(value) - } - placeholder={meta?.search?.placeholder} - value={ - (header?.column?.getFilterValue() as string) ?? "" - } - /> - ))} - - ); - })} - - ))} - - - {loading && ( - - )} - - - - {!loading && - rows.length === 0 && - (emptyComponent || "No data to display")} - - ); -}; +export const BaseTable = forwardRef( + ( + { + className, + "data-cy-row": dataCyRow, + "data-cy-table": dataCyTable, + emptyComponent, + loading, + loadingRows = 5, + table, + ...args + }: SpruceTableProps & TableProps, + ref: ForwardedRef + ) => { + const { virtualRows } = table; + const { rows } = table.getRowModel(); + return ( + <> + + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => { + const { columnDef } = header.column ?? {}; + const { meta } = columnDef; + return ( + + {flexRender(columnDef.header, header.getContext())} + {header.column.getCanFilter() && + (meta?.treeSelect ? ( + + header.column.setFilterValue(value) + } + options={ + meta.treeSelect?.filterOptions + ? meta.treeSelect.options.filter( + ({ value }) => + !!header.column + .getFacetedUniqueValues() + .get(value) + ) + : meta.treeSelect.options + } + value={ + (header?.column?.getFilterValue() as string[]) ?? + [] + } + /> + ) : ( + + header.column.setFilterValue(value) + } + placeholder={meta?.search?.placeholder} + value={ + (header?.column?.getFilterValue() as string) ?? "" + } + /> + ))} + + ); + })} + + ))} + + + {loading && ( + + )} + + + + {!loading && + rows.length === 0 && + (emptyComponent || "No data to display")} + + ); + } +); const RenderRows = ({ rows, @@ -229,6 +232,3 @@ const StyledExpandedContent = styled(ExpandedContent)` flex-grow: 1; } ` as typeof ExpandedContent; - -const BaseTableWithForwardedRef = forwardRef(BaseTable); -export { BaseTableWithForwardedRef as BaseTable };