diff --git a/packages/patternfly-4/react-table/src/components/Table/Table.test.tsx b/packages/patternfly-4/react-table/src/components/Table/Table.test.tsx index 9a564951e39..22911b619bc 100644 --- a/packages/patternfly-4/react-table/src/components/Table/Table.test.tsx +++ b/packages/patternfly-4/react-table/src/components/Table/Table.test.tsx @@ -10,9 +10,10 @@ import { headerCol, sortable, expandable, - compoundExpand + compoundExpand, IRow } from './index'; import { rows, columns, actions } from '../../test-helpers/data-sets'; +import { ColumnsType, RowsType } from './base'; describe('Simple table', () => { test('caption', () => { @@ -144,11 +145,11 @@ test('Collapsible table', () => { }); test('Compound Expandable table', () => { - const compoundColumns: any = [ + const compoundColumns: ColumnsType = [ { title: 'col1', cell: { transforms: [compoundExpand] } }, { title: 'col2', cell: { transforms: [compoundExpand] } } ]; - const compoundRows: any = [ + const compoundRows: IRow[] = [ { isOpen: true, cells: [{ title: '1', props: { isOpen: true } }, { title: '2', props: { isOpen: false } }] }, { parent: 0, compoundParent: 0, cells: [{ title: 'expanded', props: { colSpan: 2 } }] }, { isOpen: false, cells: [{ title: '3', props: { isOpen: false } }, { title: '4', props: { isOpen: false } }] }, diff --git a/packages/patternfly-4/react-table/src/components/Table/Table.tsx b/packages/patternfly-4/react-table/src/components/Table/Table.tsx index e6904c2ee44..4887cc2aa22 100644 --- a/packages/patternfly-4/react-table/src/components/Table/Table.tsx +++ b/packages/patternfly-4/react-table/src/components/Table/Table.tsx @@ -40,7 +40,7 @@ export enum TableVariant { type OnSort = (event: React.MouseEvent, columnIndex: number, extraData: IExtraColumnData) => void; type OnCollapse = (event: React.MouseEvent, rowIndex: number, isOpen: boolean, rowData: IRowData, extraData: IExtraData) => undefined; type OnExpand = (event: React.MouseEvent, rowIndex: number, colIndex: number, isOpen: boolean, rowData: IRowData, extraData: IExtraData) => undefined; -type OnSelect = (event: React.MouseEvent, isSelected: boolean, rowIndex: number, rowData: IRowData, extraData: IExtraData) => undefined; +export type OnSelect = (event: React.MouseEvent, isSelected: boolean, rowIndex: number, rowData: IRowData, extraData: IExtraData) => undefined; export interface IHeaderRow extends ColumnType { } @@ -127,8 +127,8 @@ export interface ICell { } export interface IRowCell { - title: React.ReactNode; - props: any; + title?: React.ReactNode; + props?: any; } export interface IRow extends RowType { diff --git a/packages/patternfly-4/react-table/src/components/Table/utils/formatters.js b/packages/patternfly-4/react-table/src/components/Table/utils/formatters.js deleted file mode 100644 index dfa86691658..00000000000 --- a/packages/patternfly-4/react-table/src/components/Table/utils/formatters.js +++ /dev/null @@ -1 +0,0 @@ -export const defaultTitle = data => (data && data.hasOwnProperty('title') ? data.title : data); diff --git a/packages/patternfly-4/react-table/src/components/Table/utils/formatters.test.js b/packages/patternfly-4/react-table/src/components/Table/utils/formatters.test.tsx similarity index 100% rename from packages/patternfly-4/react-table/src/components/Table/utils/formatters.test.js rename to packages/patternfly-4/react-table/src/components/Table/utils/formatters.test.tsx diff --git a/packages/patternfly-4/react-table/src/components/Table/utils/formatters.tsx b/packages/patternfly-4/react-table/src/components/Table/utils/formatters.tsx new file mode 100644 index 00000000000..e47235b5605 --- /dev/null +++ b/packages/patternfly-4/react-table/src/components/Table/utils/formatters.tsx @@ -0,0 +1,3 @@ +import { IRowCell } from '../Table'; + +export const defaultTitle = (data: IRowCell) => (data && data.hasOwnProperty('title') ? data.title : data);