From cafdf31c35148f9a6ca0c73ca38a2d46377e116f Mon Sep 17 00:00:00 2001 From: James Herdman Date: Wed, 13 Dec 2023 11:05:23 -0500 Subject: [PATCH] fix: remaining TableHead type problems BREAKING CHANGE: only properties conforming to the ColumnType are passed as props to the headerFormatter. --- src/Table/TableHead.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Table/TableHead.tsx b/src/Table/TableHead.tsx index 9a5ff5ff1..02e743efc 100644 --- a/src/Table/TableHead.tsx +++ b/src/Table/TableHead.tsx @@ -1,22 +1,28 @@ -// @ts-nocheck import React from "react"; import styled from "styled-components"; import StyledTh from "./StyledTh"; -import type { Columns } from "./Table.types"; +import type { ColumnType, Columns } from "./Table.types"; -type TableHeadProps = { +interface TableHeadProps { columns: Columns; compact?: boolean; sticky?: boolean; -}; +} const StyledHeaderRow = styled.tr(({ theme }) => ({ color: theme.colors.darkGrey, borderBottom: `1px solid ${theme.colors.lightGrey}`, })); -const defaultheaderFormatter = ({ label }) => label; -const renderHeaderCellContent = ({ headerFormatter = defaultheaderFormatter, ...column }) => headerFormatter(column); +const defaultheaderFormatter: ColumnType["headerFormatter"] = ({ label }) => label; + +const renderHeaderCellContent = ({ + headerFormatter = defaultheaderFormatter, + align, + label, + dataKey, + width, +}: ColumnType) => headerFormatter({ align, label, dataKey, width }); const TableHead = ({ columns, compact, sticky }: TableHeadProps) => { const renderColumns = (allColumns: Columns) => @@ -38,7 +44,5 @@ const TableHead = ({ columns, compact, sticky }: TableHeadProps) => { ); }; -TableHead.defaultProps = { - sticky: false, -}; + export default TableHead;