From a29a7cb2e3223a8441e49ffe37982be638b43f57 Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Thu, 10 Sep 2020 12:47:59 -0400 Subject: [PATCH] @types/react-bootstrap-table-next - Update ExpandRowProps interface (#46646) * Fix ExpandRowProps interface * Add tests * Rename param * Address lint warnings --- types/react-bootstrap-table-next/index.d.ts | 6 +++--- .../react-bootstrap-table-next-tests.tsx | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/types/react-bootstrap-table-next/index.d.ts b/types/react-bootstrap-table-next/index.d.ts index 446d9b6d91..3ee914fa6a 100644 --- a/types/react-bootstrap-table-next/index.d.ts +++ b/types/react-bootstrap-table-next/index.d.ts @@ -523,13 +523,13 @@ export interface ExpandRowProps { renderer: (row: T, rowIndex: number) => JSX.Element; expanded?: any[]; onExpand?: (row: T, isExpand: boolean, rowIndex: number, e: SyntheticEvent) => void; - onExpandAll?: (isExpandAll: boolean, results: number[], e: SyntheticEvent) => void; + onExpandAll?: (isExpandAll: boolean, results: T[], e: SyntheticEvent) => void; nonExpandable?: number[]; showExpandColumn?: boolean; onlyOneExpanding?: boolean; expandByColumnOnly?: boolean; - expandColumnRenderer?: ReactElement; - expandHeaderColumnRenderer?: ReactElement; + expandColumnRenderer?: (props: ExpandColumnRendererProps) => JSX.Element; + expandHeaderColumnRenderer?: (props: ExpandHeaderColumnRenderer) => JSX.Element; expandColumnPosition?: 'left' | 'right'; className?: string | ((isExpand: boolean, row: T, rowIndex: number) => string); } diff --git a/types/react-bootstrap-table-next/react-bootstrap-table-next-tests.tsx b/types/react-bootstrap-table-next/react-bootstrap-table-next-tests.tsx index 6fd665fbf4..fde55833e8 100644 --- a/types/react-bootstrap-table-next/react-bootstrap-table-next-tests.tsx +++ b/types/react-bootstrap-table-next/react-bootstrap-table-next-tests.tsx @@ -7,6 +7,7 @@ import BootstrapTable, { ColumnDescription, RowSelectionType, ROW_SELECT_SINGLE, + ExpandRowProps, } from 'react-bootstrap-table-next'; interface Product { @@ -180,3 +181,19 @@ render( />, document.getElementById('app'), ); + +const expandRow: ExpandRowProps = { + renderer: (row: Product) => { + return ( +
+ ); + }, + expanded: [1, 2], + onExpand: (row, isExpand, rowIndex, e) =>
, + onExpandAll: (isExpandAll, results) =>
, + showExpandColumn: true, + expandColumnPosition: 'right', + expandByColumnOnly: true, + expandHeaderColumnRenderer: ({ isAnyExpands }) =>
, + expandColumnRenderer: ({ expanded }) =>
, +};