From be4a141491fc53751e88849f4e5e5e87b1303401 Mon Sep 17 00:00:00 2001 From: Pedro Di Martino Date: Wed, 31 Jul 2024 14:32:58 +0200 Subject: [PATCH] Fix table cells type --- .../bento-design-system/src/Table/cells.tsx | 18 +++++++++--------- .../src/Table/tableColumn.tsx | 6 +++--- .../stories/Components/Table.stories.tsx | 7 ++++++- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/bento-design-system/src/Table/cells.tsx b/packages/bento-design-system/src/Table/cells.tsx index f980f63c8..6d6c15416 100644 --- a/packages/bento-design-system/src/Table/cells.tsx +++ b/packages/bento-design-system/src/Table/cells.tsx @@ -29,7 +29,7 @@ export function ButtonCell({ value: buttonProps, column: { align }, options, -}: CellProps<{}, Omit> & { +}: CellProps> & { options: Partial>; }) { const config = useBentoConfig().table; @@ -48,7 +48,7 @@ export function ButtonLinkCell({ value: buttonProps, column: { align }, options, -}: CellProps<{}, Omit> & { +}: CellProps> & { options: Partial>; }) { const config = useBentoConfig().table; @@ -67,7 +67,7 @@ export function TextCell({ value, column: { align }, options, -}: CellProps<{}, LocalizedString> & { +}: CellProps & { options: Partial>; }) { const config = useBentoConfig().table; @@ -87,7 +87,7 @@ export function TextWithIconCell({ column: { align }, options, }: CellProps< - {}, + any, { icon: ((props: IconProps) => Children) | null; iconPosition: "left" | "right"; @@ -132,7 +132,7 @@ export function TextWithIconCell({ ); } -export function ChipCell({ value: chipProps, column: { align } }: CellProps<{}, ChipProps>) { +export function ChipCell({ value: chipProps, column: { align } }: CellProps) { const config = useBentoConfig().table; const padding = config.padding.chipCell ?? config.padding.defaultCell; return ( @@ -148,7 +148,7 @@ export function LabelCell({ value, column: { align }, options, -}: CellProps<{}, LocalizedString> & { +}: CellProps & { options: Partial>; }) { const config = useBentoConfig().table; @@ -167,7 +167,7 @@ export function LinkCell({ value, column: { align }, options, -}: CellProps<{}, ComponentProps> & { +}: CellProps> & { options: Partial>; }) { const config = useBentoConfig().table; @@ -186,7 +186,7 @@ export function IconCell({ value, column: { align }, options, -}: CellProps<{}, { icon: (props: IconProps) => JSX.Element; label: LocalizedString }> & { +}: CellProps JSX.Element; label: LocalizedString }> & { options: Partial>; }) { const config = useBentoConfig().table; @@ -203,7 +203,7 @@ export function IconButtonCell({ value: iconButtonProps, column: { align }, options, -}: CellProps<{}, Omit> & { +}: CellProps> & { options: Partial>; }) { const config = useBentoConfig().table; diff --git a/packages/bento-design-system/src/Table/tableColumn.tsx b/packages/bento-design-system/src/Table/tableColumn.tsx index c157444d8..51300dc1a 100644 --- a/packages/bento-design-system/src/Table/tableColumn.tsx +++ b/packages/bento-design-system/src/Table/tableColumn.tsx @@ -146,7 +146,7 @@ export function textWithIcon({ value: _value, ...props }: CellProps< - {}, + any, { icon: ((props: IconProps) => Children) | null; text: LocalizedString; @@ -177,7 +177,7 @@ export function number({ } & Partial>) { return custom({ ...options, - Cell: ({ value: numericValue, ...props }: CellProps<{}, number>) => { + Cell: ({ value: numericValue, ...props }: CellProps) => { const value = valueFormatter(numericValue); const textCellProps = { ...props, @@ -206,7 +206,7 @@ export function numberWithIcon({ value: { numericValue, icon, tooltipContent }, ...props }: CellProps< - {}, + any, { icon: ((props: IconProps) => Children) | null; numericValue: number; diff --git a/packages/bento-design-system/stories/Components/Table.stories.tsx b/packages/bento-design-system/stories/Components/Table.stories.tsx index 6e079cac3..012416dc8 100644 --- a/packages/bento-design-system/stories/Components/Table.stories.tsx +++ b/packages/bento-design-system/stories/Components/Table.stories.tsx @@ -445,7 +445,7 @@ const meta = { data: exampleData, }, parameters: { actions: { argTypesRegex: "" } }, -} satisfies Meta>; +} satisfies Meta>; export default meta; @@ -526,6 +526,7 @@ export const WithFilter = { options={statusOptions} /> + {/* @ts-expect-error */} ); @@ -598,6 +599,7 @@ export const Grouped = { } satisfies Story; export const WithFillColumn = { + // @ts-expect-error args: { columns: [ tableColumn.text({ @@ -664,6 +666,7 @@ function repeatToLength(arr: T[], n: number): T[] { } export const VirtualizedRows = { + // @ts-expect-error args: { stickyHeaders: true, height: { custom: 340 }, @@ -673,6 +676,7 @@ export const VirtualizedRows = { } satisfies Story; export const VirtualizedRowsGroupedHeaders = { + // @ts-expect-error args: { columns: exampleGroupedColumns, stickyHeaders: true, @@ -683,6 +687,7 @@ export const VirtualizedRowsGroupedHeaders = { } satisfies Story; export const VirtualizedRowsGroupedRows = { + // @ts-expect-error args: { columns: [ ...exampleColumns,