diff --git a/src/Table/Table.types.ts b/src/Table/Table.types.ts index a0a5f7180..10397e1c3 100644 --- a/src/Table/Table.types.ts +++ b/src/Table/Table.types.ts @@ -1,20 +1,20 @@ -import { Key, CSSProperties } from "react"; +import type { Key } from "react"; import PropTypes from "prop-types"; export type RowType = unknown; -export type CellInfoType = { +export interface CellInfoType { cellData: unknown; column: ColumnType; row: RowType; -}; +} -type ColumnInfoType = { +interface ColumnInfoType { align?: ColumnAlignment; label: string; dataKey?: Key; width?: string | number; -}; +} type ColumnAlignment = "left" | "right" | "center"; diff --git a/src/Table/TableHead.tsx b/src/Table/TableHead.tsx index c4ab0a551..02e743efc 100644 --- a/src/Table/TableHead.tsx +++ b/src/Table/TableHead.tsx @@ -1,26 +1,32 @@ -// @ts-nocheck import React from "react"; import styled from "styled-components"; import StyledTh from "./StyledTh"; -import { 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: React.FC = ({ columns, compact, sticky }) => { - const renderColumns = (allColumns) => - allColumns.map((column) => ( +const TableHead = ({ columns, compact, sticky }: TableHeadProps) => { + const renderColumns = (allColumns: Columns) => + allColumns.map((column, index) => ( = ({ columns, compact, sticky }) => { ); }; -TableHead.defaultProps = { - sticky: false, -}; + export default TableHead;