Skip to content

Commit

Permalink
fix: remaining TableHead type problems
Browse files Browse the repository at this point in the history
BREAKING CHANGE: only properties conforming to the ColumnType are passed 
as props to the headerFormatter.
  • Loading branch information
jherdman authored and haideralsh committed Dec 13, 2023
1 parent 723858f commit 1f41bad
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Table/TableHead.tsx
Original file line number Diff line number Diff line change
@@ -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) =>
Expand All @@ -38,7 +44,5 @@ const TableHead = ({ columns, compact, sticky }: TableHeadProps) => {
</thead>
);
};
TableHead.defaultProps = {
sticky: false,
};

export default TableHead;

0 comments on commit 1f41bad

Please sign in to comment.