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..3e76f09fbeb 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 } 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 8eb590c2178..094a44a9db1 100644
--- a/packages/patternfly-4/react-table/src/components/Table/Table.tsx
+++ b/packages/patternfly-4/react-table/src/components/Table/Table.tsx
@@ -90,7 +90,7 @@ export interface IExtra extends IExtraData {
export type IFormatterValueType = formatterValueType & {
title?: string | React.ReactNode;
- props: any;
+ props?: any;
};
export interface ISortBy {
@@ -137,7 +137,7 @@ export interface IRowCell {
}
export interface IRow extends RowType {
- cells: (React.ReactNode | IRowCell)[];
+ cells?: (React.ReactNode | IRowCell)[];
isOpen?: boolean;
parent?: number;
props?: any;
diff --git a/packages/patternfly-4/react-table/src/components/Table/utils/__snapshots__/transformers.test.js.snap b/packages/patternfly-4/react-table/src/components/Table/utils/__snapshots__/transformers.test.js.snap
deleted file mode 100644
index 45663b7ed82..00000000000
--- a/packages/patternfly-4/react-table/src/components/Table/utils/__snapshots__/transformers.test.js.snap
+++ /dev/null
@@ -1,43 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Transformer functions expandable with parent 1`] = `
-
-
- test
-
-
-`;
-
-exports[`Transformer functions selectable unselected 1`] = `
-Object {
- "children":
-
- ,
- "className": "pf-c-table__check",
- "component": "td",
- "isVisible": true,
- "scope": "",
-}
-`;
-
-exports[`Transformer functions sortable asc 1`] = `
-Object {
- "aria-sort": "ascending",
- "children":
-
- ,
- "className": "pf-c-table__sort pf-m-selected",
-}
-`;
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);
diff --git a/packages/patternfly-4/react-table/src/components/Table/utils/transformers.test.js b/packages/patternfly-4/react-table/src/components/Table/utils/transformers.test.tsx
similarity index 90%
rename from packages/patternfly-4/react-table/src/components/Table/utils/transformers.test.js
rename to packages/patternfly-4/react-table/src/components/Table/utils/transformers.test.tsx
index a6bfad3fe4d..ba3834af394 100644
--- a/packages/patternfly-4/react-table/src/components/Table/utils/transformers.test.js
+++ b/packages/patternfly-4/react-table/src/components/Table/utils/transformers.test.tsx
@@ -14,8 +14,16 @@ import {
textCenter
} from './transformers';
import { DropdownDirection, DropdownPosition } from '@patternfly/react-core';
+import { IActions, IActionsResolver, IAreActionsDisabled, IExtraData, IRowData } from '../Table';
-const testCellActions = ({ actions, actionResolver, areActionsDisabled, rowData, expectDisabled }) => {
+const testCellActions = (
+ { actions }: { actions: IActions },
+ { actionResolver }: { actionResolver: IActionsResolver },
+ { areActionsDisabled }: { areActionsDisabled: IAreActionsDisabled },
+ { rowData }: { rowData: IRowData },
+ { extraData }: { extraData: IExtraData },
+ { expectDisabled }: { expectDisabled: boolean }
+) => {
const returnedData = cellActions(actions, actionResolver, areActionsDisabled)('', {
rowIndex: 0,
rowData,
@@ -28,7 +36,7 @@ const testCellActions = ({ actions, actionResolver, areActionsDisabled, rowData,
});
if (actionResolver) {
- actions = actionResolver(rowData);
+ actions = actionResolver(rowData, extraData);
}
expect(returnedData).toMatchObject({ className: 'pf-c-table__action' });
@@ -135,7 +143,7 @@ describe('Transformer functions', () => {
actions
},
{
- actionResolver: () => null
+ actionResolver: () => null as any
},
{
actionResolver: () => actions
@@ -165,7 +173,7 @@ describe('Transformer functions', () => {
const widths = [10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 'max'];
widths.forEach(width =>
test(`${width}`, () => {
- expect(cellWidth(width)()).toEqual({ className: `pf-m-width-${width}` });
+ expect(cellWidth(width as string)()).toEqual({ className: `pf-m-width-${width}` });
})
);
});
@@ -212,7 +220,7 @@ describe('Transformer functions', () => {
describe('expandedRow', () => {
test('with parent', () => {
- const returned = expandedRow(5)(
+ const returned = expandedRow(String(5))(
{ title: 'test' },
{ rowIndex: 2, rowData: { parent: 1 }, column: { extraParams: {} } }
);
@@ -220,11 +228,11 @@ describe('Transformer functions', () => {
});
test('no parent', () => {
- expect(expandedRow(5)({ title: 'test' }, { rowData: {}, column: { extraParams: {} } })).toBe(false);
+ expect(expandedRow(String(5))({ title: 'test' }, { rowData: {}, column: { extraParams: {} } })).toBe(false);
});
test('full width', () => {
- const returned = expandedRow(5)(
+ const returned = expandedRow(String(5))(
{ title: 'test' },
{ rowIndex: 2, rowData: { parent: 1, fullWidth: true }, column: { extraParams: {} } }
);
@@ -232,7 +240,7 @@ describe('Transformer functions', () => {
});
test('no padding', () => {
- const returned = expandedRow(5)(
+ const returned = expandedRow(String(5))(
{ title: 'test' },
{ rowIndex: 2, rowData: { parent: 1, noPadding: true }, column: { extraParams: {} } }
);
diff --git a/packages/patternfly-4/react-table/src/components/Table/utils/transformers.js b/packages/patternfly-4/react-table/src/components/Table/utils/transformers.tsx
similarity index 73%
rename from packages/patternfly-4/react-table/src/components/Table/utils/transformers.js
rename to packages/patternfly-4/react-table/src/components/Table/utils/transformers.tsx
index 3b898250b7b..d222d2fe29b 100644
--- a/packages/patternfly-4/react-table/src/components/Table/utils/transformers.js
+++ b/packages/patternfly-4/react-table/src/components/Table/utils/transformers.tsx
@@ -8,6 +8,8 @@ export { compoundExpand } from './decorators/compoundExpand';
export { headerCol } from './decorators/headerCol';
export { classNames, Visibility } from './decorators/classNames';
+import { IFormatterValueType, IExtra } from '../Table';
+
export const emptyTD = () => ({
scope: '',
component: 'td'
@@ -17,14 +19,14 @@ export const scopeColTransformer = () => ({
scope: 'col'
});
-export const emptyCol = label => ({
+export const emptyCol = (label: IFormatterValueType) => ({
...(label ? {} : { scope: '' })
});
-export const parentId = (_value, { rowData }) => ({
+export const parentId = (_value: IFormatterValueType, { rowData }: IExtra) => ({
parentId: rowData.parent
});
-export const mapProps = (_label, { property, rowData }) => ({
+export const mapProps = (_label: IFormatterValueType, { property, rowData }: IExtra) => ({
...(rowData[property] && rowData[property].props)
});